Changeset 715 for inundation/ga/storm_surge/pyvolution/region.py
- Timestamp:
- Dec 22, 2004, 2:20:59 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/region.py
r592 r715 12 12 """ 13 13 14 def __init__(self ):15 pass14 def __init__(self, location='vertices'): 15 self.location = location 16 16 17 17 def __call__(self, tag, elements, domain): … … 20 20 21 21 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 31 class Set_region(Region): 23 32 24 33 def __init__(self, tag, quantity, X, location='vertices'): … … 43 52 """ 44 53 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)) 46 58 47 48 class Add_ Value_To_Region(Region):59 60 class Add_value_to_region(Region): 49 61 """ 50 62 Will add a value to the current quantity value. 51 63 """ 52 64 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) 55 68 self.tag = tag 56 self.quantity = quantity69 self.quantity_answer = quantity 57 70 self.location = location 58 71 self.X = X 72 if initial_quantity is None: 73 self.quantity_initial_value = quantity 74 else: 75 self.quantity_initial_value = initial_quantity 59 76 if callable(X): 60 77 raise 'This class does not work with functions' … … 67 84 """ 68 85 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 94 class 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.