Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/dgmulti_2d/elixir_euler_kelvin_helmholtz_instability.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
5
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
6
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
7
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
8
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
9
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
10
# `StepsizeCallback` (CFL-Condition) and less diffusion.
11
dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = SBP(),
12
surface_integral = SurfaceIntegralWeakForm(FluxLaxFriedrichs(max_abs_speed_naive)),
13
volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha))
14
15
equations = CompressibleEulerEquations2D(1.4)
16
17
"""
18
initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D)
19
20
A version of the classical Kelvin-Helmholtz instability based on
21
- Andrés M. Rueda-Ramírez, Gregor J. Gassner (2021)
22
A Subcell Finite Volume Positivity-Preserving Limiter for DGSEM Discretizations
23
of the Euler Equations
24
[arXiv: 2102.06017](https://arxiv.org/abs/2102.06017)
25
"""
26
function initial_condition_kelvin_helmholtz_instability(x, t,
27
equations::CompressibleEulerEquations2D)
28
# change discontinuity to tanh
29
# typical resolution 128^2, 256^2
30
# domain size is [-1,+1]^2
31
slope = 15
32
amplitude = 0.02
33
B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5)
34
rho = 0.5 + 0.75 * B
35
v1 = 0.5 * (B - 1)
36
v2 = 0.1 * sin(2 * pi * x[1])
37
p = 1.0
38
return prim2cons(SVector(rho, v1, v2, p), equations)
39
end
40
initial_condition = initial_condition_kelvin_helmholtz_instability
41
42
cells_per_dimension = (32, 32)
43
mesh = DGMultiMesh(dg, cells_per_dimension; periodicity = true)
44
45
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg)
46
47
tspan = (0.0, 1.0)
48
ode = semidiscretize(semi, tspan)
49
50
summary_callback = SummaryCallback()
51
alive_callback = AliveCallback(alive_interval = 10)
52
analysis_interval = 100
53
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg))
54
save_solution = SaveSolutionCallback(interval = analysis_interval,
55
solution_variables = cons2prim)
56
callbacks = CallbackSet(summary_callback,
57
analysis_callback,
58
alive_callback, save_solution)
59
60
###############################################################################
61
# run the simulation
62
63
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
64
dt = estimate_dt(mesh, dg), ode_default_options()..., callback = callbacks);
65
66