/[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 3499 by gross, Fri Apr 8 00:14:35 2011 UTC revision 3500 by gross, Mon Apr 11 03:09:06 2011 UTC
# Line 49  class DarcyFlowVeryNew(object): Line 49  class DarcyFlowVeryNew(object):
49        
50     :note: The problem is solved in a stabelized formulation.     :note: The problem is solved in a stabelized formulation.
51     """     """
52     def __init__(self, domain, useReduced=False, *args, **kargs):     def __init__(self, domain, useReduced=False, useVPIteration=True, *args, **kargs):
53        """        """
54        initializes the Darcy flux problem        initializes the Darcy flux problem
55        :param domain: domain of the problem        :param domain: domain of the problem
# Line 57  class DarcyFlowVeryNew(object): Line 57  class DarcyFlowVeryNew(object):
57        :param useReduced: uses reduced oreder on flux and pressure        :param useReduced: uses reduced oreder on flux and pressure
58        :type useReduced: ``bool``        :type useReduced: ``bool``
59        :param adaptSubTolerance: switches on automatic subtolerance selection        :param adaptSubTolerance: switches on automatic subtolerance selection
       :type adaptSubTolerance: ``bool``  
       :param solveForFlux: if True the solver solves for the flux (do not use!)  
       :type solveForFlux: ``bool``    
60        :param useVPIteration: if True altenative iteration over v and p is performed. Otherwise V and P are calculated in a single PDE.        :param useVPIteration: if True altenative iteration over v and p is performed. Otherwise V and P are calculated in a single PDE.
61        :type useVPIteration: ``bool``            :type useVPIteration: ``bool``    
62        """        """
63        self.domain=domain        self.domain=domain
64        useVPIteration=False        self.useVPIteration=useVPIteration
       self.useVPIteration=useVPIteration or True  
       #self.useVPIteration=False  
65        self.useReduced=useReduced        self.useReduced=useReduced
66        self.verbose=False        self.verbose=False
67    
# Line 97  class DarcyFlowVeryNew(object): Line 92  class DarcyFlowVeryNew(object):
92        self.location_of_fixed_pressure = escript.Scalar(0, self.__pde_k.getFunctionSpaceForCoefficient("q"))        self.location_of_fixed_pressure = escript.Scalar(0, self.__pde_k.getFunctionSpaceForCoefficient("q"))
93        self.location_of_fixed_flux = escript.Vector(0, self.__pde_k.getFunctionSpaceForCoefficient("q"))        self.location_of_fixed_flux = escript.Vector(0, self.__pde_k.getFunctionSpaceForCoefficient("q"))
94        self.scale=1.        self.scale=1.
95          self.setTolerance()
96          
97    
98     def __L2(self,v):     def __L2(self,v):
99           return util.sqrt(util.integrate(util.length(util.interpolate(v,escript.Function(self.domain)))**2))             return util.sqrt(util.integrate(util.length(util.interpolate(v,escript.Function(self.domain)))**2))  
100     def __inner_GMRES(self,r,s):     def __inner_GMRES(self,r,s):
101           return util.integrate(util.inner(r,s))           return util.integrate(util.inner(r,s))
102                    
103     def __Aprod_GMRES(self,p):     def __Aprod_GMRES(self,p):
104        self.__pde_k.setValue(Y=0.5*util.grad(p), X=p*util.kronecker(self.__pde_k.getDomain()) )        self.__pde_k.setValue(Y=-0.5*util.grad(p), X=-p*util.kronecker(self.__pde_k.getDomain()) )
105        du=self.__pde_k.getSolution()        du=self.__pde_k.getSolution()
106        self.__pde_p.setValue(Y=util.div(du), X=0.5*(du+util.tensor_mult(self.__permeability,util.grad(p))))        self.__pde_p.setValue(Y=-util.div(du), X=0.5*(-du+util.tensor_mult(self.__permeability,util.grad(p))))
107        return self.__pde_p.getSolution()        return self.__pde_p.getSolution()
108                    
109     def getSolverOptionsFlux(self):     def getSolverOptionsFlux(self):
# Line 197  class DarcyFlowVeryNew(object): Line 195  class DarcyFlowVeryNew(object):
195           if f.getRank()>0: raise ValueError,"illegal rank of f."           if f.getRank()>0: raise ValueError,"illegal rank of f."
196           self.__f=f           self.__f=f
197                    
198     def solve(self,u0,p0, max_iter=100, verbose=False, max_num_corrections=10):     def solve(self,u0,p0, max_iter=100, verbose=False, max_num_corrections=10, iter_restart=20):
199        """        """
200        solves the problem.        solves the problem.
201                
# Line 220  class DarcyFlowVeryNew(object): Line 218  class DarcyFlowVeryNew(object):
218        self.verbose=verbose        self.verbose=verbose
219        if self.useVPIteration:        if self.useVPIteration:
220          # get u:          # get u:
221                rtol=self.getTolerance()
222          self.__pde_k.setValue(Y=0.5*util.tensor_mult(self.__permeability_inv,g),X=escript.Data())          self.__pde_k.setValue(Y=0.5*util.tensor_mult(self.__permeability_inv,g),X=escript.Data())
223          du=self.__pde_k.getSolution()          du=self.__pde_k.getSolution()
224          self.__pde_p.setValue(Y=f-util.div(du), X=0.5*(g-du))          self.__pde_p.setValue(Y=f-util.div(du), X=0.5*(g-du))
# Line 228  class DarcyFlowVeryNew(object): Line 227  class DarcyFlowVeryNew(object):
227              p0_b*0,              p0_b*0,
228              self.__inner_GMRES,              self.__inner_GMRES,
229              atol=0,              atol=0,
230              rtol=1.e-4,              rtol=rtol,
231              iter_max=100,              iter_max=max_iter,
232              iter_restart=20, verbose=self.verbose,P_R=None)              iter_restart=iter_restart, verbose=self.verbose,P_R=None)
233              self.__pde_k.setValue(Y=0.5*( util.tensor_mult(self.__permeability_inv,g) + util.grad(p)) ,              self.__pde_k.setValue(Y=0.5*( util.tensor_mult(self.__permeability_inv,g) + util.grad(p)) ,
234                                    X=p*util.kronecker(self.__pde_k.getDomain()))                                    X=p*util.kronecker(self.__pde_k.getDomain()))
235                #self.__pde_k.setValue(Y=0.5*util.grad(p), X=p*util.kronecker(self.__pde_k.getDomain()) )
236          u=self.__pde_k.getSolution()          u=self.__pde_k.getSolution()
237        else:        else:
238            X=self.__pde_k.createCoefficient("X")            X=self.__pde_k.createCoefficient("X")

Legend:
Removed from v.3499  
changed lines
  Added in v.3500

  ViewVC Help
Powered by ViewVC 1.1.26