/[escript]/trunk-mpi-branch/escript/py_src/linearPDEs.py
ViewVC logotype

Diff of /trunk-mpi-branch/escript/py_src/linearPDEs.py

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

revision 120 by jgs, Fri Mar 4 07:12:37 2005 UTC revision 121 by jgs, Fri May 6 04:26:16 2005 UTC
# Line 273  class LinearPDE: Line 273  class LinearPDE:
273    
274        @param coefficients        @param coefficients
275        """        """
276        self._setValue(**coefficients)        self.__setValue(**coefficients)
277                
278    
279     def cleanCoefficients(self):     def cleanCoefficients(self):
# Line 536  class LinearPDE: Line 536  class LinearPDE:
536          self.setReducedOrderForEquationOff()          self.setReducedOrderForEquationOff()
537                                                                                                                                                                                                                                                                                                                        
538     # ==== initialization =====================================================================     # ==== initialization =====================================================================
539     def __makeNewOperator(self):     def __getNewOperator(self):
540         """         """
541         @brief         @brief
542         """         """
# Line 547  class LinearPDE: Line 547  class LinearPDE:
547                             self.getFunctionSpaceForSolution(), \                             self.getFunctionSpaceForSolution(), \
548                             self.__matrix_type)                             self.__matrix_type)
549    
550     def __makeNewRightHandSide(self):     def __makeFreshRightHandSide(self):
551         """         """
552         @brief         @brief
553         """         """
554         return escript.Data(0.,(self.getNumEquations(),),self.getFunctionSpaceForEquation(),True)         if self.debug() : print "PDE Debug: New right hand side allocated"
555           if self.getNumEquations()>1:
556               self.__righthandside=escript.Data(0.,(self.getNumEquations(),),self.getFunctionSpaceForEquation(),True)
557           else:
558               self.__righthandside=escript.Data(0.,(),self.getFunctionSpaceForEquation(),True)
559           return self.__righthandside
560    
561     def __makeNewSolution(self):     def __getNewSolution(self):
562         """         """
563         @brief         @brief
564         """         """
565         return escript.Data(0.,(self.getNumSolutions(),),self.getFunctionSpaceForSolution(),True)         if self.debug() : print "PDE Debug: New right hand side allocated"
566           if self.getNumSolutions()>1:
567               return escript.Data(0.,(self.getNumSolutions(),),self.getFunctionSpaceForSolution(),True)
568           else:
569               return escript.Data(0.,(),self.getFunctionSpaceForSolution(),True)
570    
571     def __getFreshOperator(self):     def __makeFreshOperator(self):
572         """         """
573         @brief         @brief
574         """         """
575         if self.__operator.isEmpty():         if self.__operator.isEmpty():
576             self.__operator=self.__makeNewOperator()             self.__operator=self.__getNewOperator()
577             if self.debug() : print "PDE Debug: New operator allocated"             if self.debug() : print "PDE Debug: New operator allocated"
578         else:         else:
579             self.__operator.setValue(0.)             self.__operator.setValue(0.)
# Line 572  class LinearPDE: Line 581  class LinearPDE:
581             if self.debug() : print "PDE Debug: Operator reset to zero"             if self.debug() : print "PDE Debug: Operator reset to zero"
582         return self.__operator         return self.__operator
583    
    def __getFreshRightHandSide(self):  
        """  
        @brief  
        """  
        if self.__righthandside.isEmpty():  
            self.__righthandside=self.__makeNewRightHandSide()  
            if self.debug() : print "PDE Debug: New right hand side allocated"  
        else:  
            print "fix self.__righthandside*=0"  
            self.__righthandside*=0.  
            if self.debug() : print "PDE Debug: Right hand side reset to zero"  
        return  self.__righthandside  
   
