Path: blob/main/examples/structured_2d_dgsem/elixir_mhd_ec_shockcapturing.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the compressible ideal GLM-MHD equations5equations = IdealGlmMhdEquations2D(1.4)67initial_condition = initial_condition_weak_blast_wave89surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)10volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)11polydeg = 412basis = LobattoLegendreBasis(polydeg)13indicator_sc = IndicatorHennemannGassner(equations, basis,14alpha_max = 0.5,15alpha_min = 0.001,16alpha_smooth = true,17variable = density_pressure)18volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;19volume_flux_dg = volume_flux,20volume_flux_fv = surface_flux)21solver = DGSEM(basis, surface_flux, volume_integral)2223# Get the curved quad mesh from a mapping function24# Mapping as described in https://arxiv.org/abs/2012.1204025function mapping(xi, eta)26y = 2.0 * eta + 1.0 / 6.0 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta))2728x = 2.0 * xi + 1.0 / 6.0 * (cos(0.5 * pi * xi) * cos(2 * pi * y))2930return SVector(x, y)31end3233cells_per_dimension = (16, 16)3435mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true)3637semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)3839###############################################################################40# ODE solvers, callbacks etc.4142tspan = (0.0, 0.4)43ode = semidiscretize(semi, tspan)4445summary_callback = SummaryCallback()4647analysis_interval = 10048analysis_callback = AnalysisCallback(semi, interval = analysis_interval)4950alive_callback = AliveCallback(analysis_interval = analysis_interval)5152cfl = 1.053stepsize_callback = StepsizeCallback(cfl = cfl)5455glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)5657callbacks = CallbackSet(summary_callback,58analysis_callback,59alive_callback,60stepsize_callback,61glm_speed_callback)6263###############################################################################64# run the simulation6566sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);67dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback68ode_default_options()..., callback = callbacks);697071