Skip to content

Commit 2564ef7

Browse files
Shu-Osher testcase non-uniform Structured 1D mesh with FV O2 (#2651)
* Shu-Osher testcase non-uniform Structured 1D mesh with FV O2 * Apply suggestions from code review * Update examples/structured_1d_dgsem/elixir_euler_shu_osher_nonuniform_fvO2.jl * Update examples/structured_1d_dgsem/elixir_euler_shu_osher_nonuniform_fvO2.jl * controller * comment * toml * compat * compat * compat --------- Co-authored-by: Hendrik Ranocha <[email protected]>
1 parent 60fa350 commit 2564ef7

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using OrdinaryDiffEqSSPRK
2+
using OrdinaryDiffEqCore: PIDController
3+
using Trixi
4+
5+
###############################################################################
6+
# semidiscretization of the compressible Euler equations
7+
8+
equations = CompressibleEulerEquations1D(1.4)
9+
10+
# Shu-Osher initial condition for 1D compressible Euler equations
11+
# Example 8 from Shu, Osher (1989).
12+
# https://doi.org/10.1016/0021-9991(89)90222-2
13+
function initial_condition_shu_osher(x, t, equations::CompressibleEulerEquations1D)
14+
x0 = -4
15+
16+
rho_left = 27 / 7
17+
v_left = 4 * sqrt(35) / 9
18+
p_left = 31 / 3
19+
20+
v_right = 0.0
21+
p_right = 1.0
22+
23+
rho = ifelse(x[1] > x0, 1 + 1 / 5 * sin(5 * x[1]), rho_left)
24+
v = ifelse(x[1] > x0, v_right, v_left)
25+
p = ifelse(x[1] > x0, p_right, p_left)
26+
27+
return prim2cons(SVector(rho, v, p), equations)
28+
end
29+
30+
initial_condition = initial_condition_shu_osher
31+
32+
surface_flux = flux_hllc
33+
polydeg = 3 # governs in this case only the number of FV subcells per DG cell
34+
basis = LobattoLegendreBasis(polydeg)
35+
volume_integral = VolumeIntegralPureLGLFiniteVolumeO2(basis,
36+
volume_flux_fv = surface_flux,
37+
reconstruction_mode = reconstruction_O2_inner,
38+
slope_limiter = monotonized_central)
39+
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
40+
volume_integral = volume_integral)
41+
42+
function refined_mapping(xi)
43+
fine_fraction = 0.8
44+
a_fine = 4.0
45+
x_max = 5.0
46+
47+
# Compute the value at the boundary for continuity
48+
x_boundary = a_fine * fine_fraction
49+
# Slope for the outer region
50+
a_outer = (x_max - x_boundary) / (1 - fine_fraction)
51+
if abs(xi) <= fine_fraction
52+
x = a_fine * xi
53+
else
54+
x = x_boundary + a_outer * (abs(xi) - fine_fraction)
55+
x *= sign(xi)
56+
end
57+
return x
58+
end
59+
60+
cells_per_dimension = (128,)
61+
mesh = StructuredMesh(cells_per_dimension, refined_mapping, periodicity = false)
62+
63+
boundary_condition = BoundaryConditionDirichlet(initial_condition)
64+
boundary_conditions = boundary_condition_default(mesh, boundary_condition)
65+
66+
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
67+
boundary_conditions = boundary_conditions)
68+
69+
###############################################################################
70+
# ODE solvers, callbacks etc.
71+
72+
tspan = (0.0, 2.0)
73+
ode = semidiscretize(semi, tspan)
74+
75+
summary_callback = SummaryCallback()
76+
77+
analysis_interval = 1000
78+
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
79+
80+
alive_callback = AliveCallback(analysis_interval = analysis_interval)
81+
82+
callbacks = CallbackSet(summary_callback,
83+
analysis_callback,
84+
alive_callback)
85+
86+
###############################################################################
87+
# run the simulation
88+
89+
# Solve ODE with optimized timestep controller from https://doi.org/10.1007/s42967-021-00159-w
90+
sol = solve(ode, SSPRK43();
91+
controller = PIDController(0.55, -0.27, 0.05),
92+
abstol = 1e-4, reltol = 1e-4,
93+
callback = callbacks, ode_default_options()...)

test/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
1818
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
1919
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
2020
OrdinaryDiffEqBDF = "6ad6398a-0878-4a85-9266-38940aa047c8"
21+
OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
2122
OrdinaryDiffEqFeagin = "101fe9f7-ebb6-4678-b671-3a81e7194747"
2223
OrdinaryDiffEqHighOrderRK = "d28bc4f8-55e1-4f49-af69-84c1a99f0f58"
2324
OrdinaryDiffEqLowOrderRK = "1344f307-1e59-4825-a18e-ace9aa3fa4c6"
@@ -56,6 +57,7 @@ LinearSolve = "2.36.1, 3"
5657
MPI = "0.20.6"
5758
NLsolve = "4.5.1"
5859
OrdinaryDiffEqBDF = "1.1"
60+
OrdinaryDiffEqCore = "1.6"
5961
OrdinaryDiffEqFeagin = "1"
6062
OrdinaryDiffEqHighOrderRK = "1.1"
6163
OrdinaryDiffEqLowOrderRK = "1.2"

test/test_structured_1d.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ end
139139
@test_allocations(Trixi.rhs!, semi, sol, 1000)
140140
end
141141

142+
@trixi_testset "elixir_euler_shu_osher_nonuniform_fvO2.jl" begin
143+
@test_trixi_include(joinpath(EXAMPLES_DIR,
144+
"elixir_euler_shu_osher_nonuniform_fvO2.jl"),
145+
abstol=1e-11, reltol=1e-11,
146+
l2=[0.5000856244205995, 1.7958065770030094, 6.50409305116869],
147+
linf=[2.981082161129505, 10.10855083991654, 36.26666086388062],
148+
tspan=(0.0, 0.1))
149+
# Ensure that we do not have excessive memory allocations
150+
# (e.g., from type instabilities)
151+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
152+
end
153+
142154
@trixi_testset "elixir_euler_source_terms.jl" begin
143155
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"),
144156
# Expected errors are exactly the same as with TreeMesh!

0 commit comments

Comments
 (0)