Path: blob/main/examples/structured_3d_dgsem/elixir_mhd_ec_shockcapturing.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the compressible ideal GLM-MHD equations56equations = IdealGlmMhdEquations3D(1.4)78initial_condition = initial_condition_weak_blast_wave910surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)11volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)12polydeg = 413basis = LobattoLegendreBasis(polydeg)14indicator_sc = IndicatorHennemannGassner(equations, basis,15alpha_max = 0.5,16alpha_min = 0.001,17alpha_smooth = true,18variable = density_pressure)19volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;20volume_flux_dg = volume_flux,21volume_flux_fv = surface_flux)2223solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,24volume_integral = volume_integral)2526# Create a heavily warped curved mesh2728# Mapping as described in https://arxiv.org/abs/2012.1204029function mapping(xi_, eta_, zeta_)30# Transform input variables between -1 and 1 onto [0,3]31xi = 1.5 * xi_ + 1.532eta = 1.5 * eta_ + 1.533zeta = 1.5 * zeta_ + 1.53435y = eta +363 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) *37cos(0.5 * pi * (2 * eta - 3) / 3) *38cos(0.5 * pi * (2 * zeta - 3) / 3))3940x = xi +413 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) *42cos(2 * pi * (2 * y - 3) / 3) *43cos(0.5 * pi * (2 * zeta - 3) / 3))4445z = zeta +463 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) *47cos(pi * (2 * y - 3) / 3) *48cos(0.5 * pi * (2 * zeta - 3) / 3))4950return SVector(x, y, z)51end5253cells_per_dimension = (8, 8, 8)54mesh = StructuredMesh(cells_per_dimension, mapping)5556# create the semi discretization object57semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)5859###############################################################################60# ODE solvers, callbacks etc.6162tspan = (0.0, 1.0)63ode = semidiscretize(semi, tspan)6465summary_callback = SummaryCallback()6667analysis_interval = 10068analysis_callback = AnalysisCallback(semi, interval = analysis_interval)6970alive_callback = AliveCallback(analysis_interval = analysis_interval)7172cfl = 1.473stepsize_callback = StepsizeCallback(cfl = cfl)7475glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)7677callbacks = CallbackSet(summary_callback,78analysis_callback, alive_callback,79stepsize_callback,80glm_speed_callback)8182###############################################################################83# run the simulation8485sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);86dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback87ode_default_options()..., callback = callbacks);888990