Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/t8code_2d_dgsem/elixir_mhd_alfven_wave.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# Semidiscretization of the compressible ideal GLM-MHD equations.
6
7
gamma = 5 / 3
8
equations = IdealGlmMhdEquations2D(gamma)
9
10
initial_condition = initial_condition_convergence_test
11
12
# Get the DG approximation space
13
volume_flux = (flux_central, flux_nonconservative_powell)
14
15
solver = DGSEM(polydeg = 4, surface_flux = (flux_hlle, flux_nonconservative_powell),
16
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
17
18
coordinates_min = (0.0, 0.0)
19
coordinates_max = (sqrt(2.0), sqrt(2.0))
20
21
trees_per_dimension = (8, 8)
22
23
mesh = T8codeMesh(trees_per_dimension, polydeg = 3,
24
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
25
initial_refinement_level = 0, periodicity = true)
26
27
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
28
29
###############################################################################
30
# ODE solvers, callbacks etc.
31
32
tspan = (0.0, 1.0)
33
ode = semidiscretize(semi, tspan)
34
35
summary_callback = SummaryCallback()
36
37
analysis_interval = 100
38
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
39
40
alive_callback = AliveCallback(analysis_interval = analysis_interval)
41
42
cfl = 0.9
43
stepsize_callback = StepsizeCallback(cfl = cfl)
44
45
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)
46
47
callbacks = CallbackSet(summary_callback,
48
analysis_callback,
49
alive_callback,
50
stepsize_callback,
51
glm_speed_callback)
52
53
###############################################################################
54
# run the simulation
55
56
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
57
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
58
ode_default_options()..., callback = callbacks);
59
60