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
5586 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
boundary_conditions = boundary_condition_periodic)
25
26
###############################################################################
27
# ODE solvers, callbacks etc.
28
29
tspan = (0.0, 2.0)
30
ode = semidiscretize(semi, tspan)
31
32
summary_callback = SummaryCallback()
33
34
analysis_interval = 100
35
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
36
save_analysis = false,
37
extra_analysis_integrals = (entropy, energy_total,
38
energy_kinetic,
39
energy_internal,
40
energy_magnetic,
41
cross_helicity))
42
43
alive_callback = AliveCallback(analysis_interval = analysis_interval)
44
45
save_solution = SaveSolutionCallback(interval = 100,
46
save_initial_solution = true,
47
save_final_solution = true,
48
solution_variables = cons2prim)
49
cfl = 0.9
50
stepsize_callback = StepsizeCallback(cfl = cfl)
51
52
glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)
53
54
callbacks = CallbackSet(summary_callback,
55
analysis_callback,
56
alive_callback,
57
save_solution,
58
stepsize_callback,
59
glm_speed_callback)
60
61
###############################################################################
62
# run the simulation
63
64
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
65
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
66
ode_default_options()..., callback = callbacks);
67
68