Changeset 8382


Ignore:
Timestamp:
Apr 3, 2012, 8:26:00 PM (13 years ago)
Author:
steve
Message:

can run anuga with various flux computations (2 well balanced schemes)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/shallow_water/shallow_water_ext.c

    r8381 r8382  
    29132913
    29142914    // Local variables
    2915     double max_speed, length, inv_area, zl, zr;
     2915    double max_speed, length, inv_area;
    29162916    double timestep = 1.0e30;
    29172917    double h0 = D->H0*D->H0; // This ensures a good balance when h approaches H0.
     
    29272927    double hl, hl1, hl2;
    29282928    double hr, hr1, hr2;
     2929    double zl, zl1, zl2;
     2930    double zr, zr1, zr2;
     2931    double wr;
    29292932
    29302933    // Workspace (making them static actually made function slightly slower (Ole))
     
    29662969
    29672970            zl = D->bed_edge_values[k3i];
     2971
     2972            zl1 = D->bed_vertex_values[k3i1];
     2973            zl2 = D->bed_vertex_values[k3i2];
     2974
     2975
    29682976            hl = D->stage_edge_values[k3i] - zl;
    29692977
    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
    29722981
    29732982            // Get right hand side values either from neighbouring triangle
     
    29822991                qr[2] = D->ymom_boundary_values[m];
    29832992
    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
    29883001
    29893002            }
  • trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r8381 r8382  
    22272227        assert num.allclose(domain.quantities['ymomentum'].explicit_update, 0)
    22282228
    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
    22312233
    22322234        from anuga.config import g
     2235        from anuga import Reflective_boundary
    22332236
    22342237        a = [0.0, 0.0]
     
    22562259        domain.set_quantity('stage', stage)
    22572260
     2261
     2262
    22582263        for name in domain.conserved_quantities:
    22592264            assert num.allclose(domain.quantities[name].explicit_update, 0)
    22602265            assert num.allclose(domain.quantities[name].semi_implicit_update, 0)
    22612266
    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()
    22642274
    22652275
    22662276        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
    22682280
    22692281
    22702282        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)
    22752341
    22762342    def test_gravity_wb(self):
     
    75857651if __name__ == "__main__":
    75867652    #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')
    75887654    runner = unittest.TextTestRunner(verbosity=1)
    75897655    runner.run(suite)
  • trunk/anuga_work/shallow_water_balanced_steve/run_sw_merimbula.py

    r8381 r8382  
    4949#mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.5
    5050#mesh_filename = "test-20.tsh" ; x0 = 250.0 ; x1 = 350.0
    51 yieldstep = 1 #20
    52 finaltime = 10 #200
     51yieldstep = 20
     52finaltime = 200
    5353verbose = True
    5454
     
    9797#domain.set_CFL(0.7)
    9898#domain.set_beta(1.5)
    99 domain.set_compute_fluxes_method('wb_2')
     99domain.set_compute_fluxes_method('wb_1')
    100100domain.set_name('merimbula')
    101101
Note: See TracChangeset for help on using the changeset viewer.