Path: blob/main/examples/structured_2d_dgsem/elixir_euler_richtmyer_meshkov.jl
5586 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the compressible Euler equations56equations = CompressibleEulerEquations2D(1.4)78@doc raw"""9smoothed_discontinuity(x, a, b; slope = 15)1011A smoothed discontinuity function that transitions from `a` to `b` around `x = 0`.12The `slope` parameter controls how sharp the transition is; larger values result in a steeper transition.13This is the function ``d_{a,b}`` from the paper14- Chan, Ranocha, Rueda-Ramírez, Gassner, Warburton (2022):15On the entropy projection and the robustness of high order entropy stable discontinuous Galerkin schemes for under-resolved flows.16[DOI: 10.3389/fphy.2022.898028](https://doi.org/10.3389/fphy.2022.898028)17"""18@inline function smoothed_discontinuity(x, a, b; slope = 15)19return a + 0.5f0 * (1 + tanh(slope * x)) * (b - a)20end2122"""23initial_condition_richtmyer_meshkov_instability(x, t,24equations::CompressibleEulerEquations2D)2526Initial condition for the Richtmyer-Meshkov instability test case in two dimensions.27Taken from section 3.1.3 of the paper28- Chan, Ranocha, Rueda-Ramírez, Gassner, Warburton (2022):29On the entropy projection and the robustness of high order entropy stable discontinuous Galerkin schemes for under-resolved flows.30[DOI: 10.3389/fphy.2022.898028](https://doi.org/10.3389/fphy.2022.898028)31"""32@inline function initial_condition_richtmyer_meshkov_instability(x, t,33equations::CompressibleEulerEquations2D)34slope = 23536L_x = 40.037argument_1 = x[2] - (18 + 2 * cospi(6 * x[1] / L_x))38rho_summand_1 = smoothed_discontinuity(argument_1, 1, 0.25, slope = slope)3940argument_2 = abs(x[2] - 4) - 241rho_summand_2 = smoothed_discontinuity(argument_2, 3.22, 0, slope = slope)4243rho = rho_summand_1 + rho_summand_24445p = smoothed_discontinuity(argument_2, 4.9, 1.0, slope = slope)4647u = 048v = 049return prim2cons(SVector(rho, u, v, p), equations)50end5152polydeg = 353surface_flux = flux_hllc54volume_flux = flux_ranocha5556basis = LobattoLegendreBasis(polydeg)5758indicator_sc = IndicatorHennemannGassner(equations, basis,59alpha_max = 0.5,60alpha_min = 0.01,61alpha_smooth = false,62variable = Trixi.density_pressure)6364volume_integral = VolumeIntegralShockCapturingRRG(basis, indicator_sc;65volume_flux_dg = volume_flux,66volume_flux_fv = surface_flux,67slope_limiter = monotonized_central)6869dg = DGSEM(polydeg = polydeg, surface_flux = surface_flux,70volume_integral = volume_integral)7172num_elements_x = 3873cells_per_dimension = (num_elements_x, 3 * num_elements_x)74coordinates_min = (0.0, 0.0)75coordinates_max = (40.0 / 3, 40.0)76mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max,77periodicity = false)7879initial_condition = initial_condition_richtmyer_meshkov_instability8081semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg;82boundary_conditions = boundary_condition_slip_wall)8384###############################################################################85# ODE solvers, callbacks etc.8687tspan = (0.0, 30.0)88ode = semidiscretize(semi, tspan)8990summary_callback = SummaryCallback()9192analysis_interval = 10093analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg))9495alive_callback = AliveCallback(analysis_interval = analysis_interval)9697save_solution = SaveSolutionCallback(interval = analysis_interval,98solution_variables = cons2prim)99100callbacks = CallbackSet(summary_callback,101analysis_callback,102save_solution,103alive_callback)104105###############################################################################106# run the simulation107108sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-5, reltol = 1.0e-5,109adaptive = true, dt = 1e-2,110ode_default_options()..., callback = callbacks)111112113