/[escript]/trunk/escriptcore/py_src/flows.py
ViewVC logotype

Diff of /trunk/escriptcore/py_src/flows.py

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

revision 3630 by gross, Wed Oct 19 03:04:53 2011 UTC revision 3771 by jfenwick, Wed Jan 18 02:30:48 2012 UTC
# Line 32  Some models for flow Line 32  Some models for flow
32    
33  __author__="Lutz Gross, l.gross@uq.edu.au"  __author__="Lutz Gross, l.gross@uq.edu.au"
34    
35  import escript  from . import escript
36  import util  from . import util
37  from linearPDEs import LinearPDE, LinearPDESystem, LinearSinglePDE, SolverOptions  from .linearPDEs import LinearPDE, LinearPDESystem, LinearSinglePDE, SolverOptions
38  from pdetools import HomogeneousSaddlePointProblem,Projector, ArithmeticTuple, PCG, NegativeNorm, GMRES  from .pdetools import HomogeneousSaddlePointProblem,Projector, ArithmeticTuple, PCG, NegativeNorm, GMRES
39    
40  class DarcyFlow(object):  class DarcyFlow(object):
41     """     """
# Line 71  class DarcyFlow(object): Line 71  class DarcyFlow(object):
71                
72        """        """
73        if not solver in [DarcyFlow.EVAL, DarcyFlow.POST,  DarcyFlow.SMOOTH ] :        if not solver in [DarcyFlow.EVAL, DarcyFlow.POST,  DarcyFlow.SMOOTH ] :
74            raise ValueError,"unknown solver %d."%solver            raise ValueError("unknown solver %d."%solver)
75    
76        self.domain=domain        self.domain=domain
77        self.solver=solver        self.solver=solver
# Line 86  class DarcyFlow(object): Line 86  class DarcyFlow(object):
86    
87        if self.solver  == self.EVAL:        if self.solver  == self.EVAL:
88           self.__pde_v=None           self.__pde_v=None
89       if self.verbose: print "DarcyFlow: simple solver is used."       if self.verbose: print("DarcyFlow: simple solver is used.")
90    
91        elif self.solver  == self.POST:        elif self.solver  == self.POST:
92       if util.inf(w)<0.:       if util.inf(w)<0.:
93          raise ValueError,"Weighting factor must be non-negative."          raise ValueError("Weighting factor must be non-negative.")
94       if self.verbose: print "DarcyFlow: global postprocessing of flux is used."       if self.verbose: print("DarcyFlow: global postprocessing of flux is used.")
95           self.__pde_v=LinearPDESystem(domain)           self.__pde_v=LinearPDESystem(domain)
96           self.__pde_v.setSymmetryOn()           self.__pde_v.setSymmetryOn()
97           if self.useReduced: self.__pde_v.setReducedOrderOn()           if self.useReduced: self.__pde_v.setReducedOrderOn()
# Line 102  class DarcyFlow(object): Line 102  class DarcyFlow(object):
102           self.__pde_v=LinearPDESystem(domain)           self.__pde_v=LinearPDESystem(domain)
103           self.__pde_v.setSymmetryOn()           self.__pde_v.setSymmetryOn()
104           if self.useReduced: self.__pde_v.setReducedOrderOn()           if self.useReduced: self.__pde_v.setReducedOrderOn()
105       if self.verbose: print "DarcyFlow: flux smoothing is used."       if self.verbose: print("DarcyFlow: flux smoothing is used.")
106       self.w=0       self.w=0
107    
108        self.__f=escript.Scalar(0,self.__pde_p.getFunctionSpaceForCoefficient("X"))        self.__f=escript.Scalar(0,self.__pde_p.getFunctionSpaceForCoefficient("X"))
# Line 145  class DarcyFlow(object): Line 145  class DarcyFlow(object):
145            
146       perm=util.interpolate(permeability,self.__pde_p.getFunctionSpaceForCoefficient("A"))       perm=util.interpolate(permeability,self.__pde_p.getFunctionSpaceForCoefficient("A"))
147           self.perm_scale=util.Lsup(util.length(perm))           self.perm_scale=util.Lsup(util.length(perm))
148       if self.verbose: print "DarcyFlow: permeability scaling factor = %e."%self.perm_scale       if self.verbose: print(("DarcyFlow: permeability scaling factor = %e."%self.perm_scale))
149           perm=perm*(1./self.perm_scale)           perm=perm*(1./self.perm_scale)
150                    
151       if perm.getRank()==0:       if perm.getRank()==0:
# Line 158  class DarcyFlow(object): Line 158  class DarcyFlow(object):
158       elif perm.getRank()==2:       elif perm.getRank()==2:
159          perm_inv=util.inverse(perm)          perm_inv=util.inverse(perm)
160       else:       else:
161          raise ValueError,"illegal rank of permeability."          raise ValueError("illegal rank of permeability.")
162                    
163       self.__permeability=perm       self.__permeability=perm
164       self.__permeability_inv=perm_inv       self.__permeability_inv=perm_inv
# Line 179  class DarcyFlow(object): Line 179  class DarcyFlow(object):
179      if g.isEmpty():      if g.isEmpty():
180            g=Vector(0,self.__pde_p.getFunctionSpaceForCoefficient("Y"))            g=Vector(0,self.__pde_p.getFunctionSpaceForCoefficient("Y"))
181      else:      else:
182          if not g.getShape()==(self.domain.getDim(),): raise ValueError,"illegal shape of g"          if not g.getShape()==(self.domain.getDim(),): raise ValueError("illegal shape of g")
183      self.__g=g      self.__g=g
184        if f !=None:        if f !=None:
185       f=util.interpolate(f, self.__pde_p.getFunctionSpaceForCoefficient("Y"))       f=util.interpolate(f, self.__pde_p.getFunctionSpaceForCoefficient("Y"))
186       if f.isEmpty():             if f.isEmpty():      
187            f=Scalar(0,self.__pde_p.getFunctionSpaceForCoefficient("Y"))            f=Scalar(0,self.__pde_p.getFunctionSpaceForCoefficient("Y"))
188       else:       else:
189           if f.getRank()>0: raise ValueError,"illegal rank of f."           if f.getRank()>0: raise ValueError("illegal rank of f.")
190       self.__f=f       self.__f=f
191    
192     def getSolverOptionsFlux(self):     def getSolverOptionsFlux(self):

Legend:
Removed from v.3630  
changed lines
  Added in v.3771

  ViewVC Help
Powered by ViewVC 1.1.26