Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/structured_3d_dgsem/elixir_mhd_ec_shockcapturing.jl
5585 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
# Create a heavily warped curved mesh
28
29
# Mapping as described in https://arxiv.org/abs/2012.12040
30
function mapping(xi_, eta_, zeta_)
31
# Transform input variables between -1 and 1 onto [0,3]
32
xi = 1.5 * xi_ + 1.5
33
eta = 1.5 * eta_ + 1.5
34
zeta = 1.5 * zeta_ + 1.5
35
36
y = eta +
37
3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) *
38
cos(0.5 * pi * (2 * eta - 3) / 3) *
39
cos(0.5 * pi * (2 * zeta - 3) / 3))
40
41
x = xi +
42
3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) *
43
cos(2 * pi * (2 * y - 3) / 3) *
44
cos(0.5 * pi * (2 * zeta - 3) / 3))
45
46
z = zeta +
47
3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) *
48
cos(pi * (2 * y - 3) / 3) *
49
cos(0.5 * pi * (2 * zeta - 3) / 3))
50
51
return SVector(x, y, z)
52
end
53
54
cells_per_dimension = (8, 8, 8)
55
mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true)
56
57
# create the semi discretization object
58
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;
59
boundary_conditions = boundary_condition_periodic)
60
61
###############################################################################
62
# ODE solvers, callbacks etc.
63
64
tspan = (0.0, 1.0)
65
ode = semidiscretize(semi, tspan)
66
67
summary_callback = SummaryCallback()
68
69
analysis_interval = 100
70
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
71
72
alive_callback = AliveCallback(analysis_interval = analysis_interval)
73
74
cfl = 1.4
75
stepsize_callback = StepsizeCallback(cfl = cfl)
76
77
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)
78
79
callbacks = CallbackSet(summary_callback,
80
analysis_callback, alive_callback,
81
stepsize_callback,
82
glm_speed_callback)
83
84
###############################################################################
85
# run the simulation
86
87
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
88
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
89
ode_default_options()..., callback = callbacks);
90
91