Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/tree_3d_dgsem/elixir_mhd_ec.jl
5586 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
volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)
12
solver = DGSEM(polydeg = 3,
13
surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell),
14
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
15
16
coordinates_min = (-2.0, -2.0, -2.0)
17
coordinates_max = (2.0, 2.0, 2.0)
18
mesh = TreeMesh(coordinates_min, coordinates_max,
19
initial_refinement_level = 2,
20
n_cells_max = 10_000, periodicity = true)
21
22
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;
23
boundary_conditions = boundary_condition_periodic)
24
25
###############################################################################
26
# ODE solvers, callbacks etc.
27
28
tspan = (0.0, 0.4)
29
ode = semidiscretize(semi, tspan)
30
31
summary_callback = SummaryCallback()
32
33
analysis_interval = 100
34
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
35
36
alive_callback = AliveCallback(analysis_interval = analysis_interval)
37
38
save_solution = SaveSolutionCallback(interval = 10,
39
save_initial_solution = true,
40
save_final_solution = true,
41
solution_variables = cons2prim)
42
43
cfl = 1.4
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, alive_callback,
50
save_solution,
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