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
2055 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,
32
polydeg = 1, initial_refinement_level = 0,
33
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
34
periodicity = (false, true))
35
36
boundary_conditions = Dict(:x_neg => boundary_condition_slip_wall,
37
:x_pos => boundary_condition_slip_wall)
38
39
# The "Slip" boundary condition rotates all velocities into tangential direction
40
# and thus acts as a symmetry plane.
41
velocity_bc = Slip()
42
heat_bc = Adiabatic((x, t, equations_parabolic) -> zero(eltype(x)))
43
boundary_condition_y = BoundaryConditionNavierStokesWall(velocity_bc,
44
heat_bc)
45
46
boundary_conditions_parabolic = Dict(:x_neg => boundary_condition_y,
47
:x_pos => boundary_condition_y)
48
49
semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
50
initial_condition, solver;
51
boundary_conditions = (boundary_conditions,
52
boundary_conditions_parabolic))
53
54
###############################################################################
55
56
tspan = (0.0, 10.0)
57
ode = semidiscretize(semi, tspan)
58
59
summary_callback = SummaryCallback()
60
61
analysis_interval = 2000
62
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
63
64
alive_callback = AliveCallback(analysis_interval = analysis_interval)
65
66
stepsize_callback = StepsizeCallback(cfl = 1.3)
67
68
callbacks = CallbackSet(summary_callback,
69
analysis_callback,
70
alive_callback,
71
stepsize_callback)
72
73
###############################################################################
74
75
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
76
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
77
ode_default_options()..., callback = callbacks);
78
79