/[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 5023 by jfenwick, Thu Feb 6 06:12:20 2014 UTC revision 5024 by jfenwick, Tue Jun 10 08:46:07 2014 UTC
# Line 52  class DomainReader(ParameterSet): Line 52  class DomainReader(ParameterSet):
52            :return: the domain            :return: the domain
53            :rtype: `Domain`            :rtype: `Domain`
54            """            """
55            if self.__domain == None:            if self.__domain is None:
56               if  self.source.fileformat == "fly":               if  self.source.fileformat == "fly":
57                  self.__domain=self.__domainModule.ReadMesh(self.source.getLocalFileName(),self.integrationOrder)                  self.__domain=self.__domainModule.ReadMesh(self.source.getLocalFileName(),self.integrationOrder)
58               elif self.source.fileformat == "gmsh":               elif self.source.fileformat == "gmsh":
# Line 219  class ConstrainerOverBox(Model): Line 219  class ConstrainerOverBox(Model):
219            :return: the mask marking the locations of the constraints            :return: the mask marking the locations of the constraints
220            :rtype: `escript.Scalar`            :rtype: `escript.Scalar`
221            """            """
222            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
223            return self.__location_of_constraint            return self.__location_of_constraint
224                    
225        def value_of_constraint(self):        def value_of_constraint(self):
# Line 230  class ConstrainerOverBox(Model): Line 230  class ConstrainerOverBox(Model):
230                    ``value`` is not given ``None`` is rerturned.                    ``value`` is not given ``None`` is rerturned.
231            :rtype: `escript.Scalar`            :rtype: `escript.Scalar`
232            """            """
233            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
234            return self.__value_of_constraint            return self.__value_of_constraint
235                    
236        def __setOutput(self):        def __setOutput(self):
237            if self.__location_of_constraint == None:            if self.__location_of_constraint is None:
238               x=self.domain.getX()               x=self.domain.getX()
239               val=self.value               val=self.value
240               if isinstance(val, int) or isinstance(val, float):               if isinstance(val, int) or isinstance(val, float):
# Line 243  class ConstrainerOverBox(Model): Line 243  class ConstrainerOverBox(Model):
243                  shape=(len(val),)                  shape=(len(val),)
244               elif isinstance(val, numpy.ndarray):               elif isinstance(val, numpy.ndarray):
245                   shape=val.shape                   shape=val.shape
246               elif val == None:               elif val is None:
247                    shape=()                    shape=()
248               else:               else:
249                   shape=val.getShape()                   shape=val.getShape()
# Line 262  class ConstrainerOverBox(Model): Line 262  class ConstrainerOverBox(Model):
262                     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)
263                     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)
264                     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)
265               if not self.value == None:               if not self.value is None:
266                     self.__value_of_constraint=self.__location_of_constraint*self.value                     self.__value_of_constraint=self.__location_of_constraint*self.value
267  class ScalarConstrainerOverBox(Model):  class ScalarConstrainerOverBox(Model):
268        """        """
# Line 301  class ScalarConstrainerOverBox(Model): Line 301  class ScalarConstrainerOverBox(Model):
301            :return: the mask marking the locations of the constraints            :return: the mask marking the locations of the constraints
302            :rtype: `escript.Scalar`            :rtype: `escript.Scalar`
303            """            """
304            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
305            return self.__location_of_constraint            return self.__location_of_constraint
306                    
307        def value_of_constraint(self):        def value_of_constraint(self):
# Line 312  class ScalarConstrainerOverBox(Model): Line 312  class ScalarConstrainerOverBox(Model):
312                    ``value`` is not given ``None`` is rerturned.                    ``value`` is not given ``None`` is rerturned.
313            :rtype: `escript.Scalar`            :rtype: `escript.Scalar`
314            """            """
315            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
316            return self.__value_of_constraint            return self.__value_of_constraint
317                    
318        def __setOutput(self):        def __setOutput(self):
# Line 334  class ScalarConstrainerOverBox(Model): Line 334  class ScalarConstrainerOverBox(Model):
334                  if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol*d)                  if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol*d)
335                  if self.bottom: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol*d)                  if self.bottom: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol*d)
336                  if self.top: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol*d)                  if self.top: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol*d)
337            if not self.value == None:            if not self.value is None:
338                self.__value_of_constraint=self.__location_of_constraint*self.value                self.__value_of_constraint=self.__location_of_constraint*self.value
339    
340  class VectorConstrainerOverBox(Model):  class VectorConstrainerOverBox(Model):
# Line 379  class VectorConstrainerOverBox(Model): Line 379  class VectorConstrainerOverBox(Model):
379            :return: the mask marking the locations of the constraints            :return: the mask marking the locations of the constraints
380            :rtype: `escript.Vector`            :rtype: `escript.Vector`
381            """            """
382            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
383            return self.__location_of_constraint            return self.__location_of_constraint
384                    
385        def value_of_constraint(self):        def value_of_constraint(self):
# Line 390  class VectorConstrainerOverBox(Model): Line 390  class VectorConstrainerOverBox(Model):
390                    ``value`` is not given ``None`` is rerturned.                    ``value`` is not given ``None`` is rerturned.
391            :rtype: `escript.Vector`            :rtype: `escript.Vector`
392            """            """
393            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
394            return self.__value_of_constraint            return self.__value_of_constraint
395                    
396        def __setOutput(self):        def __setOutput(self):
# Line 423  class VectorConstrainerOverBox(Model): Line 423  class VectorConstrainerOverBox(Model):
423               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.]
424               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.]
425               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.]
426               if not self.value == None:               if not self.value is None:
427                  self.__value_of_constraint=self.__location_of_constraint*self.value                  self.__value_of_constraint=self.__location_of_constraint*self.value
428            else:            else:
429               x0,x1=x[0],x[1]               x0,x1=x[0],x[1]
# Line 440  class VectorConstrainerOverBox(Model): Line 440  class VectorConstrainerOverBox(Model):
440               top_mask=whereZero(x1-sup(x1),self.tol*d)               top_mask=whereZero(x1-sup(x1),self.tol*d)
441               if self.top[0]: self.__location_of_constraint+=top_mask*[1.,0.]               if self.top[0]: self.__location_of_constraint+=top_mask*[1.,0.]
442               if self.top[1]: self.__location_of_constraint+=top_mask*[0.,1.]               if self.top[1]: self.__location_of_constraint+=top_mask*[0.,1.]
443               if not self.value == None:               if not self.value is None:
444                  self.__value_of_constraint=self.__location_of_constraint*self.value[:2]                  self.__value_of_constraint=self.__location_of_constraint*self.value[:2]
445    
446  class ConstrainerAtBoxVertex(Model):  class ConstrainerAtBoxVertex(Model):
# Line 468  class ConstrainerAtBoxVertex(Model): Line 468  class ConstrainerAtBoxVertex(Model):
468            :return: the mask marking the locations of the constraints            :return: the mask marking the locations of the constraints
469            :rtype: `escript.Scalar`            :rtype: `escript.Scalar`
470            """            """
471            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
472            return self.__location_of_constraint            return self.__location_of_constraint
473                    
474        def value_of_constraint(self):        def value_of_constraint(self):
# Line 479  class ConstrainerAtBoxVertex(Model): Line 479  class ConstrainerAtBoxVertex(Model):
479                    ``value`` is not given ``None`` is rerturned.                    ``value`` is not given ``None`` is rerturned.
480            :rtype: `escript.Scalar`            :rtype: `escript.Scalar`
481            """            """
482            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
483            return self.__value_of_constraint            return self.__value_of_constraint
484                    
485        def __setOutput(self):        def __setOutput(self):
486            if self.__location_of_constraint == None:            if self.__location_of_constraint is None:
487               x=self.domain.getX()               x=self.domain.getX()
488               val=self.value               val=self.value
489               if isinstance(val, int) or isinstance(val, float):               if isinstance(val, int) or isinstance(val, float):
# Line 492  class ConstrainerAtBoxVertex(Model): Line 492  class ConstrainerAtBoxVertex(Model):
492                  shape=(len(val),)                  shape=(len(val),)
493               elif isinstance(val, numpy.ndarray):               elif isinstance(val, numpy.ndarray):
494                   shape=val.shape                   shape=val.shape
495               elif val == None:               elif val is None:
496                    shape=()                    shape=()
497               else:               else:
498                   shape=val.getShape()                   shape=val.getShape()
# Line 501  class ConstrainerAtBoxVertex(Model): Line 501  class ConstrainerAtBoxVertex(Model):
501               else:               else:
502                     vertex=[inf(x[0]),inf(x[1])]                     vertex=[inf(x[0]),inf(x[1])]
503               self.__location_of_constraint=whereZero(length(x-vertex),self.tol)*numpy.ones(shape)               self.__location_of_constraint=whereZero(length(x-vertex),self.tol)*numpy.ones(shape)
504               if not self.value == None:               if not self.value is None:
505                     self.__value_of_constraint=self.__location_of_constraint*self.value                     self.__value_of_constraint=self.__location_of_constraint*self.value
506  class ScalarConstrainerAtBoxVertex(Model):  class ScalarConstrainerAtBoxVertex(Model):
507        """        """
# Line 528  class ScalarConstrainerAtBoxVertex(Model Line 528  class ScalarConstrainerAtBoxVertex(Model
528            :return: the mask marking the locations of the constraints            :return: the mask marking the locations of the constraints
529            :rtype: `escript.Scalar`            :rtype: `escript.Scalar`
530            """            """
531            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
532            return self.__location_of_constraint            return self.__location_of_constraint
533                    
534        def value_of_constraint(self):        def value_of_constraint(self):
# Line 539  class ScalarConstrainerAtBoxVertex(Model Line 539  class ScalarConstrainerAtBoxVertex(Model
539                    ``value`` is not given ``None`` is rerturned.                    ``value`` is not given ``None`` is rerturned.
540            :rtype: `escript.Scalar`            :rtype: `escript.Scalar`
541            """            """
542            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
543            return self.__value_of_constraint            return self.__value_of_constraint
544                    
545        def __setOutput(self):        def __setOutput(self):
# Line 550  class ScalarConstrainerAtBoxVertex(Model Line 550  class ScalarConstrainerAtBoxVertex(Model
550            else:            else:
551                   vertex=[inf(x[0]),inf(x[1])]                   vertex=[inf(x[0]),inf(x[1])]
552            self.__location_of_constraint=whereZero(length(x-vertex),self.tol)            self.__location_of_constraint=whereZero(length(x-vertex),self.tol)
553            if not self.value == None:            if not self.value is None:
554                self.__value_of_constraint=self.__location_of_constraint*self.value                self.__value_of_constraint=self.__location_of_constraint*self.value
555    
556  class VectorConstrainerAtBoxVertex(Model):  class VectorConstrainerAtBoxVertex(Model):
# Line 579  class VectorConstrainerAtBoxVertex(Model Line 579  class VectorConstrainerAtBoxVertex(Model
579            :return: the mask marking the locations of the constraints            :return: the mask marking the locations of the constraints
580            :rtype: `escript.Vector`            :rtype: `escript.Vector`
581            """            """
582            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
583            return self.__location_of_constraint            return self.__location_of_constraint
584                    
585        def value_of_constraint(self):        def value_of_constraint(self):
# Line 590  class VectorConstrainerAtBoxVertex(Model Line 590  class VectorConstrainerAtBoxVertex(Model
590                    ``value`` is not given ``None`` is rerturned.                    ``value`` is not given ``None`` is rerturned.
591            :rtype: `escript.Vector`            :rtype: `escript.Vector`
592            """            """
593            if self.__location_of_constraint == None: self.__setOutput()            if self.__location_of_constraint is None: self.__setOutput()
594            return self.__value_of_constraint            return self.__value_of_constraint
595                    
596        def __setOutput(self):        def __setOutput(self):
# Line 608  class VectorConstrainerAtBoxVertex(Model Line 608  class VectorConstrainerAtBoxVertex(Model
608               if self.comp_mask[0]: msk[0]=1               if self.comp_mask[0]: msk[0]=1
609               if self.comp_mask[1]: msk[1]=1               if self.comp_mask[1]: msk[1]=1
610            self.__location_of_constraint=whereZero(length(x-vertex),self.tol)*numpy.ones(shape)            self.__location_of_constraint=whereZero(length(x-vertex),self.tol)*numpy.ones(shape)
611            if not self.value == None:            if not self.value is None:
612                  self.__value_of_constraint=self.__location_of_constraint*self.value                  self.__value_of_constraint=self.__location_of_constraint*self.value
613    

Legend:
Removed from v.5023  
changed lines
  Added in v.5024

  ViewVC Help
Powered by ViewVC 1.1.26