Path: blob/main/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl
2055 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)3334# create the semi discretization object35semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)3637###############################################################################38# ODE solvers, callbacks etc.3940tspan = (0.0, 1.0)41ode = semidiscretize(semi, tspan)4243summary_callback = SummaryCallback()4445analysis_interval = 10046analysis_callback = AnalysisCallback(semi, interval = analysis_interval)47alive_callback = AliveCallback(analysis_interval = analysis_interval)4849save_solution = SaveSolutionCallback(interval = 100,50save_initial_solution = true,51save_final_solution = true,52solution_variables = cons2prim)5354cfl = 1.255stepsize_callback = StepsizeCallback(cfl = cfl)5657glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)5859callbacks = CallbackSet(summary_callback,60analysis_callback, alive_callback,61save_solution,62stepsize_callback,63glm_speed_callback)6465###############################################################################66# run the simulation6768sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);69dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback70ode_default_options()..., callback = callbacks);717273