Changeset 6533 for branches/numpy/anuga/abstract_2d_finite_volumes
- Timestamp:
- Mar 17, 2009, 4:02:54 PM (16 years ago)
- Location:
- branches/numpy/anuga/abstract_2d_finite_volumes
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/numpy/anuga/abstract_2d_finite_volumes/domain.py
r6517 r6533 319 319 return self.mesh.get_boundary_polygon(*args, **kwargs) 320 320 321 # FIXME(Ole): This doesn't seem to be required322 321 def get_number_of_triangles_per_node(self, *args, **kwargs): 323 322 return self.mesh.get_number_of_triangles_per_node(*args, **kwargs) … … 349 348 def statistics(self, *args, **kwargs): 350 349 return self.mesh.statistics(*args, **kwargs) 351 352 def get_extent(self, *args, **kwargs):353 return self.mesh.get_extent(*args, **kwargs)354 350 355 351 ## -
branches/numpy/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
r6517 r6533 88 88 # FIXME (Ole): We should rename f to function to be consistent with 89 89 # Transmissive_Momentum_Set_Stage_Boundary (cf posting by rrraman) 90 def __init__(self, domain=None, 91 f=None, 92 default_boundary=None, 93 verbose=False): 90 def __init__(self, domain = None, f = None): 94 91 Boundary.__init__(self) 95 self.default_boundary = default_boundary96 self.default_boundary_invoked = False # Flag97 self.domain = domain98 self.verbose = verbose99 92 100 93 try: … … 129 122 def evaluate(self, vol_id=None, edge_id=None): 130 123 # FIXME (Ole): I think this should be get_time(), see ticket:306 131 try: 132 res = self.f(self.domain.time) 133 except Modeltime_too_early, e: 134 raise Modeltime_too_early, e 135 except Modeltime_too_late, e: 136 if self.default_boundary is None: 137 raise Exception, e # Reraise exception 138 else: 139 # Pass control to default boundary 140 res = self.default_boundary.evaluate(vol_id, edge_id) 141 142 # Ensure that result cannot be manipulated 143 # This is a real danger in case the 144 # default_boundary is a Dirichlet type 145 # for instance. 146 res = res.copy() 147 148 if self.default_boundary_invoked is False: 149 if self.verbose: 150 # Issue warning the first time 151 msg = '%s' %str(e) 152 msg += 'Instead I will use the default boundary: %s\n'\ 153 %str(self.default_boundary) 154 msg += 'Note: Further warnings will be supressed' 155 print msg 156 157 # FIXME (Ole): Replace this crude flag with 158 # Python's ability to print warnings only once. 159 # See http://docs.python.org/lib/warning-filter.html 160 self.default_boundary_invoked = True 161 162 return res 124 return self.f(self.domain.time) 163 125 164 126 … … 337 299 if self.default_boundary_invoked is False: 338 300 # Issue warning the first time 339 if self.verbose: 340 msg = '%s' %str(e) 341 msg += 'Instead I will use the default boundary: %s\n'\ 342 %str(self.default_boundary) 343 msg += 'Note: Further warnings will be supressed' 344 print msg 301 msg = '%s' %str(e) 302 msg += 'Instead I will use the default boundary: %s\n'\ 303 %str(self.default_boundary) 304 msg += 'Note: Further warnings will be supressed' 305 warn(msg) 345 306 346 307 # FIXME (Ole): Replace this crude flag with -
branches/numpy/anuga/abstract_2d_finite_volumes/quantity.py
r6517 r6533 886 886 # a crash in fittng, so disabled it until I can investigate further 887 887 # Sorry. 23 Jan 2009. Logged as ticket:314 888 #if True: # Test will fail (31 Jan 2009) 889 if False: # Test will pass (31 Jan 2009) 888 if False: 890 889 # Use mesh as defined by domain 891 890 # This used to cause problems for caching due to quantities -
branches/numpy/anuga/abstract_2d_finite_volumes/test_domain.py
r6517 r6533 542 542 conserved_quantities =\ 543 543 ['stage', 'xmomentum', 'ymomentum']) 544 domain.set_default_order(1)545 544 domain.check_integrity() 546 545 … … 651 650 conserved_quantities =\ 652 651 ['stage', 'xmomentum', 'ymomentum']) 653 domain.set_default_order(1)654 652 domain.check_integrity() 655 653 … … 802 800 [ 11.0, 11.0, 11.0], 803 801 [ 11.0, 11.0, 11.0]]) 804 805 def test_that_mesh_methods_exist(self):806 """test_that_mesh_methods_exist807 808 Test that relavent mesh methods are made available in809 domain through composition810 """811 from mesh_factory import rectangular812 from shallow_water import Domain813 814 # Create basic mesh815 points, vertices, boundary = rectangular(1, 3)816 817 # Create shallow water domain818 domain = Domain(points, vertices, boundary)819 820 821 domain.get_centroid_coordinates()822 domain.get_radii()823 domain.get_areas()824 domain.get_area()825 domain.get_vertex_coordinates()826 domain.get_triangles()827 domain.get_nodes()828 domain.get_number_of_nodes()829 domain.get_normal(0,0)830 domain.get_intersecting_segments([[0.0, 0.0], [0.0, 1.0]])831 domain.get_disconnected_triangles()832 domain.get_boundary_tags()833 domain.get_boundary_polygon()834 #domain.get_number_of_triangles_per_node()835 domain.get_triangles_and_vertices_per_node()836 domain.get_interpolation_object()837 domain.get_tagged_elements()838 domain.get_lone_vertices()839 domain.get_unique_vertices()840 g = domain.get_georeference()841 domain.set_georeference(g)842 domain.build_tagged_elements_dictionary()843 domain.statistics()844 domain.get_extent()845 846 847 848 802 849 803 #------------------------------------------------------------- -
branches/numpy/anuga/abstract_2d_finite_volumes/test_general_mesh.py
r6517 r6533 91 91 str(verts))) 92 92 self.assert_(num.allclose(num.array([nodes_absolute[1], 93 nodes_absolute[0], 94 nodes_absolute[2]]), verts)) 95 verts = domain.get_vertex_coordinates(triangle_id=0, 96 absolute=True) 97 self.assert_(num.allclose(num.array([nodes_absolute[1], 98 nodes_absolute[0], 99 nodes_absolute[2]]), verts)) 100 101 93 nodes_absolute[0], 94 nodes_absolute[2]]), 95 verts), msg) 102 96 103 97 def test_get_vertex_coordinates_triangle_id(self): -
branches/numpy/anuga/abstract_2d_finite_volumes/util.py
r6517 r6533 925 925 verbose = False): 926 926 927 # FIXME(Ole): Shouldn't print statements here be governed by verbose?928 927 assert type(gauge_filename) == type(''), 'Gauge filename must be a string' 929 928 … … 972 971 raise msg 973 972 974 if verbose: 975 print 'swwfile', swwfile 973 print 'swwfile', swwfile 976 974 977 975 # Extract parent dir name and use as label … … 2491 2489 base_name=base, 2492 2490 verbose=verbose) 2493 #print 'sww files just after get_all_swwfiles()', sww_files2494 # fudge to get SWW files in 'correct' order, oldest on the left2495 sww_files.sort()2496 2497 if verbose:2498 print 'sww files', sww_files2499 2491 2500 2492 #to make all the quantities lower case for file_function … … 2505 2497 2506 2498 core_quantities = ['stage', 'elevation', 'xmomentum', 'ymomentum'] 2507 gauge_file = out_name 2508 2509 heading = [quantity for quantity in quantities] 2510 heading.insert(0,'time') 2511 heading.insert(1,'hours') 2512 2513 #create a list of csv writers for all the points and write header 2514 points_writer = [] 2515 for point_i,point in enumerate(points): 2516 points_writer.append(writer(file(dir_name + sep + gauge_file 2517 + point_name[point_i] + '.csv', "wb"))) 2518 points_writer[point_i].writerow(heading) 2519 2520 if verbose: print 'Writing csv files' 2521 2522 quake_offset_time = None 2523 2499 2524 2500 for sww_file in sww_files: 2525 2501 sww_file = join(dir_name, sww_file+'.sww')
Note: See TracChangeset
for help on using the changeset viewer.