Path: blob/main/examples/tree_1d_dgsem/elixir_advection_doublefloat.jl
2055 views
using OrdinaryDiffEqHighOrderRK1using Trixi23using DoubleFloats45###############################################################################6# semidiscretization of the linear advection equation78# See https://github.com/JuliaMath/DoubleFloats.jl9RealT = Double641011advection_velocity = 4 / 3 # Does not need to be in higher precision12equations = LinearScalarAdvectionEquation1D(advection_velocity)1314solver = DGSEM(RealT = RealT, polydeg = 7, surface_flux = flux_lax_friedrichs)1516# CARE: Important to use higher precision datatype for coordinates17# as these are used for type promotion of the mesh (points etc.)18coordinates_min = -one(RealT) # minimum coordinate19coordinates_max = one(RealT) # maximum coordinate2021# For `TreeMesh` the datatype has to be specified explicitly,22# i.e., is not inferred from the coordinates.23mesh = TreeMesh(coordinates_min, coordinates_max,24initial_refinement_level = 3,25n_cells_max = 30_000,26RealT = RealT)2728semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,29solver)3031###############################################################################32# ODE solvers, callbacks etc.3334# CARE: Important to use higher precision datatype in specification of final time35tspan = (zero(RealT), one(RealT))3637ode = semidiscretize(semi, tspan);3839summary_callback = SummaryCallback()4041analysis_callback = AnalysisCallback(semi, interval = 100,42extra_analysis_errors = (:conservation_error,))4344# cfl does not need to be in higher precision45stepsize_callback = StepsizeCallback(cfl = 1.4)4647callbacks = CallbackSet(summary_callback,48stepsize_callback,49analysis_callback)5051###############################################################################52# run the simulation5354sol = solve(ode, DP8();55# Turn off adaptivity to avoid setting very small tolerances56adaptive = false,57dt = 42, # `dt` does not need to be in higher precision58ode_default_options()..., callback = callbacks);596061