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_free_stream.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
initial_condition = initial_condition_constant
10
11
boundary_condition_free_stream = BoundaryConditionDirichlet(initial_condition)
12
boundary_conditions = Dict(:Body => boundary_condition_free_stream,
13
:Button1 => boundary_condition_free_stream,
14
:Button2 => boundary_condition_free_stream,
15
:Eye1 => boundary_condition_free_stream,
16
:Eye2 => boundary_condition_free_stream,
17
:Smile => boundary_condition_free_stream,
18
:Bowtie => boundary_condition_free_stream)
19
20
###############################################################################
21
# Get the DG approximation space
22
23
solver = DGSEM(polydeg = 6, surface_flux = flux_hll)
24
25
###############################################################################
26
# Get the curved quad mesh from a file (downloads the file if not available locally)
27
mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/2c6440b5f8a57db131061ad7aa78ee2b/raw/1f89fdf2c874ff678c78afb6fe8dc784bdfd421f/mesh_gingerbread_man.mesh",
28
joinpath(@__DIR__, "mesh_gingerbread_man.mesh"))
29
30
mesh = UnstructuredMesh2D(mesh_file)
31
32
###############################################################################
33
# create the semi discretization object
34
35
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
36
boundary_conditions = boundary_conditions)
37
38
###############################################################################
39
# ODE solvers, callbacks etc.
40
41
tspan = (0.0, 5.0)
42
ode = semidiscretize(semi, tspan)
43
44
summary_callback = SummaryCallback()
45
46
analysis_interval = 100
47
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
48
49
alive_callback = AliveCallback(analysis_interval = analysis_interval)
50
51
save_solution = SaveSolutionCallback(interval = 100,
52
save_initial_solution = true,
53
save_final_solution = true)
54
55
stepsize_callback = StepsizeCallback(cfl = 1.0)
56
57
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution,
58
stepsize_callback)
59
60
###############################################################################
61
# run the simulation
62
63
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
64
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
65
ode_default_options()..., callback = callbacks);
66
67