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

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

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

revision 2264 by gross, Wed Feb 11 06:48:28 2009 UTC revision 2349 by gross, Mon Mar 30 08:14:23 2009 UTC
# Line 16  http://www.uq.edu.au/esscc Line 16  http://www.uq.edu.au/esscc
16  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
17  __license__="""Licensed under the Open Software License version 3.0  __license__="""Licensed under the Open Software License version 3.0
18  http://www.opensource.org/licenses/osl-3.0.php"""  http://www.opensource.org/licenses/osl-3.0.php"""
19  __url__="http://www.uq.edu.au/esscc/escript-finley"  __url__="https://launchpad.net/escript-finley"
20    
21  """  """
22  Some models for flow  Some models for flow
# Line 55  class DarcyFlow(object): Line 55  class DarcyFlow(object):
55          @type domain: L{Domain}          @type domain: L{Domain}
56          """          """
57          self.domain=domain          self.domain=domain
58            self.__l=util.longestEdge(self.domain)**2
59          self.__pde_v=LinearPDESystem(domain)          self.__pde_v=LinearPDESystem(domain)
60          if useReduced: self.__pde_v.setReducedOrderOn()          if useReduced: self.__pde_v.setReducedOrderOn()
61          self.__pde_v.setSymmetryOn()          self.__pde_v.setSymmetryOn()
62          self.__pde_v.setValue(D=util.kronecker(domain), A=util.outer(util.kronecker(domain),util.kronecker(domain)))          self.__pde_v.setValue(D=util.kronecker(domain), A=self.__l*util.outer(util.kronecker(domain),util.kronecker(domain)))
63          self.__pde_p=LinearSinglePDE(domain)          self.__pde_p=LinearSinglePDE(domain)
64          self.__pde_p.setSymmetryOn()          self.__pde_p.setSymmetryOn()
65          if useReduced: self.__pde_p.setReducedOrderOn()          if useReduced: self.__pde_p.setReducedOrderOn()
# Line 96  class DarcyFlow(object): Line 97  class DarcyFlow(object):
97                 f=Scalar(0,self.__pde_v.getFunctionSpaceForCoefficient("X"))                 f=Scalar(0,self.__pde_v.getFunctionSpaceForCoefficient("X"))
98             else:             else:
99                 if f.getRank()>0: raise ValueError,"illegal rank of f."                 if f.getRank()>0: raise ValueError,"illegal rank of f."
100             self.f=f             self.__f=f
101          if g !=None:          if g !=None:
102             g=util.interpolate(g, self.__pde_p.getFunctionSpaceForCoefficient("Y"))             g=util.interpolate(g, self.__pde_p.getFunctionSpaceForCoefficient("Y"))
103             if g.isEmpty():             if g.isEmpty():
# Line 229  class DarcyFlow(object): Line 230  class DarcyFlow(object):
230           which is solved using the PCG method (precondition is M{Q^*Q}). In each iteration step           which is solved using the PCG method (precondition is M{Q^*Q}). In each iteration step
231           PDEs with operator M{I+D^*D} and with M{Q^*Q} needs to be solved using a sub iteration scheme.           PDEs with operator M{I+D^*D} and with M{Q^*Q} needs to be solved using a sub iteration scheme.
232           """           """
233           self.verbose=verbose           self.verbose=verbose or True
234           self.show_details= show_details and self.verbose           self.show_details= show_details and self.verbose
235           rtol=self.getTolerance()           rtol=self.getTolerance()
236           atol=self.getAbsoluteTolerance()           atol=self.getAbsoluteTolerance()
# Line 326  class DarcyFlow(object): Line 327  class DarcyFlow(object):
327            if self.show_details: print "DarcyFlux: Applying operator"            if self.show_details: print "DarcyFlux: Applying operator"
328            Qdp=self.__Q(dp)            Qdp=self.__Q(dp)
329            self.__pde_v.setValue(Y=-Qdp,X=Data(), r=Data())            self.__pde_v.setValue(Y=-Qdp,X=Data(), r=Data())
330            du=self.__pde_v.getSolution(verbose=self.show_details)            du=self.__pde_v.getSolution(verbose=self.show_details, iter_max = 100000)
331            return Qdp+du            return Qdp+du
332      def __inner_GMRES(self,r,s):      def __inner_GMRES(self,r,s):
333           return util.integrate(util.inner(r,s))           return util.integrate(util.inner(r,s))
# Line 338  class DarcyFlow(object): Line 339  class DarcyFlow(object):
339            self.__pde_p.setTolerance(self.getSubProblemTolerance())            self.__pde_p.setTolerance(self.getSubProblemTolerance())
340            if self.show_details: print "DarcyFlux: Applying preconditioner"            if self.show_details: print "DarcyFlux: Applying preconditioner"
341            self.__pde_p.setValue(X=util.transposed_tensor_mult(self.__permeability,r), Y=Data(), r=Data())            self.__pde_p.setValue(X=util.transposed_tensor_mult(self.__permeability,r), Y=Data(), r=Data())
342            return self.__pde_p.getSolution(verbose=self.show_details)            return self.__pde_p.getSolution(verbose=self.show_details, iter_max = 100000)
   
343    
344      def getFlux(self,p=None, fixed_flux=Data(), show_details=False):      def getFlux(self,p=None, fixed_flux=Data(), show_details=False):
345          """          """
# Line 361  class DarcyFlow(object): Line 361  class DarcyFlow(object):
361          self.__pde_v.setTolerance(self.getSubProblemTolerance())          self.__pde_v.setTolerance(self.getSubProblemTolerance())
362          g=self.__g          g=self.__g
363          f=self.__f          f=self.__f
364          self.__pde_v.setValue(X=f*util.kronecker(self.domain), r=fixed_flux)          self.__pde_v.setValue(X=self.__l*f*util.kronecker(self.domain), r=fixed_flux)
365          if p == None:          if p == None:
366             self.__pde_v.setValue(Y=g)             self.__pde_v.setValue(Y=g)
367          else:          else:
368             self.__pde_v.setValue(Y=g-self.__Q(p))             self.__pde_v.setValue(Y=g-self.__Q(p))
369          return self.__pde_v.getSolution(verbose=show_details)          return self.__pde_v.getSolution(verbose=show_details, iter_max=100000)
370    
371  class StokesProblemCartesian(HomogeneousSaddlePointProblem):  class StokesProblemCartesian(HomogeneousSaddlePointProblem):
372       """       """

Legend:
Removed from v.2264  
changed lines
  Added in v.2349

  ViewVC Help
Powered by ViewVC 1.1.26