/[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 2792 by jfenwick, Tue Nov 17 04:23:02 2009 UTC revision 2793 by gross, Tue Dec 1 06:10:10 2009 UTC
# Line 1507  class HomogeneousSaddlePointProblem(obje Line 1507  class HomogeneousSaddlePointProblem(obje
1507          self.resetControlParameters()          self.resetControlParameters()
1508          self.setTolerance()          self.setTolerance()
1509          self.setAbsoluteTolerance()          self.setAbsoluteTolerance()
1510        def resetControlParameters(self,gamma=0.85, gamma_min=1.e-8,chi_max=0.1, omega_div=0.2, omega_conv=1.1, rtol_min=1.e-7, rtol_max=0.1, chi=1., C_p=1., C_v=1., safety_factor=0.3):        def resetControlParameters(self,gamma=0.85, gamma_min=1.e-2,chi_max=0.1, omega_div=0.2, omega_conv=1.1, rtol_min=1.e-7, rtol_max=0.9, chi=1., C_p=1., C_v=1., safety_factor=0.3):
1511           """           """
1512           sets a control parameter           sets a control parameter
1513    
# Line 1647  class HomogeneousSaddlePointProblem(obje Line 1647  class HomogeneousSaddlePointProblem(obje
1647           self.__safety_factor = safety_factor           self.__safety_factor = safety_factor
1648    
1649        #=============================================================        #=============================================================
       def initialize(self):  
         """  
         Initializes the problem (overwrite).  
         """  
         pass  
   
1650        def inner_pBv(self,p,Bv):        def inner_pBv(self,p,Bv):
1651           """           """
1652           Returns inner product of element p and Bv (overwrite).           Returns inner product of element p and Bv (overwrite).
# Line 1782  class HomogeneousSaddlePointProblem(obje Line 1776  class HomogeneousSaddlePointProblem(obje
1776           :type verbose: ``bool``           :type verbose: ``bool``
1777           :type iter_restart: ``int``           :type iter_restart: ``int``
1778           :rtype: ``tuple`` of `Data` objects           :rtype: ``tuple`` of `Data` objects
1779             :note: typically this method is overwritten by a subclass. It provides a wrapper for the ``_solve`` method.
1780             """
1781             return self._solve(v=v,p=p,max_iter=max_iter,verbose=verbose, usePCG=usePCG, iter_restart=iter_restart, max_correction_steps=max_correction_steps)
1782    
1783          def _solve(self,v,p,max_iter=20, verbose=False, usePCG=True, iter_restart=20, max_correction_steps=10):
1784             """
1785             see `_solve` method.
1786           """           """
1787           self.verbose=verbose           self.verbose=verbose
1788           rtol=self.getTolerance()           rtol=self.getTolerance()
# Line 1842  class HomogeneousSaddlePointProblem(obje Line 1843  class HomogeneousSaddlePointProblem(obje
1843                    if self.verbose: print "HomogeneousSaddlePointProblem: step %s (part 2): Bv = %e, dv = %e, v=%e"%(correction_step,norm_Bv2, norm_dv2, norm_v2)                    if self.verbose: print "HomogeneousSaddlePointProblem: step %s (part 2): Bv = %e, dv = %e, v=%e"%(correction_step,norm_Bv2, norm_dv2, norm_v2)
1844                    if error !=None:                    if error !=None:
1845                        chi_new=error_new/error                        chi_new=error_new/error
1846                        if self.verbose: print "HomogeneousSaddlePointProblem: step %s: convergence rate = %e"%(correction_step,chi_new)                        if self.verbose: print "HomogeneousSaddlePointProblem: step %s: convergence rate = %e, est. error = %e"%(correction_step,chi_new, error_new)
1847                        if chi != None:                        if chi != None:
1848                            gamma0=max(gamma, 1-chi/chi_new)                            gamma0=max(gamma, 1-chi/chi_new)
1849                            C_p*=gamma0/gamma                            C_p*=gamma0/gamma
1850                            C_v*=gamma0/gamma*(1+gamma)/(1+gamma0)                            C_v*=gamma0/gamma*(1+gamma)/(1+gamma0)
1851                        chi=chi_new                        chi=chi_new
1852                      else:
1853                          if self.verbose: print "HomogeneousSaddlePointProblem: step %s: est. error = %e"%(correction_step, error_new)
1854    
1855                    error = error_new                    error = error_new
1856                    correction_step+=1                    correction_step+=1
1857                    if correction_step>max_correction_steps:                    if correction_step>max_correction_steps:

Legend:
Removed from v.2792  
changed lines
  Added in v.2793

  ViewVC Help
Powered by ViewVC 1.1.26