Changeset 773
- Timestamp:
- Jan 21, 2005, 2:40:39 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/advection.py
r271 r773 10 10 u_t + (v_1 u)_x + (v_2 u)_y = 0 11 11 12 There is only one conserved quantity, the levelu12 There is only one conserved quantity, the stage u 13 13 14 14 The advection equation is a very simple specialisation of the generic … … 29 29 30 30 Generic_domain.__init__(self, coordinates, vertices, boundary, 31 [' level'])31 ['stage']) 32 32 33 33 if velocity is None: … … 47 47 Generic_domain.check_integrity(self) 48 48 49 msg = 'Conserved quantity must be " level"'50 assert self.conserved_quantities[0] == ' level', msg49 msg = 'Conserved quantity must be "stage"' 50 assert self.conserved_quantities[0] == 'stage', msg 51 51 52 52 … … 113 113 114 114 #Shortcuts 115 Level = self.quantities['level']115 Stage = self.quantities['stage'] 116 116 117 117 #Arrays 118 level = Level.edge_values118 stage = Stage.edge_values 119 119 120 level_bdry = Level.boundary_values120 stage_bdry = Stage.boundary_values 121 121 122 122 flux = zeros(1, Float) #Work array for summing up fluxes … … 129 129 for i in range(3): 130 130 #Quantities inside volume facing neighbour i 131 ql = level[k, i]131 ql = stage[k, i] 132 132 133 133 #Quantities at neighbour on nearest face … … 135 135 if n < 0: 136 136 m = -n-1 #Convert neg flag to index 137 qr = level_bdry[m]137 qr = stage_bdry[m] 138 138 else: 139 139 m = neighbour_edges[k,i] 140 qr = level[n, m]140 qr = stage[n, m] 141 141 142 142 … … 157 157 #quantities get updated 158 158 flux /= areas[k] 159 Level.explicit_update[k] = flux[0]159 Stage.explicit_update[k] = flux[0] 160 160 161 161 timestep = min(timestep, optimal_timestep) -
inundation/ga/storm_surge/pyvolution/bed_w_eden_boundary.py
r624 r773 55 55 ###################### 56 56 #Initial condition (constant) 57 domain.set_quantity(' level', 0.0)57 domain.set_quantity('stage', 0.0) 58 58 domain.check_integrity() 59 59 -
inundation/ga/storm_surge/pyvolution/bed_w_file_boundary.py
r624 r773 72 72 h = 0.5 73 73 h = 0.0 74 domain.set_quantity(' level', Constant_height(x_slope, h))74 domain.set_quantity('stage', Constant_height(x_slope, h)) 75 75 76 76 domain.check_integrity() -
inundation/ga/storm_surge/pyvolution/cornell_room.py
r489 r773 116 116 return z 117 117 118 domain.set_quantity(' level', height)118 domain.set_quantity('stage', height) 119 119 120 120 E = domain.quantities['elevation'].vertex_values 121 L = domain.quantities[' level'].vertex_values122 domain.set_quantity(' level', E+L)121 L = domain.quantities['stage'].vertex_values 122 domain.set_quantity('stage', E+L) 123 123 124 124 #Evolve -
inundation/ga/storm_surge/pyvolution/data_manager.py
r620 r773 321 321 322 322 #FIXME: Make this more general and rethink naming 323 if name == ' level':323 if name == 'stage': 324 324 stage[i,:] = A.astype(self.precision) 325 325 elif name == 'xmomentum': -
inundation/ga/storm_surge/pyvolution/flatbed.py
r664 r773 33 33 manning = 0.07 34 34 manning = 0.0 35 inflow_ level= 10.035 inflow_stage = 10.0 36 36 domain.set_quantity('friction', manning) 37 37 … … 53 53 domain.set_quantity('elevation', 54 54 Polygon_function([(p0,slope), (p1,wiggle), (p2,15)])) 55 #domain.set_quantity(' level',55 #domain.set_quantity('stage', 56 56 # Polygon_function([(p0,slope), (p1,wiggle), (p2,15)])) 57 57 … … 64 64 # Boundary conditions 65 65 Br = Reflective_boundary(domain) 66 Bd = Dirichlet_boundary([inflow_ level,0.,0.])66 Bd = Dirichlet_boundary([inflow_stage,0.,0.]) 67 67 68 68 domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) -
inundation/ga/storm_surge/pyvolution/flatbed_compare.py
r483 r773 47 47 domain.write_time() 48 48 49 print domain.quantities[' level'].centroid_values[:4]49 print domain.quantities['stage'].centroid_values[:4] 50 50 print domain.quantities['xmomentum'].centroid_values[:4] 51 51 print domain.quantities['ymomentum'].centroid_values[:4] 52 52 domain.distribute_to_vertices_and_edges() 53 53 print 54 print domain.quantities[' level'].vertex_values[:4,0]54 print domain.quantities['stage'].vertex_values[:4,0] 55 55 print domain.quantities['xmomentum'].vertex_values[:4,0] 56 56 print domain.quantities['ymomentum'].vertex_values[:4,0] -
inundation/ga/storm_surge/pyvolution/netherlands.py
r649 r773 160 160 # 161 161 print 'Initial condition' 162 domain.set_quantity(' level', Constant_height(Z, 0.))162 domain.set_quantity('stage', Constant_height(Z, 0.)) 163 163 164 164 #Evolve -
inundation/ga/storm_surge/pyvolution/pmesh2domain.py
r686 r773 33 33 #(when I get around to it) so it should be removed from here. 34 34 35 # set the water levelto be the elevation35 # set the water stage to be the elevation 36 36 # This doesn't work on the domain instance. 37 if vertex_quantity_dict.has_key('elevation') and not vertex_quantity_dict.has_key(' level'):38 vertex_quantity_dict[' level'] = vertex_quantity_dict['elevation']37 if vertex_quantity_dict.has_key('elevation') and not vertex_quantity_dict.has_key('stage'): 38 vertex_quantity_dict['stage'] = vertex_quantity_dict['elevation'] 39 39 domain.set_quantity_vertices_dict(vertex_quantity_dict) 40 40 #print "vertex_quantity_dict",vertex_quantity_dict -
inundation/ga/storm_surge/pyvolution/pressure_force.py
r566 r773 54 54 ymom = domain.quantities['ymomentum'].explicit_update 55 55 56 Level = domain.quantities['level']56 Stage = domain.quantities['stage'] 57 57 Elevation = domain.quantities['elevation'] 58 h = Level.vertex_values - Elevation.vertex_values58 h = Stage.vertex_values - Elevation.vertex_values 59 59 x = domain.get_vertex_coordinates() 60 60 … … 88 88 #Initial condition 89 89 h = 0.05 90 domain.set_quantity(' level', Constant_height(x_slope, h))90 domain.set_quantity('stage', Constant_height(x_slope, h)) 91 91 92 92 -
inundation/ga/storm_surge/pyvolution/quantity.py
r715 r773 377 377 378 378 379 # FIXME have a get_vertex_values as well, so the ' level' quantity can be379 # FIXME have a get_vertex_values as well, so the 'stage' quantity can be 380 380 # set, based on the elevation 381 381 def set_vertex_values(self, A, indexes = None): -
inundation/ga/storm_surge/pyvolution/realtime_visualisation.py
r324 r773 114 114 s=0 115 115 116 Q = domain.quantities[' level']116 Q = domain.quantities['stage'] 117 117 try: 118 118 Z = domain.quantities['elevation'] … … 196 196 197 197 198 Q = domain.quantities[' level']198 Q = domain.quantities['stage'] 199 199 N = Q.vertex_values.shape[0] 200 200 -
inundation/ga/storm_surge/pyvolution/run_profile.py
r515 r773 48 48 ###################### 49 49 #Initial condition 50 domain.set_quantity(' level', Constant_height(slope, 0.3))50 domain.set_quantity('stage', Constant_height(slope, 0.3)) 51 51 52 52 domain.check_integrity() -
inundation/ga/storm_surge/pyvolution/run_tsh_weir.py
r390 r773 82 82 83 83 #print domain.quantities['elevation'].vertex_values 84 #print domain.quantities[' level'].vertex_values84 #print domain.quantities['stage'].vertex_values 85 85 86 86 ###################### 87 87 #Initial condition 88 88 print 'Initial condition' 89 domain.set_quantity(' level', Constant_height(W, 0.))89 domain.set_quantity('stage', Constant_height(W, 0.)) 90 90 domain.check_integrity() 91 91 -
inundation/ga/storm_surge/pyvolution/shallow_water.py
r772 r773 67 67 tagged_elements = None): 68 68 69 conserved_quantities = [' level', 'xmomentum', 'ymomentum']69 conserved_quantities = ['stage', 'xmomentum', 'ymomentum'] 70 70 other_quantities = ['elevation', 'friction'] 71 71 … … 94 94 self.reduction = min #Looks better near steep slopes 95 95 96 self.quantities_to_be_stored = [' level']96 self.quantities_to_be_stored = ['stage'] 97 97 98 98 99 99 #Establish shortcuts to relevant quantities (for efficiency) 100 #self.w = self.quantities[' level']100 #self.w = self.quantities['stage'] 101 101 #self.uh = self.quantities['xmomentum'] 102 102 #self.vh = self.quantities['ymomentum'] … … 109 109 #Check that we are solving the shallow water wave equation 110 110 111 msg = 'First conserved quantity must be " level"'112 assert self.conserved_quantities[0] == ' level', msg111 msg = 'First conserved quantity must be "stage"' 112 assert self.conserved_quantities[0] == 'stage', msg 113 113 msg = 'Second conserved quantity must be "xmomentum"' 114 114 assert self.conserved_quantities[1] == 'xmomentum', msg … … 117 117 118 118 119 #Check that levels are >= bed elevation119 #Check that stages are >= bed elevation 120 120 from Numeric import alltrue, greater_equal 121 121 122 level = self.quantities['level']122 stage = self.quantities['stage'] 123 123 bed = self.quantities['elevation'] 124 124 … … 140 140 # This is specific to the shallow water wave equation 141 141 # Defaults for 'elevation', 'friction', 'xmomentum' and 'ymomentum' 142 # are 0.0. Default for ' level' is whatever the value of 'elevation'.142 # are 0.0. Default for 'stage' is whatever the value of 'elevation'. 143 143 # """ 144 144 … … 147 147 # print self.quantities.keys() 148 148 # if not self.quantities.has_key(name): 149 # if name == ' level':149 # if name == 'stage': 150 150 151 151 # if self.quantities.has_key('elevation'): … … 161 161 # #Lift negative heights up 162 162 # #z = self.quantities['elevation'].vertex_values 163 # #w = self.quantities[' level'].vertex_values163 # #w = self.quantities['stage'].vertex_values 164 164 165 165 # #h = w-z … … 171 171 172 172 173 # #self.quantities[' level'].interpolate()173 # #self.quantities['stage'].interpolate() 174 174 175 175 … … 206 206 #Store model data, e.g. for subsequent visualisation 207 207 if self.store is True: 208 #self.store_timestep([' level', 'xmomentum', 'ymomentum'])208 #self.store_timestep(['stage', 'xmomentum', 'ymomentum']) 209 209 self.store_timestep(self.quantities_to_be_stored) 210 210 … … 375 375 Resulting flux is then scaled by area and stored in 376 376 explicit_update for each of the three conserved quantities 377 level, xmomentum and ymomentum377 stage, xmomentum and ymomentum 378 378 379 379 The maximal allowable speed computed by the flux_function for each volume … … 392 392 393 393 #Shortcuts 394 Level = domain.quantities['level']394 Stage = domain.quantities['stage'] 395 395 Xmom = domain.quantities['xmomentum'] 396 396 Ymom = domain.quantities['ymomentum'] … … 398 398 399 399 #Arrays 400 level = Level.edge_values400 stage = Stage.edge_values 401 401 xmom = Xmom.edge_values 402 402 ymom = Ymom.edge_values 403 403 bed = Bed.edge_values 404 404 405 level_bdry = Level.boundary_values405 stage_bdry = Stage.boundary_values 406 406 xmom_bdry = Xmom.boundary_values 407 407 ymom_bdry = Ymom.boundary_values … … 416 416 for i in range(3): 417 417 #Quantities inside volume facing neighbour i 418 ql = [ level[k, i], xmom[k, i], ymom[k, i]]418 ql = [stage[k, i], xmom[k, i], ymom[k, i]] 419 419 zl = bed[k, i] 420 420 … … 423 423 if n < 0: 424 424 m = -n-1 #Convert negative flag to index 425 qr = [ level_bdry[m], xmom_bdry[m], ymom_bdry[m]]425 qr = [stage_bdry[m], xmom_bdry[m], ymom_bdry[m]] 426 426 zr = zl #Extend bed elevation to boundary 427 427 else: 428 428 m = domain.neighbour_edges[k,i] 429 qr = [ level[n, m], xmom[n, m], ymom[n, m]]429 qr = [stage[n, m], xmom[n, m], ymom[n, m]] 430 430 zr = bed[n, m] 431 431 … … 447 447 #quantities get updated 448 448 flux /= domain.areas[k] 449 Level.explicit_update[k] = flux[0]449 Stage.explicit_update[k] = flux[0] 450 450 Xmom.explicit_update[k] = flux[1] 451 451 Ymom.explicit_update[k] = flux[2] … … 465 465 466 466 #Shortcuts 467 Level = domain.quantities['level']467 Stage = domain.quantities['stage'] 468 468 Xmom = domain.quantities['xmomentum'] 469 469 Ymom = domain.quantities['ymomentum'] … … 479 479 domain.radii, 480 480 domain.areas, 481 Level.edge_values,481 Stage.edge_values, 482 482 Xmom.edge_values, 483 483 Ymom.edge_values, 484 484 Bed.edge_values, 485 Level.boundary_values,485 Stage.boundary_values, 486 486 Xmom.boundary_values, 487 487 Ymom.boundary_values, 488 Level.explicit_update,488 Stage.explicit_update, 489 489 Xmom.explicit_update, 490 490 Ymom.explicit_update) … … 549 549 550 550 #Shortcuts 551 wv = domain.quantities[' level'].vertex_values551 wv = domain.quantities['stage'].vertex_values 552 552 zv = domain.quantities['elevation'].vertex_values 553 553 xmomv = domain.quantities['xmomentum'].vertex_values … … 560 560 561 561 if hmax < domain.minimum_allowed_height: 562 #Control level562 #Control stage 563 563 wv[k, :] = zv[k, :] 564 564 … … 572 572 573 573 #Shortcuts 574 wc = domain.quantities[' level'].centroid_values574 wc = domain.quantities['stage'].centroid_values 575 575 zc = domain.quantities['elevation'].centroid_values 576 576 xmomc = domain.quantities['xmomentum'].centroid_values … … 582 582 583 583 if hc[k] < domain.minimum_allowed_height: 584 #Control level584 #Control stage 585 585 wc[k] = zc[k] 586 586 … … 595 595 596 596 #Shortcuts 597 wc = domain.quantities[' level'].centroid_values597 wc = domain.quantities['stage'].centroid_values 598 598 zc = domain.quantities['elevation'].centroid_values 599 599 xmomc = domain.quantities['xmomentum'].centroid_values … … 617 617 618 618 #Shortcuts 619 wc = domain.quantities[' level'].centroid_values619 wc = domain.quantities['stage'].centroid_values 620 620 zc = domain.quantities['elevation'].centroid_values 621 621 hc = wc - zc 622 622 623 wv = domain.quantities[' level'].vertex_values623 wv = domain.quantities['stage'].vertex_values 624 624 zv = domain.quantities['elevation'].vertex_values 625 625 hv = wv-zv 626 626 627 627 628 #Computed linear combination between constant levels and and629 # levels parallel to the bed elevation.628 #Computed linear combination between constant stages and and 629 #stages parallel to the bed elevation. 630 630 for k in range(domain.number_of_elements): 631 631 #Compute maximal variation in bed elevation … … 695 695 696 696 #Shortcuts 697 wc = domain.quantities[' level'].centroid_values697 wc = domain.quantities['stage'].centroid_values 698 698 zc = domain.quantities['elevation'].centroid_values 699 699 hc = wc - zc 700 700 701 wv = domain.quantities[' level'].vertex_values701 wv = domain.quantities['stage'].vertex_values 702 702 zv = domain.quantities['elevation'].vertex_values 703 703 hv = wv-zv … … 739 739 740 740 #Handy shorthands 741 self. level = domain.quantities['level'].edge_values741 self.stage = domain.quantities['stage'].edge_values 742 742 self.xmom = domain.quantities['xmomentum'].edge_values 743 743 self.ymom = domain.quantities['ymomentum'].edge_values … … 757 757 758 758 q = self.conserved_quantities 759 q[0] = self. level[vol_id, edge_id]759 q[0] = self.stage[vol_id, edge_id] 760 760 q[1] = self.xmom[vol_id, edge_id] 761 761 q[2] = self.ymom[vol_id, edge_id] … … 784 784 ymom = domain.quantities['ymomentum'].explicit_update 785 785 786 Level = domain.quantities['level']786 Stage = domain.quantities['stage'] 787 787 Elevation = domain.quantities['elevation'] 788 h = Level.edge_values - Elevation.edge_values788 h = Stage.edge_values - Elevation.edge_values 789 789 v = Elevation.vertex_values 790 790 … … 813 813 ymom = domain.quantities['ymomentum'].explicit_update 814 814 815 Level = domain.quantities['level']815 Stage = domain.quantities['stage'] 816 816 Elevation = domain.quantities['elevation'] 817 h = Level.edge_values - Elevation.edge_values817 h = Stage.edge_values - Elevation.edge_values 818 818 v = Elevation.vertex_values 819 819 … … 832 832 from math import sqrt 833 833 834 w = domain.quantities[' level'].centroid_values834 w = domain.quantities['stage'].centroid_values 835 835 z = domain.quantities['elevation'].centroid_values 836 836 h = w-z … … 866 866 ymom = domain.quantities['ymomentum'] 867 867 868 w = domain.quantities[' level'].centroid_values868 w = domain.quantities['stage'].centroid_values 869 869 z = domain.quantities['elevation'].centroid_values 870 870 … … 892 892 from math import sqrt 893 893 894 w = domain.quantities[' level'].centroid_values894 w = domain.quantities['stage'].centroid_values 895 895 z = domain.quantities['elevation'].centroid_values 896 896 h = w-z -
inundation/ga/storm_surge/pyvolution/shallow_water_ext.c
r767 r773 198 198 double dz, hmin, alpha; 199 199 200 //Compute linear combination between constant levels and and201 // levels parallel to the bed elevation.200 //Compute linear combination between constant stages and and 201 //stages parallel to the bed elevation. 202 202 203 203 for (k=0; k<N; k++) { … … 473 473 Resulting flux is then scaled by area and stored in 474 474 explicit_update for each of the three conserved quantities 475 level, xmomentum and ymomentum475 stage, xmomentum and ymomentum 476 476 477 477 The maximal allowable speed computed by the flux_function for each volume … … 489 489 domain.radii, 490 490 domain.areas, 491 Level.edge_values,491 Stage.edge_values, 492 492 Xmom.edge_values, 493 493 Ymom.edge_values, 494 494 Bed.edge_values, 495 Level.boundary_values,495 Stage.boundary_values, 496 496 Xmom.boundary_values, 497 497 Ymom.boundary_values, 498 Level.explicit_update,498 Stage.explicit_update, 499 499 Xmom.explicit_update, 500 500 Ymom.explicit_update) … … 511 511 PyArrayObject *neighbours, *neighbour_edges, 512 512 *normals, *edgelengths, *radii, *areas, 513 * level_edge_values,513 *stage_edge_values, 514 514 *xmom_edge_values, 515 515 *ymom_edge_values, 516 516 *bed_edge_values, 517 * level_boundary_values,517 *stage_boundary_values, 518 518 *xmom_boundary_values, 519 519 *ymom_boundary_values, 520 * level_explicit_update,520 *stage_explicit_update, 521 521 *xmom_explicit_update, 522 522 *ymom_explicit_update; … … 541 541 &normals, 542 542 &edgelengths, &radii, &areas, 543 & level_edge_values,543 &stage_edge_values, 544 544 &xmom_edge_values, 545 545 &ymom_edge_values, 546 546 &bed_edge_values, 547 & level_boundary_values,547 &stage_boundary_values, 548 548 &xmom_boundary_values, 549 549 &ymom_boundary_values, 550 & level_explicit_update,550 &stage_explicit_update, 551 551 &xmom_explicit_update, 552 552 &ymom_explicit_update)) { … … 555 555 } 556 556 557 number_of_elements = level_edge_values -> dimensions[0];557 number_of_elements = stage_edge_values -> dimensions[0]; 558 558 559 559 … … 566 566 for (i=0; i<3; i++) { 567 567 ki = k*3+i; 568 ql[0] = ((double *) level_edge_values -> data)[ki];568 ql[0] = ((double *) stage_edge_values -> data)[ki]; 569 569 ql[1] = ((double *) xmom_edge_values -> data)[ki]; 570 570 ql[2] = ((double *) ymom_edge_values -> data)[ki]; … … 575 575 if (n < 0) { 576 576 m = -n-1; //Convert negative flag to index 577 qr[0] = ((double *) level_boundary_values -> data)[m];577 qr[0] = ((double *) stage_boundary_values -> data)[m]; 578 578 qr[1] = ((double *) xmom_boundary_values -> data)[m]; 579 579 qr[2] = ((double *) ymom_boundary_values -> data)[m]; … … 583 583 584 584 nm = n*3+m; 585 qr[0] = ((double *) level_edge_values -> data)[nm];585 qr[0] = ((double *) stage_edge_values -> data)[nm]; 586 586 qr[1] = ((double *) xmom_edge_values -> data)[nm]; 587 587 qr[2] = ((double *) ymom_edge_values -> data)[nm]; … … 625 625 } 626 626 627 ((double *) level_explicit_update -> data)[k] = flux[0];627 ((double *) stage_explicit_update -> data)[k] = flux[0]; 628 628 ((double *) xmom_explicit_update -> data)[k] = flux[1]; 629 629 ((double *) ymom_explicit_update -> data)[k] = flux[2]; … … 642 642 643 643 PyArrayObject 644 *wc, // Levelat centroids644 *wc, //Stage at centroids 645 645 *zc, //Elevation at centroids 646 646 *xmomc, //Momentums at centroids … … 678 678 679 679 PyArrayObject 680 *wc, // Levelat centroids680 *wc, //Stage at centroids 681 681 *zc, //Elevation at centroids 682 682 *hc, //Height at centroids 683 *wv, // Levelat vertices683 *wv, //Stage at vertices 684 684 *zv, //Elevation at vertices 685 685 *hv, //Heights at vertices -
inundation/ga/storm_surge/pyvolution/show_balanced_limiters.py
r305 r773 77 77 # 78 78 print 'Initial condition' 79 domain.set_quantity(' level', Constant_height(Z, 0.))79 domain.set_quantity('stage', Constant_height(Z, 0.)) 80 80 81 81 from Numeric import allclose -
inundation/ga/storm_surge/pyvolution/test_advection.py
r648 r773 31 31 domain.check_integrity() 32 32 33 assert domain.quantities.has_key(' level')33 assert domain.quantities.has_key('stage') 34 34 35 35 assert domain.get_conserved_quantities(0, edge=1) == 0. … … 49 49 #Populate boundary array with dirichlet conditions. 50 50 domain.neighbours = array([[-1,-2,-3]]) 51 domain.quantities[' level'].boundary_values[:] = 1.051 domain.quantities['stage'].boundary_values[:] = 1.0 52 52 53 53 domain.order = 1 … … 58 58 59 59 domain.compute_fluxes() 60 U = -domain.quantities[' level'].explicit_update60 U = -domain.quantities['stage'].explicit_update 61 61 R = -0.5/domain.areas[0] 62 62 … … 75 75 domain.check_integrity() 76 76 77 domain.set_quantity(' level', [1.0], 'centroids')77 domain.set_quantity('stage', [1.0], 'centroids') 78 78 79 79 domain.distribute_to_vertices_and_edges() … … 82 82 83 83 domain.compute_fluxes() 84 U = -domain.quantities[' level'].explicit_update84 U = -domain.quantities['stage'].explicit_update 85 85 R = 0.5/domain.areas[0] 86 86 … … 103 103 #Populate boundary array with dirichlet conditions. 104 104 domain.neighbours = array([[-1,-2,-3]]) 105 domain.quantities[' level'].boundary_values[0] = 1.0105 domain.quantities['stage'].boundary_values[0] = 1.0 106 106 107 107 domain.distribute_to_vertices_and_edges() #Use first order default … … 110 110 111 111 domain.compute_fluxes() 112 U = domain.quantities[' level'].explicit_update112 U = domain.quantities['stage'].explicit_update 113 113 assert allclose(U, 0) 114 114 … … 134 134 #Populate boundary array with dirichlet conditions. 135 135 domain.neighbours = array([[1,-1,-2], [0,-3,-4]]) 136 domain.set_quantity(' level', [1.0, 0.0], 'centroids')136 domain.set_quantity('stage', [1.0, 0.0], 'centroids') 137 137 domain.distribute_to_vertices_and_edges() 138 138 139 139 domain.compute_fluxes() 140 140 141 X = domain.quantities[' level'].explicit_update141 X = domain.quantities['stage'].explicit_update 142 142 assert X[0] == -X[1] 143 143 … … 164 164 #Check that the boundary value gets propagated to all elements 165 165 for t in domain.evolve(yieldstep = 0.05, finaltime = 10): 166 if allclose(domain.quantities[' level'].centroid_values, 3.1415):166 if allclose(domain.quantities['stage'].centroid_values, 3.1415): 167 167 break 168 168 169 assert allclose(domain.quantities[' level'].centroid_values, 3.1415)169 assert allclose(domain.quantities['stage'].centroid_values, 3.1415) 170 170 171 171 -
inundation/ga/storm_surge/pyvolution/test_data_manager.py
r751 r773 41 41 42 42 bed = domain.quantities['elevation'].vertex_values 43 level= zeros(bed.shape, Float)43 stage = zeros(bed.shape, Float) 44 44 45 45 h = 0.3 46 for i in range( level.shape[0]):46 for i in range(stage.shape[0]): 47 47 if i % 2 == 0: 48 level[i,:] = bed[i,:] + h48 stage[i,:] = bed[i,:] + h 49 49 else: 50 level[i,:] = bed[i,:]50 stage[i,:] = bed[i,:] 51 51 52 domain.set_quantity(' level', level)53 self.initial_ level = copy.copy(domain.quantities['level'].vertex_values)52 domain.set_quantity('stage', stage) 53 self.initial_stage = copy.copy(domain.quantities['stage'].vertex_values) 54 54 55 55 domain.distribute_to_vertices_and_edges() … … 246 246 sww = get_dataobject(self.domain) 247 247 sww.store_connectivity() 248 sww.store_timestep(' level')248 sww.store_timestep('stage') 249 249 250 250 #Check contents … … 261 261 262 262 263 Q = self.domain.quantities[' level']263 Q = self.domain.quantities['stage'] 264 264 Q0 = Q.vertex_values[:,0] 265 265 Q1 = Q.vertex_values[:,1] … … 302 302 sww = get_dataobject(self.domain) 303 303 sww.store_connectivity() 304 sww.store_timestep(' level')304 sww.store_timestep('stage') 305 305 self.domain.evolve_to_end(finaltime = 0.01) 306 sww.store_timestep(' level')306 sww.store_timestep('stage') 307 307 308 308 … … 319 319 320 320 #Check values 321 Q = self.domain.quantities[' level']321 Q = self.domain.quantities['stage'] 322 322 Q0 = Q.vertex_values[:,0] 323 323 Q1 = Q.vertex_values[:,1] … … 359 359 sww = get_dataobject(self.domain) 360 360 sww.store_connectivity() 361 sww.store_timestep(' level')361 sww.store_timestep('stage') 362 362 363 363 self.domain.evolve_to_end(finaltime = 0.01) 364 sww.store_timestep(' level')364 sww.store_timestep('stage') 365 365 366 366 … … 380 380 #Check values 381 381 #Check values 382 Q = self.domain.quantities[' level']382 Q = self.domain.quantities['stage'] 383 383 Q0 = Q.vertex_values[:,0] 384 384 Q1 = Q.vertex_values[:,1] … … 417 417 #Evolution 418 418 for t in self.domain.evolve(yieldstep = 1.0, finaltime = 4.0): 419 level = self.domain.quantities['level'].vertex_values419 stage = self.domain.quantities['stage'].vertex_values 420 420 421 421 #Get NetCDF 422 422 fid = NetCDFFile(self.domain.writer.filename, 'r') 423 stage = fid.variables['stage']423 stage_file = fid.variables['stage'] 424 424 425 425 if t == 0.0: 426 assert allclose( level, self.initial_level)427 assert allclose(stage [:], level.flat)426 assert allclose(stage, self.initial_stage) 427 assert allclose(stage_file[:], stage.flat) 428 428 else: 429 assert not allclose( level, self.initial_level)430 assert not allclose(stage [:], level.flat)429 assert not allclose(stage, self.initial_stage) 430 assert not allclose(stage_file[:], stage.flat) 431 431 432 432 fid.close() … … 450 450 sww = get_dataobject(self.domain) 451 451 sww.store_connectivity() 452 sww.store_timestep(' level')452 sww.store_timestep('stage') 453 453 454 454 #Check contents -
inundation/ga/storm_surge/pyvolution/test_domain.py
r700 r773 53 53 vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4], [3,0,5], [3,0,4]] 54 54 55 conserved_quantities = [' level', 'xmomentum', 'ymomentum']55 conserved_quantities = ['stage', 'xmomentum', 'ymomentum'] 56 56 other_quantities = ['elevation', 'friction'] 57 57 … … 82 82 domain = Domain(points, vertices, boundary=None, 83 83 conserved_quantities =\ 84 [' level', 'xmomentum', 'ymomentum'])85 86 87 domain.set_quantity(' level', [[1,2,3], [5,5,5],84 ['stage', 'xmomentum', 'ymomentum']) 85 86 87 domain.set_quantity('stage', [[1,2,3], [5,5,5], 88 88 [0,0,9], [-6, 3, 3], 89 89 [0,0,0], [0,0,0]]) … … 182 182 domain = Domain(points, vertices, boundary, 183 183 conserved_quantities =\ 184 [' level', 'xmomentum', 'ymomentum'])185 domain.check_integrity() 186 187 188 189 domain.set_quantity(' level', [[1,2,3], [5,5,5],184 ['stage', 'xmomentum', 'ymomentum']) 185 domain.check_integrity() 186 187 188 189 domain.set_quantity('stage', [[1,2,3], [5,5,5], 190 190 [0,0,9], [-6, 3, 3]]) 191 191 … … 196 196 domain.update_boundary() 197 197 198 assert domain.quantities[' level'].boundary_values[0] == 5. #Dirichlet199 assert domain.quantities[' level'].boundary_values[1] == 5. #Dirichlet200 assert domain.quantities[' level'].boundary_values[2] ==\198 assert domain.quantities['stage'].boundary_values[0] == 5. #Dirichlet 199 assert domain.quantities['stage'].boundary_values[1] == 5. #Dirichlet 200 assert domain.quantities['stage'].boundary_values[2] ==\ 201 201 domain.get_conserved_quantities(2, edge=0)[0] #Transmissive (4.5) 202 assert domain.quantities[' level'].boundary_values[3] ==\202 assert domain.quantities['stage'].boundary_values[3] ==\ 203 203 domain.get_conserved_quantities(2, edge=1)[0] #Transmissive (4.5) 204 assert domain.quantities[' level'].boundary_values[4] ==\204 assert domain.quantities['stage'].boundary_values[4] ==\ 205 205 domain.get_conserved_quantities(3, edge=1)[0] #Transmissive (-1.5) 206 assert domain.quantities[' level'].boundary_values[5] ==\206 assert domain.quantities['stage'].boundary_values[5] ==\ 207 207 domain.get_conserved_quantities(3, edge=2)[0] #Transmissive (-1.5) 208 208 … … 238 238 domain = Domain(points, vertices, boundary, 239 239 conserved_quantities =\ 240 [' level', 'xmomentum', 'ymomentum'])241 domain.check_integrity() 242 243 244 domain.set_quantity(' level', [[1,2,3], [5,5,5],240 ['stage', 'xmomentum', 'ymomentum']) 241 domain.check_integrity() 242 243 244 domain.set_quantity('stage', [[1,2,3], [5,5,5], 245 245 [0,0,9], [-6, 3, 3]]) 246 246 247 assert allclose( domain.quantities[' level'].centroid_values,247 assert allclose( domain.quantities['stage'].centroid_values, 248 248 [2,5,3,0] ) 249 249 … … 258 258 259 259 #First order extrapolation 260 assert allclose( domain.quantities[' level'].vertex_values,260 assert allclose( domain.quantities['stage'].vertex_values, 261 261 [[ 2., 2., 2.], 262 262 [ 5., 5., 5.], … … 288 288 domain = Domain(points, vertices, boundary, 289 289 conserved_quantities =\ 290 [' level', 'xmomentum', 'ymomentum'])291 domain.check_integrity() 292 293 294 domain.set_quantity(' level', [1,2,3,4], 'centroids')290 ['stage', 'xmomentum', 'ymomentum']) 291 domain.check_integrity() 292 293 294 domain.set_quantity('stage', [1,2,3,4], 'centroids') 295 295 domain.set_quantity('xmomentum', [1,2,3,4], 'centroids') 296 296 domain.set_quantity('ymomentum', [1,2,3,4], 'centroids') … … 342 342 domain = Domain(points, vertices, boundary, 343 343 conserved_quantities =\ 344 [' level', 'xmomentum', 'ymomentum'])345 domain.check_integrity() 346 347 domain.set_quantity(' level', [[1,2,3], [5,5,5],344 ['stage', 'xmomentum', 'ymomentum']) 345 domain.check_integrity() 346 347 domain.set_quantity('stage', [[1,2,3], [5,5,5], 348 348 [0,0,9], [-6, 3, 3]]) 349 349 350 assert allclose( domain.quantities[' level'].centroid_values,350 assert allclose( domain.quantities['stage'].centroid_values, 351 351 [2,5,3,0] ) 352 352 … … 361 361 362 362 #First order extrapolation 363 assert allclose( domain.quantities[' level'].vertex_values,363 assert allclose( domain.quantities['stage'].vertex_values, 364 364 [[ 2., 2., 2.], 365 365 [ 5., 5., 5.], -
inundation/ga/storm_surge/pyvolution/test_generic_boundary_conditions.py
r648 r773 66 66 domain.check_integrity() 67 67 68 domain.conserved_quantities = [' level', 'ymomentum']69 domain.quantities[' level'] =\68 domain.conserved_quantities = ['stage', 'ymomentum'] 69 domain.quantities['stage'] =\ 70 70 Quantity(domain, [[1,2,3], [5,5,5], 71 71 [0,0,9], [-6, 3, 3]]) … … 124 124 125 125 domain = Domain(points, elements) 126 domain.conserved_quantities = [' level', 'ymomentum']127 domain.quantities[' level'] =\126 domain.conserved_quantities = ['stage', 'ymomentum'] 127 domain.quantities['stage'] =\ 128 128 Quantity(domain, [[1,2,3], [5,5,5], 129 129 [0,0,9], [-6, 3, 3]]) … … 193 193 194 194 domain = Domain(points, elements) 195 domain.conserved_quantities = [' level', 'xmomentum', 'ymomentum']196 domain.quantities[' level'] =\195 domain.conserved_quantities = ['stage', 'xmomentum', 'ymomentum'] 196 domain.quantities['stage'] =\ 197 197 Quantity(domain, [[1,2,3], [5,5,5], 198 198 [0,0,9], [-6, 3, 3]]) -
inundation/ga/storm_surge/pyvolution/test_interpolate_sww.py
r631 r773 46 46 47 47 bed = domain.quantities['elevation'].vertex_values 48 level= zeros(bed.shape, Float)48 stage = zeros(bed.shape, Float) 49 49 50 50 h = 0.3 51 for i in range( level.shape[0]):51 for i in range(stage.shape[0]): 52 52 if i % 2 == 0: 53 level[i,:] = bed[i,:] + h53 stage[i,:] = bed[i,:] + h 54 54 else: 55 level[i,:] = bed[i,:]55 stage[i,:] = bed[i,:] 56 56 57 domain.set_quantity(' level', level)57 domain.set_quantity('stage', stage) 58 58 59 59 domain.distribute_to_vertices_and_edges() … … 87 87 sww = get_dataobject(self.domain) 88 88 sww.store_connectivity() 89 sww.store_timestep(' level')89 sww.store_timestep('stage') 90 90 self.domain.time = 2. 91 sww.store_timestep(' level')91 sww.store_timestep('stage') 92 92 93 93 #Check contents … … 154 154 sww = get_dataobject(self.domain) 155 155 sww.store_connectivity() 156 sww.store_timestep(' level')156 sww.store_timestep('stage') 157 157 self.domain.time = 2. 158 sww.store_timestep(' level')158 sww.store_timestep('stage') 159 159 160 160 #print "self.domain.filename",self.domain.filename -
inundation/ga/storm_surge/pyvolution/test_pmesh2domain.py
r716 r773 45 45 # Vert att title \n \ 46 46 elevation \n \ 47 level\n \47 stage \n \ 48 48 friction \n \ 49 49 2 # <triangle #> [<vertex #>] [<neigbouring triangle #>] \n\ … … 85 85 answer) 86 86 87 #print domain.quantities[' level'].vertex_values87 #print domain.quantities['stage'].vertex_values 88 88 answer = [[0., 12., 10.], 89 89 [0., 10., 12.]] 90 assert allclose(domain.quantities[' level'].vertex_values,90 assert allclose(domain.quantities['stage'].vertex_values, 91 91 answer) 92 92 -
inundation/ga/storm_surge/pyvolution/test_quantity.py
r765 r773 538 538 539 539 bed = domain.quantities['elevation'].vertex_values 540 level= zeros(bed.shape, Float)540 stage = zeros(bed.shape, Float) 541 541 542 542 h = 0.03 543 for i in range( level.shape[0]):543 for i in range(stage.shape[0]): 544 544 if i % 2 == 0: 545 level[i,:] = bed[i,:] + h545 stage[i,:] = bed[i,:] + h 546 546 else: 547 level[i,:] = bed[i,:]547 stage[i,:] = bed[i,:] 548 548 549 domain.set_quantity(' level', level)550 551 level = domain.quantities['level']552 553 #Get smoothed level554 A, V = level.get_vertex_values(xy=False, smooth=True)555 Q = level.vertex_values549 domain.set_quantity('stage', stage) 550 551 stage = domain.quantities['stage'] 552 553 #Get smoothed stage 554 A, V = stage.get_vertex_values(xy=False, smooth=True) 555 Q = stage.vertex_values 556 556 557 557 … … 581 581 assert allclose(V[7,:], [5,4,8]) 582 582 583 #Get smoothed levelwith XY584 X, Y, A1, V1 = level.get_vertex_values(xy=True, smooth=True)583 #Get smoothed stage with XY 584 X, Y, A1, V1 = stage.get_vertex_values(xy=True, smooth=True) 585 585 586 586 assert allclose(A, A1) … … 623 623 624 624 bed = domain.quantities['elevation'].vertex_values 625 level= zeros(bed.shape, Float)625 stage = zeros(bed.shape, Float) 626 626 627 627 h = 0.03 628 for i in range( level.shape[0]):628 for i in range(stage.shape[0]): 629 629 if i % 2 == 0: 630 level[i,:] = bed[i,:] + h630 stage[i,:] = bed[i,:] + h 631 631 else: 632 level[i,:] = bed[i,:]632 stage[i,:] = bed[i,:] 633 633 634 domain.set_quantity(' level', level)635 636 #Get level637 level = domain.quantities['level']638 A, V = level.get_vertex_values(xy=False, smooth=False)639 Q = level.vertex_values.flat634 domain.set_quantity('stage', stage) 635 636 #Get stage 637 stage = domain.quantities['stage'] 638 A, V = stage.get_vertex_values(xy=False, smooth=False) 639 Q = stage.vertex_values.flat 640 640 641 641 for k in range(8): … … 650 650 651 651 652 X, Y, A1, V1 = level.get_vertex_values(xy=True, smooth=False)652 X, Y, A1, V1 = stage.get_vertex_values(xy=True, smooth=False) 653 653 654 654 -
inundation/ga/storm_surge/pyvolution/test_region.py
r715 r773 79 79 80 80 domain.set_quantity('elevation', 10.0) 81 domain.set_quantity(' level', 10.0)82 domain.set_region(Add_value_to_region('top', ' level', 1.0,initial_quantity='elevation'))83 #print domain.quantities[' level'].get_values()84 assert allclose(domain.quantities[' level'].get_values(),81 domain.set_quantity('stage', 10.0) 82 domain.set_region(Add_value_to_region('top', 'stage', 1.0,initial_quantity='elevation')) 83 #print domain.quantities['stage'].get_values() 84 assert allclose(domain.quantities['stage'].get_values(), 85 85 [[ 10., 10., 10.], 86 86 [ 10., 10., 10.], -
inundation/ga/storm_surge/pyvolution/test_shallow_water.py
r767 r773 187 187 domain.check_integrity() 188 188 189 for name in [' level', 'xmomentum', 'ymomentum',189 for name in ['stage', 'xmomentum', 'ymomentum', 190 190 'elevation', 'friction']: 191 191 assert domain.quantities.has_key(name) … … 219 219 220 220 221 domain.set_quantity(' level', [[1,2,3], [5,5,5],221 domain.set_quantity('stage', [[1,2,3], [5,5,5], 222 222 [0,0,9], [-6, 3, 3]]) 223 223 … … 236 236 domain.update_boundary() 237 237 238 # Level239 assert domain.quantities[' level'].boundary_values[0] == 2.5240 assert domain.quantities[' level'].boundary_values[0] ==\238 #Stage 239 assert domain.quantities['stage'].boundary_values[0] == 2.5 240 assert domain.quantities['stage'].boundary_values[0] ==\ 241 241 domain.get_conserved_quantities(0, edge=0)[0] #Reflective (2.5) 242 assert domain.quantities[' level'].boundary_values[1] == 5. #Dirichlet243 assert domain.quantities[' level'].boundary_values[2] ==\242 assert domain.quantities['stage'].boundary_values[1] == 5. #Dirichlet 243 assert domain.quantities['stage'].boundary_values[2] ==\ 244 244 domain.get_conserved_quantities(2, edge=0)[0] #Transmissive (4.5) 245 assert domain.quantities[' level'].boundary_values[3] ==\245 assert domain.quantities['stage'].boundary_values[3] ==\ 246 246 domain.get_conserved_quantities(2, edge=1)[0] #Transmissive (4.5) 247 assert domain.quantities[' level'].boundary_values[4] ==\247 assert domain.quantities['stage'].boundary_values[4] ==\ 248 248 domain.get_conserved_quantities(3, edge=1)[0] #Transmissive (-1.5) 249 assert domain.quantities[' level'].boundary_values[5] ==\249 assert domain.quantities['stage'].boundary_values[5] ==\ 250 250 domain.get_conserved_quantities(3, edge=2)[0] #Reflective (-1.5) 251 251 … … 295 295 296 296 297 domain.set_quantity(' level', [[1,2,3], [5,5,5],297 domain.set_quantity('stage', [[1,2,3], [5,5,5], 298 298 [0,0,9], [-6, 3, 3]]) 299 299 … … 317 317 def test_compute_fluxes0(self): 318 318 #Do a full triangle and check that fluxes cancel out for 319 #the constant levelcase319 #the constant stage case 320 320 321 321 a = [0.0, 0.0] … … 331 331 332 332 domain = Domain(points, vertices) 333 domain.set_quantity(' level', [[2,2,2], [2,2,2],333 domain.set_quantity('stage', [[2,2,2], [2,2,2], 334 334 [2,2,2], [2,2,2]]) 335 335 domain.check_integrity() … … 387 387 domain.compute_fluxes() 388 388 389 for name in [' level', 'xmomentum', 'ymomentum']:389 for name in ['stage', 'xmomentum', 'ymomentum']: 390 390 #print name, domain.quantities[name].explicit_update 391 391 assert allclose(domain.quantities[name].explicit_update[1], 0) … … 413 413 val3 = 2.+8.0/3 414 414 415 domain.set_quantity(' level', [[val0, val0, val0], [val1, val1, val1],415 domain.set_quantity('stage', [[val0, val0, val0], [val1, val1, val1], 416 416 [val2, val2, val2], [val3, val3, val3]]) 417 417 domain.check_integrity() … … 457 457 458 458 #assert allclose(total_flux, domain.explicit_update[1,:]) 459 for i, name in enumerate([' level', 'xmomentum', 'ymomentum']):459 for i, name in enumerate(['stage', 'xmomentum', 'ymomentum']): 460 460 assert allclose(total_flux[i], 461 461 domain.quantities[name].explicit_update[1]) … … 467 467 # [-35.68522449, 0., 69.68888889]]) 468 468 469 assert allclose(domain.quantities[' level'].explicit_update,469 assert allclose(domain.quantities['stage'].explicit_update, 470 470 [0., -0.68218178, -111.77316251, -35.68522449]) 471 471 assert allclose(domain.quantities['xmomentum'].explicit_update, … … 506 506 507 507 508 domain.set_quantity(' level', [[val0, val0-1, val0-2],508 domain.set_quantity('stage', [[val0, val0-1, val0-2], 509 509 [val1, val1+1, val1], 510 510 [val2, val2-2, val2], … … 551 551 552 552 domain.compute_fluxes() 553 for i, name in enumerate([' level', 'xmomentum', 'ymomentum']):553 for i, name in enumerate(['stage', 'xmomentum', 'ymomentum']): 554 554 assert allclose(total_flux[i], 555 555 domain.quantities[name].explicit_update[1]) … … 577 577 val3 = 2.+8.0/3 578 578 579 zl=zr=-3.75 #Assume constant bed (must be less than level)579 zl=zr=-3.75 #Assume constant bed (must be less than stage) 580 580 domain.set_quantity('elevation', zl*ones( (4,3) )) 581 581 582 582 583 domain.set_quantity(' level', [[val0, val0-1, val0-2],583 domain.set_quantity('stage', [[val0, val0-1, val0-2], 584 584 [val1, val1+1, val1], 585 585 [val2, val2-2, val2], … … 625 625 626 626 domain.compute_fluxes() 627 for i, name in enumerate([' level', 'xmomentum', 'ymomentum']):627 for i, name in enumerate(['stage', 'xmomentum', 'ymomentum']): 628 628 assert allclose(total_flux[i], 629 629 domain.quantities[name].explicit_update[1]) … … 652 652 zl=zr=4 #Too large 653 653 domain.set_quantity('elevation', zl*ones( (4,3) )) 654 domain.set_quantity(' level', [[val0, val0-1, val0-2],654 domain.set_quantity('stage', [[val0, val0-1, val0-2], 655 655 [val1, val1+1, val1], 656 656 [val2, val2-2, val2], … … 692 692 693 693 h = 0.1 694 def level(x,y):694 def stage(x,y): 695 695 return slope(x,y)+h 696 696 697 697 domain.set_quantity('elevation', slope) 698 domain.set_quantity(' level', level)699 700 initial_ level = copy.copy(domain.quantities['level'].vertex_values)698 domain.set_quantity('stage', stage) 699 700 initial_stage = copy.copy(domain.quantities['stage'].vertex_values) 701 701 702 702 domain.set_boundary({'exterior': Reflective_boundary(domain)}) … … 704 704 #Evolution 705 705 for t in domain.evolve(yieldstep = 1.0, finaltime = 2.0): 706 level = domain.quantities['level'].vertex_values706 stage = domain.quantities['stage'].vertex_values 707 707 708 708 if t == 0.0: 709 assert allclose( level, initial_level)709 assert allclose(stage, initial_stage) 710 710 else: 711 assert not allclose( level, initial_level)711 assert not allclose(stage, initial_stage) 712 712 713 713 … … 738 738 739 739 h = 0.1 740 def level(x,y):740 def stage(x,y): 741 741 return slope(x,y)+h 742 742 743 743 domain.set_quantity('elevation', slope) 744 domain.set_quantity(' level', level)744 domain.set_quantity('stage', stage) 745 745 746 746 for name in domain.conserved_quantities: … … 750 750 domain.compute_forcing_terms() 751 751 752 assert allclose(domain.quantities[' level'].explicit_update, 0)752 assert allclose(domain.quantities['stage'].explicit_update, 0) 753 753 assert allclose(domain.quantities['xmomentum'].explicit_update, -g*h*3) 754 754 assert allclose(domain.quantities['ymomentum'].explicit_update, 0) … … 776 776 777 777 h = 0.1 778 def level(x,y):778 def stage(x,y): 779 779 return slope(x,y)+h 780 780 781 781 eta = 0.07 782 782 domain.set_quantity('elevation', slope) 783 domain.set_quantity(' level', level)783 domain.set_quantity('stage', stage) 784 784 domain.set_quantity('friction', eta) 785 785 … … 790 790 domain.compute_forcing_terms() 791 791 792 assert allclose(domain.quantities[' level'].explicit_update, 0)792 assert allclose(domain.quantities['stage'].explicit_update, 0) 793 793 assert allclose(domain.quantities['xmomentum'].explicit_update, -g*h*3) 794 794 assert allclose(domain.quantities['ymomentum'].explicit_update, 0) 795 795 796 assert allclose(domain.quantities[' level'].semi_implicit_update, 0)796 assert allclose(domain.quantities['stage'].semi_implicit_update, 0) 797 797 assert allclose(domain.quantities['xmomentum'].semi_implicit_update, 0) 798 798 assert allclose(domain.quantities['ymomentum'].semi_implicit_update, 0) … … 803 803 804 804 domain.compute_forcing_terms() 805 assert allclose(domain.quantities[' level'].semi_implicit_update, 0)805 assert allclose(domain.quantities['stage'].semi_implicit_update, 0) 806 806 assert allclose(domain.quantities['xmomentum'].semi_implicit_update, S) 807 807 assert allclose(domain.quantities['ymomentum'].semi_implicit_update, 0) 808 808 809 809 #A more complex example 810 domain.quantities[' level'].semi_implicit_update[:] = 0.0810 domain.quantities['stage'].semi_implicit_update[:] = 0.0 811 811 domain.quantities['xmomentum'].semi_implicit_update[:] = 0.0 812 812 domain.quantities['ymomentum'].semi_implicit_update[:] = 0.0 … … 820 820 domain.compute_forcing_terms() 821 821 822 assert allclose(domain.quantities[' level'].semi_implicit_update, 0)822 assert allclose(domain.quantities['stage'].semi_implicit_update, 0) 823 823 assert allclose(domain.quantities['xmomentum'].semi_implicit_update, 3*S) 824 824 assert allclose(domain.quantities['ymomentum'].semi_implicit_update, 4*S) … … 844 844 #Flat surface with 1m of water 845 845 domain.set_quantity('elevation', 0) 846 domain.set_quantity(' level', 1.0)846 domain.set_quantity('stage', 1.0) 847 847 domain.set_quantity('friction', 0) 848 848 … … 871 871 S = const * sqrt(u**2 + v**2) 872 872 873 assert allclose(domain.quantities[' level'].explicit_update, 0)873 assert allclose(domain.quantities['stage'].explicit_update, 0) 874 874 assert allclose(domain.quantities['xmomentum'].explicit_update, S*u) 875 875 assert allclose(domain.quantities['ymomentum'].explicit_update, S*v) … … 895 895 #Flat surface with 1m of water 896 896 domain.set_quantity('elevation', 0) 897 domain.set_quantity(' level', 1.0)897 domain.set_quantity('stage', 1.0) 898 898 domain.set_quantity('friction', 0) 899 899 … … 938 938 S = const * sqrt(u**2 + v**2) 939 939 940 assert allclose(domain.quantities[' level'].explicit_update[k], 0)940 assert allclose(domain.quantities['stage'].explicit_update[k], 0) 941 941 assert allclose(domain.quantities['xmomentum'].explicit_update[k], S*u) 942 942 assert allclose(domain.quantities['ymomentum'].explicit_update[k], S*v) … … 968 968 #Flat surface with 1m of water 969 969 domain.set_quantity('elevation', 0) 970 domain.set_quantity(' level', 1.0)970 domain.set_quantity('stage', 1.0) 971 971 domain.set_quantity('friction', 0) 972 972 … … 1024 1024 1025 1025 for k in range(N): 1026 assert allclose(domain.quantities[' level'].explicit_update[k], 0)1026 assert allclose(domain.quantities['stage'].explicit_update[k], 0) 1027 1027 assert allclose(domain.quantities['xmomentum'].explicit_update[k], S*u) 1028 1028 assert allclose(domain.quantities['ymomentum'].explicit_update[k], S*v) … … 1053 1053 #Flat surface with 1m of water 1054 1054 domain.set_quantity('elevation', 0) 1055 domain.set_quantity(' level', 1.0)1055 domain.set_quantity('stage', 1.0) 1056 1056 domain.set_quantity('friction', 0) 1057 1057 … … 1114 1114 val3 = 2.+8.0/3 1115 1115 1116 zl=zr=-3.75 #Assume constant bed (must be less than level)1116 zl=zr=-3.75 #Assume constant bed (must be less than stage) 1117 1117 domain.set_quantity('elevation', zl*ones( (4,3) )) 1118 domain.set_quantity(' level', [[val0, val0-1, val0-2],1118 domain.set_quantity('stage', [[val0, val0-1, val0-2], 1119 1119 [val1, val1+1, val1], 1120 1120 [val2, val2-2, val2], … … 1127 1127 1128 1128 #Check that centroid values were distributed to vertices 1129 C = domain.quantities[' level'].centroid_values1129 C = domain.quantities['stage'].centroid_values 1130 1130 for i in range(3): 1131 assert allclose( domain.quantities[' level'].vertex_values[:,i], C)1131 assert allclose( domain.quantities['stage'].vertex_values[:,i], C) 1132 1132 1133 1133 … … 1156 1156 domain.set_quantity('elevation', [[0,0,0], [6,0,0], 1157 1157 [6,6,6], [6,6,6]]) 1158 domain.set_quantity(' level', [[val0, val0, val0],1158 domain.set_quantity('stage', [[val0, val0, val0], 1159 1159 [val1, val1, val1], 1160 1160 [val2, val2, val2], … … 1162 1162 1163 1163 E = domain.quantities['elevation'].vertex_values 1164 L = domain.quantities[' level'].vertex_values1165 1166 1167 #Check that some levels are not above elevation (within eps)1164 L = domain.quantities['stage'].vertex_values 1165 1166 1167 #Check that some stages are not above elevation (within eps) 1168 1168 #- so that the limiter has something to work with 1169 1169 assert not alltrue(alltrue(greater_equal(L,E-epsilon))) … … 1172 1172 domain.distribute_to_vertices_and_edges() 1173 1173 1174 #Check that all levels are above elevation (within eps)1174 #Check that all stages are above elevation (within eps) 1175 1175 assert alltrue(alltrue(greater_equal(L,E-epsilon))) 1176 1176 … … 1199 1199 val3 = 2. 1200 1200 1201 domain.set_quantity(' level', [val0, val1, val2, val3], 'centroids')1202 L = domain.quantities[' level'].vertex_values1201 domain.set_quantity('stage', [val0, val1, val2, val3], 'centroids') 1202 L = domain.quantities['stage'].vertex_values 1203 1203 1204 1204 #First order … … 1230 1230 1231 1231 domain = Domain(points, vertices) 1232 L = domain.quantities[' level'].vertex_values1233 1234 def level(x,y):1232 L = domain.quantities['stage'].vertex_values 1233 1234 def stage(x,y): 1235 1235 return x**2 1236 1236 1237 domain.set_quantity(' level', level, 'centroids')1237 domain.set_quantity('stage', stage, 'centroids') 1238 1238 1239 a, b = domain.quantities[' level'].compute_gradients()1239 a, b = domain.quantities['stage'].compute_gradients() 1240 1240 assert allclose(a[1], 3.33333334) 1241 1241 assert allclose(b[1], 0.0) … … 1267 1267 1268 1268 domain = Domain(points, vertices) 1269 L = domain.quantities[' level'].vertex_values1270 1271 def level(x,y):1269 L = domain.quantities['stage'].vertex_values 1270 1271 def stage(x,y): 1272 1272 return x**4+y**2 1273 1273 1274 domain.set_quantity(' level', level, 'centroids')1275 #print domain.quantities[' level'].centroid_values1274 domain.set_quantity('stage', stage, 'centroids') 1275 #print domain.quantities['stage'].centroid_values 1276 1276 1277 a, b = domain.quantities[' level'].compute_gradients()1277 a, b = domain.quantities['stage'].compute_gradients() 1278 1278 assert allclose(a[1], 25.18518519) 1279 1279 assert allclose(b[1], 3.33333333) … … 1312 1312 1313 1313 h = 0.1 1314 def level(x,y):1314 def stage(x,y): 1315 1315 return slope(x,y)+h 1316 1316 1317 1317 domain.set_quantity('elevation', slope) 1318 domain.set_quantity(' level', level, 'centroids')1318 domain.set_quantity('stage', stage, 'centroids') 1319 1319 1320 1320 #print domain.quantities['elevation'].centroid_values 1321 #print domain.quantities[' level'].centroid_values1321 #print domain.quantities['stage'].centroid_values 1322 1322 1323 1323 E = domain.quantities['elevation'].vertex_values 1324 L = domain.quantities[' level'].vertex_values1324 L = domain.quantities['stage'].vertex_values 1325 1325 1326 1326 #print E … … 1357 1357 1358 1358 h = 0.1 1359 def level(x,y):1359 def stage(x,y): 1360 1360 return slope(x,y)+h 1361 1361 1362 1362 domain.set_quantity('elevation', slope) 1363 domain.set_quantity(' level', level)1363 domain.set_quantity('stage', stage) 1364 1364 1365 1365 #print domain.quantities['elevation'].centroid_values 1366 #print domain.quantities[' level'].centroid_values1366 #print domain.quantities['stage'].centroid_values 1367 1367 1368 1368 E = domain.quantities['elevation'].vertex_values 1369 L = domain.quantities[' level'].vertex_values1369 L = domain.quantities['stage'].vertex_values 1370 1370 1371 1371 #print E … … 1403 1403 1404 1404 domain.set_quantity('elevation', slope) 1405 domain.set_quantity(' level',1405 domain.set_quantity('stage', 1406 1406 [0.01298164, 0.00365611, 0.01440365, -0.0381856437096], 1407 1407 'centroids') … … 1414 1414 1415 1415 E = domain.quantities['elevation'].vertex_values 1416 L = domain.quantities[' level'].vertex_values1416 L = domain.quantities['stage'].vertex_values 1417 1417 X = domain.quantities['xmomentum'].vertex_values 1418 1418 Y = domain.quantities['ymomentum'].vertex_values … … 1461 1461 assert allclose(domain.max_timestep, 0.0396825396825) 1462 1462 1463 assert allclose(domain.quantities[' level'].centroid_values[:12],1463 assert allclose(domain.quantities['stage'].centroid_values[:12], 1464 1464 [0.00171396, 0.02656103, 0.00241523, 0.02656103, 1465 1465 0.00241523, 0.02656103, 0.00241523, 0.02656103, … … 1467 1467 1468 1468 domain.distribute_to_vertices_and_edges() 1469 assert allclose(domain.quantities[' level'].vertex_values[:12,0],1469 assert allclose(domain.quantities['stage'].vertex_values[:12,0], 1470 1470 [0.0001714, 0.02656103, 0.00024152, 1471 1471 0.02656103, 0.00024152, 0.02656103, … … 1473 1473 0.02656103, 0.00024152, 0.0272623]) 1474 1474 1475 assert allclose(domain.quantities[' level'].vertex_values[:12,1],1475 assert allclose(domain.quantities['stage'].vertex_values[:12,1], 1476 1476 [0.00315012, 0.02656103, 0.00024152, 0.02656103, 1477 1477 0.00024152, 0.02656103, 0.00024152, 0.02656103, 1478 1478 0.00024152, 0.02656103, 0.00040506, 0.0272623]) 1479 1479 1480 assert allclose(domain.quantities[' level'].vertex_values[:12,2],1480 assert allclose(domain.quantities['stage'].vertex_values[:12,2], 1481 1481 [0.00182037, 0.02656103, 0.00676264, 1482 1482 0.02656103, 0.00676264, 0.02656103, … … 1529 1529 #assert allclose(domain.min_timestep, 0.0396825396825) 1530 1530 #assert allclose(domain.max_timestep, 0.0396825396825) 1531 #print domain.quantities[' level'].centroid_values1531 #print domain.quantities['stage'].centroid_values 1532 1532 1533 1533 … … 1567 1567 1568 1568 for i in range(3): 1569 #assert allclose(domain.quantities[' level'].edge_values[:4,i],1569 #assert allclose(domain.quantities['stage'].edge_values[:4,i], 1570 1570 # [0.10730244,0.12337617,0.11200126,0.12605666]) 1571 1571 … … 1609 1609 assert allclose(domain.max_timestep, 0.0210448446782) 1610 1610 1611 #print domain.quantities[' level'].vertex_values[:4,0]1611 #print domain.quantities['stage'].vertex_values[:4,0] 1612 1612 #print domain.quantities['xmomentum'].vertex_values[:4,0] 1613 1613 #print domain.quantities['ymomentum'].vertex_values[:4,0] 1614 1614 1615 1615 #FIXME: These numbers were from version before 25/10 1616 #assert allclose(domain.quantities[' level'].vertex_values[:4,0],1616 #assert allclose(domain.quantities['stage'].vertex_values[:4,0], 1617 1617 # [0.00101913,0.05352143,0.00104852,0.05354394]) 1618 1618 … … 1699 1699 1700 1700 1701 domain.set_quantity(' level', L, 'centroids')1701 domain.set_quantity('stage', L, 'centroids') 1702 1702 domain.set_quantity('xmomentum', X, 'centroids') 1703 1703 domain.set_quantity('ymomentum', Y, 'centroids') … … 1714 1714 #Centroids were correct but not vertices. 1715 1715 #Hence the check of distribute below. 1716 assert allclose(domain.quantities[' level'].centroid_values[:4],1716 assert allclose(domain.quantities['stage'].centroid_values[:4], 1717 1717 [0.00721206,0.05352143,0.01009108,0.05354394]) 1718 1718 … … 1747 1747 1748 1748 #FIXME: These numbers were from version before 25/10 1749 #assert allclose(domain.quantities[' level'].vertex_values[:4,0],1749 #assert allclose(domain.quantities['stage'].vertex_values[:4,0], 1750 1750 # [0.00101913,0.05352143,0.00104852,0.05354394]) 1751 1751 … … 1798 1798 1799 1799 #Initial condition 1800 domain.set_quantity(' level', Constant_height(x_slope, 0.05))1800 domain.set_quantity('stage', Constant_height(x_slope, 0.05)) 1801 1801 domain.check_integrity() 1802 1802 … … 1834 1834 1835 1835 #Initial condition 1836 domain.set_quantity(' level', Constant_height(x_slope, 0.05))1836 domain.set_quantity('stage', Constant_height(x_slope, 0.05)) 1837 1837 domain.check_integrity() 1838 1838 … … 1842 1842 1843 1843 #Data from earlier version of pyvolution 1844 #print domain.quantities[' level'].centroid_values1845 1846 assert allclose(domain.quantities[' level'].centroid_values,1844 #print domain.quantities['stage'].centroid_values 1845 1846 assert allclose(domain.quantities['stage'].centroid_values, 1847 1847 [-0.02998628, -0.01520652, -0.03043492, 1848 1848 -0.0149132, -0.03004706, -0.01476251, … … 1896 1896 1897 1897 #Initial condition 1898 domain.set_quantity(' level', Constant_height(x_slope, 0.05))1898 domain.set_quantity('stage', Constant_height(x_slope, 0.05)) 1899 1899 domain.check_integrity() 1900 1900 1901 assert allclose(domain.quantities[' level'].centroid_values,1901 assert allclose(domain.quantities['stage'].centroid_values, 1902 1902 [0.01296296, 0.03148148, 0.01296296, 1903 1903 0.03148148, 0.01296296, 0.03148148, … … 1926 1926 1927 1927 1928 #print domain.quantities[' level'].extrapolate_second_order()1928 #print domain.quantities['stage'].extrapolate_second_order() 1929 1929 #domain.distribute_to_vertices_and_edges() 1930 #print domain.quantities[' level'].vertex_values[:,0]1930 #print domain.quantities['stage'].vertex_values[:,0] 1931 1931 1932 1932 #Evolution … … 1936 1936 1937 1937 1938 #print domain.quantities[' level'].centroid_values1939 assert allclose(domain.quantities[' level'].centroid_values,1938 #print domain.quantities['stage'].centroid_values 1939 assert allclose(domain.quantities['stage'].centroid_values, 1940 1940 [0.01290985, 0.02356019, 0.01619096, 0.02356019, 0.01619096, 1941 1941 0.02356019, 0.01619096, 0.02356019, 0.01619096, 0.02356019, … … 1983 1983 1984 1984 #Initial condition 1985 domain.set_quantity(' level', Constant_height(x_slope, 0.05))1985 domain.set_quantity('stage', Constant_height(x_slope, 0.05)) 1986 1986 domain.check_integrity() 1987 1987 1988 assert allclose(domain.quantities[' level'].centroid_values,1988 assert allclose(domain.quantities['stage'].centroid_values, 1989 1989 [0.01296296, 0.03148148, 0.01296296, 1990 1990 0.03148148, 0.01296296, 0.03148148, … … 2013 2013 2014 2014 2015 #print domain.quantities[' level'].extrapolate_second_order()2015 #print domain.quantities['stage'].extrapolate_second_order() 2016 2016 #domain.distribute_to_vertices_and_edges() 2017 #print domain.quantities[' level'].vertex_values[:,0]2017 #print domain.quantities['stage'].vertex_values[:,0] 2018 2018 2019 2019 #Evolution … … 2027 2027 2028 2028 2029 assert allclose(domain.quantities[' level'].centroid_values,2029 assert allclose(domain.quantities['stage'].centroid_values, 2030 2030 [0.00855788, 0.01575204, 0.00994606, 0.01717072, 2031 2031 0.01005985, 0.01716362, 0.01005985, 0.01716299, … … 2075 2075 2076 2076 #Initial condition 2077 domain.set_quantity(' level', Constant_height(x_slope, 0.05))2077 domain.set_quantity('stage', Constant_height(x_slope, 0.05)) 2078 2078 domain.check_integrity() 2079 2079 2080 assert allclose(domain.quantities[' level'].centroid_values,2080 assert allclose(domain.quantities['stage'].centroid_values, 2081 2081 [0.01296296, 0.03148148, 0.01296296, 2082 2082 0.03148148, 0.01296296, 0.03148148, … … 2105 2105 2106 2106 2107 #print domain.quantities[' level'].extrapolate_second_order()2107 #print domain.quantities['stage'].extrapolate_second_order() 2108 2108 #domain.distribute_to_vertices_and_edges() 2109 #print domain.quantities[' level'].vertex_values[:,0]2109 #print domain.quantities['stage'].vertex_values[:,0] 2110 2110 2111 2111 #Evolution … … 2116 2116 2117 2117 2118 assert allclose(domain.quantities[' level'].centroid_values,2118 assert allclose(domain.quantities['stage'].centroid_values, 2119 2119 [0.00855788, 0.01575204, 0.00994606, 0.01717072, 0.01005985, 2120 2120 0.01716362, 0.01005985, 0.01716299, 0.01007098, 0.01736248, … … 2163 2163 2164 2164 #Initial condition 2165 domain.set_quantity(' level', Constant_height(x_slope, 0.05))2165 domain.set_quantity('stage', Constant_height(x_slope, 0.05)) 2166 2166 domain.check_integrity() 2167 2167 2168 assert allclose(domain.quantities[' level'].centroid_values,2168 assert allclose(domain.quantities['stage'].centroid_values, 2169 2169 [0.01296296, 0.03148148, 0.01296296, 2170 2170 0.03148148, 0.01296296, 0.03148148, … … 2193 2193 2194 2194 2195 #print domain.quantities[' level'].extrapolate_second_order()2195 #print domain.quantities['stage'].extrapolate_second_order() 2196 2196 #domain.distribute_to_vertices_and_edges() 2197 #print domain.quantities[' level'].vertex_values[:,0]2197 #print domain.quantities['stage'].vertex_values[:,0] 2198 2198 2199 2199 #Evolution … … 2202 2202 2203 2203 2204 assert allclose(domain.quantities[' level'].centroid_values,2204 assert allclose(domain.quantities['stage'].centroid_values, 2205 2205 [-0.02907028, -0.01475478, -0.02973417, -0.01447186, -0.02932665, -0.01428285, 2206 2206 -0.02901975, -0.0141361, -0.02898816, -0.01418135, -0.02961409, -0.01403487, … … 2279 2279 2280 2280 #Initial condition 2281 domain.set_quantity(' level', Constant_height(x_slope, 0.05))2281 domain.set_quantity('stage', Constant_height(x_slope, 0.05)) 2282 2282 domain.check_integrity() 2283 2283 … … 2286 2286 pass 2287 2287 2288 assert allclose(domain.quantities[' level'].centroid_values[:4],2288 assert allclose(domain.quantities['stage'].centroid_values[:4], 2289 2289 [0.00206836, 0.01296714, 0.00363415, 0.01438924]) 2290 2290 assert allclose(domain.quantities['xmomentum'].centroid_values[:4], … … 2324 2324 domain.set_boundary({'left': Bd, 'right': Br, 'bottom': Br, 'top': Br}) 2325 2325 2326 domain.set_quantity(' level', Constant_height(Z, 0.))2326 domain.set_quantity('stage', Constant_height(Z, 0.)) 2327 2327 2328 2328 for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): … … 2330 2330 2331 2331 2332 #print domain.quantities[' level'].centroid_values2332 #print domain.quantities['stage'].centroid_values 2333 2333 2334 2334 #FIXME: These numbers were from version before 25/10 2335 #assert allclose(domain.quantities[' level'].centroid_values,2335 #assert allclose(domain.quantities['stage'].centroid_values, 2336 2336 # [3.95822638e-002, 5.61022588e-002, 4.66437868e-002, 5.73081011e-002, 2337 2337 # 4.72394613e-002, 5.74684939e-002, 4.74309483e-002, 5.77458084e-002, -
inundation/ga/storm_surge/pyvolution/wind_example_scalar.py
r614 r773 22 22 #Set initial conditions 23 23 domain.set_quantity('elevation', 0.0) 24 domain.set_quantity(' level', 1.0)24 domain.set_quantity('stage', 1.0) 25 25 domain.set_quantity('friction', 0.03) 26 26 -
inundation/ga/storm_surge/pyvolution/wind_example_variable.py
r624 r773 27 27 h = 1.0 28 28 domain.set_quantity('elevation', 0.0) 29 domain.set_quantity(' level', h)29 domain.set_quantity('stage', h) 30 30 domain.set_quantity('friction', 0.01) 31 31
Note: See TracChangeset
for help on using the changeset viewer.