Changeset 9382
- Timestamp:
- Dec 14, 2014, 8:54:02 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/file/test_sww.py
r9018 r9382 201 201 swwfile = domain.get_name() + '.sww' 202 202 domain.set_datadir('.') 203 204 Br = Reflective_boundary(domain) # Side walls 205 Bd = Dirichlet_boundary([1, 0, 0]) # inflow 206 207 domain.set_boundary( {'left': Bd, 'right': Bd, 'top': Br, 'bottom': Br}) 208 209 for t in domain.evolve(yieldstep=1, finaltime = t_end): 210 pass 211 212 213 # Read it 214 215 # Get mesh and quantities from sww file 216 X = get_mesh_and_quantities_from_file(swwfile, 217 quantities=['elevation', 218 'stage', 219 'xmomentum', 220 'ymomentum'], 221 verbose=False) 222 mesh, quantities, time = X 223 224 225 # Check that mesh has been recovered 226 assert num.alltrue(mesh.triangles == domain.get_triangles()) 227 assert num.allclose(mesh.nodes, domain.get_nodes()) 228 229 # Check that time has been recovered 230 assert num.allclose(time, range(t_end+1)) 231 232 # Check that quantities have been recovered 233 # (sww files use single precision) 234 z=domain.get_quantity('elevation').get_values(location='unique vertices') 235 assert num.allclose(quantities['elevation'], z) 236 237 for q in ['stage', 'xmomentum', 'ymomentum']: 238 # Get quantity at last timestep 239 q_ref=domain.get_quantity(q).get_values(location='unique vertices') 240 241 #print q,quantities[q] 242 q_sww=quantities[q][-1,:] 243 244 msg = 'Quantity %s failed to be recovered' %q 245 assert num.allclose(q_ref, q_sww, atol=1.0e-6), msg 246 247 # Cleanup 248 #os.remove(swwfile) 249 250 def test_get_mesh_and_quantities_from_unique_vertices_sww_file(self): 251 """test_get_mesh_and_quantities_from_unique_vertices_sww_file(self): 252 """ 253 254 # Generate a test sww file with non trivial georeference 255 256 import time, os 257 258 # Setup 259 from mesh_factory import rectangular 260 261 # Create basic mesh (100m x 5m) 262 width = 5 263 length = 50 264 t_end = 10 265 points, vertices, boundary = rectangular(length, width, 50, 5) 266 267 # Create shallow water domain 268 domain = Domain(points, vertices, boundary, 269 geo_reference = Geo_reference(56,308500,6189000)) 270 271 domain.set_name('test_get_mesh_and_quantities_from_unique_vertices_sww_file') 272 swwfile = domain.get_name() + '.sww' 273 domain.set_datadir('.') 274 domain.set_store_vertices_uniquely() 203 275 204 276 Br = Reflective_boundary(domain) # Side walls
Note: See TracChangeset
for help on using the changeset viewer.