584     #============ some serivice functions  =====================================================     #============ some serivice functions  =====================================================
585     def getDomain(self):     def getDomain(self):
586       """       """
# Line 707  class LinearPDE: Line 703  class LinearPDE:
703         """         """
704         return self.applyOperator(u)-self.getRightHandSide()         return self.applyOperator(u)-self.getRightHandSide()
705    
706     def _setValue(self,**coefficients):     def __setValue(self,**coefficients):
707        """        """
708        @brief sets new values to coefficient        @brief sets new values to coefficient
709    
# Line 846  class LinearPDE: Line 842  class LinearPDE:
842            # q is the row and column mask to indicate where constraints are set:            # q is the row and column mask to indicate where constraints are set:
843            row_q=escript.Data(q,self.getFunctionSpaceForEquation())            row_q=escript.Data(q,self.getFunctionSpaceForEquation())
844            col_q=escript.Data(q,self.getFunctionSpaceForSolution())            col_q=escript.Data(q,self.getFunctionSpaceForSolution())
845            u=self.__makeNewSolution()            u=self.__getNewSolution()
846            if r.isEmpty():            if r.isEmpty():
847               r_s=self.__makeNewSolution()               r_s=self.__getNewSolution()
848            else:            else:
849               r_s=escript.Data(r,self.getFunctionSpaceForSolution())               r_s=escript.Data(r,self.getFunctionSpaceForSolution())
850            u.copyWithMask(r_s,col_q)            u.copyWithMask(r_s,col_q)
# Line 874  class LinearPDE: Line 870  class LinearPDE:
870                   if not self.getCoefficientOfPDE("C").isEmpty():                   if not self.getCoefficientOfPDE("C").isEmpty():
871                            raise Warning,"Lumped matrix does not allow coefficient C"                            raise Warning,"Lumped matrix does not allow coefficient C"
872                   if self.debug() : print "PDE Debug: New lumped operator is built."                   if self.debug() : print "PDE Debug: New lumped operator is built."
873                   mat=self.__makeNewOperator()                   mat=self.__getNewOperator()
874                   self.getDomain().addPDEToSystem(mat,escript.Data(), \                   self.getDomain().addPDEToSystem(mat,escript.Data(), \
875                             self.getCoefficientOfPDE("A"), \                             self.getCoefficientOfPDE("A"), \
876                             self.getCoefficientOfPDE("B"), \                             self.getCoefficientOfPDE("B"), \
# Line 891  class LinearPDE: Line 887  class LinearPDE:
887                   self.__operator_isValid=True                   self.__operator_isValid=True
888                if not self.__righthandside_isValid:                if not self.__righthandside_isValid:
889                   if self.debug() : print "PDE Debug: New right hand side is built."                   if self.debug() : print "PDE Debug: New right hand side is built."
890                   self.getDomain().addPDEToRHS(self.__getFreshRightHandSide(), \                   self.getDomain().addPDEToRHS(self.__makeFreshRightHandSide(), \
891                                 self.getCoefficientOfPDE("X"), \                                 self.getCoefficientOfPDE("X"), \
892                                 self.getCoefficientOfPDE("Y"),\                                 self.getCoefficientOfPDE("Y"),\
893                                 self.getCoefficientOfPDE("y"),\                                 self.getCoefficientOfPDE("y"),\
# Line 901  class LinearPDE: Line 897  class LinearPDE:
897            else:            else:
898               if not self.__operator_isValid and not self.__righthandside_isValid:               if not self.__operator_isValid and not self.__righthandside_isValid:
899                   if self.debug() : print "PDE Debug: New system is built."                   if self.debug() : print "PDE Debug: New system is built."
900                   self.getDomain().addPDEToSystem(self.__getFreshOperator(),self.__getFreshRightHandSide(), \                   self.getDomain().addPDEToSystem(self.__makeFreshOperator(),self.__makeFreshRightHandSide(), \
901                                 self.getCoefficientOfPDE("A"), \                                 self.getCoefficientOfPDE("A"), \
902                                 self.getCoefficientOfPDE("B"), \                                 self.getCoefficientOfPDE("B"), \
903                                 self.getCoefficientOfPDE("C"), \                                 self.getCoefficientOfPDE("C"), \
# Line 918  class LinearPDE: Line 914  class LinearPDE:
914                   self.__righthandside_isValid=True                   self.__righthandside_isValid=True
915               elif not self.__righthandside_isValid:               elif not self.__righthandside_isValid:
916                   if self.debug() : print "PDE Debug: New right hand side is built."                   if self.debug() : print "PDE Debug: New right hand side is built."
917                   self.getDomain().addPDEToRHS(self.__getFreshRightHandSide(), \                   self.getDomain().addPDEToRHS(self.__makeFreshRightHandSide(), \
918                                 self.getCoefficientOfPDE("X"), \                                 self.getCoefficientOfPDE("X"), \
919                                 self.getCoefficientOfPDE("Y"),\                                 self.getCoefficientOfPDE("Y"),\
920                                 self.getCoefficientOfPDE("y"),\                                 self.getCoefficientOfPDE("y"),\
# Line 927  class LinearPDE: Line 923  class LinearPDE:
923                   self.__righthandside_isValid=True                   self.__righthandside_isValid=True
924               elif not self.__operator_isValid:               elif not self.__operator_isValid:
925                   if self.debug() : print "PDE Debug: New operator is built."                   if self.debug() : print "PDE Debug: New operator is built."
926                   self.getDomain().addPDEToSystem(self.__getFreshOperator(),escript.Data(), \                   self.getDomain().addPDEToSystem(self.__makeFreshOperator(),escript.Data(), \
927                              self.getCoefficientOfPDE("A"), \                              self.getCoefficientOfPDE("A"), \
928                              self.getCoefficientOfPDE("B"), \                              self.getCoefficientOfPDE("B"), \
929                              self.getCoefficientOfPDE("C"), \                              self.getCoefficientOfPDE("C"), \
# Line 1026  class AdvectivePDE(LinearPDE): Line 1022  class AdvectivePDE(LinearPDE):
1022    
1023     def setValue(self,**args):     def setValue(self,**args):
1024         if "A" in args.keys()   or "B" in args.keys() or "C" in args.keys(): self.__Xi=escript.Data()         if "A" in args.keys()   or "B" in args.keys() or "C" in args.keys(): self.__Xi=escript.Data()
1025         self._setValue(**args)         self._LinearPDE__setValue(**args)
1026                        
1027     def getXi(self):     def getXi(self):
1028        if self.__Xi.isEmpty():        if self.__Xi.isEmpty():
# Line 1241  class Poisson(LinearPDE): Line 1237  class Poisson(LinearPDE):
1237         self.setValue(f,q)         self.setValue(f,q)
1238    
1239     def setValue(self,f=escript.Data(),q=escript.Data()):     def setValue(self,f=escript.Data(),q=escript.Data()):
1240         self._setValue(f=f,q=q)         self._LinearPDE__setValue(f=f,q=q)
1241    
1242     def getCoefficientOfPDE(self,name):     def getCoefficientOfPDE(self,name):
1243       """       """
# Line 1274  class Poisson(LinearPDE): Line 1270  class Poisson(LinearPDE):
1270           return self.getCoefficient("q")           return self.getCoefficient("q")
1271       else:       else:
1272           raise SystemError,"unknown PDE coefficient %s",name           raise SystemError,"unknown PDE coefficient %s",name
1273    
1274    # $Log$
1275    # Revision 1.7  2005/05/06 04:26:10  jgs
1276    # Merge of development branch back to main trunk on 2005-05-06
1277    #
1278    # Revision 1.1.2.20  2005/04/15 07:09:08  gross
1279    # some problems with functionspace and linearPDEs fixed.
1280    #
1281    # Revision 1.1.2.19  2005/03/04 05:27:07  gross
1282    # bug in SystemPattern fixed.
1283    #
1284    # Revision 1.1.2.18  2005/02/08 06:16:45  gross
1285    # Bugs in AdvectivePDE fixed, AdvectiveTest is stable but more testing is needed
1286    #
1287    # Revision 1.1.2.17  2005/02/08 05:56:19  gross
1288    # Reference Number handling added
1289    #
1290    # Revision 1.1.2.16  2005/02/07 04:41:28  gross
1291    # some function exposed to python to make mesh merging running
1292    #
1293    # Revision 1.1.2.15  2005/02/03 00:14:44  gross
1294    # timeseries add and ESySParameter.py renames esysXML.py for consistence
1295    #
1296    # Revision 1.1.2.14  2005/02/01 06:44:10  gross
1297    # new implementation of AdvectivePDE which now also updates right hand side. systems of PDEs are still not working
1298    #
1299    # Revision 1.1.2.13  2005/01/25 00:47:07  gross
1300    # updates in the documentation
1301    #
1302    # Revision 1.1.2.12  2005/01/12 01:28:04  matt
1303    # Added createCoefficient method for linearPDEs.
1304    #
1305    # Revision 1.1.2.11  2005/01/11 01:55:34  gross
1306    # a problem in linearPDE class fixed
1307    #
1308    # Revision 1.1.2.10  2005/01/07 01:13:29  gross
1309    # some bugs in linearPDE fixed
1310    #
1311    # Revision 1.1.2.9  2005/01/06 06:24:58  gross
1312    # some bugs in slicing fixed
1313    #
1314    # Revision 1.1.2.8  2005/01/05 04:21:40  gross
1315    # FunctionSpace checking/matchig in slicing added
1316    #
1317    # Revision 1.1.2.7  2004/12/29 10:03:41  gross
1318    # bug in setValue fixed
1319    #
1320    # Revision 1.1.2.6  2004/12/29 05:29:59  gross
1321    # AdvectivePDE successfully tested for Peclet number 1000000. there is still a problem with setValue and Data()
1322    #
1323    # Revision 1.1.2.5  2004/12/29 00:18:41  gross
1324    # AdvectivePDE added
1325    #
1326    # Revision 1.1.2.4  2004/12/24 06:05:41  gross
1327    # some changes in linearPDEs to add AdevectivePDE
1328    #
1329    # Revision 1.1.2.3  2004/12/16 00:12:34  gross
1330    # __init__ of LinearPDE does not accept any coefficient anymore
1331    #
1332    # Revision 1.1.2.2  2004/12/14 03:55:01  jgs
1333    # *** empty log message ***
1334    #
1335    # Revision 1.1.2.1  2004/12/12 22:53:47  gross
1336    # linearPDE has been renamed LinearPDE
1337    #
1338    # Revision 1.1.1.1.2.7  2004/12/07 10:13:08  gross
1339    # GMRES added
1340    #
1341    # Revision 1.1.1.1.2.6  2004/12/07 03:19:50  gross
1342    # options for GMRES and PRES20 added
1343    #
1344    # Revision 1.1.1.1.2.5  2004/12/01 06:25:15  gross
1345    # some small changes
1346    #
1347    # Revision 1.1.1.1.2.4  2004/11/24 01:50:21  gross
1348    # Finley solves 4M unknowns now
1349    #
1350    # Revision 1.1.1.1.2.3  2004/11/15 06:05:26  gross
1351    # poisson solver added
1352    #
1353    # Revision 1.1.1.1.2.2  2004/11/12 06:58:15  gross
1354    # a lot of changes to get the linearPDE class running: most important change is that there is no matrix format exposed to the user anymore. the format is chosen by the Domain according to the solver and symmetry
1355    #
1356    # Revision 1.1.1.1.2.1  2004/10/28 22:59:22  gross
1357    # finley's RecTest.py is running now: problem in SystemMatrixAdapater fixed
1358    #
1359    # Revision 1.1.1.1  2004/10/26 06:53:56  jgs
1360    # initial import of project esys2
1361    #
1362    # Revision 1.3.2.3  2004/10/26 06:43:48  jgs
1363    # committing Lutz's and Paul's changes to brach jgs
1364    #
1365    # Revision 1.3.4.1  2004/10/20 05:32:51  cochrane
1366    # Added incomplete Doxygen comments to files, or merely put the docstrings that already exist into Doxygen form.
1367    #
1368    # Revision 1.3  2004/09/23 00:53:23  jgs
1369    # minor fixes
1370    #
1371    # Revision 1.1  2004/08/28 12:58:06  gross
1372    # SimpleSolve is not running yet: problem with == of functionsspace
1373    #
1374    #

Legend:
Removed from v.120  
changed lines
  Added in v.121

  ViewVC Help
Powered by ViewVC 1.1.26