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

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

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

revision 1400 by gross, Thu Jan 24 06:04:31 2008 UTC revision 1410 by gross, Thu Feb 7 04:24:00 2008 UTC
# Line 2211  def LinearPDESystem(domain,debug=False): Line 2211  def LinearPDESystem(domain,debug=False):
2211     @rtype: L{LinearPDE}     @rtype: L{LinearPDE}
2212     """     """
2213     return LinearPDE(domain,numEquations=domain.getDim(),numSolutions=domain.getDim(),debug=debug)     return LinearPDE(domain,numEquations=domain.getDim(),numSolutions=domain.getDim(),debug=debug)
2214    
2215    class TransportPDE(object):
2216         """
2217         Warning: This is still a very experimental. The class is still changing!
2218    
2219         Mu_{,t} =-(A_{ij}u_{,j})_j-(B_{j}u)_{,j} + C_{j} u_{,j} + Y_i + X_{i,i}
2220        
2221         all coefficients are constant over time.
2222    
2223         typical usage:
2224    
2225             p=TransportPDE(dom)
2226             p.setValue(M=Scalar(1.,Function(dom),C=Scalar(1.,Function(dom)*[-1.,0.])
2227             p.setInitialSolution(u=exp(-length(dom.getX()-[0.1,0.1])**2)
2228             t=0
2229             dt=0.1
2230             while (t<1.):
2231                  u=p.solve(dt)
2232    
2233         """
2234         def __init__(self,domain,num_equations=1,theta=0.5,trace=True):
2235            self.__domain=domain
2236            self.__num_equations=num_equations
2237            self.__theta=theta
2238            self.__trace=trace
2239            self.__matrix_type=0
2240            self.setTolerance()
2241            self.__transport_problem=self.__getNewTransportProblem()
2242    
2243         def trace(self,text):
2244                 if self.__trace: print text
2245         def getSafeTimeStepSize(self):
2246            return self.__transport_problem.getSafeTimeStepSize()
2247         def getDomain(self):
2248            return self.__domain
2249         def getTheta(self):
2250            return self.__theta
2251         def getNumEquations(self):
2252            return self.__num_equations
2253         def reduced(self):
2254                 return False
2255         def getFunctionSpace(self):
2256            if self.reduced():
2257               return escript.ReducedSolution(self.getDomain())
2258            else:
2259               return escript.Solution(self.getDomain())
2260         def setTolerance(self,tol=1.e-8):
2261            self.__tolerance=tol
2262    
2263         def __getNewTransportProblem(self):
2264           """
2265           returns an instance of a new operator
2266           """
2267           self.trace("New Transport problem is allocated.")
2268           return self.getDomain().newTransportProblem( \
2269                                   self.getTheta(),
2270                                   self.getNumEquations(), \
2271                                   self.getFunctionSpace(), \
2272                                   self.__matrix_type)
2273    
2274         def setValue(self,M=escript.Data(),A=escript.Data(),B=escript.Data(),C=escript.Data(),D=escript.Data(),X=escript.Data(),Y=escript.Data(),
2275                      d=escript.Data(),y=escript.Data(),d_contact=escript.Data(),y_contact=escript.Data()):
2276             if self.getNumEquations() ==1 :
2277                    self.__source=escript.Data(0.0,(),self.getFunctionSpace())
2278             else:
2279                     self.__source=escript.Data(0.0,(self.getNumEquations(),),self.getFunctionSpace())
2280             self.getDomain().addPDEToTransportProblem(
2281                         self.__transport_problem,
2282                         self.__source,
2283                         M,A,B,C,D,X,Y,d,y,d_contact,y_contact)
2284    
2285         def setInitialSolution(self,u):
2286                 self.__transport_problem.setInitialValue(util.interpolate(u,self.getFunctionSpace()))
2287    
2288         def solve(self,dt):
2289               return self.__transport_problem.solve(self.__source,dt,{"verbose" : True , "tolerance" : self.__tolerance})
2290    

Legend:
Removed from v.1400  
changed lines
  Added in v.1410

  ViewVC Help
Powered by ViewVC 1.1.26