Changeset 9174
- Timestamp:
- Jun 17, 2014, 9:46:06 PM (11 years ago)
- Location:
- trunk/anuga_core
- Files:
-
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/run_auto_validation_tests.py
r9149 r9174 1 1 import os 2 2 3 3 4 -
trunk/anuga_core/source/anuga/shallow_water/boundaries.py
r8920 r9174 346 346 q[1] = q[2] = 0.0 347 347 return q 348 349 class Characteristic_stage_boundary(Boundary): 350 """Sets the stage via a function and the momentum is determined 351 via assumption of simple incoming wave (uses Riemann invariant) 352 353 354 Example: 355 356 def waveform(t): 357 return sea_level + normalized_amplitude/cosh(t-25)**2 358 359 Bcs = Characteristic_stage_boundary(domain, waveform) 360 361 Underlying domain must be specified when boundary is instantiated 362 """ 363 364 def __init__(self, domain=None, function=None, default_stage = 0.0): 365 """ Instantiate a 366 Characteristic_stage_boundary. 367 domain is the domain containing the boundary 368 function is the function to apply the wave 369 default_stage is the assumed stage pre the application of wave 370 """ 371 372 Boundary.__init__(self) 373 374 if domain is None: 375 msg = 'Domain must be specified for this type boundary' 376 raise Exception, msg 377 378 if function is None: 379 msg = 'Function must be specified for this type boundary' 380 raise Exception, msg 381 382 self.domain = domain 383 self.function = function 384 self.default_stage = default_stage 385 386 self.Elev = domain.quantitis['elevation'] 387 self.Stage = domain.quantitis['stage'] 388 self.Height = domain.quantitis['height'] 389 390 def __repr__(self): 391 """ Return a representation of this instance. """ 392 msg = 'Characteristic_stage_boundary ' 393 msg += '(%s) ' % self.domain 394 msg += '(%s) ' % self.default_stage 395 return msg 396 397 398 def evaluate(self, vol_id, edge_id): 399 """Calculate reflections (reverse outward momentum). 400 401 vol_id 402 edge_id 403 """ 404 405 t = self.domain.get_time() 406 407 408 value = self.function(t) 409 try: 410 stage = float(value) 411 except: 412 stage = float(value[0]) 413 414 415 416 q = self.conserved_quantities 417 #q[0] = self.stage[vol_id, edge_id] 418 q[0] = stage 419 q[1] = self.xmom[vol_id, edge_id] 420 q[2] = self.ymom[vol_id, edge_id] 421 422 normal = self.normals[vol_id, 2*edge_id:2*edge_id+2] 423 424 r = rotate(q, normal, direction = 1) 425 r[1] = -r[1] 426 q = rotate(r, normal, direction = -1) 427 428 429 return q 430 431 432 433 434 435 436 def evaluate_segment(self, domain, segment_edges): 437 """Apply reflective BC on the boundary edges defined by 438 segment_edges 439 """ 440 441 if segment_edges is None: 442 return 443 if domain is None: 444 return 445 446 t = self.domain.get_time() 447 448 449 value = self.function(t) 450 try: 451 stage = float(value) 452 except: 453 stage = float(value[0]) 454 455 456 ids = segment_edges 457 vol_ids = domain.boundary_cells[ids] 458 edge_ids = domain.boundary_edges[ids] 459 460 Stage = domain.quantities['stage'] 461 Elev = domain.quantities['elevation'] 462 Height= domain.quantities['height'] 463 Xmom = domain.quantities['xmomentum'] 464 Ymom = domain.quantities['ymomentum'] 465 Xvel = domain.quantities['xvelocity'] 466 Yvel = domain.quantities['yvelocity'] 467 468 Normals = domain.normals 469 470 #print vol_ids 471 #print edge_ids 472 #Normals.reshape((4,3,2)) 473 #print Normals.shape 474 #print Normals[vol_ids, 2*edge_ids] 475 #print Normals[vol_ids, 2*edge_ids+1] 476 477 n1 = Normals[vol_ids,2*edge_ids] 478 n2 = Normals[vol_ids,2*edge_ids+1] 479 480 # Transfer these quantities to the boundary array 481 Stage.boundary_values[ids] = Stage.edge_values[vol_ids,edge_ids] 482 Elev.boundary_values[ids] = Elev.edge_values[vol_ids,edge_ids] 483 Height.boundary_values[ids] = Height.edge_values[vol_ids,edge_ids] 484 485 # Rotate and negate Momemtum 486 q1 = Xmom.edge_values[vol_ids,edge_ids] 487 q2 = Ymom.edge_values[vol_ids,edge_ids] 488 489 r1 = -q1*n1 - q2*n2 490 r2 = -q1*n2 + q2*n1 491 492 Xmom.boundary_values[ids] = n1*r1 - n2*r2 493 Ymom.boundary_values[ids] = n2*r1 + n1*r2 494 495 # Rotate and negate Velocity 496 q1 = Xvel.edge_values[vol_ids,edge_ids] 497 q2 = Yvel.edge_values[vol_ids,edge_ids] 498 499 r1 = q1*n1 + q2*n2 500 r2 = q1*n2 - q2*n1 501 502 Xvel.boundary_values[ids] = n1*r1 - n2*r2 503 Yvel.boundary_values[ids] = n2*r1 + n1*r2 504 505 506 348 507 349 508 class Dirichlet_discharge_boundary(Boundary): -
trunk/anuga_core/source/anuga/shallow_water/test_swb2_domain.py
r8582 r9174 36 36 37 37 domain=Domain(points,vertices,boundary) # Create Domain 38 domain.set_flow_algorithm(' tsunami')39 38 domain.set_flow_algorithm('DE0') 39 40 40 domain.set_name('runup_sinusoid_v2') # Output to file runup.sww 41 41 domain.set_datadir('.') # Use current folder … … 91 91 92 92 93 print vv.max() 93 94 94 95 assert num.all(vv<1.0e-02) -
trunk/anuga_core/source/anuga_parallel/distribute_mesh.py
r9126 r9174 645 645 646 646 647 #print ghosttri648 649 # FIXME SR: For larger layers need to pass through the correct650 # boundary tag!651 652 # for t in ghosttri:653 # ghost_list.append(t[0])654 #655 #656 #657 # for t in ghosttri:658 #659 # n = mesh.neighbours[t[0], 0]660 # if not is_in_processor(ghost_list, tlower, tupper, n):661 # if boundary.has_key( (t[0], 0) ):662 # subboundary[t[0], 0] = boundary[t[0],0]663 # else:664 # subboundary[t[0], 0] = 'ghost'665 #666 #667 # n = mesh.neighbours[t[0], 1]668 # if not is_in_processor(ghost_list, tlower, tupper, n):669 # if boundary.has_key( (t[0], 1) ):670 # subboundary[t[0], 1] = boundary[t[0],1]671 # else:672 # subboundary[t[0], 1] = 'ghost'673 #674 #675 # n = mesh.neighbours[t[0], 2]676 # if not is_in_processor(ghost_list, tlower, tupper, n):677 # if boundary.has_key( (t[0], 2) ):678 # subboundary[t[0], 2] = boundary[t[0],2]679 # else:680 # subboundary[t[0], 2] = 'ghost'681 #682 683 684 685 647 new_ghost_list = ghosttri[:,0] 686 648 … … 707 669 values1 = ['ghost']*n1 708 670 709 # 1edge boundary671 # 2 edge boundary 710 672 nghb2 = mesh.neighbours[new_ghost_list,2] 711 673 gl2 = num.extract(num.logical_or(nghb2 < tlower, nghb2 >= tupper), new_ghost_list) … … 1278 1240 1279 1241 1242 1243 tri_l2g = extract_l2g_map(tri_map) 1244 node_l2g = extract_l2g_map(node_map) 1245 1280 1246 return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, \ 1281 full_send, tri_map, node_map, ghost_layer_width1247 full_send, tri_map, node_map, tri_l2g, node_l2g, ghost_layer_width 1282 1248 1283 1249 … … 1615 1581 1616 1582 [GAnodes, GAtriangles, boundary, quantities, \ 1617 ghost_rec, full_send, tri_map, node_map, ghost_layer_width] = \ 1618 build_local_mesh(submesh_cell, lower_t, upper_t, \ 1619 numproc) 1583 ghost_rec, full_send, \ 1584 tri_map, node_map, tri_l2g, node_l2g, \ 1585 ghost_layer_width] = \ 1586 build_local_mesh(submesh_cell, lower_t, upper_t, numproc) 1620 1587 1621 1588 return GAnodes, GAtriangles, boundary, quantities,\ 1622 1589 ghost_rec, full_send,\ 1623 1590 number_of_full_nodes, number_of_full_triangles, tri_map, node_map,\ 1624 ghost_layer_width 1625 1626 1627 1628 1629 1630 1631 1632 1633 1591 tri_l2g, node_l2g, ghost_layer_width 1634 1592 1635 1593 … … 1651 1609 # 1652 1610 ######################################################### 1653 def extract_submesh(submesh, triangles_per_proc, p =0):1611 def extract_submesh(submesh, triangles_per_proc, p2s_map=None, p=0): 1654 1612 1655 1613 … … 1679 1637 numprocs = len(triangles_per_proc) 1680 1638 points, vertices, boundary, quantities, ghost_recv_dict, \ 1681 full_send_dict, tri_map, node_map, ghost_layer_width = \ 1639 full_send_dict, tri_map, node_map, tri_l2g, node_l2g, \ 1640 ghost_layer_width = \ 1682 1641 build_local_mesh(submesh_cell, lower_t, upper_t, numprocs) 1683 1642 1643 if p2s_map is None: 1644 pass 1645 else: 1646 tri_l2g = p2s_map[tri_l2g] 1684 1647 1685 1648 return points, vertices, boundary, quantities, ghost_recv_dict, \ 1686 full_send_dict, tri_map, node_map, ghost_layer_width1649 full_send_dict, tri_map, node_map, tri_l2g, node_l2g, ghost_layer_width 1687 1650 1688 1651 1689 1652 1690 1691 1653 def extract_l2g_map(map): 1654 # Extract l2g data from corresponding map 1655 # Maps 1656 1657 import numpy as num 1658 1659 b = num.arange(len(map)) 1660 1661 l_ids = num.extract(map>-1,map) 1662 g_ids = num.extract(map>-1,b) 1663 1664 1665 # print len(g_ids) 1666 # print len(l_ids) 1667 # print l_ids 1668 # print g_ids 1669 1670 l2g = num.zeros_like(g_ids) 1671 l2g[l_ids] = g_ids 1672 1673 return l2g 1674 1675 1676 1677 1678 -
trunk/anuga_core/source/anuga_parallel/parallel_api.py
r9126 r9174 37 37 38 38 39 40 39 def distribute(domain, verbose=False, debug=False, parameters = None): 40 """ Distribute the domain to all processes 41 42 parameters allows user to change size of ghost layer 43 """ 44 45 if not pypar_available or numprocs == 1 : return domain # Bypass 46 47 48 if myid == 0: 49 from sequential_distribute import Sequential_distribute 50 partition = Sequential_distribute(domain, verbose, debug, parameters) 51 52 partition.distribute(numprocs) 53 54 kwargs, points, vertices, boundary, quantities, boundary_map, \ 55 domain_name, domain_dir, domain_store, domain_store_centroids, \ 56 domain_minimum_storable_height, domain_minimum_allowed_height, \ 57 domain_flow_algorithm, georef = partition.extract_submesh(0) 58 59 for p in range(1, numprocs): 60 61 tostore = partition.extract_submesh(p) 62 63 send(tostore,p) 64 65 else: 66 67 kwargs, points, vertices, boundary, quantities, boundary_map, \ 68 domain_name, domain_dir, domain_store, domain_store_centroids, \ 69 domain_minimum_storable_height, domain_minimum_allowed_height, \ 70 domain_flow_algorithm, georef = receive(0) 71 72 #--------------------------------------------------------------------------- 73 # Now Create parallel domain 74 #--------------------------------------------------------------------------- 75 parallel_domain = Parallel_domain(points, vertices, boundary, **kwargs) 76 77 78 #------------------------------------------------------------------------ 79 # Copy in quantity data 80 #------------------------------------------------------------------------ 81 for q in quantities: 82 parallel_domain.set_quantity(q, quantities[q]) 83 84 85 #------------------------------------------------------------------------ 86 # Transfer boundary conditions to each subdomain 87 #------------------------------------------------------------------------ 88 boundary_map['ghost'] = None # Add binding to ghost boundary 89 parallel_domain.set_boundary(boundary_map) 90 91 92 #------------------------------------------------------------------------ 93 # Transfer other attributes to each subdomain 94 #------------------------------------------------------------------------ 95 parallel_domain.set_name(domain_name) 96 parallel_domain.set_datadir(domain_dir) 97 parallel_domain.set_store(domain_store) 98 parallel_domain.set_store_centroids(domain_store_centroids) 99 parallel_domain.set_minimum_storable_height(domain_minimum_storable_height) 100 parallel_domain.set_minimum_allowed_height(domain_minimum_allowed_height) 101 parallel_domain.set_flow_algorithm(domain_flow_algorithm) 102 parallel_domain.geo_reference = georef 103 104 105 return parallel_domain 106 107 108 109 110 111 112 113 def old_distribute(domain, verbose=False, debug=False, parameters = None): 41 114 """ Distribute the domain to all processes 42 115 … … 125 198 ghost_recv_dict, full_send_dict,\ 126 199 number_of_full_nodes, number_of_full_triangles,\ 127 s2p_map, p2s_map, tri_map, node_map, ghost_layer_width =\ 200 s2p_map, p2s_map, tri_map, node_map, tri_l2g, node_l2g, \ 201 ghost_layer_width =\ 128 202 distribute_mesh(domain, verbose=verbose, debug=debug, parameters=parameters) 129 203 130 204 # Extract l2g maps 131 tri_l2g = extract_l2g_map(tri_map) 132 node_l2g = extract_l2g_map(node_map) 133 205 #tri_l2g = extract_l2g_map(tri_map) 206 #node_l2g = extract_l2g_map(node_map) 207 #tri_l2g = p2s_map[tri_l2g] 208 134 209 if debug: 135 210 print 'P%d' %myid … … 183 258 ghost_recv_dict, full_send_dict,\ 184 259 number_of_full_nodes, number_of_full_triangles, \ 185 tri_map, node_map, ghost_layer_width =\260 tri_map, node_map, tri_l2g, node_l2g, ghost_layer_width =\ 186 261 rec_submesh(0, verbose) 187 262 … … 189 264 190 265 # Extract l2g maps 191 tri_l2g = extract_l2g_map(tri_map) 192 node_l2g = extract_l2g_map(node_map) 193 194 # Recieve serial to parallel (s2p) and parallel to serial (p2s) triangle mapping 266 #tri_l2g = extract_l2g_map(tri_map) 267 #node_l2g = extract_l2g_map(node_map) 268 #tri_l2g = p2s_map[tri_l2g] 269 270 # Receive serial to parallel (s2p) and parallel to serial (p2s) triangle mapping 195 271 if send_s2p : 196 272 s2p_map_flat = receive(0) … … 264 340 265 341 def distribute_mesh(domain, verbose=False, debug=False, parameters=None): 266 342 """ Distribute andsend the mesh info to all the processors. 343 Should only be run from processor 0 and will send info to the other 344 processors. 345 There should be a corresponding rec_submesh called from all the other 346 processors 347 """ 267 348 268 349 if debug: … … 303 384 if verbose: print 'Distribute submeshes' 304 385 for p in range(1, numprocs): 305 send_submesh(submesh, triangles_per_proc, p , verbose)386 send_submesh(submesh, triangles_per_proc, p2s_map, p, verbose) 306 387 307 388 # Build the local mesh for processor 0 308 389 points, vertices, boundary, quantities, \ 309 ghost_recv_dict, full_send_dict, tri_map, node_map, ghost_layer_width =\ 310 extract_submesh(submesh, triangles_per_proc,0) 311 390 ghost_recv_dict, full_send_dict, \ 391 tri_map, node_map, tri_l2g, node_l2g, ghost_layer_width =\ 392 extract_submesh(submesh, triangles_per_proc, p2s_map, 0) 393 394 395 312 396 # Keep track of the number full nodes and triangles. 313 397 # This is useful later if one needs access to a ghost-free domain … … 344 428 ghost_recv_dict, full_send_dict,\ 345 429 number_of_full_nodes, number_of_full_triangles, \ 346 s2p_map, p2s_map, tri_map, node_map, ghost_layer_width 347 348 349 350 def extract_l2g_map(map): 351 # Extract l2g data from corresponding map 352 # Maps 353 354 import numpy as num 355 356 # FIXME: this is where we loss the original order of 357 # sequential domain 358 b = num.arange(len(map)) 359 360 l_ids = num.extract(map>-1,map) 361 g_ids = num.extract(map>-1,b) 362 363 # print len(g_ids) 364 # print len(l_ids) 365 # print l_ids 366 367 l2g = num.zeros_like(g_ids) 368 l2g[l_ids] = g_ids 369 370 return l2g 371 430 s2p_map, p2s_map, tri_map, node_map, tri_l2g, node_l2g, \ 431 ghost_layer_width 432 433 434 435 ## def extract_l2g_map(map): 436 ## # Extract l2g data from corresponding map 437 ## # Maps 438 439 ## import numpy as num 440 441 ## # FIXME: this is where we loss the original order of 442 ## # sequential domain 443 ## b = num.arange(len(map)) 444 445 ## l_ids = num.extract(map>-1,map) 446 ## g_ids = num.extract(map>-1,b) 447 448 ## # print len(g_ids) 449 ## # print len(l_ids) 450 ## # print l_ids 451 452 ## l2g = num.zeros_like(g_ids) 453 ## l2g[l_ids] = g_ids 454 455 ## return l2g 456 -
trunk/anuga_core/source/anuga_parallel/sequential_distribute.py
r8680 r9174 18 18 19 19 20 def sequential_distribute_dump(domain, numprocs=1, verbose=False, debug=False, parameters = None): 21 """ Distribute the domain, create parallel domain and pickle result 22 """ 23 24 25 if debug: 26 verbose = True 27 28 29 30 # FIXME: Dummy assignment (until boundaries are refactored to 31 # be independent of domains until they are applied) 32 bdmap = {} 33 for tag in domain.get_boundary_tags(): 34 bdmap[tag] = None 35 36 domain.set_boundary(bdmap) 37 38 39 domain_name = domain.get_name() 40 domain_dir = domain.get_datadir() 41 domain_store = domain.get_store() 42 domain_minimum_storable_height = domain.minimum_storable_height 43 domain_flow_algorithm = domain.get_flow_algorithm() 44 domain_minimum_allowed_height = domain.get_minimum_allowed_height() 45 georef = domain.geo_reference 46 number_of_global_triangles = domain.number_of_triangles 47 number_of_global_nodes = domain.number_of_nodes 48 boundary_map = domain.boundary_map 49 50 51 #sequential_distribute_mesh(domain, numprocs, verbose=verbose, debug=debug, parameters=parameters) 52 53 54 # Subdivide the mesh 55 if verbose: print 'sequential_distribute: Subdivide mesh' 56 new_nodes, new_triangles, new_boundary, triangles_per_proc, quantities, \ 57 s2p_map, p2s_map = \ 58 pmesh_divide_metis_with_map(domain, numprocs) 59 60 #PETE: s2p_map (maps serial domain triangles to parallel domain triangles) 61 # sp2_map (maps parallel domain triangles to domain triangles) 62 63 64 65 # Build the mesh that should be assigned to each processor, 66 # this includes ghost nodes and the communication pattern 67 if verbose: print 'sequential_distribute: Build submeshes' 68 submesh = build_submesh(new_nodes, new_triangles, new_boundary, quantities, triangles_per_proc, parameters) 69 70 if debug: 71 for p in range(numprocs): 72 N = len(submesh['ghost_nodes'][p]) 73 M = len(submesh['ghost_triangles'][p]) 74 print 'There are %d ghost nodes and %d ghost triangles on proc %d'\ 75 %(N, M, p) 76 77 #if debug: 78 # from pprint import pprint 79 # pprint(submesh) 80 81 82 # extract data to create parallel domain 83 if verbose: print 'sequential_distribute: Distribute submeshes' 84 for p in range(0, numprocs): 85 86 # Build the local mesh for processor 0 20 class Sequential_distribute(object): 21 22 def __init__(self, domain, verbose=False, debug=False, parameters=None): 23 24 if debug: 25 verbose = True 26 27 self.domain = domain 28 self.verbose = verbose 29 self.debug = debug 30 self.parameters = parameters 31 32 33 def distribute(self, numprocs=1): 34 35 self.numprocs = numprocs 36 37 domain = self.domain 38 verbose = self.verbose 39 debug = self.debug 40 parameters = self.parameters 41 42 # FIXME: Dummy assignment (until boundaries are refactored to 43 # be independent of domains until they are applied) 44 bdmap = {} 45 for tag in domain.get_boundary_tags(): 46 bdmap[tag] = None 47 48 domain.set_boundary(bdmap) 49 50 51 self.domain_name = domain.get_name() 52 self.domain_dir = domain.get_datadir() 53 self.domain_store = domain.get_store() 54 self.domain_store_centroids = domain.get_store_centroids() 55 self.domain_minimum_storable_height = domain.minimum_storable_height 56 self.domain_flow_algorithm = domain.get_flow_algorithm() 57 self.domain_minimum_allowed_height = domain.get_minimum_allowed_height() 58 self.domain_georef = domain.geo_reference 59 self.number_of_global_triangles = domain.number_of_triangles 60 self.number_of_global_nodes = domain.number_of_nodes 61 self.boundary_map = domain.boundary_map 62 63 64 # Subdivide the mesh 65 if verbose: print 'sequential_distribute: Subdivide mesh' 66 67 new_nodes, new_triangles, new_boundary, triangles_per_proc, quantities, \ 68 s2p_map, p2s_map = \ 69 pmesh_divide_metis_with_map(domain, numprocs) 70 71 72 # Build the mesh that should be assigned to each processor, 73 # this includes ghost nodes and the communication pattern 74 if verbose: print 'sequential_distribute: Build submeshes' 75 if verbose: print parameters 76 77 submesh = build_submesh(new_nodes, new_triangles, new_boundary, \ 78 quantities, triangles_per_proc, parameters=parameters) 79 80 if verbose: 81 for p in range(numprocs): 82 N = len(submesh['ghost_nodes'][p]) 83 M = len(submesh['ghost_triangles'][p]) 84 print 'There are %d ghost nodes and %d ghost triangles on proc %d'\ 85 %(N, M, p) 86 87 88 self.submesh = submesh 89 self.triangles_per_proc = triangles_per_proc 90 self.p2s_map = p2s_map 91 92 93 def extract_submesh(self, p=0): 94 """Build the local mesh for processor p 95 """ 96 97 submesh = self.submesh 98 triangles_per_proc = self.triangles_per_proc 99 p2s_map = self.p2s_map 100 verbose = self.verbose 101 debug = self.debug 102 103 assert p>=0 104 assert p<self.numprocs 105 106 87 107 points, vertices, boundary, quantities, \ 88 ghost_recv_dict, full_send_dict, tri_map, node_map, ghost_layer_width =\ 89 extract_submesh(submesh, triangles_per_proc, p) 90 91 92 # from pprint import pprint 93 # print '='*80 94 # print p 95 # print '='*80 96 # pprint(tri_map) 97 # print len(tri_map) 98 99 # Keep track of the number full nodes and triangles. 100 # This is useful later if one needs access to a ghost-free domain 101 # Here, we do it for process 0. The others are done in rec_submesh. 108 ghost_recv_dict, full_send_dict, \ 109 tri_map, node_map, tri_l2g, node_l2g, ghost_layer_width =\ 110 extract_submesh(submesh, triangles_per_proc, p2s_map, p) 111 112 102 113 number_of_full_nodes = len(submesh['full_nodes'][p]) 103 114 number_of_full_triangles = len(submesh['full_triangles'][p]) 104 115 105 # Extract l2g maps 106 tri_l2g = extract_l2g_map(tri_map) 107 node_l2g = extract_l2g_map(node_map) 108 109 116 117 if debug: 118 import pprint 119 print 50*"=" 120 print 'NODE_L2G' 121 pprint.pprint(node_l2g) 122 123 pprint.pprint(node_l2g[vertices[:,0]]) 124 125 print 'VERTICES' 126 pprint.pprint(vertices[:,0]) 127 pprint.pprint(new_triangles[tri_l2g,0]) 128 129 assert num.allclose(node_l2g[vertices[:,0]], new_triangles[tri_l2g,0]) 130 assert num.allclose(node_l2g[vertices[:,1]], new_triangles[tri_l2g,1]) 131 assert num.allclose(node_l2g[vertices[:,2]], new_triangles[tri_l2g,2]) 132 133 134 print 'POINTS' 135 pprint.pprint(points) 136 137 assert num.allclose(points[:,0], new_nodes[node_l2g,0]) 138 assert num.allclose(points[:,1], new_nodes[node_l2g,1]) 139 140 141 print 'TRI' 142 pprint.pprint(tri_l2g) 143 pprint.pprint(p2s_map[tri_l2g]) 144 145 146 assert num.allclose(original_triangles[tri_l2orig,0],node_l2g[vertices[:,0]]) 147 assert num.allclose(original_triangles[tri_l2orig,1],node_l2g[vertices[:,1]]) 148 assert num.allclose(original_triangles[tri_l2orig,2],node_l2g[vertices[:,2]]) 149 150 print 'NODES' 151 pprint.pprint(node_map) 152 pprint.pprint(node_l2g) 153 154 #tri_l2orig = p2s_map[tri_l2g] 155 110 156 s2p_map = None 111 157 p2s_map = None … … 118 164 print 'sequential_distribute: P%g, no_full_nodes = %g, no_full_triangles = %g' % (p, number_of_full_nodes, number_of_full_triangles) 119 165 120 121 #args = [points, vertices, boundary]122 166 123 167 kwargs = {'full_send_dict': full_send_dict, … … 125 169 'number_of_full_nodes': number_of_full_nodes, 126 170 'number_of_full_triangles': number_of_full_triangles, 127 'geo_reference': georef,128 'number_of_global_triangles': number_of_global_triangles,129 'number_of_global_nodes': number_of_global_nodes,171 'geo_reference': self.domain_georef, 172 'number_of_global_triangles': self.number_of_global_triangles, 173 'number_of_global_nodes': self.number_of_global_nodes, 130 174 'processor': p, 131 'numproc': numprocs,175 'numproc': self.numprocs, 132 176 's2p_map': s2p_map, 133 177 'p2s_map': p2s_map, ## jj added this … … 136 180 'ghost_layer_width': ghost_layer_width} 137 181 138 #----------------------------------------------------------------------- 139 # Now let's store the data for a parallel_domain via cPickle 140 #----------------------------------------------------------------------- 141 142 #Looks like we reduce storage by a factor of 4 by just 143 # storing the data to create the parallel_domain instead of pickling 144 # a created domain 182 183 boundary_map = self.boundary_map 184 domain_name = self.domain_name 185 domain_dir = self.domain_dir 186 domain_store = self.domain_store 187 domain_store_centroids = self.domain_store_centroids 188 domain_minimum_storable_height = self.domain_minimum_storable_height 189 domain_minimum_allowed_height = self.domain_minimum_allowed_height 190 domain_flow_algorithm = self.domain_flow_algorithm 191 domain_georef = self.domain_georef 192 193 tostore = (kwargs, points, vertices, boundary, quantities, \ 194 boundary_map, \ 195 domain_name, domain_dir, domain_store, domain_store_centroids, \ 196 domain_minimum_storable_height, \ 197 domain_minimum_allowed_height, domain_flow_algorithm, \ 198 domain_georef) 199 200 201 return tostore 202 203 204 205 206 207 208 def sequential_distribute_dump(domain, numprocs=1, verbose=False, debug=False, parameters = None): 209 """ Distribute the domain, create parallel domain and pickle result 210 """ 211 212 213 partition = Sequential_distribute(domain, verbose, debug, parameters) 214 215 partition.distribute(numprocs) 216 217 218 for p in range(0, numprocs): 219 220 tostore = partition.extract_submesh(p) 221 145 222 import cPickle 146 pickle_name = domain_name + '_P%g_%g.pickle'% (numprocs,p)223 pickle_name = partition.domain_name + '_P%g_%g.pickle'% (numprocs,p) 147 224 f = file(pickle_name, 'wb') 148 tostore = (kwargs, points, vertices, boundary, quantities, boundary_map, domain_name, domain_dir, domain_store, domain_minimum_storable_height, \149 domain_minimum_allowed_height, domain_flow_algorithm, georef)150 225 cPickle.dump( tostore, f, protocol=cPickle.HIGHEST_PROTOCOL) 151 226 … … 165 240 pickle_name = filename+'_P%g_%g.pickle'% (numprocs,myid) 166 241 f = file(pickle_name, 'rb') 167 kwargs, points, vertices, boundary, quantities, boundary_map, domain_name, domain_dir, domain_store, domain_minimum_storable_height, \ 168 domain_minimum_allowed_height, domain_flow_algorithm, georef = cPickle.load(f) 242 243 kwargs, points, vertices, boundary, quantities, boundary_map, \ 244 domain_name, domain_dir, domain_store, domain_store_centroids, \ 245 domain_minimum_storable_height, domain_minimum_allowed_height, \ 246 domain_flow_algorithm, georef = cPickle.load(f) 169 247 f.close() 170 248 … … 194 272 parallel_domain.set_name(domain_name) 195 273 parallel_domain.set_datadir(domain_dir) 274 parallel_domain.set_flow_algorithm(domain_flow_algorithm) 196 275 parallel_domain.set_store(domain_store) 276 parallel_domain.set_store_centroids(domain_store_centroids) 197 277 parallel_domain.set_minimum_storable_height(domain_minimum_storable_height) 198 278 parallel_domain.set_minimum_allowed_height(domain_minimum_allowed_height) 199 parallel_domain.set_flow_algorithm(domain_flow_algorithm)200 279 parallel_domain.geo_reference = georef 201 280 … … 203 282 return parallel_domain 204 283 205 def extract_l2g_map(map): 206 # Extract l2g data from corresponding map 207 # Maps 208 209 import numpy as num 210 211 b = num.arange(len(map)) 212 213 l_ids = num.extract(map>-1,map) 214 g_ids = num.extract(map>-1,b) 215 216 217 # print len(g_ids) 218 # print len(l_ids) 219 # print l_ids 220 # print g_ids 221 222 l2g = num.zeros_like(g_ids) 223 l2g[l_ids] = g_ids 224 225 return l2g 226 227 228 229 230 284 285 286 287 288 289 -
trunk/anuga_core/source/anuga_parallel/test_distribute_mesh.py
r8608 r9174 1502 1502 # Now test the extract_submesh for the 3 processors 1503 1503 1504 submesh_cell_0 = extract_submesh(submesh,triangles_per_proc, 0)1505 submesh_cell_1 = extract_submesh(submesh,triangles_per_proc, 1)1506 submesh_cell_2 = extract_submesh(submesh,triangles_per_proc, 2)1504 submesh_cell_0 = extract_submesh(submesh,triangles_per_proc,p=0) 1505 submesh_cell_1 = extract_submesh(submesh,triangles_per_proc,p=1) 1506 submesh_cell_2 = extract_submesh(submesh,triangles_per_proc,p=2) 1507 1507 1508 1508 -
trunk/anuga_core/source/anuga_parallel/test_parallel_distribute_mesh.py
r8605 r9174 196 196 #---------------------------------------------------------------------------------- 197 197 points, vertices, boundary, quantities, \ 198 ghost_recv_dict, full_send_dict, tri_map, node_map, ghost_layer_width =\ 198 ghost_recv_dict, full_send_dict, tri_map, node_map, tri_l2g, node_l2g, \ 199 ghost_layer_width =\ 199 200 extract_submesh(submesh, triangles_per_proc) 200 201 … … 226 227 points, vertices, boundary, quantities, \ 227 228 ghost_recv_dict, full_send_dict, \ 228 no_full_nodes, no_full_trigs, tri_map, node_map, ghost_layer_width = \ 229 no_full_nodes, no_full_trigs, tri_map, node_map, tri_l2g, node_l2g, \ 230 ghost_layer_width = \ 229 231 rec_submesh(0, verbose=False) 230 232 -
trunk/anuga_core/source/anuga_parallel/test_parallel_frac_op.py
r9122 r9174 38 38 from anuga.geometry.polygon import inside_polygon, is_inside_polygon, line_intersect 39 39 40 from parallel_operator_factory import Inlet_operator, Boyd_box_operator 40 #from parallel_operator_factory import Inlet_operator, Boyd_box_operator 41 from anuga import Inlet_operator, Boyd_box_operator 41 42 42 43 import random … … 48 49 This test exercises the parallel culvert and checks values 49 50 """ 51 50 52 verbose = False 51 53 nprocs = 3 … … 72 74 for i in range(N): 73 75 74 # Sloping Embankment Across Channel76 # Sloping Embankment Across Channel 75 77 if 5.0 < x[i] < 10.1: 76 78 # Cut Out Segment for Culvert face 77 79 if 1.0+(x[i]-5.0)/5.0 < y[i] < 4.0 - (x[i]-5.0)/5.0: 78 z[i]=z[i]80 z[i]=z[i] 79 81 else: 80 z[i] += 0.5*(x[i] -5.0) # Sloping Segment U/S Face82 z[i] += 0.5*(x[i] -5.0) # Sloping Segment U/S Face 81 83 if 10.0 < x[i] < 12.1: 82 z[i] += 2.5 # Flat Crest of Embankment84 z[i] += 2.5 # Flat Crest of Embankment 83 85 if 12.0 < x[i] < 14.5: 84 86 # Cut Out Segment for Culvert face 85 87 if 2.0-(x[i]-12.0)/2.5 < y[i] < 3.0 + (x[i]-12.0)/2.5: 86 z[i]=z[i]88 z[i]=z[i] 87 89 else: 88 z[i] += 2.5-1.0*(x[i] -12.0) # Sloping D/S Face90 z[i] += 2.5-1.0*(x[i] -12.0) # Sloping D/S Face 89 91 90 91 92 return z 92 93 … … 191 192 if boyd_box0 is not None and verbose: boyd_box0.print_statistics() 192 193 193 # if parallel:194 # factory = Parallel_operator_factory(domain, verbose = True)195 #196 # inlet0 = factory.inlet_operator_factory(line0, Q0)197 # inlet1 = factory.inlet_operator_factory(line1, Q1)198 #199 # boyd_box0 = factory.boyd_box_operator_factory(end_points=[[9.0, 2.5],[19.0, 2.5]],200 # losses=1.5,201 # width=1.5,202 # apron=5.0,203 # use_momentum_jet=True,204 # use_velocity_head=False,205 # manning=0.013,206 # verbose=False)207 #208 # else:209 # inlet0 = Inlet_operator(domain, line0, Q0)210 # inlet1 = Inlet_operator(domain, line1, Q1)211 #212 # # Enquiry point [ 19. 2.5] is contained in two domains in 4 proc case213 # boyd_box0 = Boyd_box_operator(domain,214 # end_points=[[9.0, 2.5],[19.0, 2.5]],215 # losses=1.5,216 # width=1.5,217 # apron=5.0,218 # use_momentum_jet=True,219 # use_velocity_head=False,220 # manning=0.013,221 # verbose=False)222 223 #######################################################################224 194 225 195 ##----------------------------------------------------------------------- … … 276 246 if verbose: 277 247 print 'P%d tri %d, control = %s, actual = %s, Success = %s' %(myid, i, control_data[i], stage.centroid_values[tri_ids[i]], local_success) 248 assert local_success, 'Ouput P%d tri %d, control = %s, actual = %s, Success = %s' %(myid, i, control_data[i], stage.centroid_values[tri_ids[i]], local_success) 249 250 278 251 279 252 … … 299 272 300 273 301 assert(success)274 #assert(success) 302 275 303 276 return control_data … … 322 295 323 296 if __name__=="__main__": 297 324 298 if numprocs == 1: 325 299 runner = unittest.TextTestRunner() -
trunk/anuga_core/source/anuga_parallel/test_parallel_inlet_operator.py
r9108 r9174 72 72 for i in range(N): 73 73 74 # Sloping Embankment Across Channel74 # Sloping Embankment Across Channel 75 75 if 5.0 < x[i] < 10.1: 76 76 # Cut Out Segment for Culvert face 77 77 if 1.0+(x[i]-5.0)/5.0 < y[i] < 4.0 - (x[i]-5.0)/5.0: 78 z[i]=z[i]78 z[i]=z[i] 79 79 else: 80 z[i] += 0.5*(x[i] -5.0) # Sloping Segment U/S Face80 z[i] += 0.5*(x[i] -5.0) # Sloping Segment U/S Face 81 81 if 10.0 < x[i] < 12.1: 82 z[i] += 2.5 # Flat Crest of Embankment82 z[i] += 2.5 # Flat Crest of Embankment 83 83 if 12.0 < x[i] < 14.5: 84 84 # Cut Out Segment for Culvert face 85 85 if 2.0-(x[i]-12.0)/2.5 < y[i] < 3.0 + (x[i]-12.0)/2.5: 86 z[i]=z[i]86 z[i]=z[i] 87 87 else: 88 z[i] += 2.5-1.0*(x[i] -12.0) # Sloping D/S Face88 z[i] += 2.5-1.0*(x[i] -12.0) # Sloping D/S Face 89 89 90 90 … … 104 104 success = True 105 105 106 ##-----------------------------------------------------------------------107 ## Setup domain108 ##-----------------------------------------------------------------------106 ##----------------------------------------------------------------------- 107 ## Setup domain 108 ##----------------------------------------------------------------------- 109 109 110 110 points, vertices, boundary = rectangular_cross(int(length/dx), … … 117 117 domain.set_default_order(2) 118 118 119 ##-----------------------------------------------------------------------120 ## Distribute domain121 ##-----------------------------------------------------------------------119 ##----------------------------------------------------------------------- 120 ## Distribute domain 121 ##----------------------------------------------------------------------- 122 122 123 123 if parallel: … … 126 126 127 127 128 ##-----------------------------------------------------------------------129 ## Setup boundary conditions130 ##-----------------------------------------------------------------------128 ##----------------------------------------------------------------------- 129 ## Setup boundary conditions 130 ##----------------------------------------------------------------------- 131 131 132 132 domain.set_quantity('elevation', topography) … … 141 141 142 142 143 ##-----------------------------------------------------------------------144 ## Determine triangle index coinciding with test points145 ##-----------------------------------------------------------------------143 ##----------------------------------------------------------------------- 144 ## Determine triangle index coinciding with test points 145 ##----------------------------------------------------------------------- 146 146 147 147 assert(test_points is not None) … … 173 173 inlet1 = Inlet_operator(domain, line1, Q1, verbose = False) 174 174 175 # Enquiry point [ 19. 2.5] is contained in two domains in 4 proc case176 177 ## boyd_box0 = Boyd_box_operator(domain,178 ## end_points=[[9.0, 2.5],[19.0, 2.5]],179 ## losses=1.5,180 ## width=5.0,181 ## apron=5.0,182 ## use_momentum_jet=True,183 ## use_velocity_head=False,184 ## manning=0.013,185 ## verbose=False)186 175 187 176 if inlet0 is not None and verbose: inlet0.print_statistics() … … 189 178 #if boyd_box0 is not None and verbose: boyd_box0.print_statistics() 190 179 191 # if parallel:192 # factory = Parallel_operator_factory(domain, verbose = True)193 #194 # inlet0 = factory.inlet_operator_factory(line0, Q0)195 # inlet1 = factory.inlet_operator_factory(line1, Q1)196 #197 # boyd_box0 = factory.boyd_box_operator_factory(end_points=[[9.0, 2.5],[19.0, 2.5]],198 # losses=1.5,199 # width=1.5,200 # apron=5.0,201 # use_momentum_jet=True,202 # use_velocity_head=False,203 # manning=0.013,204 # verbose=False)205 #206 # else:207 # inlet0 = Inlet_operator(domain, line0, Q0)208 # inlet1 = Inlet_operator(domain, line1, Q1)209 #210 # # Enquiry point [ 19. 2.5] is contained in two domains in 4 proc case211 # boyd_box0 = Boyd_box_operator(domain,212 # end_points=[[9.0, 2.5],[19.0, 2.5]],213 # losses=1.5,214 # width=1.5,215 # apron=5.0,216 # use_momentum_jet=True,217 # use_velocity_head=False,218 # manning=0.013,219 # verbose=False)220 221 #######################################################################222 180 223 181 ##----------------------------------------------------------------------- … … 246 204 success = True 247 205 248 ##-----------------------------------------------------------------------249 ## Assign/Test Control data250 ##-----------------------------------------------------------------------206 ##----------------------------------------------------------------------- 207 ## Assign/Test Control data 208 ##----------------------------------------------------------------------- 251 209 252 210 if not parallel: -
trunk/anuga_core/source/anuga_parallel/test_sequential_dist_sw_flow.py
r9127 r9174 33 33 from anuga_parallel.sequential_distribute import sequential_distribute_dump 34 34 from anuga_parallel.sequential_distribute import sequential_distribute_load 35 36 import anuga.utilities.plot_utils as util 35 37 36 38 … … 45 47 verbose = False 46 48 49 50 new_parameters = {} 51 new_parameters['ghost_layer_width'] = 2 52 47 53 #--------------------------------- 48 54 # Setup Functions … … 61 67 if myid == 0: 62 68 domain = rectangular_cross_domain(M, N) 63 domain.set_name(' sequential_dist_runup') # Set sww filename69 domain.set_name('odomain') # Set sww filename 64 70 domain.set_datadir('.') 65 71 domain.set_quantity('elevation', topography) # Use function for elevation … … 74 80 if myid == 0: 75 81 if verbose: print 'DUMPING PARTITION DATA' 76 sequential_distribute_dump(domain, numprocs, verbose=verbose )82 sequential_distribute_dump(domain, numprocs, verbose=verbose, parameters=new_parameters) 77 83 78 84 #-------------------------------------------------------------------------- … … 82 88 83 89 if myid == 0 and verbose : print 'DISTRIBUTING TO PARALLEL DOMAIN' 84 pdomain = distribute(domain, verbose=verbose) 90 pdomain = distribute(domain, verbose=verbose, parameters=new_parameters) 91 pdomain.set_name('pdomain') 85 92 86 93 if myid == 0 and verbose : print 'LOADING IN PARALLEL DOMAIN' 87 sdomain = sequential_distribute_load(filename=' sequential_dist_runup', verbose = verbose)88 94 sdomain = sequential_distribute_load(filename='odomain', verbose = verbose) 95 sdomain.set_name('sdomain') 89 96 90 97 if myid == 0 and verbose: print 'EVOLVING pdomain' … … 94 101 setup_and_evolve(sdomain, verbose=verbose) 95 102 103 if myid == 0: 104 if verbose: print 'EVOLVING odomain' 105 setup_and_evolve(domain, verbose=verbose) 106 107 108 if myid == 0: 109 parameter_file=open('odomain.txt', 'w') 110 from pprint import pprint 111 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 112 parameter_file.close() 113 114 parameter_file=open('sdomain.txt', 'w') 115 from pprint import pprint 116 pprint(sdomain.get_algorithm_parameters(),parameter_file,indent=4) 117 parameter_file.close() 118 119 parameter_file=open('pdomain.txt', 'w') 120 from pprint import pprint 121 pprint(pdomain.get_algorithm_parameters(),parameter_file,indent=4) 122 parameter_file.close() 96 123 97 124 assert num.allclose(pdomain.quantities['stage'].centroid_values, sdomain.quantities['stage'].centroid_values) … … 103 130 104 131 105 106 107 108 132 #--------------------------------- 133 # Now compare the merged sww files 134 #--------------------------------- 135 if myid == 0: 136 if verbose: print 'COMPARING SWW FILES' 137 138 odomain_v = util.get_output('odomain.sww') 139 odomain_c = util.get_centroids(odomain_v) 140 141 pdomain_v = util.get_output('pdomain.sww') 142 pdomain_c = util.get_centroids(pdomain_v) 143 144 sdomain_v = util.get_output('sdomain.sww') 145 sdomain_c = util.get_centroids(sdomain_v) 146 147 # Test some values against the original ordering 148 149 if verbose: 150 151 order = 0 152 print 'PDOMAIN CENTROID VALUES' 153 print num.linalg.norm(odomain_c.x-pdomain_c.x,ord=order) 154 print num.linalg.norm(odomain_c.y-pdomain_c.y,ord=order) 155 print num.linalg.norm(odomain_c.stage[-1]-pdomain_c.stage[-1],ord=order) 156 print num.linalg.norm(odomain_c.xmom[-1]-pdomain_c.xmom[-1],ord=order) 157 print num.linalg.norm(odomain_c.ymom[-1]-pdomain_c.ymom[-1],ord=order) 158 print num.linalg.norm(odomain_c.xvel[-1]-pdomain_c.xvel[-1],ord=order) 159 print num.linalg.norm(odomain_c.yvel[-1]-pdomain_c.yvel[-1],ord=order) 160 161 162 print 'SDOMAIN CENTROID VALUES' 163 print num.linalg.norm(odomain_c.x-sdomain_c.x,ord=order) 164 print num.linalg.norm(odomain_c.y-sdomain_c.y,ord=order) 165 print num.linalg.norm(odomain_c.stage[-1]-sdomain_c.stage[-1],ord=order) 166 print num.linalg.norm(odomain_c.xmom[-1]-sdomain_c.xmom[-1],ord=order) 167 print num.linalg.norm(odomain_c.ymom[-1]-sdomain_c.ymom[-1],ord=order) 168 print num.linalg.norm(odomain_c.xvel[-1]-sdomain_c.xvel[-1],ord=order) 169 print num.linalg.norm(odomain_c.yvel[-1]-sdomain_c.yvel[-1],ord=order) 170 171 print 'PDOMAIN VERTEX VALUES' 172 print num.linalg.norm(odomain_v.stage[-1]-pdomain_v.stage[-1],ord=order) 173 print num.linalg.norm(odomain_v.xmom[-1]-pdomain_v.xmom[-1],ord=order) 174 print num.linalg.norm(odomain_v.ymom[-1]-pdomain_v.ymom[-1],ord=order) 175 print num.linalg.norm(odomain_v.xvel[-1]-pdomain_v.xvel[-1],ord=order) 176 print num.linalg.norm(odomain_v.yvel[-1]-pdomain_v.yvel[-1],ord=order) 177 178 print 'SDOMAIN VERTEX VALUES' 179 print num.linalg.norm(odomain_v.stage[-1]-sdomain_v.stage[-1],ord=order) 180 print num.linalg.norm(odomain_v.xmom[-1]-sdomain_v.xmom[-1],ord=order) 181 print num.linalg.norm(odomain_v.ymom[-1]-sdomain_v.ymom[-1],ord=order) 182 print num.linalg.norm(odomain_v.xvel[-1]-sdomain_v.xvel[-1],ord=order) 183 print num.linalg.norm(odomain_v.yvel[-1]-sdomain_v.yvel[-1],ord=order) 184 185 186 187 188 assert num.allclose(odomain_c.stage,pdomain_c.stage) 189 assert num.allclose(odomain_c.xmom,pdomain_c.xmom) 190 assert num.allclose(odomain_c.ymom,pdomain_c.ymom) 191 assert num.allclose(odomain_c.xvel,pdomain_c.xvel) 192 assert num.allclose(odomain_c.yvel,pdomain_c.yvel) 193 194 assert num.allclose(odomain_v.x,pdomain_v.x) 195 assert num.allclose(odomain_v.y,pdomain_v.y) 196 197 assert num.linalg.norm(odomain_v.x-pdomain_v.x,ord=0) == 0 198 assert num.linalg.norm(odomain_v.y-pdomain_v.y,ord=0) == 0 199 assert num.linalg.norm(odomain_v.stage[-1]-pdomain_v.stage[-1],ord=0) < 100 200 assert num.linalg.norm(odomain_v.xmom[-1]-pdomain_v.xmom[-1],ord=0) < 100 201 assert num.linalg.norm(odomain_v.ymom[-1]-pdomain_v.ymom[-1],ord=0) < 100 202 assert num.linalg.norm(odomain_v.xvel[-1]-pdomain_v.xvel[-1],ord=0) < 100 203 assert num.linalg.norm(odomain_v.yvel[-1]-pdomain_v.yvel[-1],ord=0) < 100 204 205 assert num.allclose(odomain_c.x,sdomain_c.x) 206 assert num.allclose(odomain_c.y,sdomain_c.y) 207 assert num.allclose(odomain_c.stage,sdomain_c.stage) 208 assert num.allclose(odomain_c.xmom,sdomain_c.xmom) 209 assert num.allclose(odomain_c.ymom,sdomain_c.ymom) 210 assert num.allclose(odomain_c.xvel,sdomain_c.xvel) 211 assert num.allclose(odomain_c.yvel,sdomain_c.yvel) 212 213 assert num.allclose(odomain_v.x,sdomain_v.x) 214 assert num.allclose(odomain_v.y,sdomain_v.y) 215 216 order = 0 217 assert num.linalg.norm(odomain_v.x-sdomain_v.x,ord=order) == 0 218 assert num.linalg.norm(odomain_v.y-sdomain_v.y,ord=order) == 0 219 assert num.linalg.norm(odomain_v.stage[-1]-sdomain_v.stage[-1],ord=order) < 100 220 assert num.linalg.norm(odomain_v.xmom[-1]-sdomain_v.xmom[-1],ord=order) < 100 221 assert num.linalg.norm(odomain_v.ymom[-1]-sdomain_v.ymom[-1],ord=order) < 100 222 assert num.linalg.norm(odomain_v.xvel[-1]-sdomain_v.xvel[-1],ord=order) < 100 223 assert num.linalg.norm(odomain_v.yvel[-1]-sdomain_v.yvel[-1],ord=order) < 100 224 225 # COMPARE CENTROID PDOMAIN SDOMAIN 226 assert num.allclose(pdomain_c.x,sdomain_c.x) 227 assert num.allclose(pdomain_c.y,sdomain_c.y) 228 assert num.allclose(pdomain_c.stage[-1],sdomain_c.stage[-1]) 229 assert num.allclose(pdomain_c.xmom[-1],sdomain_c.xmom[-1]) 230 assert num.allclose(pdomain_c.ymom[-1],sdomain_c.ymom[-1]) 231 assert num.allclose(pdomain_c.xvel[-1],sdomain_c.xvel[-1]) 232 assert num.allclose(pdomain_c.yvel[-1],sdomain_c.yvel[-1]) 233 234 235 # COMPARE VERTEX PDOMAIN SDOMAIN 236 assert num.allclose(pdomain_v.x,sdomain_v.x) 237 assert num.allclose(pdomain_v.y,sdomain_v.y) 238 assert num.allclose(pdomain_v.stage[-1],sdomain_v.stage[-1]) 239 assert num.allclose(pdomain_v.xmom[-1],sdomain_v.xmom[-1]) 240 assert num.allclose(pdomain_v.ymom[-1],sdomain_v.ymom[-1]) 241 assert num.allclose(pdomain_v.xvel[-1],sdomain_v.xvel[-1]) 242 assert num.allclose(pdomain_v.yvel[-1],sdomain_v.yvel[-1]) 243 244 245 246 109 247 def setup_and_evolve(domain, verbose=False): 110 248 … … 113 251 #-------------------------------------------------------------------------- 114 252 domain.set_flow_algorithm('DE0') 115 domain.set_quantities_to_be_stored(None)253 #domain.set_store_vertices_uniquely() 116 254 117 255 #------------------------------------------------------------------------------ … … 131 269 for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): 132 270 if myid == 0 and verbose : domain.write_time() 133 134 271 #if myid == 0 and verbose : print domain.quantities['stage'].get_maximum_value() 272 273 274 domain.sww_merge() 275 135 276 136 277 # Test an nprocs-way run of the shallow water equations -
trunk/anuga_core/validation_tests/analytical_exact/avalanche_dry/numerical_avalanche_dry.py
r9155 r9174 103 103 alg = args.alg 104 104 cfl = args.cfl 105 verbose = args.v 105 verbose = args.verbose 106 106 107 107 if myid == 0: -
trunk/anuga_core/validation_tests/analytical_exact/avalanche_dry/validate_avalanche_dry.py
r9155 r9174 11 11 12 12 args = anuga.get_args() 13 verbose = args.v 13 verbose = args.verbose 14 14 15 15 class Test_results(unittest.TestCase): -
trunk/anuga_core/validation_tests/analytical_exact/carrier_greenspan_transient/numerical_cg_transient.py
r9155 r9174 29 29 alg = args.alg 30 30 cfl = args.cfl 31 verbose = args.v 31 verbose = args.verbose 32 32 33 33 -
trunk/anuga_core/validation_tests/analytical_exact/dam_break_dry/numerical_dam_break_dry.py
r9155 r9174 52 52 alg = args.alg 53 53 cfl = args.cfl 54 verbose = args.v 54 verbose = args.verbose 55 55 56 56 print args -
trunk/anuga_core/validation_tests/analytical_exact/dam_break_dry/validate_dam_break_dry.py
r9155 r9174 13 13 indent = anuga.indent 14 14 15 verbose = args.v 15 verbose = args.verbose 16 16 17 17 class Test_results(unittest.TestCase): -
trunk/anuga_core/validation_tests/analytical_exact/dam_break_wet/validate_dam_break_wet.py
r9155 r9174 12 12 indent = anuga.indent 13 13 14 verbose = args.v 14 verbose = args.verbose 15 15 16 16 class Test_results(unittest.TestCase): -
trunk/anuga_core/validation_tests/analytical_exact/lake_at_rest_immersed_bump/numerical_immersed_bump.py
r9155 r9174 39 39 args = anuga.get_args() 40 40 alg = args.alg 41 verbose = args.v 41 verbose = args.verbose 42 42 43 43 if myid == 0: -
trunk/anuga_core/validation_tests/analytical_exact/lake_at_rest_steep_island/numerical_steep_island.py
r9155 r9174 29 29 args = anuga.get_args() 30 30 alg = args.alg 31 verbose = args.v 31 verbose = args.verbose 32 32 33 33 dx = 1. -
trunk/anuga_core/validation_tests/analytical_exact/landslide_tsunami/produce_results.py
r9117 r9174 2 2 # import modules 3 3 #-------------------------------- 4 from anuga.validation_utilities.fabricate import * 5 from anuga.validation_utilities import run_validation_script 6 from anuga.validation_utilities import typeset_report 4 import anuga 5 from anuga.validation_utilities import produce_report 7 6 7 args = anuga.get_args() 8 8 9 # Setup the python scripts which produce the output for this 10 # validation test 11 def build(): 12 run_validation_script('runup.py') 13 run_validation_script('plot_results.py') 14 typeset_report() 9 produce_report('runup.py', args=args) 15 10 16 def clean():17 autoclean()18 19 main() -
trunk/anuga_core/validation_tests/analytical_exact/landslide_tsunami/runup.py
r9155 r9174 5 5 #-------- 6 6 import anuga 7 from anuga import myid, finalize, distribute 7 8 8 9 import numpy … … 11 12 from math import sin, pi, exp 12 13 14 15 args = anuga.get_args() 16 alg = args.alg 17 verbose = args.verbose 18 13 19 #timer = strftime('%Y%m%d_%H%M%S',localtime()) 14 20 #--------- … … 16 22 # --- Very inefficient mesh! 17 23 #--------- 18 print ' Building mesh (alternative non-uniform mesh could be much more efficient)' 24 19 25 dx = dy = 25. 20 26 l1 = 60.*1000. … … 22 28 nx =int(l1/dx) 23 29 ny =int(l2/dy) 24 points, vertices, boundary = anuga.rectangular_cross(nx,ny, len1=l1,len2=l2, origin=(-200., 0.))25 30 26 print 'Creating Domain'27 domain=anuga.Domain(points,vertices,boundary) # Create Domain28 domain.set_name('runup_v2') # Output to file runup.sww29 domain.set_datadir('.') # Use current folder30 domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1})31 32 #------------------------------------------------------------------------------33 # Setup Algorithm, either using command line arguments34 # or override manually yourself35 #------------------------------------------------------------------------------36 from anuga.utilities.argparsing import parse_standard_args37 alg, cfl = parse_standard_args()38 domain.set_flow_algorithm(alg)39 #domain.set_CFL(cfl)40 41 #------------------42 # Define topography43 #------------------44 31 45 32 # Beach slope of 1/10 … … 47 34 return -(x-200.)/10. 48 35 49 # Define initial condition using file 50 initial_prof=scipy.genfromtxt('./DATA/initial_condition.txt', skip_header=13) 51 initial_prof_fun=scipy.interpolate.interp1d(initial_prof[:,0], initial_prof[:,1], fill_value=0., bounds_error=False) 36 #-------------------------------------------------------------------------------- 37 # Create Sequential Domain 38 #-------------------------------------------------------------------------------- 39 if myid == 0: 40 print ' Building mesh (alternative non-uniform mesh could be much more efficient)' 41 points, vertices, boundary = anuga.rectangular_cross(nx,ny, len1=l1,len2=l2, origin=(-200., 0.)) 42 43 print 'Creating Domain' 44 domain=anuga.Domain(points,vertices,boundary) # Create Domain 45 domain.set_name('runup_v2') # Output to file runup.sww 46 domain.set_datadir('.') # Use current folder 47 domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1}) 48 52 49 53 def stagefun(x,y): 54 return initial_prof_fun(x-200.) 50 domain.set_flow_algorithm(alg) 55 51 56 domain.set_quantity('elevation',topography) # Use function for elevation 52 #------------------ 53 # Define Initial conditions 54 #------------------ 55 56 57 # Define initial condition using file 58 initial_prof=scipy.genfromtxt('./DATA/initial_condition.txt', skip_header=13) 59 initial_prof_fun=scipy.interpolate.interp1d(initial_prof[:,0], initial_prof[:,1], fill_value=0., bounds_error=False) 60 61 def stagefun(x,y): 62 return initial_prof_fun(x-200.) 63 64 domain.set_quantity('elevation',topography) # Use function for elevation 65 domain.set_quantity('friction',0.000) # Constant friction 66 domain.set_quantity('stage', stagefun) 57 67 58 domain.set_quantity('friction',0.000) # Constant friction 68 else: 69 70 domain = None 59 71 60 domain.set_quantity('stage', stagefun) 61 72 #------------------------------------------------------------------------ 73 # Parallel Domain 74 #------------------------------------------------------------------------ 75 domain = distribute(domain) 76 62 77 #-------------------------- 63 78 # Setup boundary conditions … … 73 88 # Produce a documentation of parameters 74 89 #------------------------------------------------------------------------------ 75 parameter_file=open('parameters.tex', 'w') 76 parameter_file.write('\\begin{verbatim}\n') 77 from pprint import pprint 78 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 79 parameter_file.write('\\end{verbatim}\n') 80 parameter_file.close() 90 if myid == 0: 91 parameter_file=open('parameters.tex', 'w') 92 parameter_file.write('\\begin{verbatim}\n') 93 from pprint import pprint 94 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 95 parameter_file.write('\\end{verbatim}\n') 96 parameter_file.close() 81 97 82 98 #------------------------------ … … 85 101 86 102 for t in domain.evolve(yieldstep=5.0,finaltime=350.0): 87 103 if myid == 0: print domain.timestepping_statistics() 88 104 #uh=domain.quantities['xmomentum'].centroid_values 89 105 #vh=domain.quantities['ymomentum'].centroid_values … … 93 109 #print 'peak speed is', vel.max() 94 110 111 112 domain.sww_merge(delete_old=True) 113 114 finalize() -
trunk/anuga_core/validation_tests/analytical_exact/mac_donald_short_channel/numerical_MacDonald.py
r9155 r9174 10 10 import anuga 11 11 from anuga import Domain as Domain 12 from anuga import myid, finalize, distribute 13 from anuga import g 12 14 from math import cos 13 15 from numpy import zeros, ones, array … … 25 27 output_file = 'MacDonald' 26 28 27 #anuga.copy_code_files(output_dir,__file__) 28 #start_screen_catcher(output_dir+'_') 29 args = anuga.get_args() 30 alg = args.alg 31 verbose = args.verbose 29 32 30 33 31 #------------------------------------------------------------------------------32 # Setup domain33 #------------------------------------------------------------------------------34 34 dx = 0.25 35 35 dy = dx … … 37 37 W = 3*dx 38 38 39 # structured mesh40 points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, 0.0))41 39 42 #domain = anuga.Domain(points, vertices, boundary)43 domain = Domain(points, vertices, boundary)44 45 domain.set_name(output_file)46 domain.set_datadir(output_dir)47 48 #------------------------------------------------------------------------------49 # Setup Algorithm, either using command line arguments50 # or override manually yourself51 #------------------------------------------------------------------------------52 from anuga.utilities.argparsing import parse_standard_args53 from anuga import g54 alg, cfl = parse_standard_args()55 domain.set_flow_algorithm(alg)56 #domain.set_CFL(cfl)57 58 #------------------------------------------------------------------------------59 # Setup initial conditions60 #------------------------------------------------------------------------------61 40 L = 100. # Channel length 62 41 q = q_s = 2. # Steady discharge … … 96 75 return elevation 97 76 98 domain.set_quantity('stage', 2.87870797)99 domain.set_quantity('elevation', bed)100 domain.set_quantity('friction', n)101 77 78 #------------------------------------------------------------------------------ 79 # Setup sequential domain 80 #------------------------------------------------------------------------------ 81 if myid == 0: 82 # structured mesh 83 points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, 0.0)) 84 85 #domain = anuga.Domain(points, vertices, boundary) 86 domain = Domain(points, vertices, boundary) 87 88 domain.set_name(output_file) 89 domain.set_datadir(output_dir) 90 91 domain.set_flow_algorithm(alg) 92 93 94 #------------------------------------------------------------------------------ 95 # Setup initial conditions 96 #------------------------------------------------------------------------------ 97 98 domain.set_quantity('stage', 2.87870797) 99 domain.set_quantity('elevation', bed) 100 domain.set_quantity('friction', n) 101 else: 102 103 domain = None 104 105 #-------------------------------------------------------------------- 106 # Parallel Domain 107 #-------------------------------------------------------------------- 108 domain = distribute(domain) 102 109 103 110 #----------------------------------------------------------------------------- … … 114 121 115 122 116 #===============================================================================117 ##from anuga.visualiser import RealtimeVisualiser118 ##vis = RealtimeVisualiser(domain)119 ##vis.render_quantity_height("stage", zScale =h0*500, dynamic=True)120 ##vis.colour_height_quantity('stage', (0.0, 0.5, 1.0))121 ##vis.start()122 #===============================================================================123 123 124 124 … … 126 126 # Produce a documentation of parameters 127 127 #------------------------------------------------------------------------------ 128 parameter_file=open('parameters.tex', 'w') 129 parameter_file.write('\\begin{verbatim}\n') 130 from pprint import pprint 131 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 132 parameter_file.write('\\end{verbatim}\n') 133 parameter_file.close() 128 if myid == 0: 129 parameter_file=open('parameters.tex', 'w') 130 parameter_file.write('\\begin{verbatim}\n') 131 from pprint import pprint 132 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 133 parameter_file.write('\\end{verbatim}\n') 134 parameter_file.close() 134 135 135 136 #------------------------------------------------------------------------------ … … 138 139 for t in domain.evolve(yieldstep = 1.0, finaltime = 100.): 139 140 #print domain.timestepping_statistics(track_speeds=True) 140 print domain.timestepping_statistics()141 if myid == 0: print domain.timestepping_statistics() 141 142 #vis.update() 142 143 143 144 144 #test against know data 145 146 #vis.evolveFinished() 145 domain.sww_merge(delete_old=True) 147 146 147 finalize() 148 -
trunk/anuga_core/validation_tests/analytical_exact/mac_donald_short_channel/produce_results.py
r9117 r9174 2 2 # import modules 3 3 #-------------------------------- 4 from anuga.validation_utilities.fabricate import * 5 from anuga.validation_utilities import run_validation_script 6 from anuga.validation_utilities import typeset_report 4 import anuga 5 from anuga.validation_utilities import produce_report 7 6 7 args = anuga.get_args() 8 8 9 # Setup the python scripts which produce the output for this 10 # validation test 11 def build(): 12 run_validation_script('numerical_MacDonald.py') 13 run_validation_script('plot_results.py') 14 typeset_report() 9 produce_report('numerical_MacDonald.py', args=args) 15 10 16 def clean():17 autoclean()18 19 main()20 -
trunk/anuga_core/validation_tests/analytical_exact/parabolic_basin/numerical_parabolic_basin.py
r9156 r9174 25 25 args = anuga.get_args() 26 26 alg = args.alg 27 verbose = args.v 27 verbose = args.verbose 28 28 29 29 m = 200 -
trunk/anuga_core/validation_tests/analytical_exact/paraboloid_basin/numerical_paraboloid_basin.py
r9158 r9174 34 34 args = anuga.get_args() 35 35 alg = args.alg 36 verbose = args.v 36 verbose = args.verbose 37 37 38 38 #------------------------------------------------------------------------------- -
trunk/anuga_core/validation_tests/analytical_exact/river_at_rest_varying_topo_width/numerical_varying_width.py
r9155 r9174 10 10 import sys 11 11 import anuga 12 from anuga import myid, finalize, distribute 12 13 from anuga import Domain as Domain 13 14 from math import cos … … 33 34 #start_screen_catcher(output_dir+'_') 34 35 36 args = anuga.get_args() 37 alg = args.alg 38 verbose = args.verbose 35 39 36 40 #------------------------------------------------------------------------------ … … 42 46 W = 60. 43 47 44 # structured mesh45 points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.,-W/2.))46 48 47 #domain = anuga.Domain(points, vertices, boundary) 48 domain = Domain(points, vertices, boundary) 49 #=============================================================================== 50 # Create sequential domain 51 #=============================================================================== 52 if myid == 0: 53 # structured mesh 54 points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.,-W/2.)) 55 56 #domain = anuga.Domain(points, vertices, boundary) 57 domain = Domain(points, vertices, boundary) 58 59 domain.set_name(output_file) 60 domain.set_datadir(output_dir) 61 62 #------------------------------------------------------------------------------ 63 # Setup Algorithm, either using command line arguments 64 # or override manually yourself 65 #------------------------------------------------------------------------------ 66 from anuga.utilities.argparsing import parse_standard_args 67 alg, cfl = parse_standard_args() 68 domain.set_flow_algorithm(alg) 69 #domain.set_CFL(cfl) 70 71 #------------------------------------------------------------------------------ 72 # Setup initial conditions 73 #------------------------------------------------------------------------------ 74 domain.set_quantity('friction', 0.0) 75 domain.set_quantity('stage', 12.0) 76 XX = array([0.,50.,100.,150.,250.,300.,350.,400.,425.,435.,450.,470.,475.,500., 77 505.,530.,550.,565.,575.,600.,650.,700.,750.,800.,820.,900.,950., 78 1000.,1500.]) 79 ZZ = array([0.,0.,2.5,5.,5.,3.,5.,5.,7.5,8.,9.,9.,9.,9.1,9.,9.,6.,5.5,5.5,5., 80 4.,3.,3.,2.3,2.,1.2,0.4,0.,0.]) 81 WW = array([40.,40.,30.,30.,30.,30.,25.,25.,30.,35.,35.,40.,40.,40.,45.,45.,50., 82 45.,40.,40.,30.,40.,40.,5.,40.,35.,25.,40.,40.])/2. 83 84 85 depth = interp1d(XX, ZZ) 86 width = interp1d(XX, WW) 87 88 def bed_elevation(x,y): 89 z = 25.0*ones_like(x) 90 wid = width(x) 91 dep = depth(x) 92 z = where( logical_and(y < wid, y>-wid), dep, z) 93 return z 94 95 domain.set_quantity('elevation', bed_elevation) 96 97 else: 98 99 domain = None 100 49 101 50 domain.set_name(output_file) 51 domain.set_datadir(output_dir) 52 53 #------------------------------------------------------------------------------ 54 # Setup Algorithm, either using command line arguments 55 # or override manually yourself 56 #------------------------------------------------------------------------------ 57 from anuga.utilities.argparsing import parse_standard_args 58 alg, cfl = parse_standard_args() 59 domain.set_flow_algorithm(alg) 60 #domain.set_CFL(cfl) 61 62 #------------------------------------------------------------------------------ 63 # Setup initial conditions 64 #------------------------------------------------------------------------------ 65 domain.set_quantity('friction', 0.0) 66 domain.set_quantity('stage', 12.0) 67 XX = array([0.,50.,100.,150.,250.,300.,350.,400.,425.,435.,450.,470.,475.,500., 68 505.,530.,550.,565.,575.,600.,650.,700.,750.,800.,820.,900.,950., 69 1000.,1500.]) 70 ZZ = array([0.,0.,2.5,5.,5.,3.,5.,5.,7.5,8.,9.,9.,9.,9.1,9.,9.,6.,5.5,5.5,5., 71 4.,3.,3.,2.3,2.,1.2,0.4,0.,0.]) 72 WW = array([40.,40.,30.,30.,30.,30.,25.,25.,30.,35.,35.,40.,40.,40.,45.,45.,50., 73 45.,40.,40.,30.,40.,40.,5.,40.,35.,25.,40.,40.])/2. 74 75 76 depth = interp1d(XX, ZZ) 77 width = interp1d(XX, WW) 78 79 def bed_elevation(x,y): 80 z = 25.0*ones_like(x) 81 wid = width(x) 82 dep = depth(x) 83 z = where( logical_and(y < wid, y>-wid), dep, z) 84 return z 85 86 domain.set_quantity('elevation', bed_elevation) 87 102 #=========================================================================== 103 # Create Parallel domain 104 #=========================================================================== 105 domain = distribute(domain) 88 106 89 107 #----------------------------------------------------------------------------- … … 99 117 100 118 101 #===============================================================================102 ##from anuga.visualiser import RealtimeVisualiser103 ##vis = RealtimeVisualiser(domain)104 ##vis.render_quantity_height("stage", zScale =h0*500, dynamic=True)105 ##vis.colour_height_quantity('stage', (0.0, 0.5, 1.0))106 ##vis.start()107 #===============================================================================108 109 110 #---------------------------------------------111 # Find triangle that contains the point Point112 # and print to file113 #---------------------------------------------114 ##Point = (0.0, 0.0)115 ##for n in range(len(domain.triangles)):116 ## tri = domain.get_vertex_coordinates(n)117 ## if is_inside_triangle(Point,tri):118 ## #print 'Point is within triangle with vertices '+'%s'%tri119 ## n_point = n120 ## break121 ##print 'n_point = ',n_point122 ##bla123 124 125 126 127 119 #------------------------------------------------------------------------------ 128 120 # Produce a documentation of parameters 129 121 #------------------------------------------------------------------------------ 130 parameter_file=open('parameters.tex', 'w') 131 parameter_file.write('\\begin{verbatim}\n') 132 from pprint import pprint 133 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 134 parameter_file.write('\\end{verbatim}\n') 135 parameter_file.close() 122 if myid == 0: 123 parameter_file=open('parameters.tex', 'w') 124 parameter_file.write('\\begin{verbatim}\n') 125 from pprint import pprint 126 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 127 parameter_file.write('\\end{verbatim}\n') 128 parameter_file.close() 136 129 137 130 #------------------------------------------------------------------------------ 138 131 # Evolve system through time 139 132 #------------------------------------------------------------------------------ 133 import time 134 t0 = time.time() 140 135 for t in domain.evolve(yieldstep = 0.1, finaltime = 5.0): 141 136 #print domain.timestepping_statistics(track_speeds=True) 142 print domain.timestepping_statistics()137 if myid == 0 and verbose: print domain.timestepping_statistics() 143 138 #vis.update() 144 139 140 if myid == 0 and verbose : print 'That took %s sec' % str(time.time()-t0) 141 domain.sww_merge(delete_old=True) 145 142 146 #test against know data 147 148 #vis.evolveFinished() 143 finalize() 149 144 145 -
trunk/anuga_core/validation_tests/analytical_exact/river_at_rest_varying_topo_width/plot_results.py
r8886 r9174 27 27 pyplot.ylabel('Stage') 28 28 pyplot.xlim([0,1500]) 29 pyplot.ylim([0,25]) 29 30 pyplot.savefig('stage_plot.png') 30 31 … … 52 53 pyplot.xlim([0,1500]) 53 54 pyplot.savefig('xvel_plot.png') 55 56 57 58 59 # Sweep in y direction 60 61 v = p2_st.x[116] 62 v2=(p2_st.x==v) 63 64 65 #p_dev = util.get_output('dam_break.sww', 0.001) 66 #p2_dev=util.get_centroids(p_dev, velocity_extrapolation=True) 67 68 #Plot stages 69 pyplot.clf() 70 pyplot.plot(p2_st.y[v2], p2_st.stage[-1,v2],'b.', label='numerical stage') 71 pyplot.plot(p2_st.y[v2], 12.*ones_like(p2_st.x[v2]),'r--', label='analytical stage') 72 pyplot.plot(p2_st.y[v2], p2_st.elev[v2],'k-', label='discretised bed') 73 pyplot.title('Stage at an instant in time') 74 pyplot.legend(loc='best') 75 pyplot.xlabel('Yposition') 76 pyplot.ylabel('Stage') 77 pyplot.xlim([-30,30]) 78 pyplot.ylim([-1,26]) 79 pyplot.savefig('stage_plot_y.png') 80 81 82 #Plot xmomentum 83 pyplot.clf() 84 pyplot.plot(p2_st.y[v2], p2_st.xmom[-1,v2], 'b.', label='numerical') 85 pyplot.plot(p2_st.y[v2], zeros(len(p2_st.x[v2])),'r-', label='analytical') 86 pyplot.title('Xmomentum at an instant in time') 87 pyplot.legend(loc='best') 88 pyplot.xlabel('Yposition') 89 pyplot.ylabel('Xmomentum') 90 pyplot.xlim([-30,30]) 91 pyplot.savefig('xmom_plot_y.png') 92 93 94 #Plot velocities 95 pyplot.clf() 96 pyplot.plot(p2_st.y[v2], p2_st.xvel[-1,v2], 'b.', label='numerical') 97 pyplot.plot(p2_st.y[v2], zeros(len(p2_st.x[v2])),'r-', label='analytical') 98 pyplot.title('Xvelocity at an instant in time') 99 pyplot.legend(loc='best') 100 pyplot.xlabel('Yposition') 101 pyplot.ylabel('Xvelocity') 102 pyplot.xlim([-30,30]) 103 pyplot.savefig('xvel_plot_y.png') -
trunk/anuga_core/validation_tests/analytical_exact/river_at_rest_varying_topo_width/produce_results.py
r9117 r9174 2 2 # import modules 3 3 #-------------------------------- 4 from anuga.validation_utilities.fabricate import * 5 from anuga.validation_utilities import run_validation_script 6 from anuga.validation_utilities import typeset_report 4 import anuga 5 from anuga.validation_utilities import produce_report 7 6 7 args = anuga.get_args() 8 8 9 # Setup the python scripts which produce the output for this 10 # validation test 11 def build(): 12 run_validation_script('numerical_varying_width.py') 13 run_validation_script('plot_results.py') 14 typeset_report() 9 produce_report('numerical_varying_width.py', args=args) 15 10 16 def clean():17 autoclean()18 19 main()20 -
trunk/anuga_core/validation_tests/analytical_exact/river_at_rest_varying_topo_width/results.tex
r9155 r9174 50 50 51 51 52 Current version of \anuga{} might not treat the wet/dry interface appropriately. The following three figures show the stage, $x$-momentum, and $x$-velocity respectively, after we run the simulation for some time. We should see excellent agreement between the analytical and numerical solutions if the method is well-balanced and if the wet/dry interface has been correctly treated. 52 Current version of \anuga{} might not treat the wet/dry interface appropriately. 53 The following figures show the stage, $x$-momentum, and $x$-velocity respectively, 54 after we run the simulation for some time. The first three show a slice in the x direction (down the river) and 55 the last three figures show a cross section across the river. We should see excellent agreement between 56 the analytical and numerical solutions if the method is well-balanced and if the wet/dry 57 interface has been correctly treated. 53 58 54 59 \begin{figure} … … 56 61 \includegraphics[width=0.9\textwidth]{stage_plot.png} 57 62 \end{center} 58 \caption{Stage results }63 \caption{Stage results down the river} 59 64 \end{figure} 60 65 … … 64 69 \includegraphics[width=0.9\textwidth]{xmom_plot.png} 65 70 \end{center} 66 \caption{Xmomentum results }71 \caption{Xmomentum results down the river} 67 72 \end{figure} 68 73 … … 72 77 \includegraphics[width=0.9\textwidth]{xvel_plot.png} 73 78 \end{center} 74 \caption{Xvelocity results} 79 \caption{Xvelocity results down the river} 80 \end{figure} 81 82 \begin{figure} 83 \begin{center} 84 \includegraphics[width=0.9\textwidth]{stage_plot_y.png} 85 \end{center} 86 \caption{Stage results across the river} 75 87 \end{figure} 76 88 77 89 90 \begin{figure} 91 \begin{center} 92 \includegraphics[width=0.9\textwidth]{xmom_plot_y.png} 93 \end{center} 94 \caption{Xmomentum results across the river} 95 \end{figure} 96 97 98 \begin{figure} 99 \begin{center} 100 \includegraphics[width=0.9\textwidth]{xvel_plot_y.png} 101 \end{center} 102 \caption{Xvelocity results accros the river} 103 \end{figure} 104 78 105 \endinput -
trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope/numerical_rundown_channel.py
r9155 r9174 12 12 from anuga.structures.inlet_operator import Inlet_operator 13 13 from anuga import Domain 14 from anuga import myid, finalize, distribute 14 15 15 #------------------------------------------------------------------------------ 16 # Setup computational domain 17 #------------------------------------------------------------------------------ 18 points, vertices, boundary = rectangular_cross(50, 50, len1=100.0, len2=100.0) 19 domain = Domain(points, vertices, boundary) # Create domain 20 domain.set_name('channel') # Output name 21 22 #------------------------------------------------------------------------------ 23 # Setup Algorithm, either using command line arguments 24 # or override manually yourself 25 #------------------------------------------------------------------------------ 26 from anuga.utilities.argparsing import parse_standard_args 27 alg, cfl = parse_standard_args() 28 domain.set_flow_algorithm(alg) 29 #domain.set_CFL(cfl) 30 31 #------------------------------------------------------------------------------ 32 # Setup initial conditions 33 #------------------------------------------------------------------------------ 16 #=============================================================================== 17 # Setup flow conditions 18 #=============================================================================== 34 19 Qin=20. 35 20 fluxin=Qin/100. #The momentum flux at the upstream boundary ( = discharge / width) 36 21 uana= 2.15843634571 # analytical Xvelocity 37 22 dana= 0.0926596702273 # analytical water depth 23 slope = -0.1 24 mannings = 0.03 38 25 39 def topography(x, y): 40 return -x/10. # linear bed slope 26 args = anuga.get_args() 27 alg = args.alg 28 verbose = args.verbose 41 29 42 def init_stage(x,y): 43 stg= -x/10.+0.01 # Constant depth: 1 cm. 44 return stg 45 #line0=[ [0.,0.], [0., 100.] ] 46 #Uin=[uana, 0.0] 47 #Inlet_operator(domain, line0, Q=Qin, velocity=Uin) 30 #------------------------------------------------------------------------------ 31 # Setup sequential computational domain 32 #------------------------------------------------------------------------------ 33 if myid == 0: 34 points, vertices, boundary = rectangular_cross(50, 50, len1=100.0, len2=100.0) 35 domain = Domain(points, vertices, boundary) # Create domain 36 domain.set_name('channel') # Output name 48 37 49 domain.set_quantity('elevation', topography) # Use function for elevation 50 domain.set_quantity('friction', 0.03) # Constant friction 51 domain.set_quantity('stage', init_stage) 38 domain.set_flow_algorithm(alg) 39 domain.set_store_centroids(True) 40 41 #------------------------------------------------------------------------------ 42 # Setup initial conditions 43 #------------------------------------------------------------------------------ 44 45 def topography(x, y): 46 return x*slope # linear bed slope 47 48 def init_stage(x,y): 49 stg= x*slope+0.01 # Constant depth: 1 cm. 50 return stg 51 52 domain.set_quantity('elevation', topography) # Use function for elevation 53 domain.set_quantity('friction', mannings) # Constant friction 54 domain.set_quantity('stage', init_stage) 52 55 56 else: 57 58 domain = None 59 60 #=============================================================================== 61 # Parallel Domain 62 #=============================================================================== 63 domain = distribute(domain) 64 65 #domain.set_store_centroids(True) 53 66 #------------------------------------------------------------------------------ 54 67 # Setup boundary conditions … … 64 77 # Produce a documentation of parameters 65 78 #------------------------------------------------------------------------------ 66 parameter_file=open('parameters.tex', 'w') 67 parameter_file.write('\\begin{verbatim}\n') 68 from pprint import pprint 69 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 70 parameter_file.write('\\end{verbatim}\n') 71 parameter_file.close() 79 if myid == 0: 80 parameter_file=open('parameters.tex', 'w') 81 parameter_file.write('\\begin{verbatim}\n') 82 from pprint import pprint 83 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 84 parameter_file.write('\\end{verbatim}\n') 85 parameter_file.close() 72 86 73 87 #------------------------------------------------------------------------------ … … 75 89 #------------------------------------------------------------------------------ 76 90 for t in domain.evolve(yieldstep=2.0, finaltime=200.0): 77 print domain.timestepping_statistics() 91 if myid ==0 and verbose: print domain.timestepping_statistics() 92 93 94 domain.sww_merge(delete_old=True) 95 96 finalize() -
trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope/plot_results.py
r9155 r9174 24 24 #------------------ 25 25 #v=(y==2.5) 26 v=(p2.y==p2.y[3])26 #v=(p2.y==p2.y[3]) 27 27 28 28 #------------------------------- … … 45 45 # Make plot animation 46 46 #-------------------- 47 # Find an y value close to y==50 48 tmp=(abs(p2.y-50.)).argmin() 49 #vx=(p2.y==p2.y[tmp]) 50 vx=(abs(p2.y - p2.y[tmp])<1.5) 51 47 52 pyplot.clf() 53 pyplot.plot(p2.x[vx],p2.stage[-1,vx]-p2.elev[vx], 'o', label='numerical') 54 pyplot.plot((0,100),(dana,dana),label='analytical') 55 pyplot.ylim([0.05,0.1]) 56 pyplot.xlabel('Xposition m') 57 pyplot.ylabel('Depth m') 58 pyplot.title('Depth down the slope (along y=50.)') 59 pyplot.legend(loc='best') 60 pyplot.savefig('depth_x.png') 48 61 49 line, = pyplot.plot( (p2.x[v].min(),p2.x[v].max()) ,( (p2.stage[:,v]-p2.elev[v]).max(),(p2.stage[:,v]-p2.elev[v]).min() ) ) 50 line.set_label('numerical') 51 pyplot.plot( (0,100),(dana,dana), 'r',label='analytical' ) 52 pyplot.legend() 53 #pyplot.plot(x[v],elev[v],'green') 54 for i in range(p2.xmom.shape[0]): 55 line.set_xdata(p2.x[v]) 56 line.set_ydata(p2.stage[i,v]-p2.elev[v]) 57 pyplot.draw() 58 pyplot.title('Flow depth: should be converging to steady uniform flow ' ) 59 pyplot.xlabel('Xposition') 60 pyplot.ylabel('Depth') 61 pyplot.ylim([0.085,0.095]) 62 pyplot.legend(loc='best') 63 pyplot.title('Flow depth at 400s')# -- there should be a central region with steady uniform flow ' ) 64 pyplot.savefig('final_depth.png') 62 63 64 65 65 66 66 67 #-------------------------------------------- … … 69 70 # Find an x value close to x==50 70 71 tmp=(abs(p2.x-50.)).argmin() 71 v=( p2.x==p2.x[tmp])72 v=(abs(p2.x - p2.x[tmp])<1.5) 72 73 73 74 pyplot.clf() 74 pyplot.plot(p2.y[v],p2.xvel[100,v], 'o', label='numerical') 75 pyplot.plot(p2.y[v],p2.stage[-1,v]-p2.elev[v], 'o', label='numerical') 76 pyplot.plot((0,100),(dana,dana),label='analytical') 77 pyplot.ylim([0.05,0.1]) 78 pyplot.xlabel('Yposition m') 79 pyplot.ylabel('Depth m') 80 pyplot.title('Depth across the slope (x=50.)') 81 pyplot.legend(loc='best') 82 pyplot.savefig('depth_y.png') 83 84 85 pyplot.clf() 86 pyplot.plot(p2.y[v],p2.xvel[-1,v], 'o', label='numerical') 75 87 pyplot.plot((0,100),(uana,uana),label='analytical') 76 88 pyplot.ylim([1.0,3.0]) … … 82 94 83 95 pyplot.clf() 84 pyplot.plot(p2.y[v],p2.yvel[ 100,v],'o', label='numerical')96 pyplot.plot(p2.y[v],p2.yvel[-1,v],'o', label='numerical') 85 97 pyplot.plot((0,100),(0.0, 0.0),label='analytical') 86 98 pyplot.xlabel('Yposition along the line x=50') -
trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope/produce_results.py
r9117 r9174 3 3 It was called "steep_slope" in an old validation test. 4 4 """ 5 #--------------------------------6 # import modules7 #--------------------------------8 5 9 from anuga.validation_utilities.fabricate import * 10 from anuga.validation_utilities import run_validation_script 11 from anuga.validation_utilities import typeset_report 6 import anuga 7 from anuga.validation_utilities import produce_report 12 8 13 # Setup the python scripts which produce the output for this 14 # validation test 15 def build(): 16 run_validation_script('numerical_rundown_channel.py') 17 run_validation_script('plot_results.py') 18 typeset_report() 9 args = anuga.get_args() 19 10 20 def clean(): 21 autoclean() 11 produce_report('numerical_rundown_channel.py', args=args) 22 12 23 main() 13 14 -
trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope/results.tex
r8801 r9174 9 9 Suppose that we are given a one dimensional domain. The steady state conditions with a contant water depth everywhere make the shallow water equations to the single identity 10 10 \begin{equation} 11 z_x = - S_f .11 z_x = - S_f, 12 12 \end{equation} 13 Here $q=uh$ is the momentum or water discharge and $S_f$ is the symbol for the force of bottom friction involving Manning's coefficient $n$. We take 13 where $z_x$ is the bed slope, and $S_f$ is the symbol for the force of bottom friction. We take Manning's friction 14 14 \begin{equation} 15 S_f = n^2 \frac{q|q|}{h^{10/3}} .15 S_f = n^2 \frac{q|q|}{h^{10/3}} 16 16 \end{equation} 17 If $q$, $n$, and $z_x$ are given, then the analytical solution is 17 where $n$ is the Manning's coefficient and $q$ is the discharge $uh$. 18 If $q$, $n$, and $z_x$ are given, then the analytical solution for $u$ and $h$ is 18 19 \begin{equation} 19 20 u(x)= \left[- n^{-2} q^{4/3} z_x\right]^{3/10}, … … 35 36 36 37 37 Some simualtion results are as follows. 38 Figures~\ref{fig:depthdownchan} shows the steady state depth in the downstream direction. There should be a good agreement with the analytical solution, at least away from the boundaries. 38 Some simulation results are as follows. 39 Figures~\ref{fig:depthdownchan} shows the steady state depth in the downstream direction. 40 There should be a good agreement with the analytical solution, at least away from the boundaries. 41 42 Figures~\ref{fig:depthacrosschan} shows the steady state depth across the slope around the line x = 50m. 43 There should be a good agreement with the analytical solution, at least away from the boundaries. 44 39 45 Figures~\ref{fig:xvelscrosschan} and~\ref{fig:yvelscroschan} show the steady state $x$- and $y$-velocities, along a slice in the cross slope direction (near $x=50$). The $x$-velocities should agree well with the analytical solution, and the $y$-velocities should be zero. 40 46 41 47 \begin{figure} 42 48 \begin{center} 43 \includegraphics[width=0.8\textwidth]{ final_depth.png}49 \includegraphics[width=0.8\textwidth]{depth_x.png} 44 50 \caption{Depth in the downstream direction} 45 51 \label{fig:depthdownchan} … … 47 53 \end{figure} 48 54 55 \begin{figure} 56 \begin{center} 57 \includegraphics[width=0.8\textwidth]{depth_y.png} 58 \caption{Depth across the slope around $x$ = 50m} 59 \label{fig:depthacrosschan} 60 \end{center} 61 \end{figure} 49 62 50 63 \begin{figure} -
trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope_coarse/numerical_rundown_channel_coarse.py
r9155 r9174 9 9 #------------------------------------------------------------------------------ 10 10 import anuga 11 from anuga import rectangular_cross as rectangular_cross12 from anuga .structures.inlet_operatorimport Inlet_operator11 from anuga import rectangular_cross 12 from anuga import Inlet_operator 13 13 from anuga import Domain 14 from anuga import myid, finalize, distribute 15 16 Qin = 0.1 17 fluxin=Qin/100. #The momentum flux at the upstream boundary ( = discharge / width) 18 mann=0.03 # Manning's coef 19 bedslope=-0.1 20 uana= ( mann**(-2.)*abs(bedslope)*fluxin**(4./3.) )**(3./10.) # Velocity 21 dana= fluxin/uana # Depth 22 23 24 25 args = anuga.get_args() 26 alg = args.alg 27 verbose = args.verbose 14 28 15 29 #------------------------------------------------------------------------------ 16 # Setup computational domain30 # Setup sequential computational domain 17 31 #------------------------------------------------------------------------------ 18 points, vertices, boundary = rectangular_cross(14, 10, len1=140.0, len2=100.0) 19 domain = Domain(points, vertices, boundary) # Create domain 20 domain.set_name('channel') # Output name 32 if myid == 0: 33 points, vertices, boundary = rectangular_cross(40, 10, len1=400.0, len2=100.0) 34 domain = Domain(points, vertices, boundary) # Create domain 35 domain.set_name('channel') # Output name 36 37 domain.set_flow_algorithm(alg) 21 38 22 #------------------------------------------------------------------------------ 23 # Setup Algorithm, either using command line arguments 24 # or override manually yourself 25 #------------------------------------------------------------------------------ 26 from anuga.utilities.argparsing import parse_standard_args 27 alg, cfl = parse_standard_args() 28 domain.set_flow_algorithm(alg) 29 #domain.set_CFL(cfl) 39 40 #------------------------------------------------------------------------------ 41 # Setup initial conditions 42 #------------------------------------------------------------------------------ 30 43 31 #------------------------------------------------------------------------------ 32 # Setup initial conditions 33 #------------------------------------------------------------------------------ 34 Qin=0.1 35 #fluxin=Qin/100. #The momentum flux at the upstream boundary ( = discharge / width) 36 #uana= 2.15843634571 # analytical Xvelocity 37 #dana= 0.0926596702273 # analytical water depth 44 45 def topography(x, y): 46 return -x/10. # linear bed slope 47 48 def init_stage(x,y): 49 stg= -x/10.+0.004 # Constant depth: 10 cm. 50 return stg 51 #line0=[ [0.,0.], [0., 100.] ] 52 #Uin=[uana, 0.0] 53 #Inlet_operator(domain, line0, Q=Qin, velocity=Uin) 54 38 55 39 def topography(x, y): 40 return -x/10. # linear bed slope 41 42 def init_stage(x,y): 43 stg= -x/10.+0.10 # Constant depth: 10 cm. 44 return stg 45 #line0=[ [0.,0.], [0., 100.] ] 46 #Uin=[uana, 0.0] 47 #Inlet_operator(domain, line0, Q=Qin, velocity=Uin) 48 49 line1=[ [0.,0.], [0., 100.] ] 50 #Qin=0.1 51 Inlet_operator(domain, line1,Qin) 52 53 54 domain.set_quantity('elevation', topography) # Use function for elevation 55 domain.set_quantity('friction', 0.03) # Constant friction 56 domain.set_quantity('stage', init_stage) 56 57 domain.set_quantity('elevation', topography) # Use function for elevation 58 domain.set_quantity('friction', mann) # Constant friction 59 domain.set_quantity('stage', init_stage) 60 domain.set_quantity('xmomentum', dana*uana) 61 else: 62 63 domain = None 64 65 #=========================================================================== 66 # Create Parallel Domain 67 #=========================================================================== 68 domain = distribute(domain) 57 69 58 70 #------------------------------------------------------------------------------ … … 60 72 #------------------------------------------------------------------------------ 61 73 Bt = anuga.Transmissive_boundary(domain) 74 #Bts = anuga.Transmissive_momentum_set_stage_boundary(domain, dana-160.0) 75 Bts = anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain, lambda t: dana-160.0) 62 76 #BdIN = anuga.Dirichlet_boundary([dana, fluxin, 0.0]) 63 #BdOUT = anuga.Dirichlet_boundary([dana-10., fluxin, 0.0]) 77 BdOUT = anuga.Dirichlet_boundary([dana-40., dana*uana, 0.0]) 78 79 print dana-40. 80 64 81 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 65 domain.set_boundary({'left': Br, 'right': Bt, 'top': Br, 'bottom': Br}) 82 domain.set_boundary({'left': Br, 'right': BdOUT, 'top': Br, 'bottom': Br}) 83 84 85 line1=[ [0.0, 0.], [0.0, 100.] ] 86 Qin=0.1 87 inlet = Inlet_operator(domain, line1, Q = Qin) 88 89 90 #if inlet: print inlet.statistics() 91 92 93 stage = domain.quantities['stage'] 94 elev = domain.quantities['elevation'] 95 96 print (stage-elev).get_integral() 97 98 99 100 66 101 67 102 … … 69 104 # Produce a documentation of parameters 70 105 #------------------------------------------------------------------------------ 71 parameter_file=open('parameters.tex', 'w') 72 parameter_file.write('\\begin{verbatim}\n') 73 from pprint import pprint 74 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 75 parameter_file.write('\\end{verbatim}\n') 76 parameter_file.close() 106 if myid == 0: 107 parameter_file=open('parameters.tex', 'w') 108 parameter_file.write('\\begin{verbatim}\n') 109 from pprint import pprint 110 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 111 parameter_file.write('\\end{verbatim}\n') 112 parameter_file.close() 77 113 78 114 #------------------------------------------------------------------------------ 79 115 # Evolve system through time 80 116 #------------------------------------------------------------------------------ 81 for t in domain.evolve(yieldstep=10.0, finaltime=2000.0): 82 print domain.timestepping_statistics() 83 print (domain.areas*(domain.quantities['stage'].centroid_values - domain.quantities['elevation'].centroid_values)).sum() 84 s3 = domain.get_flow_through_cross_section([[30., 0.0], [30., 100.]]) 85 s4 = domain.get_flow_through_cross_section([[32., 0.0], [32., 100.]]) 86 s5 = domain.get_flow_through_cross_section([[34., 0.0], [34., 100.]]) 87 s2 = domain.get_flow_through_cross_section([[45., 0.0], [45., 100.]]) 88 s1 = domain.get_flow_through_cross_section([[53., 0.0], [53., 100.]]) 89 s0 = domain.get_flow_through_cross_section([[60., 0.0], [60., 100.]]) 90 print 'Xsectional flow:', s0, s1, s2, s3, s4, s5 117 for t in domain.evolve(yieldstep=10.0, finaltime=3000.0): 118 if myid == 0 and verbose: print domain.timestepping_statistics() 119 #print (stage-elev).get_integral() 120 #print (domain.areas*(domain.quantities['stage'].centroid_values - domain.quantities['elevation'].centroid_values)).sum() 121 #s3 = domain.get_flow_through_cross_section([[30., 0.0], [30., 100.]]) 122 #s4 = domain.get_flow_through_cross_section([[32., 0.0], [32., 100.]]) 123 #s5 = domain.get_flow_through_cross_section([[34., 0.0], [34., 100.]]) 124 #s2 = domain.get_flow_through_cross_section([[45., 0.0], [45., 100.]]) 125 #s1 = domain.get_flow_through_cross_section([[53., 0.0], [53., 100.]]) 126 #s0 = domain.get_flow_through_cross_section([[60., 0.0], [60., 100.]]) 127 #print 'Xsectional flow:', s0, s1, s2, s3, s4, s5 128 129 130 domain.sww_merge(delete_old=True) 131 132 finalize() -
trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope_coarse/plot_results.py
r9155 r9174 26 26 #v=(p2.y==p2.y[3]) 27 27 28 tmp = abs(p2.y-50.)29 n = tmp.argmin()30 v=(p2.y==p2.y[n])31 32 ll=p2.vel.shape[0]-133 34 28 #------------------------------- 35 29 # Define variables of case study … … 51 45 # Make plot animation 52 46 #-------------------- 47 # Find an y value close to y==50 48 #tmp=(abs(p2.y-50.)).argmin() 49 #vx=(p2.y==p2.y[tmp]) 50 vx=(abs(p2.y - 50.0)<10.0) 51 53 52 pyplot.clf() 53 pyplot.plot(p2.x[vx],p2.stage[-1,vx]-p2.elev[vx], 'o', label='numerical') 54 pyplot.plot((0,400),(dana,dana),label='analytical') 55 pyplot.ylim([0.0,0.01]) 56 pyplot.xlabel('Xposition m') 57 pyplot.ylabel('Depth m') 58 pyplot.title('Depth down the slope (along y=50.)') 59 pyplot.legend(loc='best') 60 pyplot.savefig('depth_x.png') 54 61 55 line, = pyplot.plot( (p2.x[v].min(),p2.x[v].max()) ,( (p2.stage[:,v]-p2.elev[v]).max(),(p2.stage[:,v]-p2.elev[v]).min() ) ) 56 line.set_label('numerical') 57 pyplot.plot( (0,140),(dana,dana), 'r',label='analytical' ) 58 pyplot.yscale('log') 59 pyplot.legend() 60 #pyplot.plot(x[v],elev[v],'green') 61 for i in range(p2.xmom.shape[0]): 62 line.set_xdata(p2.x[v]) 63 line.set_ydata(p2.stage[i,v]-p2.elev[v]) 64 pyplot.draw() 65 pyplot.title('Flow depth: should be converging to steady uniform flow ' ) 66 pyplot.xlabel('Xposition') 67 pyplot.ylabel('Depth') 68 #pyplot.ylim([0.085,0.095]) 62 63 64 pyplot.clf() 65 pyplot.plot(p2.x[vx],p2.xvel[-1,vx], 'o', label='numerical') 66 pyplot.plot((0,400),(uana,uana),label='analytical') 67 #pyplot.ylim([0.0,0.05]) 68 pyplot.xlabel('Xposition m') 69 pyplot.ylabel('Depth m') 70 pyplot.title('Velocity down the slope (along y=50.)') 69 71 pyplot.legend(loc='best') 70 pyplot.title('Flow depth at 800s')# -- there should be a central region with steady uniform flow ' ) 71 pyplot.savefig('final_depth.png') 72 pyplot.savefig('xvelocity_x.png') 73 74 75 72 76 73 77 #-------------------------------------------- … … 75 79 #-------------------------------------------- 76 80 # Find an x value close to x==50 77 tmp=(abs(p2.x-50.)).argmin()78 v=( p2.x==p2.x[tmp])81 #tmp=(abs(p2.x-50.)).argmin() 82 v=(abs(p2.x - 50.0)<10.0) 79 83 80 84 pyplot.clf() 81 pyplot.plot(p2.y[v],p2.xvel[ll,v], 'o', label='numerical') 85 pyplot.plot(p2.y[v],p2.stage[-1,v]-p2.elev[v], 'o', label='numerical') 86 pyplot.plot((0,100),(dana,dana),label='analytical') 87 pyplot.ylim([0.0,0.005]) 88 pyplot.xlabel('Yposition m') 89 pyplot.ylabel('Depth m') 90 pyplot.title('Depth across the slope (x=50.)') 91 pyplot.legend(loc='best') 92 pyplot.savefig('depth_y.png') 93 94 95 pyplot.clf() 96 pyplot.plot(p2.y[v],p2.xvel[-1,v], 'o', label='numerical') 82 97 pyplot.plot((0,100),(uana,uana),label='analytical') 83 #pyplot.ylim([1.0,3.0])98 pyplot.ylim([0.0,0.35]) 84 99 pyplot.xlabel('Yposition along the line x=50') 85 100 pyplot.ylabel('Xvelocity m/s') 86 101 pyplot.title('Final Xvelocity around the line x=50.') 87 102 pyplot.legend(loc='best') 88 pyplot.ylim((0,1.5*uana))89 103 pyplot.savefig('x_velocity.png') 90 104 91 105 pyplot.clf() 92 pyplot.plot(p2.y[v],p2.yvel[ ll,v],'o', label='numerical')106 pyplot.plot(p2.y[v],p2.yvel[-1,v],'o', label='numerical') 93 107 pyplot.plot((0,100),(0.0, 0.0),label='analytical') 108 #pyplot.ylim([0.0,0.3]) 94 109 pyplot.xlabel('Yposition along the line x=50') 95 110 pyplot.ylabel('Yvelocity') -
trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope_coarse/produce_results.py
r9117 r9174 3 3 It was called "steep_slope" in an old validation test. 4 4 """ 5 #--------------------------------6 # import modules7 #--------------------------------8 5 9 from anuga.validation_utilities.fabricate import * 10 from anuga.validation_utilities import run_validation_script 11 from anuga.validation_utilities import typeset_report 6 import anuga 7 from anuga.validation_utilities import produce_report 12 8 13 # Setup the python scripts which produce the output for this 14 # validation test 15 def build(): 16 run_validation_script('numerical_rundown_channel_coarse.py') 17 run_validation_script('plot_results.py') 18 typeset_report() 9 args = anuga.get_args() 19 10 20 def clean(): 21 autoclean() 11 produce_report('numerical_rundown_channel_coarse.py', args=args) 22 12 23 main() 13 14 -
trunk/anuga_core/validation_tests/behaviour_only/lid_driven_cavity/numerical_lid_driven_cavity.py
r9036 r9174 23 23 alg, cfl = parse_standard_args() 24 24 domain.set_flow_algorithm(alg) 25 domain.set_CFL(cfl)25 #domain.set_CFL(cfl) 26 26 27 27 domain.set_name('dimensional_lid_driven') # Output to file runup.sww -
trunk/anuga_core/validation_tests/behaviour_only/weir_1/runup.py
r9121 r9174 60 60 alg, cfl = parse_standard_args() 61 61 domain.set_flow_algorithm(alg) 62 domain.set_CFL(cfl)62 #domain.set_CFL(cfl) 63 63 64 64 domain.set_name('runup_riverwall') -
trunk/anuga_core/validation_tests/case_studies/okushiri/run_okushiri.py
r9134 r9174 84 84 alg, cfl = parse_standard_args() 85 85 domain.set_flow_algorithm(alg) 86 domain.set_CFL(cfl)86 #domain.set_CFL(cfl) 87 87 88 88 -
trunk/anuga_core/validation_tests/case_studies/patong/run_model.py
r9140 r9174 38 38 import shutil 39 39 40 41 verbose = True 40 #-------------------------------------------------- 41 # Pick up useful command line arguments (which over rides 42 # values set before 43 #-------------------------------------------------- 44 cfl = anuga.args.cfl 45 alg = anuga.args.alg 46 verbose = anuga.args.verbose 47 np = anuga.args.np 48 49 if myid == 0 and verbose: 50 print 80*'#' 51 print '#' 52 print '# Long Validation Test, takes 10 minutes on my desktop' 53 print '#' 54 print '# Consider running in parallel' 55 print '#' 56 print 80*'#' 57 42 58 #------------------------------------------------------------------------------- 43 59 # Copy scripts to time stamped output directory and capture screen … … 133 149 domain.set_name(project.scenario_name) 134 150 domain.set_datadir(project.output_run) 135 print 'WARNING: FORCING FLOW ALGORITHM TO DE0 -- NEEDS TO BE CHANGED FOR INTEGRATION INTO VALIDATION TESTS' 136 #domain.set_flow_algorithm('tsunami')137 domain.set_flow_algorithm('DE0')151 152 domain.set_flow_algorithm(alg) 153 #domain.set_CFL(cfl) 138 154 139 155 #------------------------------------------------------------------------------- -
trunk/anuga_core/validation_tests/case_studies/towradgi/Towradgi_historic_flood.py
r9076 r9174 225 225 alg, cfl = parse_standard_args() 226 226 domain.set_flow_algorithm(alg) 227 domain.set_CFL(cfl)227 #domain.set_CFL(cfl) 228 228 #domain.set_flow_algorithm('DE1') 229 229 #domain.set_store_vertices_smoothly() -
trunk/anuga_core/validation_tests/experimental_data/dam_break_yeh_petroff/numerical_Yeh_Petroff.py
r9038 r9174 58 58 59 59 domain.set_flow_algorithm(alg) 60 domain.set_CFL(cfl)60 #domain.set_CFL(cfl) 61 61 #domain.set_minimum_allowed_height(0.01) # Avoid such statements in the validation tests 62 62 -
trunk/anuga_core/validation_tests/other_references/radial_dam_break_dry/radial_dam_break.py
r8890 r9174 50 50 alg, cfl = parse_standard_args() 51 51 domain.set_flow_algorithm(alg) 52 domain.set_CFL(cfl)52 #domain.set_CFL(cfl) 53 53 #domain.set_minimum_allowed_height(0.002) 54 54 -
trunk/anuga_core/validation_tests/other_references/radial_dam_break_wet/radial_dam_break.py
r8891 r9174 50 50 alg, cfl = parse_standard_args() 51 51 domain.set_flow_algorithm(alg) 52 domain.set_CFL(cfl)52 #domain.set_CFL(cfl) 53 53 54 54 #------------------------------------------------------------------------------ -
trunk/anuga_core/validation_tests/reports/all_tests_report.tex
r9147 r9174 91 91 %====================== 92 92 93 \inputresults{ analytical_exact/dam_break_dry}94 \inputresults{ analytical_exact/dam_break_wet}95 \inputresults{ analytical_exact/avalanche_dry}96 \inputresults{ analytical_exact/avalanche_wet}97 \inputresults{ analytical_exact/carrier_greenspan_periodic}98 \inputresults{ analytical_exact/carrier_greenspan_transient}99 \inputresults{ analytical_exact/deep_wave}100 \inputresults{ analytical_exact/mac_donald_short_channel}101 \inputresults{ analytical_exact/parabolic_basin}102 \inputresults{ analytical_exact/paraboloid_basin}103 104 \inputresults{ analytical_exact/runup_on_beach}105 \inputresults{ analytical_exact/runup_on_sinusoid_beach}106 \inputresults{ analytical_exact/landslide_tsunami}107 108 \inputresults{ analytical_exact/lake_at_rest_immersed_bump}109 \inputresults{ analytical_exact/lake_at_rest_steep_island}110 \inputresults{ analytical_exact/river_at_rest_varying_topo_width}111 \inputresults{ analytical_exact/rundown_mild_slope}112 \inputresults{ analytical_exact/rundown_mild_slope_coarse}113 \inputresults{ analytical_exact/subcritical_over_bump}114 \inputresults{ analytical_exact/transcritical_with_shock}115 \inputresults{ analytical_exact/transcritical_without_shock}116 \inputresults{ analytical_exact/trapezoidal_channel}93 \inputresults{../analytical_exact/dam_break_dry} 94 \inputresults{../analytical_exact/dam_break_wet} 95 \inputresults{../analytical_exact/avalanche_dry} 96 \inputresults{../analytical_exact/avalanche_wet} 97 \inputresults{../analytical_exact/carrier_greenspan_periodic} 98 \inputresults{../analytical_exact/carrier_greenspan_transient} 99 \inputresults{../analytical_exact/deep_wave} 100 \inputresults{../analytical_exact/mac_donald_short_channel} 101 \inputresults{../analytical_exact/parabolic_basin} 102 \inputresults{../analytical_exact/paraboloid_basin} 103 104 \inputresults{../analytical_exact/runup_on_beach} 105 \inputresults{../analytical_exact/runup_on_sinusoid_beach} 106 \inputresults{../analytical_exact/landslide_tsunami} 107 108 \inputresults{../analytical_exact/lake_at_rest_immersed_bump} 109 \inputresults{../analytical_exact/lake_at_rest_steep_island} 110 \inputresults{../analytical_exact/river_at_rest_varying_topo_width} 111 \inputresults{../analytical_exact/rundown_mild_slope} 112 \inputresults{../analytical_exact/rundown_mild_slope_coarse} 113 \inputresults{../analytical_exact/subcritical_over_bump} 114 \inputresults{../analytical_exact/transcritical_with_shock} 115 \inputresults{../analytical_exact/transcritical_without_shock} 116 \inputresults{../analytical_exact/trapezoidal_channel} 117 117 118 118 %%====================== 119 119 \chapter{Tests against reference data or solutions} \label{ch:ref} 120 120 %%====================== 121 \inputresults{ experimental_data/dam_break_yeh_petroff}122 \inputresults{ behaviour_only/lid_driven_cavity}123 124 \inputresults{ other_references/radial_dam_break_dry}125 \inputresults{ other_references/radial_dam_break_wet}126 127 \inputresults{ case_studies/okushiri}121 \inputresults{../experimental_data/dam_break_yeh_petroff} 122 \inputresults{../behaviour_only/lid_driven_cavity} 123 124 \inputresults{../other_references/radial_dam_break_dry} 125 \inputresults{../other_references/radial_dam_break_wet} 126 127 \inputresults{../case_studies/okushiri} 128 128 129 129 … … 151 151 \section{Algorithm Parameters} 152 152 Note that parameters can be communicated from the \verb|local_parameters.py| 153 file in the \verb| anuga_validation_tests| directory. If there is no file153 file in the \verb|validation_tests/reports| directory. If there is no file 154 154 \verb|local_parameters.py| then the parameters are taken from the 155 \verb| parameters.py| file. You should not change this file.155 \verb|anuga.validation_utilities.parameters|. 156 156 157 157 In particular the … … 160 160 test directories. 161 161 162 You can pass though the parameters straight from the \verb|parameters.py| fileas follows162 You can pass though the standard parameters as follows 163 163 \begin{verbatim} 164 from anuga _validation_tests.parameters import alg165 from anuga _validation_tests.parameters import cfl164 from anuga.validation_utilities.parameters import alg 165 from anuga.validation_utilities.parameters import cfl 166 166 \end{verbatim} 167 167 … … 172 172 173 173 \begin{verbatim} 174 from anuga _validation_test_utilities.fabricate import *175 from anuga _validation_test_utilities import run_validation_script174 from anuga.validation_utilities.fabricate import * 175 from anuga.validation_utilities import run_validation_script 176 176 177 177 # Setup the python scripts which produce the output for this … … 180 180 run_validation_script('run_problem.py') 181 181 run_validation_script('plot_problem.py') 182 run('python',' latex_report.py')182 run('python','typeset_report.py') 183 183 pass 184 184 -
trunk/anuga_core/validation_tests/reports/local-defs.tex
r9112 r9174 3 3 4 4 5 \newcommand{\inputresults}[1]{\graphicspath{{#1/}}\input{#1/results}} 5 \newcommand{\inputresults}[1]{\graphicspath{{../}{#1/}}\input{#1/results}} 6 %\newcommand{\inputresults}[1]{\graphicspath{{../}}\input{#1/results}}
Note: See TracChangeset
for help on using the changeset viewer.