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