/[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 425 by gross, Tue Jan 10 04:10:39 2006 UTC revision 531 by gross, Wed Feb 15 08:11:10 2006 UTC
# Line 419  class LinearPDE(object): Line 419  class LinearPDE(object):
419     @cvar MKL: Intel's MKL solver library     @cvar MKL: Intel's MKL solver library
420     @cvar UMFPACK: the UMFPACK library     @cvar UMFPACK: the UMFPACK library
421     @cvar ITERATIVE: The default iterative solver     @cvar ITERATIVE: The default iterative solver
422       @cvar AMG: algebraic multi grid
423       @cvar RILU: recursive ILU
424    
425     """     """
426     DEFAULT= 0     DEFAULT= 0
# Line 443  class LinearPDE(object): Line 445  class LinearPDE(object):
445     UMFPACK= 16     UMFPACK= 16
446     ITERATIVE= 20     ITERATIVE= 20
447     PASO= 21     PASO= 21
448       AMG= 22
449       RILU = 23
450    
451     __TOL=1.e-13     __TOL=1.e-13
452     __PACKAGE_KEY="package"     __PACKAGE_KEY="package"
# Line 821  class LinearPDE(object): Line 825  class LinearPDE(object):
825         sets a new solver         sets a new solver
826    
827         @param solver: sets a new solver method.         @param solver: sets a new solver method.
828         @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}, L{AMG}
829         @param preconditioner: sets a new solver method.         @param preconditioner: sets a new solver method.
830         @type solver: one of L{DEFAULT}, L{JACOBI} L{ILU0}, L{ILUT},L{SSOR}         @type preconditioner: one of L{DEFAULT}, L{JACOBI} L{ILU0}, L{ILUT},L{SSOR}, L{RILU}
831         """         """
832         if solver==None: solve=self.DEFAULT         if solver==None: solve=self.DEFAULT
833         if preconditioner==None: preconditioner=self.DEFAULT         if preconditioner==None: preconditioner=self.DEFAULT
# Line 856  class LinearPDE(object): Line 860  class LinearPDE(object):
860         elif m[0]==self.GMRES: method= "GMRES"         elif m[0]==self.GMRES: method= "GMRES"
861         elif m[0]==self.PRES20: method= "PRES20"         elif m[0]==self.PRES20: method= "PRES20"
862         elif m[0]==self.LUMPING: method= "LUMPING"         elif m[0]==self.LUMPING: method= "LUMPING"
863           elif m[0]==self.AMG: method= "AMG"
864         if m[1]==self.DEFAULT: method+="+DEFAULT"         if m[1]==self.DEFAULT: method+="+DEFAULT"
865         elif m[1]==self.JACOBI: method+= "+JACOBI"         elif m[1]==self.JACOBI: method+= "+JACOBI"
866         elif m[1]==self.ILU0: method+= "+ILU0"         elif m[1]==self.ILU0: method+= "+ILU0"
867         elif m[1]==self.ILUT: method+= "+ILUT"         elif m[1]==self.ILUT: method+= "+ILUT"
868         elif m[1]==self.SSOR: method+= "+SSOR"         elif m[1]==self.SSOR: method+= "+SSOR"
869           elif m[1]==self.AMG: method+= "+AMG"
870           elif m[1]==self.RILU: method+= "+RILU"
871         if p==self.DEFAULT: package="DEFAULT"         if p==self.DEFAULT: package="DEFAULT"
872         elif p==self.PASO: package= "PASO"         elif p==self.PASO: package= "PASO"
873         elif p==self.MKL: package= "MKL"         elif p==self.MKL: package= "MKL"
# Line 1525  class LinearPDE(object): Line 1532  class LinearPDE(object):
1532         if not self.__operator_is_Valid or not self.__righthandside_isValid:         if not self.__operator_is_Valid or not self.__righthandside_isValid:
1533            if self.isUsingLumping():            if self.isUsingLumping():
1534                if not self.__operator_is_Valid:                if not self.__operator_is_Valid:
1535                   if not self.getFunctionSpaceForEquation()==self.getFunctionSpaceForSolution(): raise TypeError,"Lumped matrix requires same order for equations and unknowns"                   if not self.getFunctionSpaceForEquation()==self.getFunctionSpaceForSolution():
1536                   if not self.getCoefficientOfGeneralPDE("A").isEmpty(): raise Warning,"Using coefficient A in lumped matrix can produce wrong results"                        raise TypeError,"Lumped matrix requires same order for equations and unknowns"
1537                   if not self.getCoefficientOfGeneralPDE("B").isEmpty(): raise Warning,"Using coefficient B in lumped matrix can produce wrong results"                   if not self.getCoefficientOfGeneralPDE("A").isEmpty():
1538                   if not self.getCoefficientOfGeneralPDE("C").isEmpty(): raise Warning,"Using coefficient C in lumped matrix can produce wrong results"                        raise ValueError,"coefficient A in lumped matrix may not be present."
1539                   mat=self.__getNewOperator()                   if not self.getCoefficientOfGeneralPDE("B").isEmpty():
1540                   self.getDomain().addPDEToSystem(mat,escript.Data(), \                        raise ValueError,"coefficient A in lumped matrix may not be present."
1541                             self.getCoefficientOfGeneralPDE("A"), \                   if not self.getCoefficientOfGeneralPDE("C").isEmpty():
1542                             self.getCoefficientOfGeneralPDE("B"), \                        raise ValueError,"coefficient A in lumped matrix may not be present."
1543                             self.getCoefficientOfGeneralPDE("C"), \                   D=self.getCoefficientOfGeneralPDE("D")
1544                             self.getCoefficientOfGeneralPDE("D"), \                   if not D.isEmpty():
1545                             escript.Data(), \                       if self.getNumSolutions()>1:
1546                             escript.Data(), \                          D_times_e=util.matrixmult(D,numarray.ones((self.getNumSolutions(),)))
1547                             self.getCoefficientOfGeneralPDE("d"), \                       else:
1548                             escript.Data(),\                          D_times_e=D
1549                             self.getCoefficientOfGeneralPDE("d_contact"), \                   else:
1550                             escript.Data())                      D_times_e=escript.Data()
1551                   self.__operator=1./(mat*escript.Data(1,(self.getNumSolutions(),),self.getFunctionSpaceForSolution(),True))                   d=self.getCoefficientOfGeneralPDE("d")
1552                   del mat                   if not d.isEmpty():
1553                         if self.getNumSolutions()>1:
1554                            d_times_e=util.matrixmult(d,numarray.ones((self.getNumSolutions(),)))
1555                         else:
1556                            d_times_e=d
1557                     else:
1558                        d_times_e=escript.Data()
1559                     d_contact=self.getCoefficientOfGeneralPDE("d_contact")
1560                     if not d_contact.isEmpty():
1561                         if self.getNumSolutions()>1:
1562                            d_contact_times_e=util.matrixmult(d_contact,numarray.ones((self.getNumSolutions(),)))
1563                         else:
1564                            d_contact_times_e=d_contact
1565                     else:
1566                        d_contact_times_e=escript.Data()
1567        
1568                     self.__operator=self.__getNewRightHandSide()
1569                     self.getDomain().addPDEToRHS(self.__operator, \
1570                                                  escript.Data(), \
1571                                                  D_times_e, \
1572                                                  d_times_e,\
1573                                                  d_contact_times_e)
1574                     self.__operator=1./self.__operator
1575                   self.trace("New lumped operator has been built.")                   self.trace("New lumped operator has been built.")
1576                   self.__operator_is_Valid=True                   self.__operator_is_Valid=True
1577                if not self.__righthandside_isValid:                if not self.__righthandside_isValid:

Legend:
Removed from v.425  
changed lines
  Added in v.531

  ViewVC Help
Powered by ViewVC 1.1.26