Changeset 8578
- Timestamp:
- Sep 14, 2012, 9:56:39 PM (13 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/__init__.py
r8572 r8578 73 73 from anuga.shallow_water.boundaries import \ 74 74 Transmissive_n_momentum_zero_t_momentum_set_stage_boundary 75 from anuga.abstract_2d_finite_volumes.generic_boundary_conditions import \ 76 Compute_fluxes_boundary 75 77 76 78 … … 172 174 """ 173 175 174 if 'verbose' in kwargs: 175 verbose = kwargs['verbose'] 176 kwargs.pop('verbose') 177 else: 176 try: 177 verbose = kwargs.pop('verbose') 178 except: 178 179 verbose = False 180 179 181 180 182 points, vertices, boundary = rectangular_cross(*args, **kwargs) -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
r8538 r8578 208 208 Q.boundary_values[ids] = q_bdry[j] 209 209 210 class Compute_fluxes_boundary(Boundary): 211 """ Associate the Compute_fluxes_boundary BC 212 to each boundary segment where a special calculation 213 of the fluxes will occur. 214 """ 215 216 def __init__(self): 217 Boundary.__init__(self) 218 """ Instantiate a Compute_fluxes_boundary. 219 domain: underlying domain 220 """ 221 222 223 def __repr__(self): 224 """ Return a representation of this instance. """ 225 return 'Compute_fluxes_boundary(%s)' % self.domain 226 227 def evaluate(self, vol_id, edge_id): 228 """Do something basic""" 229 230 return None 231 232 def evaluate_segment(self, domain, segment_edges): 233 """Don't do any calculation when applying this BC. 234 The work will be done in compute_fluxes. 235 """ 236 237 return 210 238 211 239 … … 601 629 def evaluate(self, vol_id=None, edge_id=None): 602 630 """Return linearly interpolated values based on domain.time 603 631 at midpoint of segment defined by vol_id and edge_id. 604 632 """ 605 633 … … 828 856 829 857 858 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r8574 r8578 809 809 raise Exception(msg) 810 810 811 812 813 # Add a flag which can be used to distinguish flux boundaries within 814 # compute_fluxes_central 815 # Initialise to zero (which means 'not a flux_boundary') 816 self.boundary_flux_type = self.boundary_edges*0 817 818 # HACK to set the values of domain.boundary_flux 819 for k, ((vol_id, edge_id), B) in enumerate(self.boundary_objects): 820 # If Boundary set to Compute_fluxes_boundary identify as flux boundary 821 #print vol_id, edge_id, B 822 823 import anuga 824 if ( isinstance(B,anuga.Compute_fluxes_boundary) ): 825 self.boundary_flux_type[k]=1 826 827 811 828 ## 812 829 # @brief Set quantities based on a regional tag. -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py
r8570 r8578 553 553 554 554 555 for j in range(self.boundary_length):555 for j in xrange(self.boundary_length): 556 556 id = self.boundary_cells[j] 557 557 edge = self.boundary_edges[j] -
trunk/anuga_core/source/anuga/fit_interpolate/fit.py
r8536 r8578 46 46 47 47 import numpy as num 48 import sys 48 49 49 50 … … 100 101 triangles, 101 102 mesh, 102 mesh_origin ,103 verbose )103 mesh_origin=mesh_origin, 104 verbose=verbose) 104 105 105 106 m = self.mesh.number_of_nodes # Nbr of basis functions (vertices) … … 110 111 self.point_count = 0 111 112 if self.alpha <> 0: 112 if verbose: log.critical('Building smoothing matrix') 113 self._build_smoothing_matrix_D() 114 113 if verbose: log.critical('Fit: Building smoothing matrix') 114 self._build_smoothing_matrix_D(verbose=verbose) 115 116 if verbose: log.critical('Fit: Get Boundary Polygon') 115 117 bd_poly = self.mesh.get_boundary_polygon() 116 118 self.mesh_boundary_polygon = ensure_numeric(bd_poly) 119 120 if verbose: log.critical('Fit: Done') 121 117 122 118 123 def _build_coefficient_matrix_B(self, … … 126 131 """ 127 132 133 if verbose: 134 print 'Fit: Build Coefficient Matrix B' 135 136 128 137 if self.alpha <> 0: 129 138 #if verbose: log.critical('Building smoothing matrix') 130 139 #self._build_smoothing_matrix_D() 140 # FIXME SR: This is quite time consuming. 141 # As AtA and D have same structure it should be possible 142 # to speed this up. 131 143 self.B = self.AtA + self.alpha*self.D 132 144 else: 133 145 self.B = self.AtA 134 146 147 148 if verbose: 149 print 'Fit: Convert Coefficient Matrix B to Sparse_CSR' 150 135 151 # Convert self.B matrix to CSR format for faster matrix vector 136 152 self.B = Sparse_CSR(self.B) 137 153 138 def _build_smoothing_matrix_D(self ):154 def _build_smoothing_matrix_D(self, verbose=False): 139 155 """Build m x m smoothing matrix, where 140 156 m is the number of basis functions phi_k (one per vertex) … … 169 185 self.D = Sparse(m,m) 170 186 187 if verbose : 188 print '['+60*' '+']', 189 sys.stdout.flush() 190 191 N = len(self.mesh) 192 M = N/60 193 171 194 # For each triangle compute contributions to D = D1+D2 172 for i in range(len(self.mesh)): 195 for i in xrange(N): 196 197 if verbose and i%M == 0 : 198 #restart_line() 199 print '\r['+(i/M)*'.'+(60-(i/M))*' ' +']', 200 sys.stdout.flush() 173 201 174 202 # Get area … … 212 240 self.D[v2,v0] += e20 213 241 self.D[v0,v2] += e20 242 243 if verbose: 244 print '' 214 245 215 246 def get_D(self): … … 242 273 The number of attributes of the data points does not change 243 274 """ 244 275 276 277 if verbose: 278 print 'Fit: Build Matrix AtA Atz' 279 245 280 # Build n x m interpolation matrix 246 281 if self.AtA == None: … … 271 306 # Compute matrix elements for points inside the mesh 272 307 triangles = self.mesh.triangles # Shorthand 273 for d, i in enumerate(inside_indices): 308 309 310 if verbose : 311 print '['+60*' '+']', 312 sys.stdout.flush() 313 314 m = n/60 315 316 317 for i in xrange(n): 318 d = inside_indices[i] 274 319 # For each data_coordinate point 275 320 # if verbose and d%((n+10)/10)==0: log.critical('Doing %d of %d' 276 321 # %(d, n)) 277 x = point_coordinates[i] 322 323 324 if verbose and i%m == 0 : 325 print '\r['+(i/m)*'.'+(60-(i/m))*' '+']', 326 sys.stdout.flush() 327 328 329 x = point_coordinates[d] 278 330 279 331 element_found, sigma0, sigma1, sigma2, k = \ … … 302 354 303 355 # data point has fallen within a hole - so ignore it. 304 356 357 358 if verbose: 359 print '' 360 305 361 self.AtA = AtA 306 362 … … 324 380 325 381 """ 326 382 383 384 if verbose: 385 print 'Fit.fit: Initializing' 386 327 387 # Use blocking to load in the point info 328 388 if isinstance(point_coordinates_or_filename, basestring): … … 357 417 points = geo_block.get_data_points(absolute=True) 358 418 z = geo_block.get_attributes(attribute_name=attribute_name) 359 self.build_fit_subset(points, z, verbose=verbose)419 self.build_fit_subset(points, z, attribute_name, verbose) 360 420 361 421 # FIXME(Ole): I thought this test would make sense here … … 368 428 else: 369 429 point_coordinates = point_coordinates_or_filename 370 430 431 432 371 433 if point_coordinates is None: 372 if verbose: log.critical(' Warning: no data points in fit')434 if verbose: log.critical('Fit.fit: Warning: no data points in fit') 373 435 msg = 'No interpolation matrix.' 374 436 assert self.AtA is not None, msg … … 381 443 # if isinstance(point_coordinates,Geospatial_data) and z is None: 382 444 # z will come from the geo-ref 383 self.build_fit_subset(point_coordinates, z, verbose) 445 self.build_fit_subset(point_coordinates, z, verbose=verbose) 446 447 448 449 384 450 385 451 # Check sanity … … 393 459 msg += 'positive value,\ne.g. 1.0e-3.' 394 460 raise TooFewPointsError(msg) 461 395 462 396 463 self._build_coefficient_matrix_B(verbose) … … 408 475 #raise VertsWithNoTrianglesError(msg) 409 476 410 477 if verbose: 478 print 'Fit.fit: Solve Fitting Equation' 479 411 480 return conjugate_gradient(self.B, self.Atz, self.Atz, 412 481 imax=2*len(self.Atz) ) … … 575 644 576 645 if verbose: log.critical('FitInterpolate: Building mesh') 577 mesh = Mesh(vertex_coordinates, triangles )578 mesh.check_integrity()646 mesh = Mesh(vertex_coordinates, triangles, verbose=verbose) 647 #mesh.check_integrity() # expensive 579 648 580 649 … … 648 717 old_title_list = mesh_dict['vertex_attribute_titles'] 649 718 650 if verbose: log.critical(' tsh file %s loaded' % mesh_file)719 if verbose: log.critical('Fit_to_Mesh_File: tsh file %s loaded' % mesh_file) 651 720 652 721 # load in the points file … … 668 737 mesh_origin = None 669 738 670 if verbose: log.critical(" points file loaded")671 if verbose: log.critical(" fitting to mesh")739 if verbose: log.critical("Fit_to_Mesh_File: points file loaded") 740 if verbose: log.critical("Fit_to_Mesh_File: fitting to mesh") 672 741 f = fit_to_mesh(point_coordinates, 673 742 vertex_coordinates, … … 679 748 data_origin = None, 680 749 mesh_origin = mesh_origin) 681 if verbose: log.critical(" finished fitting to mesh")750 if verbose: log.critical("Fit_to_Mesh_File: finished fitting to mesh") 682 751 683 752 # convert array to list of lists … … 688 757 old_title_list.extend(title_list) 689 758 #FIXME can this be done a faster way? - DSG 690 for i in range(len(old_point_attributes)):759 for i in xrange(len(old_point_attributes)): 691 760 old_point_attributes[i].extend(new_point_attributes[i]) 692 761 mesh_dict['vertex_attributes'] = old_point_attributes … … 696 765 mesh_dict['vertex_attribute_titles'] = title_list 697 766 698 if verbose: log.critical(" exporting to file %s" % mesh_output_file)767 if verbose: log.critical("Fit_to_Mesh_File: exporting to file %s" % mesh_output_file) 699 768 700 769 try: -
trunk/anuga_core/source/anuga/fit_interpolate/general_fit_interpolate.py
r7751 r8578 91 91 92 92 if verbose: log.critical('FitInterpolate: Building mesh') 93 self.mesh = Mesh(vertex_coordinates, triangles )93 self.mesh = Mesh(vertex_coordinates, triangles, verbose=verbose) 94 94 #self.mesh.check_integrity() # Time consuming 95 95 else: … … 102 102 #This stores indices of vertices 103 103 t0 = time.time() 104 self.root = MeshQuadtree(self.mesh )104 self.root = MeshQuadtree(self.mesh, verbose=verbose) 105 105 106 106 build_quadtree_time = time.time()-t0 -
trunk/anuga_core/source/anuga/operators/test_set_stage_operators.py
r8577 r8578 21 21 22 22 23 class Test_set_ operators(unittest.TestCase):23 class Test_set_stage_operators(unittest.TestCase): 24 24 def setUp(self): 25 25 pass … … 142 142 143 143 144 145 146 144 def test_set_stage_operator_function(self): 145 from anuga.config import rho_a, rho_w, eta_w 146 from math import pi, cos, sin 147 148 a = [0.0, 0.0] 149 b = [0.0, 2.0] 150 c = [2.0, 0.0] 151 d = [0.0, 4.0] 152 e = [2.0, 2.0] 153 f = [4.0, 0.0] 154 155 156 157 158 159 points = [a, b, c, d, e, f] 160 # bac, bce, ecf, dbe 161 vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]] 162 163 domain = Domain(points, vertices) 164 165 #Flat surface with 1m of water 166 domain.set_quantity('elevation', 0) 167 domain.set_quantity('stage', 1.0) 168 domain.set_quantity('friction', 0) 169 170 Br = Reflective_boundary(domain) 171 domain.set_boundary({'exterior': Br}) 172 173 174 # print domain.quantities['stage'].centroid_values 175 # print domain.quantities['xmomentum'].centroid_values 176 # print domain.quantities['ymomentum'].centroid_values 177 178 # Apply operator to these triangles 179 indices = [0,1,3] 180 181 182 def stage(t): 183 if t < 10.0: 184 return 5.0 185 else: 186 return 10.0 187 188 operator = Set_stage_operator(domain, stage=stage, indices=indices) 189 190 # Apply Operator at time t=1.0 191 domain.set_time(1.0) 192 operator() 193 194 stage_ex = [ 5., 5., 1., 5.] 195 196 197 # print domain.quantities['stage'].centroid_values 198 # print domain.quantities['xmomentum'].centroid_values 199 # print domain.quantities['ymomentum'].centroid_values 200 201 assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex) 202 assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0) 203 assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0) 204 205 # Apply Operator at time t=15.0 206 domain.set_time(15.0) 207 operator() 208 209 stage_ex = [ 10., 10., 1., 10.] 210 211 212 # print domain.quantities['stage'].centroid_values 213 # print domain.quantities['xmomentum'].centroid_values 214 # print domain.quantities['ymomentum'].centroid_values 215 216 assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex) 217 assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0) 218 assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0) 219 220 221 def test_set_stage_operator_large_function(self): 222 from anuga.config import rho_a, rho_w, eta_w 223 from math import pi, cos, sin 224 225 226 length = 2.0 227 width = 2.0 228 dx = dy = 0.5 229 domain = rectangular_cross_domain(int(length/dx), int(width/dy), 230 len1=length, len2=width) 231 232 233 #Flat surface with 1m of water 234 domain.set_quantity('elevation', 0.0) 235 domain.set_quantity('stage', 1.0) 236 domain.set_quantity('friction', 0) 237 238 R = Reflective_boundary(domain) 239 domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} ) 240 241 242 # print domain.quantities['stage'].centroid_values 243 # print domain.quantities['xmomentum'].centroid_values 244 # print domain.quantities['ymomentum'].centroid_values 245 246 247 248 def stage(t): 249 if t < 10.0: 250 return 5.0 251 else: 252 return 7.0 253 254 polygon = [(0.5,0.5), (1.5,0.5), (1.5,1.5), (0.5,1.5)] 255 operator = Polygonal_set_stage_operator(domain, stage=stage, polygon=polygon) 256 257 # Apply Operator at time t=1.0 258 domain.set_time(1.0) 259 operator() 260 261 stage_ex = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 262 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 263 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 1.0, 1.0, 264 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 5.0, 5.0, 5.0, 5.0, 265 5.0, 5.0, 5.0, 5.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 266 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 267 1.0, 1.0, 1.0, 1.0] 268 269 270 # print domain.quantities['elevation'].centroid_values 271 # print domain.quantities['stage'].centroid_values 272 # print domain.quantities['xmomentum'].centroid_values 273 # print domain.quantities['ymomentum'].centroid_values 274 275 assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex) 276 assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0) 277 assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0) 278 279 # Apply Operator at time t=15.0 280 domain.set_time(15.0) 281 operator() 282 283 stage_ex = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 284 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 285 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 1.0, 1.0, 286 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 7.0, 7.0, 7.0, 7.0, 287 7.0, 7.0, 7.0, 7.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 288 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 289 1.0, 1.0, 1.0, 1.0] 290 291 292 # print domain.quantities['stage'].centroid_values 293 # print domain.quantities['xmomentum'].centroid_values 294 # print domain.quantities['ymomentum'].centroid_values 295 296 assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex) 297 assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0) 298 assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0) 299 300 301 302 147 303 if __name__ == "__main__": 148 suite = unittest.makeSuite(Test_set_ operators, 'test')304 suite = unittest.makeSuite(Test_set_stage_operators, 'test') 149 305 runner = unittest.TextTestRunner(verbosity=1) 150 306 runner.run(suite) -
trunk/anuga_core/source/anuga/pmesh/mesh_quadtree.py
r7872 r8578 24 24 25 25 import numpy as num 26 import sys 26 27 27 28 … … 41 42 It contains optimisations and search patterns specific to meshes. 42 43 """ 43 def __init__(self, mesh ):44 def __init__(self, mesh, verbose=False): 44 45 """Build quad tree for mesh. 45 46 … … 60 61 61 62 normals = mesh.get_normals() 62 63 64 if verbose : 65 print '['+60*' '+']', 66 sys.stdout.flush() 67 68 M = N/60 69 63 70 # Check each triangle 64 for i in range(N): 71 for i in xrange(N): 72 73 if verbose and i%M == 0 : 74 #restart_line() 75 print '\r['+(i/M)*'.'+(60-(i/M))*' ' +']', 76 sys.stdout.flush() 77 65 78 i3 = 3*i 66 79 x0, y0 = V[i3, :] … … 68 81 x2, y2 = V[i3+2, :] 69 82 83 #FIXME SR: Should save memory by just using triangle id! 70 84 node_data = [i, V[i3:i3+3, :], normals[i, :]] 71 85 … … 74 88 min([y0, y1, y2]), max([y0, y1, y2])), \ 75 89 node_data)) 90 91 if verbose: 92 print '' 76 93 77 94 def search_fast(self, point): -
trunk/anuga_core/source/anuga/shallow_water/boundaries.py
r8538 r8578 477 477 478 478 # Assign conserved quantities and return 479 q = num.array([elevation + depth, xmomentum, ymomentum], num. Float)479 q = num.array([elevation + depth, xmomentum, ymomentum], num.float) 480 480 return q 481 481 … … 580 580 q[j] += self.mean_stage 581 581 return q 582 583 584 585 586 -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r8570 r8578 1042 1042 1043 1043 elif self.compute_fluxes_method == 'tsunami': 1044 # Using Gareth Davies well nbalanced scheme1044 # Using Gareth Davies well balanced scheme 1045 1045 # Flux calculation and gravity incorporated in same 1046 1046 # procedure … … 1054 1054 1055 1055 # Shortcuts 1056 Stage = domain.quantities['stage']1057 Xmom = domain.quantities['xmomentum']1058 Ymom = domain.quantities['ymomentum']1059 Bed = domain.quantities['elevation']1056 Stage = self.quantities['stage'] 1057 Xmom = self.quantities['xmomentum'] 1058 Ymom = self.quantities['ymomentum'] 1059 Bed = self.quantities['elevation'] 1060 1060 1061 1061 timestep = self.evolve_max_timestep … … 1109 1109 if self.compute_fluxes_method == 'tsunami': 1110 1110 1111 1112 # FIXME SR: Clean up code to just take self (domain) as 1113 # input argument 1111 1114 from swb2_domain_ext import protect 1112 1115 … … 1120 1123 areas = self.areas 1121 1124 1122 protect(self.minimum_allowed_height, domain.maximum_allowed_speed,1123 domain.epsilon, wc, wv, zc,zv, xmomc, ymomc, areas)1124 1125 1126 from swb2_domain_ext import extrapolate_second_order_edge_sw as extrapol2 1125 protect(self.minimum_allowed_height, self.maximum_allowed_speed, 1126 self.epsilon, wc, wv, zc,zv, xmomc, ymomc, areas) 1127 1128 1129 from swb2_domain_ext import extrapolate_second_order_edge_sw as extrapol2_ext 1127 1130 1128 1131 # Shortcuts … … 1132 1135 Elevation = self.quantities['elevation'] 1133 1136 1134 extrapol2 (self,1137 extrapol2_ext(self, 1135 1138 self.surrogate_neighbours, 1136 1139 self.number_of_boundaries, … … 1154 1157 1155 1158 else: 1159 # Code for original method 1156 1160 if self.use_edge_limiter: 1157 1161 self.distribute_using_edge_limiter() 1158 1162 else: 1159 #distribute_using_vertex_limiter(self)1160 1163 self.distribute_using_vertex_limiter() 1161 1164 … … 1193 1196 raise Exception('Unknown order') 1194 1197 1195 balance_deep_and_shallow(self)1198 self.balance_deep_and_shallow() 1196 1199 1197 1200 # Compute edge values by interpolation … … 1200 1203 Q.interpolate_from_vertices_to_edges() 1201 1204 1202 def distribute_using_vertex_limiter( domain):1205 def distribute_using_vertex_limiter(self): 1203 1206 """Distribution from centroids to vertices specific to the SWW equation. 1204 1207 … … 1221 1224 1222 1225 # Remove very thin layers of water 1223 domain.protect_against_infinitesimal_and_negative_heights()1226 self.protect_against_infinitesimal_and_negative_heights() 1224 1227 1225 1228 # Extrapolate all conserved quantities 1226 if domain.optimised_gradient_limiter:1229 if self.optimised_gradient_limiter: 1227 1230 # MH090605 if second order, 1228 1231 # perform the extrapolation and limiting on 1229 1232 # all of the conserved quantities 1230 1233 1231 if ( domain._order_ == 1):1232 for name in domain.conserved_quantities:1233 Q = domain.quantities[name]1234 if (self._order_ == 1): 1235 for name in self.conserved_quantities: 1236 Q = self.quantities[name] 1234 1237 Q.extrapolate_first_order() 1235 elif domain._order_ == 2:1236 domain.extrapolate_second_order_sw()1238 elif self._order_ == 2: 1239 self.extrapolate_second_order_sw() 1237 1240 else: 1238 1241 raise Exception('Unknown order') … … 1240 1243 # Old code: 1241 1244 for name in domain.conserved_quantities: 1242 Q = domain.quantities[name]1243 1244 if domain._order_ == 1:1245 Q = self.quantities[name] 1246 1247 if self._order_ == 1: 1245 1248 Q.extrapolate_first_order() 1246 elif domain._order_ == 2:1249 elif self._order_ == 2: 1247 1250 Q.extrapolate_second_order_and_limit_by_vertex() 1248 1251 else: … … 1250 1253 1251 1254 # Take bed elevation into account when water heights are small 1252 balance_deep_and_shallow(domain)1255 self.balance_deep_and_shallow() 1253 1256 1254 1257 # Compute edge values by interpolation 1255 for name in domain.conserved_quantities:1256 Q = domain.quantities[name]1258 for name in self.conserved_quantities: 1259 Q = self.quantities[name] 1257 1260 Q.interpolate_from_vertices_to_edges() 1258 1261 … … 1267 1270 1268 1271 # shortcuts 1269 wc = domain.quantities['stage'].centroid_values1270 wv = domain.quantities['stage'].vertex_values1271 zc = domain.quantities['elevation'].centroid_values1272 zv = domain.quantities['elevation'].vertex_values1273 xmomc = domain.quantities['xmomentum'].centroid_values1274 ymomc = domain.quantities['ymomentum'].centroid_values1275 areas = domain.areas1276 1277 protect( domain.minimum_allowed_height, domain.maximum_allowed_speed,1278 domain.epsilon, wc, wv, zc,zv, xmomc, ymomc, areas)1272 wc = self.quantities['stage'].centroid_values 1273 wv = self.quantities['stage'].vertex_values 1274 zc = self.quantities['elevation'].centroid_values 1275 zv = self.quantities['elevation'].vertex_values 1276 xmomc = self.quantities['xmomentum'].centroid_values 1277 ymomc = self.quantities['ymomentum'].centroid_values 1278 areas = self.areas 1279 1280 protect(self.minimum_allowed_height, self.maximum_allowed_speed, 1281 self.epsilon, wc, wv, zc,zv, xmomc, ymomc, areas) 1279 1282 1280 1283 else: … … 1290 1293 self.epsilon, wc, zc, xmomc, ymomc) 1291 1294 1292 1295 1296 def balance_deep_and_shallow(self): 1297 """Compute linear combination between stage as computed by 1298 gradient-limiters limiting using w, and stage computed by 1299 gradient-limiters limiting using h (h-limiter). 1300 The former takes precedence when heights are large compared to the 1301 bed slope while the latter takes precedence when heights are 1302 relatively small. Anything in between is computed as a balanced 1303 linear combination in order to avoid numerical disturbances which 1304 would otherwise appear as a result of hard switching between 1305 modes. 1306 1307 Wrapper for C implementation 1308 """ 1309 1310 from shallow_water_ext import balance_deep_and_shallow \ 1311 as balance_deep_and_shallow_ext 1312 1313 # Shortcuts 1314 wc = self.quantities['stage'].centroid_values 1315 zc = self.quantities['elevation'].centroid_values 1316 wv = self.quantities['stage'].vertex_values 1317 zv = self.quantities['elevation'].vertex_values 1318 1319 # Momentums at centroids 1320 xmomc = self.quantities['xmomentum'].centroid_values 1321 ymomc = self.quantities['ymomentum'].centroid_values 1322 1323 # Momentums at vertices 1324 xmomv = self.quantities['xmomentum'].vertex_values 1325 ymomv = self.quantities['ymomentum'].vertex_values 1326 1327 balance_deep_and_shallow_ext(self, 1328 wc, zc, wv, zv, wc, 1329 xmomc, ymomc, xmomv, ymomv) 1293 1330 1294 1331 def update_other_quantities(self): … … 1990 2027 ## domain.epsilon, wc, zc, xmomc, ymomc) 1991 2028 1992 def balance_deep_and_shallow(domain): 1993 """Compute linear combination between stage as computed by 1994 gradient-limiters limiting using w, and stage computed by 1995 gradient-limiters limiting using h (h-limiter). 1996 The former takes precedence when heights are large compared to the 1997 bed slope while the latter takes precedence when heights are 1998 relatively small. Anything in between is computed as a balanced 1999 linear combination in order to avoid numerical disturbances which 2000 would otherwise appear as a result of hard switching between 2001 modes. 2002 2003 Wrapper for C implementation 2004 """ 2005 2006 from anuga.shallow_water.shallow_water_ext import balance_deep_and_shallow \ 2007 as balance_deep_and_shallow_c 2008 2009 # Shortcuts 2010 wc = domain.quantities['stage'].centroid_values 2011 zc = domain.quantities['elevation'].centroid_values 2012 wv = domain.quantities['stage'].vertex_values 2013 zv = domain.quantities['elevation'].vertex_values 2014 2015 # Momentums at centroids 2016 xmomc = domain.quantities['xmomentum'].centroid_values 2017 ymomc = domain.quantities['ymomentum'].centroid_values 2018 2019 # Momentums at vertices 2020 xmomv = domain.quantities['xmomentum'].vertex_values 2021 ymomv = domain.quantities['ymomentum'].vertex_values 2022 2023 balance_deep_and_shallow_c(domain, 2024 wc, zc, wv, zv, wc, 2025 xmomc, ymomc, xmomv, ymomv) 2029 2026 2030 2027 2031 -
trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r8539 r8578 7012 7012 # Large test set revealed one problem 7013 7013 points_file = os.path.join(path, 'test_points_large.csv') 7014 7015 domain.set_quantity('elevation', filename=points_file, 7016 use_cache=False, verbose=verbose) 7014 7017 try: 7015 7018 domain.set_quantity('elevation', filename=points_file,
Note: See TracChangeset
for help on using the changeset viewer.