Path: blob/main/examples/dgmulti_2d/elixir_euler_kelvin_helmholtz_instability.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of4# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.5# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.6# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.7# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.8# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the9# `StepsizeCallback` (CFL-Condition) and less diffusion.10dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = SBP(),11surface_integral = SurfaceIntegralWeakForm(FluxLaxFriedrichs(max_abs_speed_naive)),12volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha))1314equations = CompressibleEulerEquations2D(1.4)1516"""17initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D)1819A version of the classical Kelvin-Helmholtz instability based on20- Andrés M. Rueda-Ramírez, Gregor J. Gassner (2021)21A Subcell Finite Volume Positivity-Preserving Limiter for DGSEM Discretizations22of the Euler Equations23[arXiv: 2102.06017](https://arxiv.org/abs/2102.06017)24"""25function initial_condition_kelvin_helmholtz_instability(x, t,26equations::CompressibleEulerEquations2D)27# change discontinuity to tanh28# typical resolution 128^2, 256^229# domain size is [-1,+1]^230slope = 1531amplitude = 0.0232B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5)33rho = 0.5 + 0.75 * B34v1 = 0.5 * (B - 1)35v2 = 0.1 * sin(2 * pi * x[1])36p = 1.037return prim2cons(SVector(rho, v1, v2, p), equations)38end39initial_condition = initial_condition_kelvin_helmholtz_instability4041cells_per_dimension = (32, 32)42mesh = DGMultiMesh(dg, cells_per_dimension; periodicity = true)4344semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg)4546tspan = (0.0, 1.0)47ode = semidiscretize(semi, tspan)4849summary_callback = SummaryCallback()50alive_callback = AliveCallback(alive_interval = 10)51analysis_interval = 10052analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg))53save_solution = SaveSolutionCallback(interval = analysis_interval,54solution_variables = cons2prim)55callbacks = CallbackSet(summary_callback,56analysis_callback,57alive_callback, save_solution)5859###############################################################################60# run the simulation6162sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);63dt = estimate_dt(mesh, dg), ode_default_options()..., callback = callbacks);646566