- Timestamp:
- Aug 28, 2007, 2:23:35 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r4684 r4685 229 229 domain.compute_fluxes() 230 230 231 print domain.get_quantity('stage').explicit_update231 #print domain.get_quantity('stage').explicit_update 232 232 # FIXME (Ole): TODO the general case 233 233 #assert allclose(domain.get_quantity('stage').explicit_update[1], ........??) … … 1306 1306 1307 1307 ##################################################### 1308 def test_initial_condition(self): 1309 """Test that initial condition is output at time == 0 1308 1309 def test_flux_optimisation(self): 1310 """test_flux_optimisation 1311 Test that fluxes are correctly computed using 1312 dry and still cell exclusions 1310 1313 """ 1311 1314 … … 1344 1347 domain.set_boundary({'exterior': Reflective_boundary(domain)}) 1345 1348 1349 1350 # Check that update arrays are initialised to zero 1351 assert allclose(domain.get_quantity('stage').explicit_update, 0) 1352 assert allclose(domain.get_quantity('xmomentum').explicit_update, 0) 1353 assert allclose(domain.get_quantity('ymomentum').explicit_update, 0) 1354 1355 1356 # Get true values 1357 domain.optimise_dry_cells = False 1358 domain.compute_fluxes() 1359 stage_ref = copy.copy(domain.get_quantity('stage').explicit_update) 1360 xmom_ref = copy.copy(domain.get_quantity('xmomentum').explicit_update) 1361 ymom_ref = copy.copy(domain.get_quantity('ymomentum').explicit_update) 1362 1363 # Try with flux optimisation 1364 domain.optimise_dry_cells = True 1365 domain.compute_fluxes() 1366 1367 assert allclose(stage_ref, domain.get_quantity('stage').explicit_update) 1368 assert allclose(xmom_ref, domain.get_quantity('xmomentum').explicit_update) 1369 assert allclose(ymom_ref, domain.get_quantity('ymomentum').explicit_update) 1370 1371 1372 1373 def test_initial_condition(self): 1374 """test_initial_condition 1375 Test that initial condition is output at time == 0 and that 1376 computed values change as system evolves 1377 """ 1378 1379 from anuga.config import g 1380 import copy 1381 1382 a = [0.0, 0.0] 1383 b = [0.0, 2.0] 1384 c = [2.0, 0.0] 1385 d = [0.0, 4.0] 1386 e = [2.0, 2.0] 1387 f = [4.0, 0.0] 1388 1389 points = [a, b, c, d, e, f] 1390 #bac, bce, ecf, dbe 1391 vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]] 1392 1393 domain = Domain(points, vertices) 1394 1395 #Set up for a gradient of (3,0) at mid triangle (bce) 1396 def slope(x, y): 1397 return 3*x 1398 1399 h = 0.1 1400 def stage(x,y): 1401 return slope(x,y)+h 1402 1403 domain.set_quantity('elevation', slope) 1404 domain.set_quantity('stage', stage) 1405 1406 # Allow slope limiters to work (FIXME (Ole): Shouldn't this be automatic in ANUGA?) 1407 domain.distribute_to_vertices_and_edges() 1408 1409 initial_stage = copy.copy(domain.quantities['stage'].vertex_values) 1410 1411 domain.set_boundary({'exterior': Reflective_boundary(domain)}) 1412 1413 domain.optimise_dry_cells = True 1346 1414 #Evolution 1347 for t in domain.evolve(yieldstep = 1.0, finaltime = 2.0):1415 for t in domain.evolve(yieldstep = 0.5, finaltime = 2.0): 1348 1416 stage = domain.quantities['stage'].vertex_values 1349 1417 … … 1352 1420 else: 1353 1421 assert not allclose(stage, initial_stage) 1422 1354 1423 1355 1424 os.remove(domain.get_name() + '.sww') … … 4799 4868 4800 4869 if __name__ == "__main__": 4801 suite = unittest.makeSuite(Test_Shallow_Water,'test_flux_computation') 4870 4871 suite = unittest.makeSuite(Test_Shallow_Water,'test') 4802 4872 #suite = unittest.makeSuite(Test_Shallow_Water,'test_tight_slope_limiters') 4803 4873 #suite = unittest.makeSuite(Test_Shallow_Water,'test_get_maximum_inundation_from_sww')
Note: See TracChangeset
for help on using the changeset viewer.