/[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 2325 by gross, Thu Mar 19 05:32:13 2009 UTC revision 2337 by gross, Thu Mar 26 07:07:42 2009 UTC
# Line 2529  class TransportPDE(LinearProblem): Line 2529  class TransportPDE(LinearProblem):
2529             u = p.solve(dt)             u = p.solve(dt)
2530    
2531     """     """
2532     def __init__(self,domain,numEquations=None,numSolutions=None, theta=0.5,debug=False):     def __init__(self,domain,numEquations=None,numSolutions=None, useBackwardEuler=False, debug=False):
2533       """       """
2534       Initializes a transport problem.       Initializes a transport problem.
2535    
# Line 2541  class TransportPDE(LinearProblem): Line 2541  class TransportPDE(LinearProblem):
2541                            of solution components is extracted from the                            of solution components is extracted from the
2542                            coefficients.                            coefficients.
2543       @param debug: if True debug information is printed       @param debug: if True debug information is printed
2544       @param theta: time stepping control:       @param useBackwardEuler: if set the backward Euler scheme is used. Otherwise the Crank-Nicholson scheme is applied. Note that backward Euler scheme will return a safe time step size which is practically infinity as the scheme is unconditional unstable. The Crank-Nicholson scheme provides a higher accuracy but requires to limit the time step size to be stable.
2545          - 1.0: backward Euler,       @type useBackwardEuler: C{bool}
         - 0.0: forward Euler,  
         - 0.5: Crank-Nicholson scheme, U{see here<http://en.wikipedia.org/wiki/Crank-Nicolson_method>}  
   
2546       """       """
2547       if theta<0 or theta>1:       if useBackwardEuler:
2548                raise ValueError,"theta (=%s) needs to be between 0 and 1 (inclusive)."%theta           self.__useBackwardEuler=True
2549         else:
2550             self.__useBackwardEuler=False
2551       super(TransportPDE, self).__init__(domain,numEquations,numSolutions,debug)       super(TransportPDE, self).__init__(domain,numEquations,numSolutions,debug)
2552    
      self.__theta=theta  
2553       self.setConstraintWeightingFactor()       self.setConstraintWeightingFactor()
2554       #       #
2555       #   the coefficients of the transport problem       #   the coefficients of the transport problem
# Line 2593  class TransportPDE(LinearProblem): Line 2591  class TransportPDE(LinearProblem):
2591       """       """
2592       return "<TransportPDE %d>"%id(self)       return "<TransportPDE %d>"%id(self)
2593    
2594     def getTheta(self):     def useBackwardEuler(self):
2595        """        """
2596        Returns the time stepping control parameter.        Returns true if backward Euler is used. Otherwise false is returned.
2597        @rtype: float        @rtype: bool
2598        """        """
2599        return self.__theta        return self.__useBackwardEuler
2600    
2601    
2602     def checkSymmetry(self,verbose=True):     def checkSymmetry(self,verbose=True):
# Line 2719  class TransportPDE(LinearProblem): Line 2717  class TransportPDE(LinearProblem):
2717         """         """
2718         Returns an instance of a new transport operator.         Returns an instance of a new transport operator.
2719         """         """
2720           if self.useBackwardEuler():
2721             theta=1.
2722           else:
2723             theta=0.5
2724    
2725         self.trace("New Transport problem is allocated.")         self.trace("New Transport problem is allocated.")
2726         return self.getDomain().newTransportProblem( \         return self.getDomain().newTransportProblem( \
2727                                 self.getTheta(),                                 theta,
2728                                 self.getNumEquations(), \                                 self.getNumEquations(), \
2729                                 self.getFunctionSpaceForSolution(), \                                 self.getFunctionSpaceForSolution(), \
2730                                 self.getSystemType())                                 self.getSystemType())

Legend:
Removed from v.2325  
changed lines
  Added in v.2337

  ViewVC Help
Powered by ViewVC 1.1.26