Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/tree_3d_dgsem/elixir_euler_shockcapturing_amr.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
equations = CompressibleEulerEquations3D(1.4)
8
9
initial_condition = initial_condition_weak_blast_wave
10
11
surface_flux = flux_ranocha # OBS! Using a non-dissipative flux is only sensible to test EC,
12
# but not for real shock simulations
13
volume_flux = flux_ranocha
14
polydeg = 3
15
basis = LobattoLegendreBasis(polydeg)
16
indicator_sc = IndicatorHennemannGassner(equations, basis,
17
alpha_max = 0.5,
18
alpha_min = 0.001,
19
alpha_smooth = true,
20
variable = density_pressure)
21
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
22
volume_flux_dg = volume_flux,
23
volume_flux_fv = surface_flux)
24
solver = DGSEM(basis, surface_flux, volume_integral)
25
26
coordinates_min = (-2.0, -2.0, -2.0)
27
coordinates_max = (2.0, 2.0, 2.0)
28
mesh = TreeMesh(coordinates_min, coordinates_max,
29
initial_refinement_level = 3,
30
n_cells_max = 100_000)
31
32
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
33
34
###############################################################################
35
# ODE solvers, callbacks etc.
36
37
tspan = (0.0, 0.4)
38
ode = semidiscretize(semi, tspan)
39
40
summary_callback = SummaryCallback()
41
42
analysis_interval = 100
43
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
44
45
alive_callback = AliveCallback(analysis_interval = analysis_interval)
46
47
save_solution = SaveSolutionCallback(interval = 100,
48
save_initial_solution = true,
49
save_final_solution = true,
50
solution_variables = cons2prim)
51
52
amr_indicator = IndicatorHennemannGassner(semi,
53
alpha_smooth = false,
54
variable = density_pressure)
55
56
amr_controller = ControllerThreeLevel(semi, amr_indicator,
57
base_level = 2,
58
max_level = 4, max_threshold = 0.0003)
59
60
amr_callback = AMRCallback(semi, amr_controller,
61
interval = 1,
62
adapt_initial_condition = true,
63
adapt_initial_condition_only_refine = true)
64
65
stepsize_callback = StepsizeCallback(cfl = 1.3)
66
67
callbacks = CallbackSet(summary_callback,
68
analysis_callback, alive_callback,
69
save_solution,
70
amr_callback, stepsize_callback)
71
72
###############################################################################
73
# run the simulation
74
75
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
76
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
77
ode_default_options()..., callback = callbacks);
78
79