/[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 4575 by jfenwick, Wed Jul 24 02:50:22 2013 UTC revision 4576 by sshaw, Mon Dec 9 23:35:30 2013 UTC
# Line 153  class DarcyFlow(object): Line 153  class DarcyFlow(object):
153            self.location_of_fixed_flux=util.wherePositive(location_of_fixed_flux)            self.location_of_fixed_flux=util.wherePositive(location_of_fixed_flux)
154            if not self.__pde_v == None:            if not self.__pde_v == None:
155                self.__pde_v.setValue(q=self.location_of_fixed_flux)                self.__pde_v.setValue(q=self.location_of_fixed_flux)
156                      
157        if permeability!=None:        if permeability!=None:
       
158           perm=util.interpolate(permeability,self.__pde_p.getFunctionSpaceForCoefficient("A"))           perm=util.interpolate(permeability,self.__pde_p.getFunctionSpaceForCoefficient("A"))
159           self.perm_scale=util.Lsup(util.length(perm))           self.perm_scale=util.Lsup(util.length(perm))
160           if self.verbose: print(("DarcyFlow: permeability scaling factor = %e."%self.perm_scale))           if self.verbose: print(("DarcyFlow: permeability scaling factor = %e."%self.perm_scale))
# Line 166  class DarcyFlow(object): Line 165  class DarcyFlow(object):
165              perm_inv=(1./perm)              perm_inv=(1./perm)
166              perm_inv=perm_inv*util.kronecker(self.domain.getDim())              perm_inv=perm_inv*util.kronecker(self.domain.getDim())
167              perm=perm*util.kronecker(self.domain.getDim())              perm=perm*util.kronecker(self.domain.getDim())
           
           
168           elif perm.getRank()==2:           elif perm.getRank()==2:
169              perm_inv=util.inverse(perm)              perm_inv=util.inverse(perm)
170           else:           else:
# Line 175  class DarcyFlow(object): Line 172  class DarcyFlow(object):
172                    
173           self.__permeability=perm           self.__permeability=perm
174           self.__permeability_inv=perm_inv           self.__permeability_inv=perm_inv
175        
176           #====================           #====================
177           self.__pde_p.setValue(A=self.__permeability)           self.__pde_p.setValue(A=self.__permeability)
178           if self.solver  == self.EVAL:           if self.solver  == self.EVAL:
# Line 199  class DarcyFlow(object): Line 196  class DarcyFlow(object):
196          self.__permeability_invXg_ref=util.integrate(self.__permeability_invXg)/util.vol(self.domain)          self.__permeability_invXg_ref=util.integrate(self.__permeability_invXg)/util.vol(self.domain)
197        if f !=None:        if f !=None:
198           f=util.interpolate(f, self.__pde_p.getFunctionSpaceForCoefficient("Y"))           f=util.interpolate(f, self.__pde_p.getFunctionSpaceForCoefficient("Y"))
199           if f.isEmpty():                 if f.isEmpty():  
200               f=Scalar(0,self.__pde_p.getFunctionSpaceForCoefficient("Y"))               f=Scalar(0,self.__pde_p.getFunctionSpaceForCoefficient("Y"))
201           else:           else:
202               if f.getRank()>0: raise ValueError("illegal rank of f.")               if f.getRank()>0: raise ValueError("illegal rank of f.")
# Line 223  class DarcyFlow(object): Line 220  class DarcyFlow(object):
220        """        """
221        if not self.__pde_v == None:        if not self.__pde_v == None:
222            self.__pde_v.setSolverOptions(options)            self.__pde_v.setSolverOptions(options)
223        
224     def getSolverOptionsPressure(self):     def getSolverOptionsPressure(self):
225        """        """
226        Returns the solver options used to solve the pressure problems        Returns the solver options used to solve the pressure problems
# Line 314  class DarcyFlow(object): Line 311  class DarcyFlow(object):
311                 self.__pde_v.setValue(r=1./self.perm_scale * u0)                 self.__pde_v.setValue(r=1./self.perm_scale * u0)
312              u= self.__pde_v.getSolution() * self.perm_scale              u= self.__pde_v.getSolution() * self.perm_scale
313          return u          return u
314            
315  class StokesProblemCartesian(pdt.HomogeneousSaddlePointProblem):  class StokesProblemCartesian(pdt.HomogeneousSaddlePointProblem):
316       """       """
317       solves       solves
# Line 351  class StokesProblemCartesian(pdt.Homogen Line 348  class StokesProblemCartesian(pdt.Homogen
348           self.domain=domain           self.domain=domain
349           self.__pde_v=lpe.LinearPDE(domain,numEquations=self.domain.getDim(),numSolutions=self.domain.getDim())           self.__pde_v=lpe.LinearPDE(domain,numEquations=self.domain.getDim(),numSolutions=self.domain.getDim())
350           self.__pde_v.setSymmetryOn()           self.__pde_v.setSymmetryOn()
351        
352           self.__pde_prec=lpe.LinearPDE(domain)           self.__pde_prec=lpe.LinearPDE(domain)
353           self.__pde_prec.setReducedOrderOn()           self.__pde_prec.setReducedOrderOn()
354           self.__pde_prec.setSymmetryOn()           self.__pde_prec.setSymmetryOn()
# Line 363  class StokesProblemCartesian(pdt.Homogen Line 360  class StokesProblemCartesian(pdt.Homogen
360    
361       def getSolverOptionsVelocity(self):       def getSolverOptionsVelocity(self):
362           """           """
363       returns the solver options used  solve the equation for velocity.           returns the solver options used  solve the equation for velocity.
364                
365       :rtype: `SolverOptions`           :rtype: `SolverOptions`
366       """           """
367           return self.__pde_v.getSolverOptions()           return self.__pde_v.getSolverOptions()
368       def setSolverOptionsVelocity(self, options=None):       def setSolverOptionsVelocity(self, options=None):
369           """           """
370       set the solver options for solving the equation for velocity.           set the solver options for solving the equation for velocity.
371                
372       :param options: new solver  options           :param options: new solver  options
373       :type options: `SolverOptions`           :type options: `SolverOptions`
374       """           """
375           self.__pde_v.setSolverOptions(options)           self.__pde_v.setSolverOptions(options)
376       def getSolverOptionsPressure(self):       def getSolverOptionsPressure(self):
377           """           """
378       returns the solver options used  solve the equation for pressure.           returns the solver options used  solve the equation for pressure.
379       :rtype: `SolverOptions`           :rtype: `SolverOptions`
380       """           """
381           return self.__pde_prec.getSolverOptions()           return self.__pde_prec.getSolverOptions()
382       def setSolverOptionsPressure(self, options=None):       def setSolverOptionsPressure(self, options=None):
383           """           """
384       set the solver options for solving the equation for pressure.           set the solver options for solving the equation for pressure.
385       :param options: new solver  options           :param options: new solver  options
386       :type options: `SolverOptions`           :type options: `SolverOptions`
387       """           """
388           self.__pde_prec.setSolverOptions(options)           self.__pde_prec.setSolverOptions(options)
389    
390       def setSolverOptionsDiv(self, options=None):       def setSolverOptionsDiv(self, options=None):
391           """           """
392       set the solver options for solving the equation to project the divergence of           set the solver options for solving the equation to project the divergence of
393       the velocity onto the function space of presure.           the velocity onto the function space of presure.
394                
395       :param options: new solver options           :param options: new solver options
396       :type options: `SolverOptions`           :type options: `SolverOptions`
397       """           """
398           self.__pde_proj.setSolverOptions(options)           self.__pde_proj.setSolverOptions(options)
399       def getSolverOptionsDiv(self):       def getSolverOptionsDiv(self):
400           """           """
401       returns the solver options for solving the equation to project the divergence of           returns the solver options for solving the equation to project the divergence of
402       the velocity onto the function space of presure.           the velocity onto the function space of presure.
403                
404       :rtype: `SolverOptions`           :rtype: `SolverOptions`
405       """           """
406           return self.__pde_proj.getSolverOptions()           return self.__pde_proj.getSolverOptions()
407    
408       def updateStokesEquation(self, v, p):       def updateStokesEquation(self, v, p):
# Line 427  class StokesProblemCartesian(pdt.Homogen Line 424  class StokesProblemCartesian(pdt.Homogen
424          :param surface_stress: normal surface stress          :param surface_stress: normal surface stress
425          :type surface_stress: `Vector` object on `FunctionSpace` `FunctionOnBoundary` or similar          :type surface_stress: `Vector` object on `FunctionSpace` `FunctionOnBoundary` or similar
426          :param stress: initial stress          :param stress: initial stress
427      :type stress: `Tensor` object on `FunctionSpace` `Function` or similar          :type stress: `Tensor` object on `FunctionSpace` `Function` or similar
428          """          """
429          if eta !=None:          if eta !=None:
430              k=util.kronecker(self.domain.getDim())              k=util.kronecker(self.domain.getDim())

Legend:
Removed from v.4575  
changed lines
  Added in v.4576

  ViewVC Help
Powered by ViewVC 1.1.26