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
2055 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
26
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,
27
solver)
28
29
###############################################################################
30
# ODE solvers, callbacks etc.
31
32
# CARE: Important to use higher precision datatype in specification of final time
33
tspan = (zero(RealT), one(RealT))
34
35
ode = semidiscretize(semi, tspan);
36
37
summary_callback = SummaryCallback()
38
39
analysis_callback = AnalysisCallback(semi, interval = 100,
40
extra_analysis_errors = (:conservation_error,))
41
42
# cfl does not need to be in higher precision
43
stepsize_callback = StepsizeCallback(cfl = 0.25)
44
45
callbacks = CallbackSet(summary_callback,
46
stepsize_callback,
47
analysis_callback)
48
49
###############################################################################
50
# run the simulation
51
52
sol = solve(ode, Feagin14();
53
# Turn off adaptivity to avoid setting very small tolerances
54
adaptive = false,
55
dt = 42, # `dt` does not need to be in higher precision
56
ode_default_options()..., callback = callbacks);
57
58