Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/structured_2d_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
equations = IdealGlmMhdEquations2D(1.4)
7
8
initial_condition = initial_condition_weak_blast_wave
9
10
surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)
11
volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)
12
polydeg = 4
13
basis = LobattoLegendreBasis(polydeg)
14
indicator_sc = IndicatorHennemannGassner(equations, basis,
15
alpha_max = 0.5,
16
alpha_min = 0.001,
17
alpha_smooth = true,
18
variable = density_pressure)
19
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
20
volume_flux_dg = volume_flux,
21
volume_flux_fv = surface_flux)
22
solver = DGSEM(basis, surface_flux, volume_integral)
23
24
# Get the curved quad mesh from a mapping function
25
# Mapping as described in https://arxiv.org/abs/2012.12040
26
function mapping(xi, eta)
27
y = 2.0 * eta + 1.0 / 6.0 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta))
28
29
x = 2.0 * xi + 1.0 / 6.0 * (cos(0.5 * pi * xi) * cos(2 * pi * y))
30
31
return SVector(x, y)
32
end
33
34
cells_per_dimension = (16, 16)
35
36
mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true)
37
38
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
39
40
###############################################################################
41
# ODE solvers, callbacks etc.
42
43
tspan = (0.0, 0.4)
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
cfl = 1.0
54
stepsize_callback = StepsizeCallback(cfl = cfl)
55
56
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)
57
58
callbacks = CallbackSet(summary_callback,
59
analysis_callback,
60
alive_callback,
61
stepsize_callback,
62
glm_speed_callback)
63
64
###############################################################################
65
# run the simulation
66
67
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
68
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
69
ode_default_options()..., callback = callbacks);
70
71