Path: blob/main/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl
5586 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the compressible ideal GLM-MHD equations56equations = IdealGlmMhdEquations3D(5 / 3)78initial_condition = initial_condition_convergence_test910volume_flux = (flux_central, flux_nonconservative_powell)11solver = DGSEM(polydeg = 5,12surface_flux = (flux_hlle,13flux_nonconservative_powell),14volume_integral = VolumeIntegralFluxDifferencing(volume_flux))1516# Create the mesh17# Note, we use the domain [-1, 1]^3 for the Alfvén wave convergence test case so the18# warped mapping simplifies (quite a bit)1920# Mapping as described in https://arxiv.org/abs/2012.1204021function mapping(xi, eta, zeta)22y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta) * cos(0.5 * pi * zeta))2324x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y) * cos(0.5 * pi * zeta))2526z = zeta + 0.125 * (cos(0.5 * pi * x) * cos(pi * y) * cos(0.5 * pi * zeta))2728return SVector(x, y, z)29end3031cells_per_dimension = (4, 4, 4)32mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true)3334# create the semi discretization object35semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;36boundary_conditions = boundary_condition_periodic)3738###############################################################################39# ODE solvers, callbacks etc.4041tspan = (0.0, 1.0)42ode = semidiscretize(semi, tspan)4344summary_callback = SummaryCallback()4546analysis_interval = 10047analysis_callback = AnalysisCallback(semi, interval = analysis_interval)48alive_callback = AliveCallback(analysis_interval = analysis_interval)4950save_solution = SaveSolutionCallback(interval = 100,51save_initial_solution = true,52save_final_solution = true,53solution_variables = cons2prim)5455cfl = 1.256stepsize_callback = StepsizeCallback(cfl = cfl)5758glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)5960callbacks = CallbackSet(summary_callback,61analysis_callback, alive_callback,62save_solution,63stepsize_callback,64glm_speed_callback)6566###############################################################################67# run the simulation6869sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);70dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback71ode_default_options()..., callback = callbacks);727374