Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/p4est_2d_dgsem/elixir_navierstokes_freestream_symmetry.jl
2831 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Navier-Stokes equations
6
7
prandtl_number() = 0.72
8
mu = 1e-3 # equivalent to Re = 1000
9
10
equations = CompressibleEulerEquations2D(1.4)
11
equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu,
12
Prandtl = prandtl_number())
13
14
# Flow in y-direction to test the symmetry BCs at the left and right boundaries
15
function initial_condition_freestream(x, t, equations)
16
rho = 1.4
17
v1 = 0.0
18
v2 = 1.0
19
p = 1.0
20
21
return prim2cons(SVector(rho, v1, v2, p), equations)
22
end
23
initial_condition = initial_condition_freestream
24
25
volume_flux = flux_ranocha
26
solver = DGSEM(polydeg = 3, surface_flux = flux_hlle)
27
28
coordinates_min = (0.0, 0.0)
29
coordinates_max = (1.0, 1.0)
30
trees_per_dimension = (4, 4)
31
mesh = P4estMesh(trees_per_dimension, polydeg = 1,
32
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
33
periodicity = (false, true))
34
35
boundary_conditions = (; x_neg = boundary_condition_slip_wall,
36
x_pos = boundary_condition_slip_wall)
37
38
# The "Slip" boundary condition rotates all velocities into tangential direction
39
# and thus acts as a symmetry plane.
40
velocity_bc = Slip()
41
heat_bc = Adiabatic((x, t, equations_parabolic) -> zero(eltype(x)))
42
boundary_condition_y = BoundaryConditionNavierStokesWall(velocity_bc,
43
heat_bc)
44
45
boundary_conditions_parabolic = (; x_neg = boundary_condition_y,
46
x_pos = boundary_condition_y)
47
48
semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
49
initial_condition, solver;
50
boundary_conditions = (boundary_conditions,
51
boundary_conditions_parabolic))
52
53
###############################################################################
54
55
tspan = (0.0, 10.0)
56
ode = semidiscretize(semi, tspan)
57
58
summary_callback = SummaryCallback()
59
60
analysis_interval = 2000
61
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
62
63
alive_callback = AliveCallback(analysis_interval = analysis_interval)
64
65
stepsize_callback = StepsizeCallback(cfl = 1.3)
66
67
callbacks = CallbackSet(summary_callback,
68
analysis_callback,
69
alive_callback,
70
stepsize_callback)
71
72
###############################################################################
73
74
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
75
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
76
ode_default_options()..., callback = callbacks);
77
78