Ignore:
Timestamp:
Dec 22, 2004, 2:20:59 PM (20 years ago)
Author:
duncan
Message:

added getting and setting of unique vertex quantities, with a subset of triangles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/region.py

    r592 r715  
    1212    """   
    1313
    14     def __init__(self):
    15         pass
     14    def __init__(self, location='vertices'):
     15        self.location = location
    1616       
    1717    def __call__(self, tag, elements, domain):
     
    2020
    2121
    22 class Set_Region(Region):
     22    def build_indexes(self, elements, domain):
     23        """
     24        Return a list of triangle_id or vertex_id, depending on the location
     25        """
     26        if self.location == 'unique vertices':
     27            return domain.get_unique_vertices(elements)
     28        else:
     29            return elements
     30               
     31class Set_region(Region):
    2332   
    2433    def __init__(self, tag, quantity, X, location='vertices'):
     
    4352        """   
    4453        if tag == self.tag:
    45             domain.set_quantity(self.quantity, self.X, indexes = elements)
     54            domain.set_quantity(self.quantity,
     55                                self.X,
     56                                location=self.location,
     57                                indexes=self.build_indexes(elements, domain))
    4658
    47 
    48 class Add_Value_To_Region(Region):
     59       
     60class Add_value_to_region(Region):
    4961    """
    5062    Will add a value to the current quantity value.
    5163    """
    5264   
    53     def __init__(self, tag, quantity, X, location='vertex'):
    54         Region.__init__(self)
     65    def __init__(self, tag, quantity, X, location='vertices', initial_quantity=None):
     66        #I have to get this going!
     67        #Region.__init__(self)
    5568        self.tag = tag
    56         self.quantity = quantity
     69        self.quantity_answer = quantity
    5770        self.location = location
    5871        self.X = X
     72        if initial_quantity is None:
     73            self.quantity_initial_value = quantity
     74        else:
     75            self.quantity_initial_value = initial_quantity
    5976        if callable(X):
    6077            raise 'This class does not work with functions' 
     
    6784        """   
    6885        if tag == self.tag:
    69             new_values = domain.get_quantity(self.quantity,
    70                                              indexes = elements) + self.X
    71             domain.set_quantity(self.quantity, new_values, indexes = elements)
     86            new_values = domain.get_quantity(self.quantity_initial_value,
     87                          indexes=self.build_indexes(elements, domain),
     88                          location=self.location) + self.X
     89            domain.set_quantity(self.quantity_answer, new_values,
     90                                indexes=self.build_indexes(elements, domain),
     91                                location=self.location)
     92
     93
     94class Stage_no_less_than_elevation(Region):
     95    """
     96    Will set the stage to not be less than the elevation.
     97    This would be good, but it's not region dependent.
     98    Wait for it to become a default for pyvolution.
     99    """
     100   
     101    def __init__(self):
     102        pass
Note: See TracChangeset for help on using the changeset viewer.