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_basic.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_convergence_test
10
source_terms = source_terms_convergence_test
11
12
boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition)
13
boundary_conditions = Dict(:Slant => boundary_condition_convergence_test,
14
:Bezier => boundary_condition_convergence_test,
15
:Right => boundary_condition_convergence_test,
16
:Bottom => boundary_condition_convergence_test,
17
:Top => boundary_condition_convergence_test)
18
19
###############################################################################
20
# Get the DG approximation space
21
22
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
23
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
24
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
25
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
26
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
27
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
28
# `StepsizeCallback` (CFL-Condition) and less diffusion.
29
solver = DGSEM(polydeg = 8, surface_flux = FluxLaxFriedrichs(max_abs_speed_naive))
30
31
###############################################################################
32
# Get the curved quad mesh from a file (downloads the file if not available locally)
33
mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/52056f1487853fab63b7f4ed7f171c80/raw/9d573387dfdbb8bce2a55db7246f4207663ac07f/mesh_trixi_unstructured_mesh_docs.mesh",
34
joinpath(@__DIR__, "mesh_trixi_unstructured_mesh_docs.mesh"))
35
36
mesh = UnstructuredMesh2D(mesh_file)
37
38
###############################################################################
39
# create the semi discretization object
40
41
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
42
source_terms = source_terms,
43
boundary_conditions = boundary_conditions)
44
45
###############################################################################
46
# ODE solvers, callbacks etc.
47
48
tspan = (0.0, 3.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_restart = SaveRestartCallback(interval = 50,
59
save_final_restart = true)
60
61
save_solution = SaveSolutionCallback(interval = 10,
62
save_initial_solution = true,
63
save_final_solution = true)
64
65
stepsize_callback = StepsizeCallback(cfl = 0.9)
66
67
callbacks = CallbackSet(summary_callback,
68
analysis_callback,
69
alive_callback,
70
save_restart,
71
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