Path: blob/main/examples/structured_3d_dgsem/elixir_mhd_ec.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the compressible ideal GLM-MHD equations56equations = IdealGlmMhdEquations3D(1.4)78initial_condition = initial_condition_weak_blast_wave910volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)11solver = DGSEM(polydeg = 3,12surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell),13volume_integral = VolumeIntegralFluxDifferencing(volume_flux))1415# Create a heavily warped curved mesh1617# Mapping as described in https://arxiv.org/abs/2012.1204018function mapping(xi_, eta_, zeta_)19# Transform input variables between -1 and 1 onto [0,3]20xi = 1.5 * xi_ + 1.521eta = 1.5 * eta_ + 1.522zeta = 1.5 * zeta_ + 1.52324y = eta +253 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) *26cos(0.5 * pi * (2 * eta - 3) / 3) *27cos(0.5 * pi * (2 * zeta - 3) / 3))2829x = xi +303 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) *31cos(2 * pi * (2 * y - 3) / 3) *32cos(0.5 * pi * (2 * zeta - 3) / 3))3334z = zeta +353 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) *36cos(pi * (2 * y - 3) / 3) *37cos(0.5 * pi * (2 * zeta - 3) / 3))3839return SVector(x, y, z)40end4142cells_per_dimension = (4, 4, 4)43mesh = StructuredMesh(cells_per_dimension, mapping)4445# create the semi discretization object46semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)4748###############################################################################49# ODE solvers, callbacks etc.5051tspan = (0.0, 1.0)52ode = semidiscretize(semi, tspan)5354summary_callback = SummaryCallback()5556analysis_interval = 10057analysis_callback = AnalysisCallback(semi, interval = analysis_interval)5859alive_callback = AliveCallback(analysis_interval = analysis_interval)6061save_solution = SaveSolutionCallback(interval = 100,62save_initial_solution = true,63save_final_solution = true,64solution_variables = cons2prim)6566cfl = 1.467stepsize_callback = StepsizeCallback(cfl = cfl)6869glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)7071callbacks = CallbackSet(summary_callback,72analysis_callback, alive_callback,73save_solution,74stepsize_callback,75glm_speed_callback)7677###############################################################################78# run the simulation7980sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);81dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback82ode_default_options()..., callback = callbacks);838485