/[escript]/trunk/modellib/py_src/geometry.py
ViewVC logotype

Diff of /trunk/modellib/py_src/geometry.py

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

temp/modellib/py_src/geometry.py revision 1387 by trankine, Fri Jan 11 07:45:26 2008 UTC trunk/modellib/py_src/geometry.py revision 2236 by gross, Tue Feb 3 06:13:50 2009 UTC
# Line 1  Line 1 
1    
2    ########################################################
3  #  #
4  # $Id$  # Copyright (c) 2003-2008 by University of Queensland
5  #  # Earth Systems Science Computational Center (ESSCC)
6  #######################################################  # http://www.uq.edu.au/esscc
 #  
 #           Copyright 2003-2007 by ACceSS MNRF  
 #       Copyright 2007 by University of Queensland  
 #  
 #                http://esscc.uq.edu.au  
 #        Primary Business: Queensland, Australia  
 #  Licensed under the Open Software License version 3.0  
 #     http://www.opensource.org/licenses/osl-3.0.php  
7  #  #
8  #######################################################  # Primary Business: Queensland, Australia
9    # Licensed under the Open Software License version 3.0
10    # http://www.opensource.org/licenses/osl-3.0.php
11  #  #
12    ########################################################
13    
14    __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15  __copyright__="""  Copyright (c) 2006 by ACcESS MNRF  Earth Systems Science Computational Center (ESSCC)
16                      http://www.access.edu.au  http://www.uq.edu.au/esscc
17                  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
18  __license__="""Licensed under the Open Software License version 3.0  __license__="""Licensed under the Open Software License version 3.0
19               http://www.opensource.org/licenses/osl-3.0.php"""  http://www.opensource.org/licenses/osl-3.0.php"""
20    __url__="http://www.uq.edu.au/esscc/escript-finley"
21    
22  from esys.escript import *  from esys.escript import *
23  from esys.escript.modelframe import Model,ParameterSet  from esys.escript.modelframe import Model,ParameterSet
# Line 226  class ConstrainerOverBox(Model): Line 223  class ConstrainerOverBox(Model):
223            return the values used to constrain a solution            return the values used to constrain a solution
224    
225            @return: values to be used at the locations of the constraints. If            @return: values to be used at the locations of the constraints. If
226                    L{value} is not given C{None} is rerturned.                    C{value} is not given C{None} is rerturned.
227            @rtype: L{escript.Scalar}            @rtype: L{escript.Scalar}
228            """            """
229            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint == None: self.__setOutput()
# Line 308  class ScalarConstrainerOverBox(Model): Line 305  class ScalarConstrainerOverBox(Model):
305            return the values used to constrain a solution            return the values used to constrain a solution
306    
307            @return: values to be used at the locations of the constraints. If            @return: values to be used at the locations of the constraints. If
308                    L{value} is not given C{None} is rerturned.                    C{value} is not given C{None} is rerturned.
309            @rtype: L{escript.Scalar}            @rtype: L{escript.Scalar}
310            """            """
311            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint == None: self.__setOutput()
# Line 319  class ScalarConstrainerOverBox(Model): Line 316  class ScalarConstrainerOverBox(Model):
316            self.__location_of_constraint=Scalar(0,x.getFunctionSpace())            self.__location_of_constraint=Scalar(0,x.getFunctionSpace())
317            if self.domain.getDim()==3:            if self.domain.getDim()==3:
318                  x0,x1,x2=x[0],x[1],x[2]                  x0,x1,x2=x[0],x[1],x[2]
319                  if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol)                  d=max(sup(x0)-inf(x0), sup(x1)-inf(x1), sup(x2)-inf(x2))
320                  if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol)                  if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol*d)
321                  if self.front: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol)                  if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol*d)
322                  if self.back: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol)                  if self.front: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol*d)
323                  if self.bottom: self.__location_of_constraint+=whereZero(x2-inf(x2),self.tol)                  if self.back: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol*d)
324                  if self.top: self.__location_of_constraint+=whereZero(x2-sup(x2),self.tol)                  if self.bottom: self.__location_of_constraint+=whereZero(x2-inf(x2),self.tol*d)
325                    if self.top: self.__location_of_constraint+=whereZero(x2-sup(x2),self.tol*d)
326            else:            else:
327                  x0,x1=x[0],x[1]                  x0,x1=x[0],x[1]
328                  if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol)                  d=max(sup(x0)-inf(x0), sup(x1)-inf(x1))
329                  if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol)                  if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol*d)
330                  if self.bottom: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol)                  if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol*d)
331                  if self.top: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol)                  if self.bottom: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol*d)
332                    if self.top: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol*d)
333            if not self.value == None:            if not self.value == None:
334                self.__value_of_constraint=self.__location_of_constraint*self.value                self.__value_of_constraint=self.__location_of_constraint*self.value
335    
# Line 384  class VectorConstrainerOverBox(Model): Line 383  class VectorConstrainerOverBox(Model):
383            return the values used to constrain a solution            return the values used to constrain a solution
384    
385            @return: values to be used at the locations of the constraints. If            @return: values to be used at the locations of the constraints. If
386                    L{value} is not given C{None} is rerturned.                    C{value} is not given C{None} is rerturned.
387            @rtype: L{escript.Vector}            @rtype: L{escript.Vector}
388            """            """
389            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint == None: self.__setOutput()
# Line 395  class VectorConstrainerOverBox(Model): Line 394  class VectorConstrainerOverBox(Model):
394            self.__location_of_constraint=Vector(0,x.getFunctionSpace())            self.__location_of_constraint=Vector(0,x.getFunctionSpace())
395            if self.domain.getDim()==3:            if self.domain.getDim()==3:
396               x0,x1,x2=x[0],x[1],x[2]               x0,x1,x2=x[0],x[1],x[2]
397               left_mask=whereZero(x0-inf(x0),self.tol)               d=max(sup(x0)-inf(x0), sup(x1)-inf(x1), sup(x2)-inf(x2))
398                 left_mask=whereZero(x0-inf(x0),self.tol*d)
399               if self.left[0]: self.__location_of_constraint+=left_mask*[1.,0.,0.]               if self.left[0]: self.__location_of_constraint+=left_mask*[1.,0.,0.]
400               if self.left[1]: self.__location_of_constraint+=left_mask*[0.,1.,0.]               if self.left[1]: self.__location_of_constraint+=left_mask*[0.,1.,0.]
401               if self.left[2]: self.__location_of_constraint+=left_mask*[0.,0.,1.]               if self.left[2]: self.__location_of_constraint+=left_mask*[0.,0.,1.]
402               right_mask=whereZero(x0-sup(x0),self.tol)               right_mask=whereZero(x0-sup(x0),self.tol*d)
403               if self.right[0]: self.__location_of_constraint+=right_mask*[1.,0.,0.]               if self.right[0]: self.__location_of_constraint+=right_mask*[1.,0.,0.]
404               if self.right[1]: self.__location_of_constraint+=right_mask*[0.,1.,0.]               if self.right[1]: self.__location_of_constraint+=right_mask*[0.,1.,0.]
405               if self.right[2]: self.__location_of_constraint+=right_mask*[0.,0.,1.]               if self.right[2]: self.__location_of_constraint+=right_mask*[0.,0.,1.]
406               front_mask=whereZero(x1-inf(x1),self.tol)               front_mask=whereZero(x1-inf(x1),self.tol*d)
407               if self.front[0]: self.__location_of_constraint+=front_mask*[1.,0.,0.]               if self.front[0]: self.__location_of_constraint+=front_mask*[1.,0.,0.]
408               if self.front[1]: self.__location_of_constraint+=front_mask*[0.,1.,0.]               if self.front[1]: self.__location_of_constraint+=front_mask*[0.,1.,0.]
409               if self.front[2]: self.__location_of_constraint+=front_mask*[0.,0.,1.]               if self.front[2]: self.__location_of_constraint+=front_mask*[0.,0.,1.]
410               back_mask=whereZero(x1-sup(x1),self.tol)               back_mask=whereZero(x1-sup(x1),self.tol*d)
411               if self.back[0]: self.__location_of_constraint+=back_mask*[1.,0.,0.]               if self.back[0]: self.__location_of_constraint+=back_mask*[1.,0.,0.]
412               if self.back[1]: self.__location_of_constraint+=back_mask*[0.,1.,0.]               if self.back[1]: self.__location_of_constraint+=back_mask*[0.,1.,0.]
413               if self.back[2]: self.__location_of_constraint+=back_mask*[0.,0.,1.]               if self.back[2]: self.__location_of_constraint+=back_mask*[0.,0.,1.]
414               bottom_mask=whereZero(x2-inf(x2),self.tol)               bottom_mask=whereZero(x2-inf(x2),self.tol*d)
415               if self.bottom[0]: self.__location_of_constraint+=bottom_mask*[1.,0.,0.]               if self.bottom[0]: self.__location_of_constraint+=bottom_mask*[1.,0.,0.]
416               if self.bottom[1]: self.__location_of_constraint+=bottom_mask*[0.,1.,0.]               if self.bottom[1]: self.__location_of_constraint+=bottom_mask*[0.,1.,0.]
417               if self.bottom[2]: self.__location_of_constraint+=bottom_mask*[0.,0.,1.]               if self.bottom[2]: self.__location_of_constraint+=bottom_mask*[0.,0.,1.]
418               top_mask=whereZero(x2-sup(x2),self.tol)               top_mask=whereZero(x2-sup(x2),self.tol*d)
419               if self.top[0]: self.__location_of_constraint+=top_mask*[1.,0.,0.]               if self.top[0]: self.__location_of_constraint+=top_mask*[1.,0.,0.]
420               if self.top[1]: self.__location_of_constraint+=top_mask*[0.,1.,0.]               if self.top[1]: self.__location_of_constraint+=top_mask*[0.,1.,0.]
421               if self.top[2]: self.__location_of_constraint+=top_mask*[0.,0.,1.]               if self.top[2]: self.__location_of_constraint+=top_mask*[0.,0.,1.]
# Line 423  class VectorConstrainerOverBox(Model): Line 423  class VectorConstrainerOverBox(Model):
423                  self.__value_of_constraint=self.__location_of_constraint*self.value                  self.__value_of_constraint=self.__location_of_constraint*self.value
424            else:            else:
425               x0,x1=x[0],x[1]               x0,x1=x[0],x[1]
426               left_mask=whereZero(x0-inf(x0),self.tol)               d=max(sup(x0)-inf(x0), sup(x1)-inf(x1))
427                 left_mask=whereZero(x0-inf(x0),self.tol*d)
428               if self.left[0]: self.__location_of_constraint+=left_mask*[1.,0.]               if self.left[0]: self.__location_of_constraint+=left_mask*[1.,0.]
429               if self.left[1]: self.__location_of_constraint+=left_mask*[0.,1.]               if self.left[1]: self.__location_of_constraint+=left_mask*[0.,1.]
430               right_mask=whereZero(x0-sup(x0),self.tol)               right_mask=whereZero(x0-sup(x0),self.tol*d)
431               if self.right[0]: self.__location_of_constraint+=right_mask*[1.,0.]               if self.right[0]: self.__location_of_constraint+=right_mask*[1.,0.]
432               if self.right[1]: self.__location_of_constraint+=right_mask*[0.,1.]               if self.right[1]: self.__location_of_constraint+=right_mask*[0.,1.]
433               bottom_mask=whereZero(x1-inf(x1),self.tol)               bottom_mask=whereZero(x1-inf(x1),self.tol*d)
434               if self.bottom[0]: self.__location_of_constraint+=bottom_mask*[1.,0.]               if self.bottom[0]: self.__location_of_constraint+=bottom_mask*[1.,0.]
435               if self.bottom[1]: self.__location_of_constraint+=bottom_mask*[0.,1.]               if self.bottom[1]: self.__location_of_constraint+=bottom_mask*[0.,1.]
436               top_mask=whereZero(x1-sup(x1),self.tol)               top_mask=whereZero(x1-sup(x1),self.tol*d)
437               if self.top[0]: self.__location_of_constraint+=top_mask*[1.,0.]               if self.top[0]: self.__location_of_constraint+=top_mask*[1.,0.]
438               if self.top[1]: self.__location_of_constraint+=top_mask*[0.,1.]               if self.top[1]: self.__location_of_constraint+=top_mask*[0.,1.]
439               if not self.value == None:               if not self.value == None:
# Line 471  class ConstrainerAtBoxVertex(Model): Line 472  class ConstrainerAtBoxVertex(Model):
472            return the values used to constrain a solution            return the values used to constrain a solution
473    
474            @return: values to be used at the locations of the constraints. If            @return: values to be used at the locations of the constraints. If
475                    L{value} is not given C{None} is rerturned.                    C{value} is not given C{None} is rerturned.
476            @rtype: L{escript.Scalar}            @rtype: L{escript.Scalar}
477            """            """
478            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint == None: self.__setOutput()
# Line 531  class ScalarConstrainerAtBoxVertex(Model Line 532  class ScalarConstrainerAtBoxVertex(Model
532            return the values used to constrain a solution            return the values used to constrain a solution
533    
534            @return: values to be used at the locations of the constraints. If            @return: values to be used at the locations of the constraints. If
535                    L{value} is not given C{None} is rerturned.                    C{value} is not given C{None} is rerturned.
536            @rtype: L{escript.Scalar}            @rtype: L{escript.Scalar}
537            """            """
538            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint == None: self.__setOutput()
# Line 582  class VectorConstrainerAtBoxVertex(Model Line 583  class VectorConstrainerAtBoxVertex(Model
583            return the values used to constrain a solution            return the values used to constrain a solution
584    
585            @return: values to be used at the locations of the constraints. If            @return: values to be used at the locations of the constraints. If
586                    L{value} is not given C{None} is rerturned.                    C{value} is not given C{None} is rerturned.
587            @rtype: L{escript.Vector}            @rtype: L{escript.Vector}
588            """            """
589            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint == None: self.__setOutput()

Legend:
Removed from v.1387  
changed lines
  Added in v.2236

  ViewVC Help
Powered by ViewVC 1.1.26