# Diff of /trunk/escript/py_src/faultsystems.py

revision 2675 by gross, Mon Sep 21 02:32:17 2009 UTC revision 2676 by gross, Mon Sep 21 08:06:37 2009 UTC
20
21  from esys.escript import *  from esys.escript import *
22    from esys.escript.pdetools import Locator
23  import numpy  import numpy
24  import math  import math
25
# Line 410  class FaultSystem: Line 411  class FaultSystem:
411       if self.getDim()==3:       if self.getDim()==3:
412          normals=[]          normals=[]
413          for i in xrange(n_segs):          for i in xrange(n_segs):
414             normals.append(numpy.array([sin(dips[i])*strike_vectors[i][1], -sin(dips[i])*strike_vectors[i][0], cos(dips[i])]) )             normals.append(numpy.array([sin(dips[i])*strike_vectors[i][1],-sin(dips[i])*strike_vectors[i][0], cos(dips[i])]) )
415
416          d=numpy.cross(strike_vectors[0],normals[0])          d=numpy.cross(strike_vectors[0],normals[0])
417          if d[2]>0:          if d[2]>0:
# Line 474  class FaultSystem: Line 475  class FaultSystem:
475
476    def getMaxValue(self,f, tol=sqrt(EPSILON)):    def getMaxValue(self,f, tol=sqrt(EPSILON)):
477       """       """
478       returns the maximum value of ``f``, the fault and the location on the fault in fault coordinates.       returns the tag of the fault of where ``f`` takes the maximum value and a `Locator` object which can be used to collect values from `Data` class objects at the location where the minimum is taken.
479
480       :param f: a distribution of values       :param f: a distribution of values
481       :type f: `escript.Data`       :type f: `escript.Data`
482       :param tol: relative tolerance used to decide if point is on fault       :param tol: relative tolerance used to decide if point is on fault
483       :type f: ``tol``       :type f: ``tol``
484       :return: the maximum value of across all faults in the fault system, the fault tag the maximum is taken, and the coordinates of the location in the coordinates of the fault. The returned fault tag is ``None`` if no points on the fault are available       :return: the fault tag the maximum is taken, and a `Locator` object to collect the value at location of maximum value.
485       """       """
486       ref=-Lsup(f)*2       ref=-Lsup(f)*2
487       f_max=ref       f_max=ref
488       t_max=None       t_max=None
489       p_max=None       loc_max=None
490       x=f.getFunctionSpace().getX()       x=f.getFunctionSpace().getX()
491       for t in self.getTags():       for t in self.getTags():
492          p,m=self.getParametrization(x,tag=t, tol=tol)          p,m=self.getParametrization(x,tag=t, tol=tol)
# Line 494  class FaultSystem: Line 495  class FaultSystem:
495          if f_t>f_max:          if f_t>f_max:
496             f_max=f_t             f_max=f_t
497             t_max=t             t_max=t
498             p_max=p.getTupleForGlobalDataPoint(*loc)[0]             loc_max=loc
499
500       return f_max, t_max, p_max       if loc_max == None:
501             return None, None
502         else:
503             return t_max, Locator(x.getFunctionSpace(),x.getTupleForGlobalDataPoint(*loc_max))
504
505    def getMinValue(self,f, tol=sqrt(EPSILON)):    def getMinValue(self,f, tol=sqrt(EPSILON)):
506       """       """
507       returns the minimum value of ``f``, the fault and the location on the fault in fault coordinates.       returns the tag of the fault of where ``f`` takes the minimum value and a `Locator` object which can be used to collect values from `Data` class objects at the location where the minimum is taken.
508
509       :param f: a distribution of values       :param f: a distribution of values
510       :type f: `escript.Data`       :type f: `escript.Data`
511       :param tol: relative tolerance used to decide if point is on fault       :param tol: relative tolerance used to decide if point is on fault
512       :type f: ``tol``       :type f: ``tol``
513       :return: the minimum value of across all faults in the fault system, the fault tag the minimum is taken, and the coordinates of the location in the coordinates of the fault. The returned fault tag is ``None`` if no points on the fault are available       :return: the fault tag the minimum is taken, and a `Locator` object to collect the value at location of minimum value.
514       """       """
515       ref=Lsup(f)*2       ref=Lsup(f)*2
516       f_min=ref       f_min=ref
517       t_min=None       t_min=None
518       p_min=None       loc_min=None
519       x=f.getFunctionSpace().getX()       x=f.getFunctionSpace().getX()
520       for t in self.getTags():       for t in self.getTags():
521          p,m=self.getParametrization(x,tag=t, tol=tol)          p,m=self.getParametrization(x,tag=t, tol=tol)
# Line 520  class FaultSystem: Line 524  class FaultSystem:
524          if f_t<f_min:          if f_t<f_min:
525             f_min=f_t             f_min=f_t
526             t_min=t             t_min=t
527             p_min=p.getTupleForGlobalDataPoint(*loc)[0]             loc_min=loc
528
529       return f_min, t_min, p_min       if loc_min == None:
530             return None, None
531         else:
532             return t_min, Locator(x.getFunctionSpace(),x.getTupleForGlobalDataPoint(*loc_min))
533
534    def getParametrization(self,x,tag=None, tol=sqrt(EPSILON), outsider=None):    def getParametrization(self,x,tag=None, tol=sqrt(EPSILON), outsider=None):
535      """      """

Legend:
 Removed from v.2675 changed lines Added in v.2676