Changeset 4702
- Timestamp:
- Sep 5, 2007, 10:06:48 AM (17 years ago)
- Location:
- anuga_core/source/anuga/abstract_2d_finite_volumes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py
r4701 r4702 573 573 # FIXME (Ole): This is under construction. See ticket:192 574 574 575 from anuga.abstract_2d_finite_volumes.util import\ 576 apply_expression_to_dictionary 577 575 578 if q is None: 576 579 self.quantities_to_be_monitored = None … … 582 585 q = [q] # Turn argument into a list 583 586 584 # Check correcness 587 # Check correcness and initialise 588 self.quantities_to_be_monitored = {} 585 589 for quantity_name in q: 586 590 msg = 'Quantity %s is not a valid conserved quantity'\ 587 591 %quantity_name 588 592 589 assert quantity_name in self.conserved_quantities, msg 593 594 if not quantity_name in self.quantities: 595 # See if this expression is valid 596 apply_expression_to_dictionary(quantity_name, self.quantities) 597 598 # Initialise extrema 599 self.quantities_to_be_monitored[quantity_name] = [None, None] 600 590 601 591 602 if polygon is not None: … … 598 609 599 610 600 self.quantities_to_be_monitored = q611 601 612 self.monitor_polygon = polygon 602 613 self.monitor_time_interval = time_interval … … 694 705 695 706 x, y = self.get_centroid_coordinates()[k] 696 697 area = self.get_areas()[k]698 max_speed = self.max_speed[k] 707 radius = self.get_radii()[k] 708 area = self.get_areas()[k] 709 max_speed = self.max_speed[k] 699 710 700 711 msg += ' Triangle #%d with centroid (%.4f, %.4f), ' %(k, x, y) 701 712 msg += 'area = %.4f and radius = %.4f ' %(area, radius) 702 713 msg += 'had the largest computed speed: %.6f m/s ' %(max_speed) 703 714 if max_speed > 0.0: 704 715 msg += '(timestep=%.6f)\n' %(radius/max_speed) 705 716 else: 706 msg += '(timestep=%.6f)\n' %(0) 717 msg += '(timestep=%.6f)\n' %(0) 707 718 708 719 # Report all quantity values at vertices … … 1015 1026 """Go through list of boundary objects and update boundary values 1016 1027 for all conserved quantities on boundary. 1017 1018 1019 1020 1028 It is assumed that the ordering of conserved quantities is 1029 consistent between the domain and the boundary object, i.e. 1030 the jth element of vector q must correspond to the jth conserved 1031 quantity in domain. 1021 1032 """ 1022 1033 … … 1024 1035 #FIXME: Boundary objects should not include ghost nodes. 1025 1036 for i, ((vol_id, edge_id), B) in enumerate(self.boundary_objects): 1026 1027 1028 1037 if B is None: 1038 print 'WARNING: Ignored boundary segment %d (None)' 1039 else: 1029 1040 q = B.evaluate(vol_id, edge_id) 1030 1041 -
anuga_core/source/anuga/abstract_2d_finite_volumes/test_domain.py
r4670 r4702 192 192 193 193 194 194 def test_set_quanitities_to_be_monitored(self): 195 """test_set_quanitities_to_be_monitored 196 """ 197 198 a = [0.0, 0.0] 199 b = [0.0, 2.0] 200 c = [2.0,0.0] 201 d = [0.0, 4.0] 202 e = [2.0, 2.0] 203 f = [4.0,0.0] 204 205 points = [a, b, c, d, e, f] 206 #bac, bce, ecf, dbe, daf, dae 207 vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]] 208 209 210 domain = Domain(points, vertices, boundary=None, 211 conserved_quantities =\ 212 ['stage', 'xmomentum', 'ymomentum'], 213 other_quantities = ['elevation', 'friction', 'depth']) 214 215 216 assert domain.quantities_to_be_monitored is None 217 domain.set_quantities_to_be_monitored(['stage', 'stage-elevation']) 218 assert len(domain.quantities_to_be_monitored) == 2 219 assert domain.quantities_to_be_monitored.has_key('stage') 220 assert domain.quantities_to_be_monitored.has_key('stage-elevation') 221 assert domain.quantities_to_be_monitored['stage'][0] == None 222 assert domain.quantities_to_be_monitored['stage'][1] == None 223 224 225 # Check that invalid request are dealt with 226 try: 227 domain.set_quantities_to_be_monitored(['yyyyy']) 228 except: 229 pass 230 else: 231 msg = 'Should have caught illegal quantity' 232 raise Exception, msg 233 234 try: 235 domain.set_quantities_to_be_monitored(['stage-xx']) 236 except NameError: 237 pass 238 else: 239 msg = 'Should have caught illegal quantity' 240 raise Exception, msg 195 241 196 242 def test_set_quantity_from_expression(self):
Note: See TracChangeset
for help on using the changeset viewer.