Skip to content

Commit

Permalink
p4est_2d_dgsem/elixir_euler_shockcapturing_ec_float32.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
ranocha committed Aug 21, 2024
1 parent ad04ca8 commit 0c1ea8d
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
66 changes: 66 additions & 0 deletions examples/p4est_2d_dgsem/elixir_euler_shockcapturing_ec_float32.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the compressible Euler equations

equations = CompressibleEulerEquations2D(1.4f0)

initial_condition = initial_condition_weak_blast_wave

surface_flux = flux_ranocha
volume_flux = flux_ranocha
polydeg = 4
basis = LobattoLegendreBasis(Float32, polydeg)
indicator_sc = IndicatorHennemannGassner(equations, basis,
alpha_max = 1.0f0,
alpha_min = 0.001f0,
alpha_smooth = true,
variable = density_pressure)
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
volume_flux_dg = volume_flux,
volume_flux_fv = surface_flux)

solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
volume_integral = volume_integral, RealT = Float32)

###############################################################################

coordinates_min = (-1.0f0, -1.0f0)
coordinates_max = (+1.0f0, +1.0f0)

trees_per_dimension = (4, 4)
mesh = P4estMesh(trees_per_dimension,
polydeg = 4, initial_refinement_level = 2,
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
periodicity = true, RealT = Float32)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0f0, 2.0f0)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)

alive_callback = AliveCallback(analysis_interval = analysis_interval)

stepsize_callback = StepsizeCallback(cfl = 1.0f0)

callbacks = CallbackSet(summary_callback,
analysis_callback,
alive_callback,
stepsize_callback)
###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1.0f0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks);
summary_callback() # print the timer summary
25 changes: 25 additions & 0 deletions test/test_p4est_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,31 @@ end
end
end

@trixi_testset "elixir_euler_shockcapturing_ec_float32.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_ec_float32.jl"),
l2=[
0.09539953f0,
0.10563527f0,
0.105637245f0,
0.3507514f0
],
linf=[
0.2942562f0,
0.4079147f0,
0.3972956f0,
1.0810697f0
],
tspan=(0.0f0, 1.0f0))
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end

@trixi_testset "elixir_euler_sedov.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"),
l2=[
Expand Down

0 comments on commit 0c1ea8d

Please sign in to comment.