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

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

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

revision 2061 by jfenwick, Wed Nov 19 03:40:21 2008 UTC revision 2100 by gross, Wed Nov 26 08:13:00 2008 UTC
# Line 29  Utility functions for escript Line 29  Utility functions for escript
29  @var __version__: version  @var __version__: version
30  @var __date__: date of the version  @var __date__: date of the version
31  @var EPSILON: smallest positive value with 1.<1.+EPSILON  @var EPSILON: smallest positive value with 1.<1.+EPSILON
32    @var DBLE_MAX: largest positive float
33  """  """
34    
35  __author__="Lutz Gross, l.gross@uq.edu.au"  __author__="Lutz Gross, l.gross@uq.edu.au"
# Line 46  from esys.escript import printParallelTh Line 47  from esys.escript import printParallelTh
47  #   some helpers:  #   some helpers:
48  #=========================================================  #=========================================================
49  def getEpsilon():  def getEpsilon():
50       #     ------------------------------------------------------------------       return escript.getMachinePrecision()
      #     Compute EPSILON, the machine precision.  The call to daxpp is  
      #     inTENded to fool compilers that use extra-length registers.  
      #     31 Map 1999: Hardwire EPSILON so the debugger can step thru easily.  
      #     ------------------------------------------------------------------  
      eps    = 2.**(-12)  
      p=2.  
      while p>1.:  
             eps/=2.  
             p=1.+eps  
      return eps*2.  
   
51  EPSILON=getEpsilon()  EPSILON=getEpsilon()
52    
53    def getMaxFloat():
54         return escript.getMaxFloat()
55    DBLE_MAX=getMaxFloat()
56    
57    
58  def getTagNames(domain):  def getTagNames(domain):
59      """      """
60      returns a list of the tag names used by the domain      returns a list of the tag names used by the domain
# Line 5044  def interpolate(arg,where): Line 5039  def interpolate(arg,where):
5039      if isinstance(arg,Symbol):      if isinstance(arg,Symbol):
5040         return Interpolate_Symbol(arg,where)         return Interpolate_Symbol(arg,where)
5041      elif isinstance(arg,escript.Data):      elif isinstance(arg,escript.Data):
5042         if where == arg.getFunctionSpace():         if arg.isEmpty():
5043              return arg
5044           elif where == arg.getFunctionSpace():
5045            return arg            return arg
5046         else:         else:
5047            return escript.Data(arg,where)            return escript.Data(arg,where)
# Line 5196  def normalize(arg,zerolength=0): Line 5193  def normalize(arg,zerolength=0):
5193      mm=1-m      mm=1-m
5194      return arg*(mm/(l*mm+m))      return arg*(mm/(l*mm+m))
5195    
5196    def deviatoric(arg):
5197        """
5198        returns the deviatoric version of arg
5199        """
5200        return arg-(trace(arg)/trace(kronecker(arg.getDomain())))*kronecker(arg.getDomain())
5201    
5202    def diameter(domain):
5203        """
5204        returns the diameter of a domain
5205    
5206        @param domain: a domain
5207        @type domain: L{escript.Domain}
5208        @rtype: C{float}
5209        """
5210        x=domain.getX()
5211        out=0.
5212        for i in xrange(domain.getDim()):
5213           x_i=x[i]
5214           out=max(out,sup(x_i)-inf(x_i))
5215        return out
5216  #=============================  #=============================
5217  #  #
5218    

Legend:
Removed from v.2061  
changed lines
  Added in v.2100

  ViewVC Help
Powered by ViewVC 1.1.26