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_source_terms.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
initial_condition = initial_condition_convergence_test
10
11
###############################################################################
12
# Get the FDSBP approximation operator
13
14
D_SBP = derivative_operator(SummationByPartsOperators.MattssonNordström2004(),
15
derivative_order = 1, accuracy_order = 4,
16
xmin = -1.0, xmax = 1.0, N = 10)
17
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
18
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
19
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
20
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
21
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
22
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
23
# `StepsizeCallback` (CFL-Condition) and less diffusion.
24
solver = FDSBP(D_SBP,
25
surface_integral = SurfaceIntegralStrongForm(FluxLaxFriedrichs(max_abs_speed_naive)),
26
volume_integral = VolumeIntegralStrongForm())
27
28
###############################################################################
29
# Get the curved quad mesh from a file (downloads the file if not available locally)
30
mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/12ce661d7c354c3d94c74b964b0f1c96/raw/8275b9a60c6e7ebbdea5fc4b4f091c47af3d5273/mesh_periodic_square_with_twist.mesh",
31
joinpath(@__DIR__, "mesh_periodic_square_with_twist.mesh"))
32
33
mesh = UnstructuredMesh2D(mesh_file, periodicity = true)
34
35
###############################################################################
36
# create the semi discretization object
37
38
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
39
source_terms = source_terms_convergence_test)
40
41
###############################################################################
42
# ODE solvers, callbacks etc.
43
44
tspan = (0.0, 1.0)
45
ode = semidiscretize(semi, tspan)
46
47
summary_callback = SummaryCallback()
48
49
analysis_interval = 100
50
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
51
52
alive_callback = AliveCallback(analysis_interval = analysis_interval)
53
54
save_solution = SaveSolutionCallback(interval = 100,
55
save_initial_solution = true,
56
save_final_solution = true)
57
58
callbacks = CallbackSet(summary_callback, analysis_callback,
59
alive_callback, save_solution)
60
61
###############################################################################
62
# run the simulation
63
64
sol = solve(ode, SSPRK43(), abstol = 1.0e-9, reltol = 1.0e-9;
65
ode_default_options()..., callback = callbacks)
66
67