/[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 122 by jgs, Thu Jun 9 05:38:05 2005 UTC revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC
# Line 201  class LinearPDE: Line 201  class LinearPDE:
201       @param args:       @param args:
202       """       """
203       # COEFFICIENTS can be overwritten by subclasses:       # COEFFICIENTS can be overwritten by subclasses:
204       self.COEFFICIENTS={       self.__COEFFICIENTS={
205         "A"         : PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.EQUATION,PDECoefficient.DIM,PDECoefficient.SOLUTION,PDECoefficient.DIM),PDECoefficient.OPERATOR),         "A"         : PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.EQUATION,PDECoefficient.DIM,PDECoefficient.SOLUTION,PDECoefficient.DIM),PDECoefficient.OPERATOR),
206         "B"         : PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.EQUATION,PDECoefficient.DIM,PDECoefficient.SOLUTION),PDECoefficient.OPERATOR),         "B"         : PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.EQUATION,PDECoefficient.DIM,PDECoefficient.SOLUTION),PDECoefficient.OPERATOR),
207         "C"         : PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.EQUATION,PDECoefficient.SOLUTION,PDECoefficient.DIM),PDECoefficient.OPERATOR),         "C"         : PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.EQUATION,PDECoefficient.SOLUTION,PDECoefficient.DIM),PDECoefficient.OPERATOR),
# Line 215  class LinearPDE: Line 215  class LinearPDE:
215         "r"         : PDECoefficient(PDECoefficient.CONTINUOUS,(PDECoefficient.EQUATION,),PDECoefficient.RIGHTHANDSIDE),         "r"         : PDECoefficient(PDECoefficient.CONTINUOUS,(PDECoefficient.EQUATION,),PDECoefficient.RIGHTHANDSIDE),
216         "q"         : PDECoefficient(PDECoefficient.CONTINUOUS,(PDECoefficient.SOLUTION,),PDECoefficient.BOTH)}         "q"         : PDECoefficient(PDECoefficient.CONTINUOUS,(PDECoefficient.SOLUTION,),PDECoefficient.BOTH)}
217    
218         self.COEFFICIENTS=self.__COEFFICIENTS
219       # initialize attributes       # initialize attributes
220       self.__debug=None       self.__debug=None
221       self.__domain=domain       self.__domain=domain
# Line 276  class LinearPDE: Line 277  class LinearPDE:
277        """        """
278        return self.COEFFICIENTS.has_key(name)        return self.COEFFICIENTS.has_key(name)
279    
280       def hasPDECoefficient(self,name):
281          """
282          return true if name is the name of a coefficient
283    
284          @param name:
285          """
286          return self.__COEFFICIENTS.has_key(name)
287    
288     def getFunctionSpaceForEquation(self):     def getFunctionSpaceForEquation(self):
289       """       """
290       return true if the test functions should use reduced order       return true if the test functions should use reduced order
# Line 310  class LinearPDE: Line 319  class LinearPDE:
319       """       """
320       return escript.Data(0,self.getShapeOfCoefficient(name),self.getFunctionSpaceForCoefficient(name))       return escript.Data(0,self.getShapeOfCoefficient(name),self.getFunctionSpaceForCoefficient(name))
321                
322       def createNewCoefficientOfPDE(self,name):
323         """
324         returns a new coefficient appropriate for coefficient name:
325         """
326         return escript.Data(0,self.getShapeOfCoefficientOfPDE(name),self.getFunctionSpaceForCoefficientOfPDE(name))
327          
328       def getShapeOfCoefficientOfPDE(self,name):
329         """
330         return the shape of the coefficient name
331    
332         @param name:
333         """
334         if self.hasPDECoefficient(name):
335            return self.__COEFFICIENTS[name].buildShape(self.getNumEquations(),self.getNumSolutions(),self.getDomain().getDim())
336         else:
337            raise ValueError,"Unknown coefficient %s requested"%name
338    
339       def getFunctionSpaceForCoefficientOfPDE(self,name):
340         """
341         return the atoms of the coefficient name
342    
343         @param name:
344         """
345         if self.hasPDECoefficient(name):
346            return self.__COEFFICIENTS[name].getFunctionSpace(self.getDomain())
347         else:
348            raise ValueError,"unknown coefficient %s requested"%name
349    
350     def getShapeOfCoefficient(self,name):     def getShapeOfCoefficient(self,name):
351       """       """
# Line 320  class LinearPDE: Line 356  class LinearPDE:
356       if self.hasCoefficient(name):       if self.hasCoefficient(name):
357          return self.COEFFICIENTS[name].buildShape(self.getNumEquations(),self.getNumSolutions(),self.getDomain().getDim())          return self.COEFFICIENTS[name].buildShape(self.getNumEquations(),self.getNumSolutions(),self.getDomain().getDim())
358       else:       else:
359          raise ValueError,"Solution coefficient %s requested"%name          raise ValueError,"Unknown coefficient %s requested"%name
360    
361     def getFunctionSpaceForCoefficient(self,name):     def getFunctionSpaceForCoefficient(self,name):
362       """       """
# Line 331  class LinearPDE: Line 367  class LinearPDE:
367       if self.hasCoefficient(name):       if self.hasCoefficient(name):
368          return self.COEFFICIENTS[name].getFunctionSpace(self.getDomain())          return self.COEFFICIENTS[name].getFunctionSpace(self.getDomain())
369       else:       else:
370          raise ValueError,"Solution coefficient %s requested"%name          raise ValueError,"unknown coefficient %s requested"%name
371    
372     def alteredCoefficient(self,name):     def alteredCoefficient(self,name):
373       """       """
# Line 1240  class AdvectivePDE(LinearPDE): Line 1276  class AdvectivePDE(LinearPDE):
1276    
1277  class Poisson(LinearPDE):  class Poisson(LinearPDE):
1278     """     """
1279     Class to define a Poisson equstion problem:     Class to define a Poisson equation problem:
1280    
1281     class to define a linear PDE of the form     class to define a linear PDE of the form
1282     \f[     \f[
# Line 1269  class Poisson(LinearPDE): Line 1305  class Poisson(LinearPDE):
1305         self.setValue(f,q)         self.setValue(f,q)
1306    
1307     def setValue(self,f=escript.Data(),q=escript.Data()):     def setValue(self,f=escript.Data(),q=escript.Data()):
1308           """set value of PDE parameters f and q"""
1309         self._LinearPDE__setValue(f=f,q=q)         self._LinearPDE__setValue(f=f,q=q)
1310    
1311     def getCoefficientOfPDE(self,name):     def getCoefficientOfPDE(self,name):
# Line 1304  class Poisson(LinearPDE): Line 1341  class Poisson(LinearPDE):
1341       else:       else:
1342           raise SystemError,"unknown PDE coefficient %s",name           raise SystemError,"unknown PDE coefficient %s",name
1343    
1344    class LameEquation(LinearPDE):
1345       """
1346       Class to define a Lame equation problem:
1347    
1348       class to define a linear PDE of the form
1349       \f[
1350       -(\mu (u_{i,j}+u_{j,i}))_{,j} - \lambda u_{j,ji}} = F_i -\sigma_{ij,j}
1351       \f]
1352    
1353       with boundary conditons:
1354    
1355       \f[
1356       n_j(\mu (u_{i,j}+u_{j,i})-sigma_{ij}) + n_i\lambda u_{j,j} = f_i
1357       \f]
1358    
1359       and constraints:
1360    
1361       \f[
1362       u_i=r_i \quad \mathrm{where} \quad q_i>0
1363       \f]
1364       """
1365    
1366       def __init__(self,domain,f=escript.Data(),q=escript.Data()):
1367           LinearPDE.__init__(self,domain,domain.getDim(),domain.getDim())
1368           self.COEFFICIENTS={
1369           "lame_lambda"  : PDECoefficient(PDECoefficient.INTERIOR,(),PDECoefficient.OPERATOR),
1370           "lame_mu"      : PDECoefficient(PDECoefficient.INTERIOR,(),PDECoefficient.OPERATOR),
1371           "F"            : PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.EQUATION,),PDECoefficient.RIGHTHANDSIDE),
1372           "sigma"        : PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.EQUATION,PDECoefficient.DIM),PDECoefficient.RIGHTHANDSIDE),
1373           "f"            : PDECoefficient(PDECoefficient.BOUNDARY,(PDECoefficient.EQUATION,),PDECoefficient.RIGHTHANDSIDE),
1374           "r"            : PDECoefficient(PDECoefficient.CONTINUOUS,(PDECoefficient.EQUATION,),PDECoefficient.BOTH),
1375           "q"            : PDECoefficient(PDECoefficient.CONTINUOUS,(PDECoefficient.EQUATION,),PDECoefficient.BOTH)}
1376           self.setSymmetryOn()
1377    
1378       def setValue(self,lame_lambda=escript.Data(),lame_mu=escript.Data(),F=escript.Data(),sigma=escript.Data(),f=escript.Data(),r=escript.Data(),q=escript.Data()):
1379           """set value of PDE parameters"""
1380           self._LinearPDE__setValue(lame_lambda=lame_lambda, \
1381                                     lame_mu=lame_mu, \
1382                                     F=F, \
1383                                     sigma=sigma, \
1384                                     f=f, \
1385                                     r=r, \
1386                                     q=q)
1387       def getCoefficientOfPDE(self,name):
1388         """
1389         return the value of the coefficient name of the general PDE
1390    
1391         @param name:
1392         """
1393         if name == "A" :
1394             out =self.createNewCoefficientOfPDE("A")
1395             for i in range(self.getDim()):
1396               for j in range(self.getDim()):
1397                 out[i,i,j,j] += self.getCoefficient("lame_lambda")
1398                 out[i,j,j,i] += self.getCoefficient("lame_mu")
1399                 out[i,j,i,j] += self.getCoefficient("lame_mu")
1400             return out
1401         elif name == "B" :
1402             return escript.Data()
1403         elif name == "C" :
1404             return escript.Data()
1405         elif name == "D" :
1406             return escript.Data()
1407         elif name == "X" :
1408             return self.getCoefficient("sigma")
1409         elif name == "Y" :
1410             return self.getCoefficient("F")
1411         elif name == "d" :
1412             return escript.Data()
1413         elif name == "y" :
1414             return self.getCoefficient("f")
1415         elif name == "d_contact" :
1416             return escript.Data()
1417         elif name == "y_contact" :
1418             return escript.Data()
1419         elif name == "r" :
1420             return self.getCoefficient("r")
1421         elif name == "q" :
1422             return self.getCoefficient("q")
1423         else:
1424             raise SystemError,"unknown PDE coefficient %s",name
1425    
1426  # $Log$  # $Log$
1427  # Revision 1.8  2005/06/09 05:37:59  jgs  # Revision 1.10  2005/08/12 01:45:36  jgs
1428  # Merge of development branch back to main trunk on 2005-06-09  # erge of development branch dev-02 back to main trunk on 2005-08-12
1429    #
1430    # Revision 1.9.2.1  2005/07/29 07:10:27  gross
1431    # new functions in util and a new pde type in linearPDEs
1432    #
1433    # Revision 1.1.2.25  2005/07/28 04:21:09  gross
1434    # Lame equation: (linear elastic, isotropic) added
1435  #  #
1436  # Revision 1.7  2005/05/06 04:26:10  jgs  # Revision 1.1.2.24  2005/07/22 06:37:11  gross
1437  # Merge of development branch back to main trunk on 2005-05-06  # some extensions to modellib and linearPDEs
1438  #  #
1439  # Revision 1.1.2.23  2005/05/13 00:55:20  cochrane  # Revision 1.1.2.23  2005/05/13 00:55:20  cochrane
1440  # Fixed up some docstrings.  Moved module-level functions to top of file so  # Fixed up some docstrings.  Moved module-level functions to top of file so

Legend:
Removed from v.122  
changed lines
  Added in v.147

  ViewVC Help
Powered by ViewVC 1.1.26