Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/p4est_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
solver = DGSEM(polydeg = 4,
15
surface_flux = (flux_hlle,
16
flux_nonconservative_powell),
17
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
18
19
coordinates_min = (0.0, 0.0)
20
coordinates_max = (sqrt(2.0), sqrt(2.0))
21
22
trees_per_dimension = (8, 8)
23
mesh = P4estMesh(trees_per_dimension,
24
polydeg = 3, initial_refinement_level = 0,
25
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
26
periodicity = true)
27
28
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
29
30
###############################################################################
31
# ODE solvers, callbacks etc.
32
33
tspan = (0.0, 1.0)
34
ode = semidiscretize(semi, tspan)
35
36
summary_callback = SummaryCallback()
37
38
analysis_interval = 100
39
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
40
41
alive_callback = AliveCallback(analysis_interval = analysis_interval)
42
43
cfl = 0.9
44
stepsize_callback = StepsizeCallback(cfl = cfl)
45
46
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)
47
48
callbacks = CallbackSet(summary_callback,
49
analysis_callback,
50
alive_callback,
51
stepsize_callback,
52
glm_speed_callback)
53
54
###############################################################################
55
# run the simulation
56
57
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
58
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
59
ode_default_options()..., callback = callbacks);
60
61