1+ using OrdinaryDiffEqSSPRK, OrdinaryDiffEqLowStorageRK
2+ using Trixi
3+ using TrixiShallowWater
4+
5+ # ##############################################################################
6+ # semidiscretization of the shallow water equations with a discontinuous
7+ # bottom topography function for a fully wet configuration
8+
9+ equations = HyperbolicSainteMarieEquations1D (gravity= 1.0 , b0= 0.1 )
10+
11+ function initial_condition_periodic (x, t, equations:: HyperbolicSainteMarieEquations1D )
12+ h = 1 + exp (sinpi (2 * x[1 ]))
13+ v = 1
14+ w = 1
15+ p = 10
16+ b = 0.1 * exp (sinpi (2 * x[1 ]))
17+ H = h+ b
18+ return prim2cons (SVector (H, v, w, p, b), equations)
19+ end
20+
21+ initial_condition = initial_condition_periodic
22+ # ##############################################################################
23+ # Get the DG approximation space
24+ alpha_coefficients = (1 / 2 , 1.0 , 2 / 3 )
25+ volume_flux = (flux_conservative_artiano_ranocha (alpha_coefficients... ), flux_nonconservative_artiano_ranocha (alpha_coefficients... ))
26+ surface_flux = volume_flux
27+ polydeg = 3
28+ solver = DGSEM (polydeg= polydeg, surface_flux= surface_flux,
29+ volume_integral= VolumeIntegralFluxDifferencing (volume_flux))
30+ boundary_condition = BoundaryConditionDirichlet (initial_condition)
31+ # ##############################################################################
32+ # Get the TreeMesh and setup a periodic mesh
33+ coordinates_min = 0.0
34+ coordinates_max = 1.0
35+ mesh = TreeMesh (coordinates_min, coordinates_max,
36+ initial_refinement_level= 7 ,
37+ n_cells_max= 10_000 ,
38+ periodicity= true )
39+
40+ # Create the semi discretization object
41+ semi = SemidiscretizationHyperbolic (mesh, equations, initial_condition, solver, source_terms = source_term_hyperbolic_sainte_marie,
42+ boundary_conditions = boundary_condition_periodic)
43+
44+ # ##############################################################################
45+ # ODE solver
46+ tspan = (0.0 , 0.2 )
47+ ode = semidiscretize (semi, tspan)
48+
49+ # ##############################################################################
50+ # Callbacks
51+
52+ summary_callback = SummaryCallback ()
53+
54+ analysis_interval = 1000
55+ analysis_callback = AnalysisCallback (semi, interval= analysis_interval, extra_analysis_integrals = (entropy, ))
56+
57+ alive_callback = AliveCallback (analysis_interval= analysis_interval)
58+
59+ stepsize_callback = StepsizeCallback (cfl= 0.1 )
60+
61+ callbacks = CallbackSet (
62+ summary_callback,
63+ analysis_callback,
64+ alive_callback
65+ )
66+
67+ # ##############################################################################
68+ # run the simulation
69+
70+ sol = solve (ode,
71+ SSPRK43 (thread= Trixi. True ());
72+ dt= 1.0 , # solve needs some value here but it will be overwritten by the stepsize_callback
73+ ode_default_options ()... , callback= callbacks);
0 commit comments