/[escript]/branches/3.4.1/modellib/py_src/input.py
ViewVC logotype

Diff of /branches/3.4.1/modellib/py_src/input.py

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

revision 903 by gross, Fri Nov 17 01:59:49 2006 UTC revision 904 by gross, Fri Nov 17 08:49:44 2006 UTC
# Line 248  class ScalarDistributionFromTags(Paramet Line 248  class ScalarDistributionFromTags(Paramet
248      @type value9: C{float}      @type value9: C{float}
249      """      """
250      def __init__(self,debug=False):      def __init__(self,debug=False):
251          Model.__init__(self,debug=debug)          super(ScalarDistributionFromTags, self).__init__(debug=debug)
252          self.declareParameter(domain=None,          self.declareParameter(domain=None,
253                                default=0.,                                default=0.,
254                                tag0=None,                                tag0=None,
# Line 279  class ScalarDistributionFromTags(Paramet Line 279  class ScalarDistributionFromTags(Paramet
279          Link against this method to get the output of this model.          Link against this method to get the output of this model.
280          """          """
281          d=Scalar(self.default,Function(self.domain))          d=Scalar(self.default,Function(self.domain))
282          if not self.tag0 == None: d=setTaggedValue(self.tag0,self.value0)          if not self.tag0 == None: d.setTaggedValue(self.tag0,self.value0)
283          if not self.tag1 == None: d=setTaggedValue(self.tag1,self.value1)          if not self.tag1 == None: d.setTaggedValue(self.tag1,self.value1)
284          if not self.tag2 == None: d=setTaggedValue(self.tag2,self.value2)          if not self.tag2 == None: d.setTaggedValue(self.tag2,self.value2)
285          if not self.tag3 == None: d=setTaggedValue(self.tag3,self.value3)          if not self.tag3 == None: d.setTaggedValue(self.tag3,self.value3)
286          if not self.tag4 == None: d=setTaggedValue(self.tag4,self.value4)          if not self.tag4 == None: d.setTaggedValue(self.tag4,self.value4)
287          if not self.tag5 == None: d=setTaggedValue(self.tag5,self.value5)          if not self.tag5 == None: d.setTaggedValue(self.tag5,self.value5)
288          if not self.tag6 == None: d=setTaggedValue(self.tag6,self.value6)          if not self.tag6 == None: d.setTaggedValue(self.tag6,self.value6)
289          if not self.tag7 == None: d=setTaggedValue(self.tag7,self.value7)          if not self.tag7 == None: d.setTaggedValue(self.tag7,self.value7)
290          if not self.tag8 == None: d=setTaggedValue(self.tag8,self.value8)          if not self.tag8 == None: d.setTaggedValue(self.tag8,self.value8)
291          if not self.tag9 == None: d=setTaggedValue(self.tag9,self.value9)          if not self.tag9 == None: d.setTaggedValue(self.tag9,self.value9)
292          return d          return d
293    
294  class LinearCombination(ParameterSet):  class LinearCombination(ParameterSet):
# Line 361  class LinearCombination(ParameterSet): Line 361  class LinearCombination(ParameterSet):
361              out += fv3              out += fv3
362          return out          return out
363    
364    class MergeConstraints(ParameterSet):
365        """
366        Returns a linear combination of the f0*v0+f1*v1+f2*v2+f3*v3+f4*v4
367        """
368        def __init__(self,debug=False):
369            super(MergeConstraints, self).__init__(debug=debug)
370            self.declareParameter(location_of_constraint0=None, \
371                                  value_of_constraint0=None, \
372                                  location_of_constraint1=None, \
373                                  value_of_constraint1=None, \
374                                  location_of_constraint2=None, \
375                                  value_of_constraint2=None, \
376                                  location_of_constraint3=None, \
377                                  value_of_constraint3=None, \
378                                  location_of_constraint4=None, \
379                                  value_of_constraint4=None)
380        def location_of_constraint(self):
381              """
382              return the values used to constrain a solution
383    
384              @return: the mask marking the locations of the constraints
385              @rtype: L{escript.Vector}
386              """
387              out_loc=0
388              if not self.location_of_constraint0 == None and not self.value_of_constraint0== None:
389                   out_loc=wherePositive(out_loc+wherePositive(self.location_of_constraint0))
390              if not self.location_of_constraint1 == None and not self.value_of_constraint1== None:
391                   out_loc=wherePositive(out_loc+wherePositive(self.location_of_constraint1))
392              if not self.location_of_constraint2 == None and not self.value_of_constraint2== None:
393                   out_loc=wherePositive(out_loc+wherePositive(self.location_of_constraint2))
394              if not self.location_of_constraint3 == None and not self.value_of_constraint3== None:
395                   out_loc=wherePositive(out_loc+wherePositive(self.location_of_constraint3))
396              return out_loc
397    
398        def value_of_constraint(self):
399              """
400              return the values used to constrain a solution
401    
402              @return: values to be used at the locations of the constraints. If
403                      L{value} is not given C{None} is rerturned.
404              @rtype: L{escript.Vector}
405              """
406              out_loc=0
407              out=0
408              if not self.location_of_constraint0 == None and not self.value_of_constraint0== None:
409                   tmp=wherePositive(self.location_of_constraint0)
410                   out=out*out_loc+self.value_of_constraint0*tmp
411                   out_loc=wherePositive(out_loc+tmp)
412              if not self.location_of_constraint1 == None and not self.value_of_constraint1== None:
413                   tmp=wherePositive(self.location_of_constraint1)
414                   out=out*out_loc+self.value_of_constraint1*tmp
415                   out_loc=wherePositive(out_loc+tmp)
416              if not self.location_of_constraint2 == None and not self.value_of_constraint2== None:
417                   tmp=wherePositive(self.location_of_constraint2)
418                   out=out*out_loc+self.value_of_constraint2*tmp
419                   out_loc=wherePositive(out_loc+tmp)
420              if not self.location_of_constraint3 == None and not self.value_of_constraint3== None:
421                   tmp=wherePositive(self.location_of_constraint3)
422                   out=out*out_loc+self.value_of_constraint3*tmp
423                   out_loc=wherePositive(out_loc+tmp)
424              return out
425  # vim: expandtab shiftwidth=4:  # vim: expandtab shiftwidth=4:

Legend:
Removed from v.903  
changed lines
  Added in v.904

  ViewVC Help
Powered by ViewVC 1.1.26