/[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

revision 992 by gross, Fri Feb 9 08:55:28 2007 UTC revision 993 by gross, Fri Feb 23 06:39:38 2007 UTC
# Line 248  class ConstrainerOverBox(Model): Line 248  class ConstrainerOverBox(Model):
248            return self.__value_of_constraint            return self.__value_of_constraint
249                    
250        def __setOutput(self):        def __setOutput(self):
251            x=self.domain.getX()            if self.__location_of_constraint == None:
252            val=self.value               x=self.domain.getX()
253            if isinstance(val, int) or isinstance(val, float):               val=self.value
254               shape=()               if isinstance(val, int) or isinstance(val, float):
255            elif isinstance(val, list) or isinstance(val, tuple) :                  shape=()
256               shape=(len(val),)               elif isinstance(val, list) or isinstance(val, tuple) :
257            elif isinstance(val, numarray.NumArray):                  shape=(len(val),)
258                shape=val.shape               elif isinstance(val, numarray.NumArray):
259            else:                   shape=val.shape
260                shape=val.getShape()               elif val == None:
261            self.__location_of_constraint=Data(0,shape,x.getFunctionSpace())                    shape=()
262            if self.domain.getDim()==3:               else:
263                  x0,x1,x2=x[0],x[1],x[2]                   shape=val.getShape()
264                  if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol)               self.__location_of_constraint=Data(0,shape,x.getFunctionSpace())
265                  if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol)               if self.domain.getDim()==3:
266                  if self.front: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol)                     x0,x1,x2=x[0],x[1],x[2]
267                  if self.back: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol)                     if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol)
268                  if self.bottom: self.__location_of_constraint+=whereZero(x2-inf(x2),self.tol)                     if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol)
269                  if self.top: self.__location_of_constraint+=whereZero(x2-sup(x2),self.tol)                     if self.front: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol)
270            else:                     if self.back: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol)
271                  x0,x1=x[0],x[1]                     if self.bottom: self.__location_of_constraint+=whereZero(x2-inf(x2),self.tol)
272                  if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol)                     if self.top: self.__location_of_constraint+=whereZero(x2-sup(x2),self.tol)
273                  if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol)               else:
274                  if self.bottom: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol)                     x0,x1=x[0],x[1]
275                  if self.top: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol)                     if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol)
276            self.__value_of_constraint=self.__location_of_constraint*self.value                     if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol)
277                       if self.bottom: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol)
278                       if self.top: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol)
279                 if not self.value == None:
280                       self.__value_of_constraint=self.__location_of_constraint*self.value
281  class ScalarConstrainerOverBox(Model):  class ScalarConstrainerOverBox(Model):
282        """        """
283        Creates a characteristic function for the location of constraints        Creates a characteristic function for the location of constraints
# Line 342  class ScalarConstrainerOverBox(Model): Line 346  class ScalarConstrainerOverBox(Model):
346                  if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol)                  if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol)
347                  if self.bottom: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol)                  if self.bottom: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol)
348                  if self.top: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol)                  if self.top: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol)
349            if self.value:            if not self.value == None:
350                self.__value_of_constraint=self.__location_of_constraint*self.value                self.__value_of_constraint=self.__location_of_constraint*self.value
351    
352  class VectorConstrainerOverBox(Model):  class VectorConstrainerOverBox(Model):
# Line 430  class VectorConstrainerOverBox(Model): Line 434  class VectorConstrainerOverBox(Model):
434               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.]
435               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.]
436               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.]
437               if self.value:               if not self.value == None:
438                  self.__value_of_constraint=self.__location_of_constraint*self.value                  self.__value_of_constraint=self.__location_of_constraint*self.value
439            else:            else:
440               x0,x1=x[0],x[1]               x0,x1=x[0],x[1]
# Line 446  class VectorConstrainerOverBox(Model): Line 450  class VectorConstrainerOverBox(Model):
450               top_mask=whereZero(x1-sup(x1),self.tol)               top_mask=whereZero(x1-sup(x1),self.tol)
451               if self.top[0]: self.__location_of_constraint+=top_mask*[1.,0.]               if self.top[0]: self.__location_of_constraint+=top_mask*[1.,0.]
452               if self.top[1]: self.__location_of_constraint+=top_mask*[0.,1.]               if self.top[1]: self.__location_of_constraint+=top_mask*[0.,1.]
453               if self.value:               if not self.value == None:
454                  self.__value_of_constraint=self.__location_of_constraint*self.value[:2]                  self.__value_of_constraint=self.__location_of_constraint*self.value[:2]
455    
456  # vim: expandtab shiftwidth=4:  # vim: expandtab shiftwidth=4:

Legend:
Removed from v.992  
changed lines
  Added in v.993

  ViewVC Help
Powered by ViewVC 1.1.26