Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/p4est_3d_dgsem/elixir_navierstokes_freestream_boundaries.jl
5586 views
1
using OrdinaryDiffEqStabilizedRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
equations = CompressibleEulerEquations3D(1.4)
8
9
function initial_condition_const(x, t, equations)
10
RealT = eltype(x)
11
rho = 1
12
rho_v1 = convert(RealT, 0.1)
13
rho_v2 = convert(RealT, -0.2)
14
rho_v3 = convert(RealT, 0.7)
15
rho_e_total = 10
16
return SVector(rho, rho_v1, rho_v2, rho_v3, rho_e_total)
17
end
18
initial_condition = initial_condition_const
19
20
polydeg = 3
21
solver = DGSEM(polydeg = polydeg, surface_flux = flux_lax_friedrichs)
22
solver_parabolic = ParabolicFormulationBassiRebay1()
23
24
mu() = 0.5
25
prandtl_number() = 0.72
26
equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(),
27
Prandtl = prandtl_number())
28
29
###############################################################################
30
# Get the uncurved mesh from a file (downloads the file if not available locally)
31
32
default_mesh_file = joinpath(@__DIR__, "mesh_cube_with_boundaries.inp")
33
isfile(default_mesh_file) ||
34
Trixi.download("https://gist.githubusercontent.com/DanielDoehring/710eab379fe3042dc08af6f2d1076e49/raw/38e9803bc0dab9b32a61d9542feac5343c3e6f4b/mesh_cube_with_boundaries.inp",
35
default_mesh_file)
36
mesh_file = default_mesh_file
37
38
boundary_symbols = [:PhysicalSurface1, :PhysicalSurface2]
39
40
mesh = P4estMesh{3}(mesh_file, polydeg = polydeg, initial_refinement_level = 0,
41
boundary_symbols = boundary_symbols)
42
43
boundary_conditions = (; PhysicalSurface1 = BoundaryConditionDirichlet(initial_condition),
44
PhysicalSurface2 = BoundaryConditionDirichlet(initial_condition))
45
46
semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
47
initial_condition,
48
solver; solver_parabolic,
49
boundary_conditions = (boundary_conditions,
50
boundary_conditions))
51
52
###############################################################################
53
# ODE solvers, callbacks etc.
54
55
tspan = (0.0, 1.0)
56
ode = semidiscretize(semi, tspan)
57
58
summary_callback = SummaryCallback()
59
60
analysis_interval = 100
61
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
62
63
alive_callback = AliveCallback(analysis_interval = analysis_interval)
64
65
callbacks = CallbackSet(summary_callback,
66
analysis_callback, alive_callback)
67
68
###############################################################################
69
# run the simulation
70
71
sol = solve(ode, ROCK4(max_stages = 8); adaptive = false, dt = 1e-3,
72
ode_default_options()..., callback = callbacks);
73
74