/[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 149 by jgs, Thu Sep 1 03:31:39 2005 UTC revision 150 by jgs, Thu Sep 15 03:44:45 2005 UTC
# Line 62  class PDECoefficient: Line 62  class PDECoefficient:
62      @cvar BOUNDARY: indicator that coefficient is defined on the boundary of the PDE domain      @cvar BOUNDARY: indicator that coefficient is defined on the boundary of the PDE domain
63      @cvar CONTACT: indicator that coefficient is defined on the contact region within the PDE domain      @cvar CONTACT: indicator that coefficient is defined on the contact region within the PDE domain
64      @cvar SOLUTION: indicator that coefficient is defined trough a solution of the PDE      @cvar SOLUTION: indicator that coefficient is defined trough a solution of the PDE
65        @cvar REDUCED: indicator that coefficient is defined trough a reduced solution of the PDE
66      @cvar BY_EQUATION: indicator that the dimension of the coefficient shape is defined by the number PDE equations      @cvar BY_EQUATION: indicator that the dimension of the coefficient shape is defined by the number PDE equations
67      @cvar BY_SOLUTION: indicator that the dimension of the coefficient shape is defined by the number PDE solutions      @cvar BY_SOLUTION: indicator that the dimension of the coefficient shape is defined by the number PDE solutions
68      @cvar BY_DIM: indicator that the dimension of the coefficient shape is defined by the spatial dimension      @cvar BY_DIM: indicator that the dimension of the coefficient shape is defined by the spatial dimension
# Line 74  class PDECoefficient: Line 75  class PDECoefficient:
75      BOUNDARY=1      BOUNDARY=1
76      CONTACT=2      CONTACT=2
77      SOLUTION=3      SOLUTION=3
78        REDUCED=4
79      BY_EQUATION=5      BY_EQUATION=5
80      BY_SOLUTION=6      BY_SOLUTION=6
81      BY_DIM=7      BY_DIM=7
# Line 86  class PDECoefficient: Line 88  class PDECoefficient:
88         Initialise a PDE Coefficient type         Initialise a PDE Coefficient type
89                
90         @param where: describes where the coefficient lives         @param where: describes where the coefficient lives
91         @type where: one of L{INTERIOR}, L{BOUNDARY}, L{CONTACT}, L{SOLUTION}         @type where: one of L{INTERIOR}, L{BOUNDARY}, L{CONTACT}, L{SOLUTION}, L{REDUCED}
92         @param pattern: describes the shape of the coefficient and how the shape is build for a given         @param pattern: describes the shape of the coefficient and how the shape is build for a given
93                spatial dimension and numbers of equation and solution in then PDE. For instance,                spatial dimension and numbers of equation and solution in then PDE. For instance,
94                (L{BY_EQUATION},L{BY_SOLUTION},L{BY_DIM}) descrbes a rank 3 coefficient which                (L{BY_EQUATION},L{BY_SOLUTION},L{BY_DIM}) descrbes a rank 3 coefficient which
# Line 134  class PDECoefficient: Line 136  class PDECoefficient:
136                  return escript.ReducedSolution(domain)                  return escript.ReducedSolution(domain)
137              else:              else:
138                  return escript.Solution(domain)                  return escript.Solution(domain)
139           elif self.what==self.REDUCED:
140                if reducedEquationOrder and reducedSolutionOrder:
141                    return escript.ReducedSolution(domain)
142                else:
143                    return escript.ReducedSolution(domain)
144    
145      def getValue(self):      def getValue(self):
146         """         """
# Line 392  class LinearPDE: Line 399  class LinearPDE:
399     In this case the the coefficient M{d_contact} and M{y_contact} are eaach scalar     In this case the the coefficient M{d_contact} and M{y_contact} are eaach scalar
400     both in the L{FunctionOnContactZero<escript.FunctionOnContactZero>} or L{FunctionOnContactOne<escript.FunctionOnContactOne>}.     both in the L{FunctionOnContactZero<escript.FunctionOnContactZero>} or L{FunctionOnContactOne<escript.FunctionOnContactOne>}.
401    
402       @cvar DEFAULT: The default method used to solve the system of linear equations
    @cvar DEFAULT_METHOD: The default method used to solve the system of linear equations  
403     @cvar DIRECT: The direct solver based on LDU factorization     @cvar DIRECT: The direct solver based on LDU factorization
404     @cvar CHOLEVSKY: The direct solver based on LDLt factorization (can only be applied for symmetric PDEs)     @cvar CHOLEVSKY: The direct solver based on LDLt factorization (can only be applied for symmetric PDEs)
405     @cvar PCG: The preconditioned conjugate gradient method (can only be applied for symmetric PDEs)     @cvar PCG: The preconditioned conjugate gradient method (can only be applied for symmetric PDEs)
# Line 410  class LinearPDE: Line 416  class LinearPDE:
416     @cvar NO_REORDERING: No matrix reordering allowed     @cvar NO_REORDERING: No matrix reordering allowed
417     @cvar MINIMUM_FILL_IN: Reorder matrix to reduce fill-in during factorization     @cvar MINIMUM_FILL_IN: Reorder matrix to reduce fill-in during factorization
418     @cvar NESTED_DISSECTION: Reorder matrix to improve load balancing during factorization     @cvar NESTED_DISSECTION: Reorder matrix to improve load balancing during factorization
419       @cvar PASO: PASO solver package
420       @cvar SCSL: SGI SCSL solver library
421       @cvar MKL: Intel's MKL solver library
422       @cvar UMFPACK: the UMFPACK library
423       @cvar ITERATIVE: The default iterative solver
424    
425     """     """
426     DEFAULT_METHOD=0     DEFAULT= 0
427     DIRECT=1     DIRECT= 1
428     CHOLEVSKY=2     CHOLEVSKY= 2
429     PCG=3     PCG= 3
430     CR=4     CR= 4
431     CGS=5     CGS= 5
432     BICGSTAB=6     BICGSTAB= 6
433     SSOR=7     SSOR= 7
434     ILU0=8     ILU0= 8
435     ILUT=9     ILUT= 9
436     JACOBI=10     JACOBI= 10
437     GMRES=11     GMRES= 11
438     PRES20=12     PRES20= 12
439     LUMPING=13     LUMPING= 13
440     NO_REORDERING=0     NO_REORDERING= 17
441     MINIMUM_FILL_IN=1     MINIMUM_FILL_IN= 18
442     NESTED_DISSECTION=2     NESTED_DISSECTION= 19
443       SCSL= 14
444       MKL= 15
445       UMFPACK= 16
446       ITERATIVE= 20
447       PASO= 21
448    
449     __TOL=1.e-13     __TOL=1.e-13
450       __PACKAGE_KEY="package"
451     __METHOD_KEY="method"     __METHOD_KEY="method"
452     __SYMMETRY_KEY="symmetric"     __SYMMETRY_KEY="symmetric"
453     __TOLERANCE_KEY="tolerance"     __TOLERANCE_KEY="tolerance"
# Line 479  class LinearPDE: Line 497  class LinearPDE:
497       self.__reduce_equation_order=False       self.__reduce_equation_order=False
498       self.__reduce_solution_order=False       self.__reduce_solution_order=False
499       self.__tolerance=1.e-8       self.__tolerance=1.e-8
500       self.__solver_method=self.DEFAULT_METHOD       self.__solver_method=self.DEFAULT
501       self.__matrix_type=self.__domain.getSystemMatrixTypeId(self.DEFAULT_METHOD,False)       self.__solver_package=self.DEFAULT
502         self.__matrix_type=self.__domain.getSystemMatrixTypeId(self.DEFAULT,self.DEFAULT,False)
503       self.__sym=False       self.__sym=False
504    
505       self.resetCoefficients()       self.resetCoefficients()
# Line 769  class LinearPDE: Line 788  class LinearPDE:
788            else:            else:
789               options[self.__TOLERANCE_KEY]=self.getTolerance()               options[self.__TOLERANCE_KEY]=self.getTolerance()
790               options[self.__METHOD_KEY]=self.getSolverMethod()               options[self.__METHOD_KEY]=self.getSolverMethod()
791                 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.")
794               self.trace("solver options: %s"%str(options))               self.trace("solver options: %s"%str(options))
# Line 801  class LinearPDE: Line 821  class LinearPDE:
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_METHOD}, 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         """         """
826         if solver==None: solve=self.DEFAULT_METHOD         if solver==None: solve=self.DEFAULT
827         if not solver==self.getSolverMethod():         if not solver==self.getSolverMethod():
828             self.__solver_method=solver             self.__solver_method=solver
829             self.__checkMatrixType()             self.__checkMatrixType()
# Line 819  class LinearPDE: Line 838  class LinearPDE:
838         """         """
839    
840         m=self.getSolverMethod()         m=self.getSolverMethod()
841         if m==self.DEFAULT_METHOD: return "DEFAULT_METHOD"         p=self.getSolverPackage()
842         elif m==self.DIRECT: return "DIRECT"         if m==self.DEFAULT: method="DEFAULT"
843         elif m==self.CHOLEVSKY: return "CHOLEVSKY"         elif m==self.DIRECT: method= "DIRECT"
844         elif m==self.PCG: return "PCG"         elif m==self.ITERATIVE: method= "ITERATIVE"
845         elif m==self.CR: return "CR"         elif m==self.CHOLEVSKY: method= "CHOLEVSKY"
846         elif m==self.CGS: return "CGS"         elif m==self.PCG: method= "PCG"
847         elif m==self.BICGSTAB: return "BICGSTAB"         elif m==self.CR: method= "CR"
848         elif m==self.SSOR: return "SSOR"         elif m==self.CGS: method= "CGS"
849         elif m==self.GMRES: return "GMRES"         elif m==self.BICGSTAB: method= "BICGSTAB"
850         elif m==self.PRES20: return "PRES20"         elif m==self.SSOR: method= "SSOR"
851         elif m==self.LUMPING: return "LUMPING"         elif m==self.GMRES: method= "GMRES"
852         return None         elif m==self.PRES20: method= "PRES20"
853           elif m==self.LUMPING: method= "LUMPING"
854           else : method="unknown"
855           if p==self.DEFAULT: package="DEFAULT"
856           elif p==self.PASO: package= "PASO"
857           elif p==self.MKL: package= "MKL"
858           elif p==self.SCSL: package= "SCSL"
859           elif p==self.UMFPACK: package= "UMFPACK"
860           else : method="unknown"
861           return "%s solver of %s package"%(method,package)
862    
863    
864     def getSolverMethod(self):     def getSolverMethod(self):
# Line 842  class LinearPDE: Line 870  class LinearPDE:
870         """         """
871         return self.__solver_method         return self.__solver_method
872    
873       def setSolverPackage(self,package=None):
874           """
875           sets a new solver package
876    
877           @param solver: sets a new solver method.
878           @type solver: one of L{DEFAULT}, L{PASO} L{SCSL}, L{MKL}, L{UMLPACK}
879           """
880           if package==None: package=self.DEFAULT
881           if not package==self.getSolverPackage():
882               self.__solver_method=solver
883               self.__checkMatrixType()
884               self.trace("New solver is %s"%self.getSolverMethodName())
885    
886       def getSolverPackage(self):
887           """
888           returns the package of the solver
889    
890           @return: the solver package currently being used.
891           @rtype: C{int}
892           """
893           return self.__solver_package
894    
895     def isUsingLumping(self):     def isUsingLumping(self):
896        """        """
897        checks if matrix lumping is used a solver method        checks if matrix lumping is used a solver method
# Line 1042  class LinearPDE: Line 1092  class LinearPDE:
1092       """       """
1093       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.
1094       """       """
1095       new_matrix_type=self.getDomain().getSystemMatrixTypeId(self.getSolverMethod(),self.isSymmetric())       new_matrix_type=self.getDomain().getSystemMatrixTypeId(self.getSolverMethod(),self.getSolverPackage(),self.isSymmetric())
1096       if not new_matrix_type==self.__matrix_type:       if not new_matrix_type==self.__matrix_type:
1097           self.trace("Matrix type is now %d."%new_matrix_type)           self.trace("Matrix type is now %d."%new_matrix_type)
1098           self.__matrix_type=new_matrix_type           self.__matrix_type=new_matrix_type
# Line 2169  class AdvectivePDE(LinearPDE): Line 2219  class AdvectivePDE(LinearPDE):
2219    
2220    
2221  # $Log$  # $Log$
2222    # Revision 1.13  2005/09/15 03:44:19  jgs
2223    # Merge of development branch dev-02 back to main trunk on 2005-09-15
2224    #
2225  # Revision 1.12  2005/09/01 03:31:28  jgs  # Revision 1.12  2005/09/01 03:31:28  jgs
2226  # Merge of development branch dev-02 back to main trunk on 2005-09-01  # Merge of development branch dev-02 back to main trunk on 2005-09-01
2227  #  #
# Line 2178  class AdvectivePDE(LinearPDE): Line 2231  class AdvectivePDE(LinearPDE):
2231  # Revision 1.10  2005/08/12 01:45:36  jgs  # Revision 1.10  2005/08/12 01:45:36  jgs
2232  # erge of development branch dev-02 back to main trunk on 2005-08-12  # erge of development branch dev-02 back to main trunk on 2005-08-12
2233  #  #
2234    # Revision 1.9.2.15  2005/09/14 08:09:18  matt
2235    # Added "REDUCED" solution PDECoefficient descriptors for LinearPDEs.
2236    #
2237    # Revision 1.9.2.14  2005/09/07 06:26:16  gross
2238    # the solver from finley are put into the standalone package paso now
2239    #
2240  # Revision 1.9.2.13  2005/08/31 08:45:03  gross  # Revision 1.9.2.13  2005/08/31 08:45:03  gross
2241  # in the case of lumping no new system is allocated if the constraint is changed.  # in the case of lumping no new system is allocated if the constraint is changed.
2242  #  #

Legend:
Removed from v.149  
changed lines
  Added in v.150

  ViewVC Help
Powered by ViewVC 1.1.26