Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/unstructured_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
gamma = 5 / 3
7
equations = IdealGlmMhdEquations2D(gamma)
8
9
initial_condition = initial_condition_convergence_test
10
11
volume_flux = (flux_central, flux_nonconservative_powell)
12
solver = DGSEM(polydeg = 7,
13
surface_flux = (flux_hlle,
14
flux_nonconservative_powell),
15
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
16
17
# Get the unstructured quad mesh from a file (downloads the file if not available locally)
18
mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh",
19
joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh"))
20
21
mesh = UnstructuredMesh2D(mesh_file, periodicity = true)
22
23
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
24
25
###############################################################################
26
# ODE solvers, callbacks etc.
27
28
tspan = (0.0, 2.0)
29
ode = semidiscretize(semi, tspan)
30
31
summary_callback = SummaryCallback()
32
33
analysis_interval = 100
34
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
35
save_analysis = false,
36
extra_analysis_integrals = (entropy, energy_total,
37
energy_kinetic,
38
energy_internal,
39
energy_magnetic,
40
cross_helicity))
41
42
alive_callback = AliveCallback(analysis_interval = analysis_interval)
43
44
save_solution = SaveSolutionCallback(interval = 100,
45
save_initial_solution = true,
46
save_final_solution = true,
47
solution_variables = cons2prim)
48
cfl = 0.9
49
stepsize_callback = StepsizeCallback(cfl = cfl)
50
51
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)
52
53
callbacks = CallbackSet(summary_callback,
54
analysis_callback,
55
alive_callback,
56
save_solution,
57
stepsize_callback,
58
glm_speed_callback)
59
60
###############################################################################
61
# run the simulation
62
63
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
64
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
65
ode_default_options()..., callback = callbacks);
66
67