Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/structured_1d_dgsem/elixir_advection_float128.jl
5586 views
1
using OrdinaryDiffEqFeagin
2
using Trixi
3
4
using Quadmath
5
6
###############################################################################
7
# semidiscretization of the linear advection equation
8
9
# See https://github.com/JuliaMath/Quadmath.jl
10
RealT = Float128
11
12
advection_velocity = 4 / 3 # Does not need to be in higher precision
13
equations = LinearScalarAdvectionEquation1D(advection_velocity)
14
15
solver = DGSEM(RealT = RealT, polydeg = 13, surface_flux = flux_lax_friedrichs)
16
17
# CARE: Important to use higher precision datatype for coordinates
18
# as these are used for type promotion of the mesh (points etc.)
19
coordinates_min = (-one(RealT),)
20
coordinates_max = (one(RealT),)
21
cells_per_dimension = (1,)
22
23
# `StructuredMesh` infers datatype from coordinates
24
mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max,
25
periodicity = true)
26
27
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,
28
solver;
29
boundary_conditions = boundary_condition_periodic)
30
31
###############################################################################
32
# ODE solvers, callbacks etc.
33
34
# CARE: Important to use higher precision datatype in specification of final time
35
tspan = (zero(RealT), one(RealT))
36
37
ode = semidiscretize(semi, tspan);
38
39
summary_callback = SummaryCallback()
40
41
analysis_callback = AnalysisCallback(semi, interval = 100,
42
extra_analysis_errors = (:conservation_error,))
43
44
# cfl does not need to be in higher precision
45
stepsize_callback = StepsizeCallback(cfl = 0.25)
46
47
callbacks = CallbackSet(summary_callback,
48
stepsize_callback,
49
analysis_callback)
50
51
###############################################################################
52
# run the simulation
53
54
sol = solve(ode, Feagin14();
55
# Turn off adaptivity to avoid setting very small tolerances
56
adaptive = false,
57
dt = 42, # `dt` does not need to be in higher precision
58
ode_default_options()..., callback = callbacks);
59
60