/[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 3618 by gross, Tue Sep 6 02:02:17 2011 UTC revision 3619 by gross, Wed Oct 5 03:53:34 2011 UTC
# Line 109  class DarcyFlow(object): Line 109  class DarcyFlow(object):
109        self.__g=escript.Vector(0,self.__pde_p.getFunctionSpaceForCoefficient("Y"))        self.__g=escript.Vector(0,self.__pde_p.getFunctionSpaceForCoefficient("Y"))
110        self.location_of_fixed_pressure = escript.Scalar(0, self.__pde_p.getFunctionSpaceForCoefficient("q"))        self.location_of_fixed_pressure = escript.Scalar(0, self.__pde_p.getFunctionSpaceForCoefficient("q"))
111        self.location_of_fixed_flux = escript.Vector(0, self.__pde_p.getFunctionSpaceForCoefficient("q"))        self.location_of_fixed_flux = escript.Vector(0, self.__pde_p.getFunctionSpaceForCoefficient("q"))
112          self.perm_scale=1.
113            
114                    
115     def setValue(self,f=None, g=None, location_of_fixed_pressure=None, location_of_fixed_flux=None, permeability=None):     def setValue(self,f=None, g=None, location_of_fixed_pressure=None, location_of_fixed_flux=None, permeability=None):
# Line 143  class DarcyFlow(object): Line 144  class DarcyFlow(object):
144        if permeability!=None:        if permeability!=None:
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))
148             perm=perm*(1./self.perm_scale)
149                    
150       if perm.getRank()==0:       if perm.getRank()==0:
151    
# Line 176  class DarcyFlow(object): Line 179  class DarcyFlow(object):
179            g=Vector(0,self.__pde_p.getFunctionSpaceForCoefficient("Y"))            g=Vector(0,self.__pde_p.getFunctionSpaceForCoefficient("Y"))
180      else:      else:
181          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"
182      self.__g=g      self.__g=g
183        if f !=None:        if f !=None:
184       f=util.interpolate(f, self.__pde_p.getFunctionSpaceForCoefficient("Y"))       f=util.interpolate(f, self.__pde_p.getFunctionSpaceForCoefficient("Y"))
185       if f.isEmpty():             if f.isEmpty():      
# Line 233  class DarcyFlow(object): Line 236  class DarcyFlow(object):
236        :rtype: ``tuple`` of `escript.Data`.        :rtype: ``tuple`` of `escript.Data`.
237    
238        """        """
239        self.__pde_p.setValue(X=self.__g ,        self.__pde_p.setValue(X=self.__g * 1./self.perm_scale,
240                              Y=self.__f,                              Y=self.__f,
241                              y= - util.inner(self.domain.getNormal(),u0 * self.location_of_fixed_flux),                              y= - util.inner(self.domain.getNormal(),u0 * self.location_of_fixed_flux),
242                              r=p0)                              r=p0)
# Line 254  class DarcyFlow(object): Line 257  class DarcyFlow(object):
257          :return: flux          :return: flux
258          :rtype: `escript.Data`          :rtype: `escript.Data`
259          """          """
         u_eval=self.__g-util.tensor_mult(self.__permeability,util.grad(p))  
260          if self.solver  == self.EVAL:          if self.solver  == self.EVAL:
261             u = self.__g-util.tensor_mult(self.__permeability,util.grad(p))             u = self.__g-self.perm_scale * util.tensor_mult(self.__permeability,util.grad(p))
262          elif self.solver  == self.POST or self.solver  == self.SMOOTH:          elif self.solver  == self.POST or self.solver  == self.SMOOTH:
263              self.__pde_v.setValue(Y=util.tensor_mult(self.__permeability_inv,self.__g)-util.grad(p))              self.__pde_v.setValue(Y=util.tensor_mult(self.__permeability_inv,self.__g * 1./self.perm_scale)-util.grad(p))
264              if u0 == None:              if u0 == None:
265             self.__pde_v.setValue(r=escript.Data())             self.__pde_v.setValue(r=escript.Data())
266          else:          else:
267             self.__pde_v.setValue(r=u0)             self.__pde_v.setValue(r=u0)
268              u= self.__pde_v.getSolution()              u= self.__pde_v.getSolution() * self.perm_scale
269      return u      return u
270                
271  class StokesProblemCartesian(HomogeneousSaddlePointProblem):  class StokesProblemCartesian(HomogeneousSaddlePointProblem):

Legend:
Removed from v.3618  
changed lines
  Added in v.3619

  ViewVC Help
Powered by ViewVC 1.1.26