Changeset 8374 for trunk/anuga_work/shallow_water_balanced_steve
- Timestamp:
- Mar 30, 2012, 5:14:21 PM (13 years ago)
- Location:
- trunk/anuga_work/shallow_water_balanced_steve
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/shallow_water_balanced_steve/swb_domain.py
r8366 r8374 130 130 131 131 132 def distribute_to_vertices_and_edges (self):132 def distribute_to_vertices_and_edges_w_v(self): 133 133 """Distribution from centroids to edges specific to the SWW eqn. 134 134 … … 203 203 raise Exception('Unknown order: %s' % str(self._order_)) 204 204 205 for name in [ 'height' ]:206 Q = self.quantities[name]207 if self._order_ == 1:208 Q.extrapolate_first_order()209 elif self._order_ == 2:210 #Q.extrapolate_second_order_and_limit_by_edge()211 Q.extrapolate_second_order_and_limit_by_vertex()212 else:213 raise Exception('Unknown order: %s' % str(self._order_))214 205 215 206 … … 227 218 #protect(self) 228 219 229 z_V[:] = w_V - h_V220 h_V[:] = w_V - z_V 230 221 uh_V[:] = u_V * h_V 231 222 vh_V[:] = v_V * h_V … … 246 237 247 238 248 249 def distribute_to_vertices_and_edges_h(self): 239 def distribute_to_vertices_and_edges_w_h(self): 250 240 """Distribution from centroids to edges specific to the SWW eqn. 251 241 … … 256 246 In addition, all conserved quantities get distributed as per either a 257 247 constant (order==1) or a piecewise linear function (order==2). 258 248 259 249 260 250 Precondition: 261 251 All conserved quantities defined at centroids and bed elevation defined at 262 252 edges. 263 253 264 254 Postcondition 265 255 Evolved quantities defined at vertices and edges 266 256 """ 267 257 258 from anuga.shallow_water.shallow_water_domain import \ 259 protect_against_infinitesimal_and_negative_heights as protect 268 260 269 261 #Shortcuts … … 276 268 V = self.quantities['yvelocity'] 277 269 270 #Arrays 271 w_C = W.centroid_values 272 uh_C = UH.centroid_values 273 vh_C = VH.centroid_values 274 z_C = Z.centroid_values 275 h_C = H.centroid_values 276 u_C = U.centroid_values 277 v_C = V.centroid_values 278 279 #num_min = num.min(w_C-z_C) 280 #if num_min < -1.0e-5: 281 # print '**** num.min(w_C-z_C)', num_min 282 283 284 w_C[:] = num.maximum(w_C, z_C) 285 h_C[:] = w_C - z_C 286 287 288 assert num.min(h_C) >= 0.0 289 290 num.putmask(uh_C, h_C < 1.0e-15, 0.0) 291 num.putmask(vh_C, h_C < 1.0e-15, 0.0) 292 #num.putmask(h_C, h_C < 1.0e-15, 1.0e-16) 293 294 # Noelle has an alternative method for calculating velcities 295 # Check it out in the GPU shallow water paper 296 H0 = 1.0e-16 297 u_C[:] = uh_C/(h_C + H0/h_C) 298 v_C[:] = vh_C/(h_C + H0/h_C) 299 300 #num.putmask(h_C, h_C < 1.0e-15, 0.0) 301 302 for name in [ 'stage', 'xvelocity', 'yvelocity' ]: 303 Q = self.quantities[name] 304 if self._order_ == 1: 305 Q.extrapolate_first_order() 306 elif self._order_ == 2: 307 Q.extrapolate_second_order_and_limit_by_edge() 308 #Q.extrapolate_second_order_and_limit_by_vertex() 309 else: 310 raise Exception('Unknown order: %s' % str(self._order_)) 311 312 for name in [ 'height' ]: 313 Q = self.quantities[name] 314 if self._order_ == 1: 315 Q.extrapolate_first_order() 316 elif self._order_ == 2: 317 #Q.extrapolate_second_order_and_limit_by_edge() 318 Q.extrapolate_second_order_and_limit_by_vertex() 319 else: 320 raise Exception('Unknown order: %s' % str(self._order_)) 321 322 323 w_V = W.vertex_values 324 u_V = U.vertex_values 325 v_V = V.vertex_values 326 z_V = Z.vertex_values 327 328 h_V = H.vertex_values 329 uh_V = UH.vertex_values 330 vh_V = VH.vertex_values 331 332 333 # Update other quantities 334 #protect(self) 335 336 z_V[:] = w_V - h_V 337 uh_V[:] = u_V * h_V 338 vh_V[:] = v_V * h_V 339 340 341 num_min = num.min(h_V) 342 if num_min < -1.0e-14: 343 #print 'num.min(h_V)', num_min 344 pass 345 346 347 # Compute edge values by interpolation 348 for name in ['xmomentum', 'ymomentum', 'elevation']: 349 Q = self.quantities[name] 350 Q.interpolate_from_vertices_to_edges() 351 352 353 354 355 def distribute_to_vertices_and_edges_h(self): 356 """Distribution from centroids to edges specific to the SWW eqn. 357 358 It will ensure that h (w-z) is always non-negative even in the 359 presence of steep bed-slopes by taking a weighted average between shallow 360 and deep cases. 361 362 In addition, all conserved quantities get distributed as per either a 363 constant (order==1) or a piecewise linear function (order==2). 364 365 366 Precondition: 367 All conserved quantities defined at centroids and bed elevation defined at 368 edges. 369 370 Postcondition 371 Evolved quantities defined at vertices and edges 372 """ 373 374 375 #Shortcuts 376 W = self.quantities['stage'] 377 UH = self.quantities['xmomentum'] 378 VH = self.quantities['ymomentum'] 379 H = self.quantities['height'] 380 Z = self.quantities['elevation'] 381 U = self.quantities['xvelocity'] 382 V = self.quantities['yvelocity'] 383 278 384 #Arrays 279 385 w_C = W.centroid_values -
trunk/anuga_work/shallow_water_balanced_steve/swb_domain_ext.c
r8203 r8374 612 612 k3 = 3*k; // base index 613 613 614 // Get stage 614 // Get stage centroid values 615 615 w0 = ((double*) w -> data)[k3 + 0]; 616 616 w1 = ((double*) w -> data)[k3 + 1];
Note: See TracChangeset
for help on using the changeset viewer.