Skip to content

Commit 470f555

Browse files
committed
add hypsm
1 parent a9ae27b commit 470f555

4 files changed

Lines changed: 411 additions & 2 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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);

src/TrixiShallowWater.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export ShallowWaterEquations1D, ShallowWaterEquations2D,
2828
ShallowWaterTwoLayerEquations1D, ShallowWaterTwoLayerEquations2D,
2929
ShallowWaterMultiLayerEquations1D, ShallowWaterMultiLayerEquations2D,
3030
ShallowWaterEquationsQuasi1D,
31-
ShallowWaterMomentEquations1D, ShallowWaterLinearizedMomentEquations1D
31+
ShallowWaterMomentEquations1D, ShallowWaterLinearizedMomentEquations1D,
32+
HyperbolicSainteMarieEquations1D
3233

3334
export hydrostatic_reconstruction_chen_noelle, flux_nonconservative_chen_noelle,
3435
min_max_speed_chen_noelle, flux_hll_chen_noelle,
@@ -39,7 +40,8 @@ export hydrostatic_reconstruction_chen_noelle, flux_nonconservative_chen_noelle,
3940
flux_nonconservative_audusse_etal, hydrostatic_reconstruction_audusse_etal,
4041
FluxHydrostaticReconstruction,
4142
source_term_manning_friction, source_term_newtonian_slip_friction,
42-
source_term_bottom_friction
43+
source_term_bottom_friction, source_term_hyperbolic_sainte_marie,
44+
flux_conservative_artiano_ranocha, flux_nonconservative_artiano_ranocha
4345

4446
export ManningFriction, MeyerPeterMueller, GrassModel, ShieldsStressModel,
4547
dissipation_roe, water_sediment_height

src/equations/equations.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ Retrieve the number of moments from an equation instance of the `AbstractMomentE
8888
NMOMENTS
8989
end
9090

91+
include("hyperbolic_sainte_marie_1d.jl")
92+
9193
# TODO: Add suitable default thresholds for Float32
9294
# Provide default thresholds dependent on number format (Currently default thresholds are only provided
9395
# for Float64)

0 commit comments

Comments
 (0)