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
5586 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
boundary_conditions = boundary_condition_periodic)
40
41
###############################################################################
42
# ODE solvers, callbacks etc.
43
44
tspan = (0.0, 0.4)
45
ode = semidiscretize(semi, tspan)
46
47
summary_callback = SummaryCallback()
48
49
analysis_interval = 100
50
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
51
52
alive_callback = AliveCallback(analysis_interval = analysis_interval)
53
54
cfl = 1.0
55
stepsize_callback = StepsizeCallback(cfl = cfl)
56
57
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)
58
59
callbacks = CallbackSet(summary_callback,
60
analysis_callback,
61
alive_callback,
62
stepsize_callback,
63
glm_speed_callback)
64
65
###############################################################################
66
# run the simulation
67
68
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
69
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
70
ode_default_options()..., callback = callbacks);
71
72