Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/unstructured_2d_fdsbp/elixir_euler_free_stream.jl
2055 views
1
using OrdinaryDiffEqSSPRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the compressible Euler equations
6
7
equations = CompressibleEulerEquations2D(1.4)
8
9
# Free-stream initial condition
10
initial_condition = initial_condition_constant
11
12
# Boundary conditions for free-stream testing
13
boundary_condition_free_stream = BoundaryConditionDirichlet(initial_condition)
14
boundary_conditions = Dict(:Body => boundary_condition_free_stream,
15
:Button1 => boundary_condition_free_stream,
16
:Button2 => boundary_condition_free_stream,
17
:Eye1 => boundary_condition_free_stream,
18
:Eye2 => boundary_condition_free_stream,
19
:Smile => boundary_condition_free_stream,
20
:Bowtie => boundary_condition_free_stream)
21
22
###############################################################################
23
# Get the FDSBP approximation space
24
25
D_SBP = derivative_operator(SummationByPartsOperators.MattssonAlmquistVanDerWeide2018Accurate(),
26
derivative_order = 1, accuracy_order = 4,
27
xmin = -1.0, xmax = 1.0, N = 12)
28
solver = FDSBP(D_SBP,
29
surface_integral = SurfaceIntegralStrongForm(flux_hll),
30
volume_integral = VolumeIntegralStrongForm())
31
32
###############################################################################
33
# Get the curved quad mesh from a file (downloads the file if not available locally)
34
mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/2c6440b5f8a57db131061ad7aa78ee2b/raw/1f89fdf2c874ff678c78afb6fe8dc784bdfd421f/mesh_gingerbread_man.mesh",
35
joinpath(@__DIR__, "mesh_gingerbread_man.mesh"))
36
37
mesh = UnstructuredMesh2D(mesh_file)
38
39
###############################################################################
40
# create the semi discretization object
41
42
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
43
boundary_conditions = boundary_conditions)
44
45
###############################################################################
46
# ODE solvers, callbacks etc.
47
48
tspan = (0.0, 5.0)
49
ode = semidiscretize(semi, tspan)
50
51
summary_callback = SummaryCallback()
52
53
analysis_interval = 100
54
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
55
56
alive_callback = AliveCallback(analysis_interval = analysis_interval)
57
58
save_solution = SaveSolutionCallback(interval = 100,
59
save_initial_solution = true,
60
save_final_solution = true)
61
62
callbacks = CallbackSet(summary_callback, analysis_callback,
63
alive_callback, save_solution)
64
65
###############################################################################
66
# run the simulation
67
68
# set small tolerances for the free-stream preservation test
69
sol = solve(ode, SSPRK43(), abstol = 1.0e-12, reltol = 1.0e-12;
70
ode_default_options()..., callback = callbacks)
71
72