Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
equations = CompressibleEulerEquations2D(1.4)
8
9
@inline function uniform_flow_state(x, t, equations::CompressibleEulerEquations2D)
10
11
# set the freestream flow parameters
12
rho_freestream = 1.0
13
u_freestream = 0.3
14
p_freestream = inv(equations.gamma)
15
16
theta = pi / 90.0 # analogous with a two degree angle of attack
17
si, co = sincos(theta)
18
v1 = u_freestream * co
19
v2 = u_freestream * si
20
21
prim = SVector(rho_freestream, v1, v2, p_freestream)
22
return prim2cons(prim, equations)
23
end
24
25
initial_condition = uniform_flow_state
26
27
boundary_condition_uniform_flow = BoundaryConditionDirichlet(uniform_flow_state)
28
boundary_conditions = Dict(:Bottom => boundary_condition_uniform_flow,
29
:Top => boundary_condition_uniform_flow,
30
:Right => boundary_condition_uniform_flow,
31
:Left => boundary_condition_uniform_flow,
32
:Circle => boundary_condition_slip_wall)
33
34
###############################################################################
35
# Get the DG approximation space
36
37
solver = DGSEM(polydeg = 4, surface_flux = flux_hll)
38
39
###############################################################################
40
# Get the curved quad mesh from a file
41
mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/8b9b11a1eedfa54b215c122c3d17b271/raw/0d2b5d98c87e67a6f384693a8b8e54b4c9fcbf3d/mesh_box_around_circle.mesh",
42
joinpath(@__DIR__, "mesh_box_around_circle.mesh"))
43
44
mesh = UnstructuredMesh2D(mesh_file)
45
46
###############################################################################
47
# create the semi discretization object
48
49
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
50
boundary_conditions = boundary_conditions)
51
52
###############################################################################
53
# ODE solvers, callbacks etc.
54
55
tspan = (0.0, 0.5)
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
save_solution = SaveSolutionCallback(interval = 10,
66
save_initial_solution = true,
67
save_final_solution = true)
68
69
stepsize_callback = StepsizeCallback(cfl = 1.0)
70
71
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution,
72
stepsize_callback)
73
74
###############################################################################
75
# run the simulation
76
77
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
78
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
79
ode_default_options()..., callback = callbacks);
80
81