Changeset 8382
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/shallow_water/shallow_water_ext.c
r8381 r8382 2913 2913 2914 2914 // Local variables 2915 double max_speed, length, inv_area , zl, zr;2915 double max_speed, length, inv_area; 2916 2916 double timestep = 1.0e30; 2917 2917 double h0 = D->H0*D->H0; // This ensures a good balance when h approaches H0. … … 2927 2927 double hl, hl1, hl2; 2928 2928 double hr, hr1, hr2; 2929 double zl, zl1, zl2; 2930 double zr, zr1, zr2; 2931 double wr; 2929 2932 2930 2933 // Workspace (making them static actually made function slightly slower (Ole)) … … 2966 2969 2967 2970 zl = D->bed_edge_values[k3i]; 2971 2972 zl1 = D->bed_vertex_values[k3i1]; 2973 zl2 = D->bed_vertex_values[k3i2]; 2974 2975 2968 2976 hl = D->stage_edge_values[k3i] - zl; 2969 2977 2970 hl1 = D->stage_vertex_values[k3i1] - D->bed_vertex_values[k3i1]; 2971 hl2 = D->stage_vertex_values[k3i2] - D->bed_vertex_values[k3i2]; 2978 hl1 = D->stage_vertex_values[k3i1] - zl1; 2979 hl2 = D->stage_vertex_values[k3i2] - zl2; 2980 2972 2981 2973 2982 // Get right hand side values either from neighbouring triangle … … 2982 2991 qr[2] = D->ymom_boundary_values[m]; 2983 2992 2984 zr = zl; // Extend bed elevation to boundary and assume flat 2985 hr = D->stage_boundary_values[m] - zr; 2986 hr1 = hr; 2987 hr2 = hr; 2993 zr = zl; // Extend bed elevation to boundary and assume flat stage 2994 2995 wr = D->stage_boundary_values[m]; 2996 2997 hr = wr - zr; 2998 hr1 = wr-zl2; 2999 hr2 = wr-zl1; 3000 2988 3001 2989 3002 } -
trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r8381 r8382 2227 2227 assert num.allclose(domain.quantities['ymomentum'].explicit_update, 0) 2228 2228 2229 def test_gravity_3(self): 2230 #Showing standard gravity term is not well balanced 2229 2230 2231 def test_well_balanced_flux_1(self): 2232 #testing that compute_fluxes_method = wb_1 is well balance 2231 2233 2232 2234 from anuga.config import g 2235 from anuga import Reflective_boundary 2233 2236 2234 2237 a = [0.0, 0.0] … … 2256 2259 domain.set_quantity('stage', stage) 2257 2260 2261 2262 2258 2263 for name in domain.conserved_quantities: 2259 2264 assert num.allclose(domain.quantities[name].explicit_update, 0) 2260 2265 assert num.allclose(domain.quantities[name].semi_implicit_update, 0) 2261 2266 2262 domain.set_compute_fluxes_method('original') 2263 domain.compute_forcing_terms() 2267 2268 Br = Reflective_boundary(domain) # Solid reflective wall 2269 domain.set_boundary({'exterior' :Br}) 2270 domain.update_boundary() 2271 2272 domain.set_compute_fluxes_method('wb_1') 2273 domain.compute_fluxes() 2264 2274 2265 2275 2266 2276 print domain.quantities['xmomentum'].explicit_update 2267 #print domain.quantities['ymomentum'].explicit_update 2277 print domain.quantities['stage'].vertex_values 2278 print domain.quantities['elevation'].vertex_values 2279 print domain.quantities['ymomentum'].explicit_update 2268 2280 2269 2281 2270 2282 assert num.allclose(domain.quantities['stage'].explicit_update, 0) 2271 assert num.allclose(domain.quantities['xmomentum'].explicit_update, 2272 [-382.2, -323.4, -205.8, -382.2]) 2273 assert num.allclose(domain.quantities['ymomentum'].explicit_update, 0) 2274 2283 assert num.allclose(domain.quantities['xmomentum'].explicit_update, 0.0) 2284 assert num.allclose(domain.quantities['ymomentum'].explicit_update, 0.0) 2285 2286 2287 def test_well_balanced_flux_2(self): 2288 #esting that compute_fluxes_method = wb_2 is well balance 2289 2290 from anuga.config import g 2291 from anuga import Reflective_boundary 2292 2293 a = [0.0, 0.0] 2294 b = [0.0, 2.0] 2295 c = [2.0, 0.0] 2296 d = [0.0, 4.0] 2297 e = [2.0, 2.0] 2298 f = [4.0, 0.0] 2299 2300 points = [a, b, c, d, e, f] 2301 # bac, bce, ecf, dbe 2302 vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]] 2303 2304 domain = Domain(points, vertices) 2305 2306 #Set up for a gradient of (3,0) at mid triangle (bce) 2307 def slope(x, y): 2308 return 3*x 2309 2310 h = 15 2311 def stage(x, y): 2312 return h 2313 2314 domain.set_quantity('elevation', slope) 2315 domain.set_quantity('stage', stage) 2316 2317 2318 2319 for name in domain.conserved_quantities: 2320 assert num.allclose(domain.quantities[name].explicit_update, 0) 2321 assert num.allclose(domain.quantities[name].semi_implicit_update, 0) 2322 2323 2324 Br = Reflective_boundary(domain) # Solid reflective wall 2325 domain.set_boundary({'exterior' :Br}) 2326 domain.update_boundary() 2327 2328 domain.set_compute_fluxes_method('wb_2') 2329 domain.compute_fluxes() 2330 2331 2332 print domain.quantities['xmomentum'].explicit_update 2333 print domain.quantities['stage'].vertex_values 2334 print domain.quantities['elevation'].vertex_values 2335 print domain.quantities['ymomentum'].explicit_update 2336 2337 2338 assert num.allclose(domain.quantities['stage'].explicit_update, 0) 2339 assert num.allclose(domain.quantities['xmomentum'].explicit_update, 0.0) 2340 assert num.allclose(domain.quantities['ymomentum'].explicit_update, 0.0) 2275 2341 2276 2342 def test_gravity_wb(self): … … 7585 7651 if __name__ == "__main__": 7586 7652 #suite = unittest.makeSuite(Test_Shallow_Water, 'test_rainfall_forcing_with_evolve') 7587 suite = unittest.makeSuite(Test_Shallow_Water, 'test ')7653 suite = unittest.makeSuite(Test_Shallow_Water, 'test_well') 7588 7654 runner = unittest.TextTestRunner(verbosity=1) 7589 7655 runner.run(suite) -
trunk/anuga_work/shallow_water_balanced_steve/run_sw_merimbula.py
r8381 r8382 49 49 #mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.5 50 50 #mesh_filename = "test-20.tsh" ; x0 = 250.0 ; x1 = 350.0 51 yieldstep = 1 #2052 finaltime = 10 #20051 yieldstep = 20 52 finaltime = 200 53 53 verbose = True 54 54 … … 97 97 #domain.set_CFL(0.7) 98 98 #domain.set_beta(1.5) 99 domain.set_compute_fluxes_method('wb_ 2')99 domain.set_compute_fluxes_method('wb_1') 100 100 domain.set_name('merimbula') 101 101
Note: See TracChangeset
for help on using the changeset viewer.