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_euler_tandem_spheres.jl
5586 views
1
using Trixi
2
using OrdinaryDiffEqLowStorageRK
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
gamma = 1.4
8
equations = CompressibleEulerEquations3D(gamma)
9
10
# Simulation setup roughly based on testcase CS1 (Tandem Spheres) from the
11
# 5th International Workshop on High-Order CFD Methods.
12
# For description see:
13
# https://how5.cenaero.be/content/cs1-tandem-spheres-re3900
14
# This is a simplified inviscid version of the testcase, mainly
15
# designed to test the import of second-order (curved) elements in 3D.
16
17
D = 1 # Sphere diameter, follows from mesh
18
U() = 0.1
19
rho_ref() = 1.4
20
21
@inline function initial_condition(x, t, equations)
22
# set the freestream flow parameters
23
rho_freestream = rho_ref()
24
25
# v_total = 0.1 = Mach (for c = 1)
26
v1 = U()
27
v2 = 0.0
28
v3 = 0.0
29
30
p_freestream = 1.0
31
32
prim = SVector(rho_freestream, v1, v2, v3, p_freestream)
33
return prim2cons(prim, equations)
34
end
35
36
bc_farfield = BoundaryConditionDirichlet(initial_condition)
37
38
polydeg = 2
39
surface_flux = flux_hll
40
41
# Flux Differencing required to make this example run
42
volume_flux = flux_ranocha
43
volume_integral = VolumeIntegralFluxDifferencing(volume_flux)
44
45
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
46
volume_integral = volume_integral)
47
48
# Mesh taken from https://acdl.mit.edu/HOW5/CS1_TandemSpheres/pointwise/gmsh/
49
# and converted to Abaqus .inp format using Gmsh after adding
50
#
51
# $PhysicalNames
52
# 4
53
# 2 2 "BackSphere"
54
# 2 3 "FarField"
55
# 2 4 "FrontSphere"
56
# 3 1 "Fluid"
57
# $EndPhysicalNames
58
#
59
# in the .msh file.
60
61
mesh_file = joinpath(@__DIR__, "TandemSpheresHexMesh1P2_fixed.inp")
62
using Downloads
63
Downloads.download("https://zenodo.org/records/18921889/files/TandemSpheresHexMesh1P2_fixed.inp?download=1",
64
mesh_file)
65
66
# Boundary symbols follow from nodesets in the mesh file
67
boundary_symbols = [:FrontSphere, :BackSphere, :FarField]
68
mesh = P4estMesh{3}(mesh_file; boundary_symbols = boundary_symbols)
69
70
boundary_conditions = (; FrontSphere = boundary_condition_slip_wall,
71
BackSphere = boundary_condition_slip_wall,
72
FarField = bc_farfield)
73
74
semi = SemidiscretizationHyperbolic(mesh, equations,
75
initial_condition, solver;
76
boundary_conditions = boundary_conditions)
77
78
t_star_end = 1.0 # 100 recommended in testcase description
79
t_end = t_star_end * D / U() # convert `t_star` to unit-equipped time
80
tspan = (0.0, t_end)
81
ode = semidiscretize(semi, tspan)
82
83
###############################################################################
84
85
summary_callback = SummaryCallback()
86
87
analysis_interval = 500
88
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
89
90
alive_callback = AliveCallback(alive_interval = 50)
91
92
save_sol_interval = 500
93
save_solution = SaveSolutionCallback(interval = save_sol_interval,
94
save_initial_solution = false)
95
96
callbacks = CallbackSet(summary_callback,
97
alive_callback,
98
analysis_callback,
99
save_solution)
100
101
###############################################################################
102
103
tols = 1e-5
104
sol = solve(ode, RDPK3SpFSAL35(thread = Trixi.True());
105
abstol = tols, reltol = tols,
106
ode_default_options()..., callback = callbacks);
107
108