Ignore:
Timestamp:
Oct 14, 2005, 1:32:41 PM (19 years ago)
Author:
ole
Message:

Implemented arbitrary expressions in set_quantity using functionality from changeset:1916

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/domain.py

    r1919 r1924  
    143143
    144144    def set_quantity(self, name, *args, **kwargs):
    145                      #X,
    146                      #location = 'vertices',
    147                      #indices = None):
    148145        """Set values for named quantity
    149146
    150         name: Name of quantity
    151         X: Compatible list, Numeric array, const or function (see below)
    152         location: Where values are to be stored.
    153                   Permissible options are: vertices, edges, centroids
    154 
    155         In case of location == 'centroids' the dimension values must
    156         be a list of a Numerical array of length N, N being the number
    157         of elements. Otherwise it must be of dimension Nx3.
    158 
    159         Indices is the set of element ids that the operation applies to
    160 
    161         The values will be stored in elements following their
    162         internal ordering.
    163 
    164         #FIXME (Ole): I suggest the following interface
    165         set_quantity(name, X, location, region)
    166         where
    167             name: Name of quantity
    168             X:
    169               -Compatible list,
    170               -Numeric array,
    171               -const or function (see below)
    172               -another quantity Q or an expression of the form
    173               a*Q+b, where a is a scalar or a compatible array or a quantity
    174               Q is a quantity
    175               b is either a scalar, a quantity or a compatible array
    176               pts file
    177             location: Where values are to be stored.
    178                       Permissible options are: vertices, edges, centroid
    179             region: Identify subset of triangles. Permissible values are
    180                     - tag name (refers to tagged region)
    181                     - indices (refers to specific triangles)
    182                     - polygon (identifies region)
    183 
    184             This should work for all values of X
    185 
    186 
     147
     148        One keyword argument is documented here:
     149        expression = None, # Arbitrary expression
     150
     151        expression:
     152          Arbitrary expression involving quantity names
     153
     154        See Quantity.set_values for further documentation.
    187155        """
    188156
    189157        #FIXME (Ole): Allow new quantities
     158
    190159       
    191160        #from quantity import Quantity, Conserved_quantity
     
    197166        ##    self.quantities[name] = Quantity(self)
    198167
    199         #Set value
    200         #FIXME: use **kwargs
    201         #self.quantities[name].set_values(X,
    202         #                                 location = location,
    203         #                                 indices = indices)
     168
     169        #Do the expression stuff
     170        if kwargs.has_key('expression'):
     171            expression = kwargs['expression']
     172            del kwargs['expression']           
     173
     174            Q = create_quantity_from_expression(self, expression)
     175
     176            kwargs['quantity'] = Q
     177
     178           
     179           
     180
    204181        self.quantities[name].set_values(*args, **kwargs)
    205182
Note: See TracChangeset for help on using the changeset viewer.