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
2055 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)
32
33
# create the semi discretization object
34
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
35
36
###############################################################################
37
# ODE solvers, callbacks etc.
38
39
tspan = (0.0, 1.0)
40
ode = semidiscretize(semi, tspan)
41
42
summary_callback = SummaryCallback()
43
44
analysis_interval = 100
45
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
46
47
alive_callback = AliveCallback(analysis_interval = analysis_interval)
48
49
cfl = 1.4
50
stepsize_callback = StepsizeCallback(cfl = cfl)
51
52
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)
53
54
callbacks = CallbackSet(summary_callback,
55
analysis_callback, alive_callback,
56
stepsize_callback,
57
glm_speed_callback)
58
59
###############################################################################
60
# run the simulation
61
62
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
63
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
64
ode_default_options()..., callback = callbacks);
65
66