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

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

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

revision 3378 by jfenwick, Thu Nov 18 00:20:21 2010 UTC revision 3379 by gross, Wed Nov 24 04:48:49 2010 UTC
# Line 75  class SolverOptions(object): Line 75  class SolverOptions(object):
75      :cvar JACOBI: The Jacobi preconditioner      :cvar JACOBI: The Jacobi preconditioner
76      :cvar GMRES: The Gram-Schmidt minimum residual method      :cvar GMRES: The Gram-Schmidt minimum residual method
77      :cvar PRES20: Special GMRES with restart after 20 steps and truncation after 5 residuals      :cvar PRES20: Special GMRES with restart after 20 steps and truncation after 5 residuals
78      :cvar LUMPING: Matrix lumping      :cvar ROWSUM_LUMPING: Matrix lumping using row sum
79        :cvar HRZ_LUMPING: Matrix lumping using the HRZ approach
80      :cvar NO_REORDERING: No matrix reordering allowed      :cvar NO_REORDERING: No matrix reordering allowed
81      :cvar MINIMUM_FILL_IN: Reorder matrix to reduce fill-in during factorization      :cvar MINIMUM_FILL_IN: Reorder matrix to reduce fill-in during factorization
82      :cvar NESTED_DISSECTION: Reorder matrix to improve load balancing during factorization      :cvar NESTED_DISSECTION: Reorder matrix to improve load balancing during factorization
# Line 113  class SolverOptions(object): Line 114  class SolverOptions(object):
114      GMRES= 11      GMRES= 11
115      PRES20= 12      PRES20= 12
116      LUMPING= 13      LUMPING= 13
117        ROWSUM_LUMPING= 13
118        HRZ_LUMPING= 14
119      NO_REORDERING= 17      NO_REORDERING= 17
120      MINIMUM_FILL_IN= 18      MINIMUM_FILL_IN= 18
121      NESTED_DISSECTION= 19      NESTED_DISSECTION= 19
# Line 247  class SolverOptions(object): Line 250  class SolverOptions(object):
250          if key == self.JACOBI: return "JACOBI"          if key == self.JACOBI: return "JACOBI"
251          if key == self.GMRES: return "GMRES"          if key == self.GMRES: return "GMRES"
252          if key == self.PRES20: return "PRES20"          if key == self.PRES20: return "PRES20"
253          if key == self.LUMPING: return "LUMPING"          if key == self.ROWSUM_LUMPING: return "ROWSUM_LUMPING"
254            if key == self.HRZ_LUMPING: return "HRZ_LUMPING"
255          if key == self.NO_REORDERING: return "NO_REORDERING"          if key == self.NO_REORDERING: return "NO_REORDERING"
256          if key == self.MINIMUM_FILL_IN: return "MINIMUM_FILL_IN"          if key == self.MINIMUM_FILL_IN: return "MINIMUM_FILL_IN"
257          if key == self.NESTED_DISSECTION: return "NESTED_DISSECTION"          if key == self.NESTED_DISSECTION: return "NESTED_DISSECTION"
# Line 471  class SolverOptions(object): Line 475  class SolverOptions(object):
475          :param method: key of the solver method to be used.          :param method: key of the solver method to be used.
476          :type method: in `SolverOptions.DEFAULT`, `SolverOptions.DIRECT`, `SolverOptions.CHOLEVSKY`, `SolverOptions.PCG`,          :type method: in `SolverOptions.DEFAULT`, `SolverOptions.DIRECT`, `SolverOptions.CHOLEVSKY`, `SolverOptions.PCG`,
477                          `SolverOptions.CR`, `SolverOptions.CGS`, `SolverOptions.BICGSTAB`,                          `SolverOptions.CR`, `SolverOptions.CGS`, `SolverOptions.BICGSTAB`,
478                          `SolverOptions.GMRES`, `SolverOptions.PRES20`, `SolverOptions.LUMPING`, `SolverOptions.ITERATIVE`,                          `SolverOptions.GMRES`, `SolverOptions.PRES20`, `SolverOptions.ROWSUM_LUMPING`, `SolverOptions.HRZ_LUMPING`, `SolverOptions.ITERATIVE`,
479                          `SolverOptions.NONLINEAR_GMRES`, `SolverOptions.TFQMR`, `SolverOptions.MINRES`                          `SolverOptions.NONLINEAR_GMRES`, `SolverOptions.TFQMR`, `SolverOptions.MINRES`
480          :note: Not all packages support all solvers. It can be assumed that a package makes a reasonable choice if it encounters an unknown solver method.          :note: Not all packages support all solvers. It can be assumed that a package makes a reasonable choice if it encounters an unknown solver method.
481          """          """
482      if method==None: method=0      if method==None: method=0
483          if not method in [ SolverOptions.DEFAULT, SolverOptions.DIRECT, SolverOptions.CHOLEVSKY, SolverOptions.PCG,          if not method in [ SolverOptions.DEFAULT, SolverOptions.DIRECT, SolverOptions.CHOLEVSKY, SolverOptions.PCG,
484                             SolverOptions.CR, SolverOptions.CGS, SolverOptions.BICGSTAB,                             SolverOptions.CR, SolverOptions.CGS, SolverOptions.BICGSTAB,
485                             SolverOptions.GMRES, SolverOptions.PRES20, SolverOptions.LUMPING, SolverOptions.ITERATIVE,                             SolverOptions.GMRES, SolverOptions.PRES20, SolverOptions.ROWSUM_LUMPING, SolverOptions.HRZ_LUMPING,
486                               SolverOptions.ITERATIVE,
487                             SolverOptions.NONLINEAR_GMRES, SolverOptions.TFQMR, SolverOptions.MINRES ]:                             SolverOptions.NONLINEAR_GMRES, SolverOptions.TFQMR, SolverOptions.MINRES ]:
488               raise ValueError,"unknown solver method %s"%method               raise ValueError,"unknown solver method %s"%method
489          self.__method=method          self.__method=method
# Line 488  class SolverOptions(object): Line 493  class SolverOptions(object):
493    
494          :rtype: in the list `SolverOptions.DEFAULT`, `SolverOptions.DIRECT`, `SolverOptions.CHOLEVSKY`, `SolverOptions.PCG`,          :rtype: in the list `SolverOptions.DEFAULT`, `SolverOptions.DIRECT`, `SolverOptions.CHOLEVSKY`, `SolverOptions.PCG`,
495                          `SolverOptions.CR`, `SolverOptions.CGS`, `SolverOptions.BICGSTAB`,                          `SolverOptions.CR`, `SolverOptions.CGS`, `SolverOptions.BICGSTAB`,
496                          `SolverOptions.GMRES`, `SolverOptions.PRES20`, `SolverOptions.LUMPING`, `SolverOptions.ITERATIVE`,                          `SolverOptions.GMRES`, `SolverOptions.PRES20`, `SolverOptions.ROWSUM_LUMPING`, `SolverOptions.HRZ_LUMPING`, `SolverOptions.ITERATIVE`,
497                          `SolverOptions.NONLINEAR_GMRES`, `SolverOptions.TFQMR`, `SolverOptions.MINRES`                          `SolverOptions.NONLINEAR_GMRES`, `SolverOptions.TFQMR`, `SolverOptions.MINRES`
498          """          """
499          return self.__method          return self.__method
# Line 1736  class LinearProblem(object): Line 1741  class LinearProblem(object):
1741        :return: True if the current solver method is lumping        :return: True if the current solver method is lumping
1742        :rtype: ``bool``        :rtype: ``bool``
1743        """        """
1744        return self.getSolverOptions().getSolverMethod()==self.getSolverOptions().LUMPING        return self.getSolverOptions().getSolverMethod() in [ SolverOptions.ROWSUM_LUMPING, SolverOptions.HRZ_LUMPING ]
1745     # ==========================================================================     # ==========================================================================
1746     #    symmetry  flag:     #    symmetry  flag:
1747     # ==========================================================================     # ==========================================================================
# Line 2615  class LinearPDE(LinearProblem): Line 2620  class LinearPDE(LinearProblem):
2620        """        """
2621        Returns the system type which needs to be used by the current set up.        Returns the system type which needs to be used by the current set up.
2622        """        """
2623        solver_options=self.getSolverOptions()        if self.isUsingLumping():
2624        return self.getDomain().getSystemMatrixTypeId(solver_options.getSolverMethod(), solver_options.getPreconditioner(),solver_options.getPackage(), solver_options.isSymmetric())       return "__ESCRIPT_DATA"
2625          else:
2626         solver_options=self.getSolverOptions()
2627         return self.getDomain().getSystemMatrixTypeId(solver_options.getSolverMethod(), solver_options.getPreconditioner(),solver_options.getPackage(), solver_options.isSymmetric())
2628    
2629     def checkSymmetry(self,verbose=True):     def checkSymmetry(self,verbose=True):
2630        """        """
# Line 2667  class LinearPDE(LinearProblem): Line 2675  class LinearPDE(LinearProblem):
2675         if not self.isSolutionValid():         if not self.isSolutionValid():
2676            mat,f=self.getSystem()            mat,f=self.getSystem()
2677            if self.isUsingLumping():            if self.isUsingLumping():
2678             if not util.inf(abs(mat)) > 0.:
2679             raise ZeroDivisionError,"Lumped mass matrix as zero entry (try order 1 elements or HRZ lumping)."
2680               self.setSolution(f*1/mat)               self.setSolution(f*1/mat)
2681            else:            else:
2682               self.trace("PDE is resolved.")               self.trace("PDE is resolved.")
# Line 2740  class LinearPDE(LinearProblem): Line 2750  class LinearPDE(LinearProblem):
2750                   self.resetOperator()                   self.resetOperator()
2751                   operator=self.getCurrentOperator()                   operator=self.getCurrentOperator()
2752                   if hasattr(self.getDomain(), "addPDEToLumpedSystem") :                   if hasattr(self.getDomain(), "addPDEToLumpedSystem") :
2753                      self.getDomain().addPDEToLumpedSystem(operator, D_times_e, d_times_e)              hrz_lumping=( self.getSolverOptions().getSolverMethod() ==  SolverOptions.HRZ_LUMPING )
2754                      self.getDomain().addPDEToLumpedSystem(operator, D_reduced_times_e, d_reduced_times_e)              self.getDomain().addPDEToLumpedSystem(operator, D_times_e, d_times_e,  hrz_lumping )
2755                self.getDomain().addPDEToLumpedSystem(operator, D_reduced_times_e, d_reduced_times_e, hrz_lumping)
2756                   else:                   else:
2757                      self.getDomain().addPDEToRHS(operator, \                      self.getDomain().addPDEToRHS(operator, \
2758                                                   escript.Data(), \                                                   escript.Data(), \

Legend:
Removed from v.3378  
changed lines
  Added in v.3379

  ViewVC Help
Powered by ViewVC 1.1.26