Path: blob/main/examples/tree_1d_dgsem/elixir_euler_positivity.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the compressible Euler equations56equations = CompressibleEulerEquations1D(1.4)78"""9initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D)1011The Sedov blast wave setup based on Flash12- https://flash.rochester.edu/site/flashcode/user_support/flash_ug_devel/node187.html#SECTION01011400000000000000013"""14function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D)15# Set up polar coordinates16RealT = eltype(x)17inicenter = SVector(0)18x_norm = x[1] - inicenter[1]19r = abs(x_norm)2021# Setup based on https://flash.rochester.edu/site/flashcode/user_support/flash_ug_devel/node187.html#SECTION01011400000000000000022r0 = 0.21875f0 # = 3.5 * smallest dx (for domain length=4 and max-ref=6)23# r0 = 0.5 # = more reasonable setup24E = 125p0_inner = 6 * (equations.gamma - 1) * E / (3 * convert(RealT, pi) * r0)26p0_outer = convert(RealT, 1.0e-5) # = true Sedov setup27# p0_outer = 1.0e-3 # = more reasonable setup2829# Calculate primitive variables30rho = 131v1 = 032p = r > r0 ? p0_outer : p0_inner3334return prim2cons(SVector(rho, v1, p), equations)35end36initial_condition = initial_condition_sedov_blast_wave3738# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of39# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.40# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.41# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.42# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.43# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the44# `StepsizeCallback` (CFL-Condition) and less diffusion.45surface_flux = FluxLaxFriedrichs(max_abs_speed_naive)46volume_flux = flux_ranocha47basis = LobattoLegendreBasis(3)48indicator_sc = IndicatorHennemannGassner(equations, basis,49alpha_max = 0.5,50alpha_min = 0.001,51alpha_smooth = true,52variable = density_pressure)53volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;54volume_flux_dg = volume_flux,55volume_flux_fv = surface_flux)56solver = DGSEM(basis, surface_flux, volume_integral)5758coordinates_min = (-2.0,)59coordinates_max = (2.0,)60mesh = TreeMesh(coordinates_min, coordinates_max,61initial_refinement_level = 6,62n_cells_max = 10_000)6364semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)6566###############################################################################67# ODE solvers, callbacks etc.6869tspan = (0.0, 4.0)70ode = semidiscretize(semi, tspan)7172summary_callback = SummaryCallback()7374analysis_interval = 50075analysis_callback = AnalysisCallback(semi, interval = analysis_interval)7677alive_callback = AliveCallback(analysis_interval = analysis_interval)7879save_solution = SaveSolutionCallback(interval = 100,80save_initial_solution = true,81save_final_solution = true,82solution_variables = cons2prim)8384amr_indicator = IndicatorLöhner(semi,85variable = density_pressure)86amr_controller = ControllerThreeLevel(semi, amr_indicator,87base_level = 4,88med_level = 0, med_threshold = 0.1, # med_level = current level89max_level = 6, max_threshold = 0.3)90amr_callback = AMRCallback(semi, amr_controller,91interval = 2,92adapt_initial_condition = true,93adapt_initial_condition_only_refine = true)9495stepsize_callback = StepsizeCallback(cfl = 0.5)9697callbacks = CallbackSet(summary_callback,98analysis_callback, alive_callback,99save_solution,100amr_callback, stepsize_callback)101102stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),103variables = (Trixi.density, pressure))104105###############################################################################106# run the simulation107108sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, williamson_condition = false);109dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback110ode_default_options()..., callback = callbacks);111112113