/[escript]/trunk/escript/py_src/pdetools.py
ViewVC logotype

Diff of /trunk/escript/py_src/pdetools.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2251 by gross, Fri Feb 6 06:50:39 2009 UTC revision 2261 by gross, Tue Feb 10 08:38:53 2009 UTC
# Line 817  def __FDGMRES(F0, defect, x0, atol, iter Line 817  def __FDGMRES(F0, defect, x0, atol, iter
817    
818     return xhat,stopped     return xhat,stopped
819    
820  def GMRES(r, Aprod, x, bilinearform, atol=0, rtol=1.e-8, iter_max=100, iter_restart=20, verbose=False):  def GMRES(r, Aprod, x, bilinearform, atol=0, rtol=1.e-8, iter_max=100, iter_restart=20, verbose=False,P_R=None):
821     """     """
822     Solver for     Solver for
823    
# Line 881  def GMRES(r, Aprod, x, bilinearform, ato Line 881  def GMRES(r, Aprod, x, bilinearform, ato
881        else:        else:
882           r2=1*r           r2=1*r
883        x2=x*1.        x2=x*1.
884        x,stopped=_GMRESm(r2, Aprod, x, bilinearform, atol2, iter_max=iter_max-iter, iter_restart=m, verbose=verbose)        x,stopped=_GMRESm(r2, Aprod, x, bilinearform, atol2, iter_max=iter_max-iter, iter_restart=m, verbose=verbose,P_R=P_R)
885        iter+=iter_restart        iter+=iter_restart
886        if stopped: break        if stopped: break
887        if verbose: print "GMRES: restart."        if verbose: print "GMRES: restart."
# Line 889  def GMRES(r, Aprod, x, bilinearform, ato Line 889  def GMRES(r, Aprod, x, bilinearform, ato
889     if verbose: print "GMRES: tolerance has been reached."     if verbose: print "GMRES: tolerance has been reached."
890     return x     return x
891    
892  def _GMRESm(r, Aprod, x, bilinearform, atol, iter_max=100, iter_restart=20, verbose=False):  def _GMRESm(r, Aprod, x, bilinearform, atol, iter_max=100, iter_restart=20, verbose=False, P_R=None):
893     iter=0     iter=0
894    
895     h=numarray.zeros((iter_restart+1,iter_restart),numarray.Float64)     h=numarray.zeros((iter_restart+1,iter_restart),numarray.Float64)
# Line 910  def _GMRESm(r, Aprod, x, bilinearform, a Line 910  def _GMRESm(r, Aprod, x, bilinearform, a
910    
911      if iter  >= iter_max: raise MaxIterReached,"maximum number of %s steps reached."%iter_max      if iter  >= iter_max: raise MaxIterReached,"maximum number of %s steps reached."%iter_max
912    
913      p=Aprod(v[iter])          if P_R!=None:
914                p=Aprod(P_R(v[iter]))
915            else:
916            p=Aprod(v[iter])
917      v.append(p)      v.append(p)
918    
919      v_norm1=math.sqrt(bilinearform(v[iter+1], v[iter+1]))      v_norm1=math.sqrt(bilinearform(v[iter+1], v[iter+1]))
# Line 970  def _GMRESm(r, Aprod, x, bilinearform, a Line 973  def _GMRESm(r, Aprod, x, bilinearform, a
973      xhat += v[i]*y[i]      xhat += v[i]*y[i]
974     else:     else:
975       xhat=v[0] * 0       xhat=v[0] * 0
976       if P_R!=None:
977     x += xhat        x += P_R(xhat)
978       else:
979          x += xhat
980     if iter<iter_restart-1:     if iter<iter_restart-1:
981        stopped=True        stopped=True
982     else:     else:

Legend:
Removed from v.2251  
changed lines
  Added in v.2261

  ViewVC Help
Powered by ViewVC 1.1.26