/[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 386 by gross, Tue Dec 13 07:35:31 2005 UTC revision 387 by gross, Tue Dec 20 00:37:20 2005 UTC
# Line 449  class LinearPDE(object): Line 449  class LinearPDE(object):
449     __METHOD_KEY="method"     __METHOD_KEY="method"
450     __SYMMETRY_KEY="symmetric"     __SYMMETRY_KEY="symmetric"
451     __TOLERANCE_KEY="tolerance"     __TOLERANCE_KEY="tolerance"
452       __PRECONDITIONER_KEY="preconditioner"
453    
454    
455     def __init__(self,domain,numEquations=None,numSolutions=None,debug=False):     def __init__(self,domain,numEquations=None,numSolutions=None,debug=False):
# Line 498  class LinearPDE(object): Line 499  class LinearPDE(object):
499       self.__tolerance=1.e-8       self.__tolerance=1.e-8
500       self.__solver_method=self.DEFAULT       self.__solver_method=self.DEFAULT
501       self.__solver_package=self.DEFAULT       self.__solver_package=self.DEFAULT
502         self.__preconditioner=self.DEFAULT
503       self.__matrix_type=self.__domain.getSystemMatrixTypeId(self.DEFAULT,self.DEFAULT,False)       self.__matrix_type=self.__domain.getSystemMatrixTypeId(self.DEFAULT,self.DEFAULT,False)
504       self.__sym=False       self.__sym=False
505    
# Line 772  class LinearPDE(object): Line 774  class LinearPDE(object):
774         @type verbose: C{bool}         @type verbose: C{bool}
775         @keyword reordering: reordering scheme to be used during elimination. Allowed values are         @keyword reordering: reordering scheme to be used during elimination. Allowed values are
776                              L{NO_REORDERING}, L{MINIMUM_FILL_IN}, L{NESTED_DISSECTION}                              L{NO_REORDERING}, L{MINIMUM_FILL_IN}, L{NESTED_DISSECTION}
        @keyword preconditioner: preconditioner method to be used. Allowed values are  
                                 L{SSOR}, L{ILU0}, L{ILUT}, L{JACOBI}  
777         @keyword iter_max: maximum number of iteration steps allowed.         @keyword iter_max: maximum number of iteration steps allowed.
778         @keyword drop_tolerance: threshold for drupping in L{ILUT}         @keyword drop_tolerance: threshold for drupping in L{ILUT}
779         @keyword drop_storage: maximum of allowed memory in L{ILUT}         @keyword drop_storage: maximum of allowed memory in L{ILUT}
# Line 786  class LinearPDE(object): Line 786  class LinearPDE(object):
786               self.__solution=self.copyConstraint(f*mat)               self.__solution=self.copyConstraint(f*mat)
787            else:            else:
788               options[self.__TOLERANCE_KEY]=self.getTolerance()               options[self.__TOLERANCE_KEY]=self.getTolerance()
789               options[self.__METHOD_KEY]=self.getSolverMethod()               options[self.__METHOD_KEY]=self.getSolverMethod()[0]
790                 options[self.__PRECONDITIONER_KEY]=self.getSolverMethod()[1]
791               options[self.__PACKAGE_KEY]=self.getSolverPackage()               options[self.__PACKAGE_KEY]=self.getSolverPackage()
792               options[self.__SYMMETRY_KEY]=self.isSymmetric()               options[self.__SYMMETRY_KEY]=self.isSymmetric()
793               self.trace("PDE is resolved.")               self.trace("PDE is resolved.")
# Line 815  class LinearPDE(object): Line 816  class LinearPDE(object):
816     # =============================================================================     # =============================================================================
817     #   solver settings:     #   solver settings:
818     # =============================================================================     # =============================================================================
819     def setSolverMethod(self,solver=None):     def setSolverMethod(self,solver=None,preconditioner=None):
820         """         """
821         sets a new solver         sets a new solver
822    
823         @param solver: sets a new solver method.         @param solver: sets a new solver method.
824         @type solver: one of L{DEFAULT}, L{ITERATIVE} L{DIRECT}, L{CHOLEVSKY}, L{PCG}, L{CR}, L{CGS}, L{BICGSTAB}, L{SSOR}, L{GMRES}, L{PRES20}, L{LUMPING}.         @type solver: one of L{DEFAULT}, L{ITERATIVE} L{DIRECT}, L{CHOLEVSKY}, L{PCG}, L{CR}, L{CGS}, L{BICGSTAB}, L{SSOR}, L{GMRES}, L{PRES20}, L{LUMPING}.
825           @param preconditioner: sets a new solver method.
826           @type solver: one of L{DEFAULT}, L{JACOBI} L{ILU0}, L{ILUT},L{SSOR}
827         """         """
828         if solver==None: solve=self.DEFAULT         if solver==None: solve=self.DEFAULT
829         if not solver==self.getSolverMethod():         if preconditioner==None: preconditioner=self.DEFAULT
830           if not (solver,preconditioner)==self.getSolverMethod():
831             self.__solver_method=solver             self.__solver_method=solver
832               self.__preconditioner=preconditioner
833             self.__checkMatrixType()             self.__checkMatrixType()
834             self.trace("New solver is %s"%self.getSolverMethodName())             self.trace("New solver is %s"%self.getSolverMethodName())
835    
# Line 838  class LinearPDE(object): Line 843  class LinearPDE(object):
843    
844         m=self.getSolverMethod()         m=self.getSolverMethod()
845         p=self.getSolverPackage()         p=self.getSolverPackage()
846         if m==self.DEFAULT: method="DEFAULT"         if m[0]==self.DEFAULT: method="DEFAULT"
847         elif m==self.DIRECT: method= "DIRECT"         elif m[0]==self.DIRECT: method= "DIRECT"
848         elif m==self.ITERATIVE: method= "ITERATIVE"         elif m[0]==self.ITERATIVE: method= "ITERATIVE"
849         elif m==self.CHOLEVSKY: method= "CHOLEVSKY"         elif m[0]==self.CHOLEVSKY: method= "CHOLEVSKY"
850         elif m==self.PCG: method= "PCG"         elif m[0]==self.PCG: method= "PCG"
851         elif m==self.CR: method= "CR"         elif m[0]==self.CR: method= "CR"
852         elif m==self.CGS: method= "CGS"         elif m[0]==self.CGS: method= "CGS"
853         elif m==self.BICGSTAB: method= "BICGSTAB"         elif m[0]==self.BICGSTAB: method= "BICGSTAB"
854         elif m==self.SSOR: method= "SSOR"         elif m[0]==self.SSOR: method= "SSOR"
855         elif m==self.GMRES: method= "GMRES"         elif m[0]==self.GMRES: method= "GMRES"
856         elif m==self.PRES20: method= "PRES20"         elif m[0]==self.PRES20: method= "PRES20"
857         elif m==self.LUMPING: method= "LUMPING"         elif m[0]==self.LUMPING: method= "LUMPING"
858         else : method="unknown"         else : method="unknown"
859           if m[1]==self.DEFAULT: method+="DEFAULT"
860           elif m[1]==self.JACOBI: method+= "JACOBI"
861           elif m[1]==self.ILU0: method+= "ILU0"
862           elif m[1]==self.ILUT: method+= "ILUT"
863           elif m[1]==self.SSOR: method+= "SSOR"
864           else : method+="unknown"
865         if p==self.DEFAULT: package="DEFAULT"         if p==self.DEFAULT: package="DEFAULT"
866         elif p==self.PASO: package= "PASO"         elif p==self.PASO: package= "PASO"
867         elif p==self.MKL: package= "MKL"         elif p==self.MKL: package= "MKL"
# Line 867  class LinearPDE(object): Line 878  class LinearPDE(object):
878         @return: the solver method currently be used.         @return: the solver method currently be used.
879         @rtype: C{int}         @rtype: C{int}
880         """         """
881         return self.__solver_method         return self.__solver_method,self.__preconditioner
882    
883     def setSolverPackage(self,package=None):     def setSolverPackage(self,package=None):
884         """         """
# Line 898  class LinearPDE(object): Line 909  class LinearPDE(object):
909        @return: True is lumping is currently used a solver method.        @return: True is lumping is currently used a solver method.
910        @rtype: C{bool}        @rtype: C{bool}
911        """        """
912        return self.getSolverMethod()==self.LUMPING        return self.getSolverMethod()[0]==self.LUMPING
913    
914     def setTolerance(self,tol=1.e-8):     def setTolerance(self,tol=1.e-8):
915         """         """
# Line 1091  class LinearPDE(object): Line 1102  class LinearPDE(object):
1102       """       """
1103       reassess the matrix type and, if a new matrix is needed, resets the system.       reassess the matrix type and, if a new matrix is needed, resets the system.
1104       """       """
1105       new_matrix_type=self.getDomain().getSystemMatrixTypeId(self.getSolverMethod(),self.getSolverPackage(),self.isSymmetric())       new_matrix_type=self.getDomain().getSystemMatrixTypeId(self.getSolverMethod()[0],self.getSolverPackage(),self.isSymmetric())
1106       if not new_matrix_type==self.__matrix_type:       if not new_matrix_type==self.__matrix_type:
1107           self.trace("Matrix type is now %d."%new_matrix_type)           self.trace("Matrix type is now %d."%new_matrix_type)
1108           self.__matrix_type=new_matrix_type           self.__matrix_type=new_matrix_type

Legend:
Removed from v.386  
changed lines
  Added in v.387

  ViewVC Help
Powered by ViewVC 1.1.26