Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/tree_1d_dgsem/elixir_advection_doublefloat.jl
2055 views
1
using OrdinaryDiffEqHighOrderRK
2
using Trixi
3
4
using DoubleFloats
5
6
###############################################################################
7
# semidiscretization of the linear advection equation
8
9
# See https://github.com/JuliaMath/DoubleFloats.jl
10
RealT = Double64
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 = 7, 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) # minimum coordinate
20
coordinates_max = one(RealT) # maximum coordinate
21
22
# For `TreeMesh` the datatype has to be specified explicitly,
23
# i.e., is not inferred from the coordinates.
24
mesh = TreeMesh(coordinates_min, coordinates_max,
25
initial_refinement_level = 3,
26
n_cells_max = 30_000,
27
RealT = RealT)
28
29
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,
30
solver)
31
32
###############################################################################
33
# ODE solvers, callbacks etc.
34
35
# CARE: Important to use higher precision datatype in specification of final time
36
tspan = (zero(RealT), one(RealT))
37
38
ode = semidiscretize(semi, tspan);
39
40
summary_callback = SummaryCallback()
41
42
analysis_callback = AnalysisCallback(semi, interval = 100,
43
extra_analysis_errors = (:conservation_error,))
44
45
# cfl does not need to be in higher precision
46
stepsize_callback = StepsizeCallback(cfl = 1.4)
47
48
callbacks = CallbackSet(summary_callback,
49
stepsize_callback,
50
analysis_callback)
51
52
###############################################################################
53
# run the simulation
54
55
sol = solve(ode, DP8();
56
# Turn off adaptivity to avoid setting very small tolerances
57
adaptive = false,
58
dt = 42, # `dt` does not need to be in higher precision
59
ode_default_options()..., callback = callbacks);
60
61