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_mhd_ec_shockcapturing.jl
5586 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible ideal GLM-MHD equations
6
7
equations = IdealGlmMhdEquations3D(1.4)
8
9
initial_condition = initial_condition_weak_blast_wave
10
11
surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)
12
volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)
13
polydeg = 4
14
basis = LobattoLegendreBasis(polydeg)
15
indicator_sc = IndicatorHennemannGassner(equations, basis,
16
alpha_max = 0.5,
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
coordinates_min = (-2.0, -2.0, -2.0)
28
coordinates_max = (2.0, 2.0, 2.0)
29
mesh = TreeMesh(coordinates_min, coordinates_max,
30
initial_refinement_level = 3,
31
n_cells_max = 10_000, periodicity = true)
32
33
# create the semi discretization object
34
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;
35
boundary_conditions = boundary_condition_periodic)
36
37
###############################################################################
38
# ODE solvers, callbacks etc.
39
40
tspan = (0.0, 1.0)
41
ode = semidiscretize(semi, tspan)
42
43
summary_callback = SummaryCallback()
44
45
analysis_interval = 100
46
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
47
48
alive_callback = AliveCallback(analysis_interval = analysis_interval)
49
50
cfl = 1.4
51
stepsize_callback = StepsizeCallback(cfl = cfl)
52
53
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)
54
55
callbacks = CallbackSet(summary_callback,
56
analysis_callback, alive_callback,
57
stepsize_callback,
58
glm_speed_callback)
59
60
###############################################################################
61
# run the simulation
62
63
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
64
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
65
ode_default_options()..., callback = callbacks);
66
67