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_time_series.jl
2055 views
1
# An elixir that has an alternative convergence test that uses
2
# the `TimeSeriesCallback` on several gauge points. Many of the
3
# gauge points are selected as "stress tests" for the element
4
# identification, e.g., a gauge point that lies on an
5
# element corner of a curvilinear mesh
6
7
using OrdinaryDiffEqLowStorageRK
8
using Trixi
9
10
###############################################################################
11
# semidiscretization of the compressible Euler equations
12
13
equations = CompressibleEulerEquations2D(1.4)
14
15
# Modify the manufactured solution test to use `L = sqrt(2)`
16
# in the initial condition and source terms
17
function initial_condition_convergence_shifted(x, t,
18
equations::CompressibleEulerEquations2D)
19
c = 2
20
A = 0.1
21
L = sqrt(2)
22
f = 1 / L
23
ω = 2 * pi * f
24
ini = c + A * sin(ω * (x[1] + x[2] - t))
25
26
rho = ini
27
rho_v1 = ini
28
rho_v2 = ini
29
rho_e = ini^2
30
31
return SVector(rho, rho_v1, rho_v2, rho_e)
32
end
33
34
@inline function source_terms_convergence_shifted(u, x, t,
35
equations::CompressibleEulerEquations2D)
36
# Same settings as in `initial_condition`
37
c = 2
38
A = 0.1
39
L = sqrt(2)
40
f = 1 / L
41
ω = 2 * pi * f
42
γ = equations.gamma
43
44
x1, x2 = x
45
si, co = sincos(ω * (x1 + x2 - t))
46
rho = c + A * si
47
rho_x = ω * A * co
48
# Note that d/dt rho = -d/dx rho = -d/dy rho.
49
50
tmp = (2 * rho - 1) * (γ - 1)
51
52
du1 = rho_x
53
du2 = rho_x * (1 + tmp)
54
du3 = du2
55
du4 = 2 * rho_x * (rho + tmp)
56
57
return SVector(du1, du2, du3, du4)
58
end
59
60
initial_condition = initial_condition_convergence_shifted
61
62
source_term = source_terms_convergence_shifted
63
64
###############################################################################
65
# Get the DG approximation space
66
67
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
68
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
69
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
70
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
71
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
72
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
73
# `StepsizeCallback` (CFL-Condition) and less diffusion.
74
solver = DGSEM(polydeg = 6, surface_flux = FluxLaxFriedrichs(max_abs_speed_naive))
75
76
###############################################################################
77
# Get the curved quad mesh from a file (downloads the file if not available locally)
78
79
mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/b434e724e3972a9c4ee48d58c80cdcdb/raw/55c916cd8c0294a2d4a836e960dac7247b7c8ccf/mesh_multiple_flips.mesh",
80
joinpath(@__DIR__, "mesh_multiple_flips.mesh"))
81
82
mesh = UnstructuredMesh2D(mesh_file, periodicity = true)
83
84
###############################################################################
85
# create the semi discretization object
86
87
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
88
source_terms = source_term)
89
90
###############################################################################
91
# ODE solvers, callbacks etc.
92
93
tspan = (0.0, 1.0)
94
ode = semidiscretize(semi, tspan)
95
96
summary_callback = SummaryCallback()
97
98
analysis_interval = 1000
99
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
100
101
alive_callback = AliveCallback(analysis_interval = analysis_interval)
102
103
time_series = TimeSeriesCallback(semi,
104
[(0.75, 0.7), (1.23, 0.302), (0.8, 1.0),
105
(0.353553390593274, 0.353553390593274),
106
(0.505, 1.125), (1.37, 0.89), (0.349, 0.7153),
107
(0.883883476483184, 0.406586401289607),
108
(sqrt(2), sqrt(2))];
109
interval = 10)
110
111
callbacks = CallbackSet(summary_callback,
112
analysis_callback,
113
time_series,
114
alive_callback)
115
116
###############################################################################
117
# run the simulation
118
119
sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6,
120
ode_default_options()..., callback = callbacks);
121
122