Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/t8code_2d_dgsem/elixir_euler_shockcapturing_ec.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# Semidiscretization of the compressible Euler equations.
6
7
equations = CompressibleEulerEquations2D(1.4)
8
9
initial_condition = initial_condition_weak_blast_wave
10
11
surface_flux = flux_ranocha
12
volume_flux = flux_ranocha
13
polydeg = 4
14
basis = LobattoLegendreBasis(polydeg)
15
indicator_sc = IndicatorHennemannGassner(equations, basis,
16
alpha_max = 1.0,
17
alpha_min = 0.001,
18
alpha_smooth = true,
19
variable = density_pressure)
20
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
21
volume_flux_dg = volume_flux,
22
volume_flux_fv = surface_flux)
23
24
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
25
volume_integral = volume_integral)
26
27
###############################################################################
28
29
coordinates_min = (-1.0, -1.0)
30
coordinates_max = (1.0, 1.0)
31
32
trees_per_dimension = (4, 4)
33
34
mesh = T8codeMesh(trees_per_dimension, polydeg = 4,
35
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
36
initial_refinement_level = 2, periodicity = true)
37
38
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
39
40
###############################################################################
41
# ODE solvers, callbacks etc.
42
43
tspan = (0.0, 2.0)
44
ode = semidiscretize(semi, tspan)
45
46
summary_callback = SummaryCallback()
47
48
analysis_interval = 100
49
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
50
51
alive_callback = AliveCallback(analysis_interval = analysis_interval)
52
53
save_solution = SaveSolutionCallback(interval = 100,
54
save_initial_solution = true,
55
save_final_solution = true,
56
solution_variables = cons2prim)
57
58
stepsize_callback = StepsizeCallback(cfl = 1.0)
59
60
callbacks = CallbackSet(summary_callback,
61
analysis_callback,
62
alive_callback,
63
save_solution,
64
stepsize_callback)
65
66
###############################################################################
67
# run the simulation
68
69
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
70
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
71
ode_default_options()..., callback = callbacks);
72
73