Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arbitrary Precision LGL Basis #2128

Merged
merged 80 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
de8e30c
test higher precision
DanielDoehring Oct 22, 2024
d665597
try to get higher order convergence
DanielDoehring Oct 22, 2024
4255ef2
type stability
DanielDoehring Oct 22, 2024
e873a68
fmt
DanielDoehring Oct 22, 2024
2c983ec
conservation
DanielDoehring Oct 22, 2024
4782a6e
correct
DanielDoehring Oct 22, 2024
b961bd8
working version
DanielDoehring Oct 23, 2024
17a440e
changes
DanielDoehring Oct 23, 2024
7de4a29
rm ODE
DanielDoehring Oct 23, 2024
f62efd4
rm unused
DanielDoehring Oct 23, 2024
7923397
Merge branch 'main' into DoubleFloats
DanielDoehring Oct 23, 2024
9d5223d
Merge branch 'DoubleFloats' of github.com:DanielDoehring/Trixi.jl int…
DanielDoehring Oct 23, 2024
a4b236c
Apply suggestions from code review
DanielDoehring Oct 23, 2024
bb32f03
RealT for TreeMesh
DanielDoehring Oct 23, 2024
8103d0a
undo tree
DanielDoehring Oct 23, 2024
6b1f45b
Merge branch 'DoubleFloats' of github.com:DanielDoehring/Trixi.jl int…
DanielDoehring Oct 23, 2024
05b484f
Revert "undo tree"
DanielDoehring Oct 23, 2024
1262aba
ones, zeros
DanielDoehring Oct 23, 2024
a9d5184
Apply suggestions from code review
DanielDoehring Oct 23, 2024
2bb4dfe
Merge branch 'DoubleFloats' of github.com:DanielDoehring/Trixi.jl int…
DanielDoehring Oct 23, 2024
1b44920
reprod test vals f32
DanielDoehring Oct 23, 2024
51b602d
LV suggestion
DanielDoehring Oct 23, 2024
c05a5bb
typo
DanielDoehring Oct 23, 2024
f978a97
shorten
DanielDoehring Oct 23, 2024
9fb2853
data safety
DanielDoehring Oct 23, 2024
525c6be
typesafety
DanielDoehring Oct 23, 2024
e14d7e1
fix
DanielDoehring Oct 23, 2024
42f401e
docstring
DanielDoehring Oct 23, 2024
685d1d6
comments
DanielDoehring Oct 23, 2024
4588a3e
Type general projection
DanielDoehring Oct 23, 2024
57a43d3
error
DanielDoehring Oct 23, 2024
f3c857a
syntax
DanielDoehring Oct 23, 2024
93b95e2
bring back conv
DanielDoehring Oct 23, 2024
21e6256
tolerance always dynamic
DanielDoehring Oct 23, 2024
facf55f
convert pi
DanielDoehring Oct 24, 2024
6701fab
tighter tolerances
DanielDoehring Oct 24, 2024
3622c85
warning only
DanielDoehring Oct 24, 2024
a99c886
update some float test vals
DanielDoehring Oct 24, 2024
1c94c99
remove unused/NON_TESTED
DanielDoehring Oct 24, 2024
ab63829
Merge branch 'DoubleFloats' of https://github.com/DanielDoehring/Trix…
DanielDoehring Oct 24, 2024
d686f48
restructure arguments
DanielDoehring Oct 25, 2024
4db0811
docstrings
DanielDoehring Oct 25, 2024
8afec06
remove random 1000
DanielDoehring Oct 25, 2024
221ce89
old behaviour
DanielDoehring Oct 25, 2024
b694f8e
compliance with deprecated dgsem
DanielDoehring Oct 25, 2024
d478eea
Avoid breaking change
DanielDoehring Oct 25, 2024
e2454c6
avoid ambiguity
DanielDoehring Oct 25, 2024
182601f
pass datatype through
DanielDoehring Oct 29, 2024
caf56b0
do not cast to float
DanielDoehring Oct 29, 2024
e85f3e3
remvoe comment
DanielDoehring Oct 29, 2024
7bcb1d6
more type generality
DanielDoehring Oct 29, 2024
bde331f
do not mix up things
DanielDoehring Oct 29, 2024
49830ea
Merge branch 'main' into DoubleFloats
DanielDoehring Nov 6, 2024
6ae356f
move example
DanielDoehring Nov 8, 2024
c818782
Merge branch 'main' into DoubleFloats
DanielDoehring Nov 8, 2024
4b1e190
tests
DanielDoehring Nov 8, 2024
8334f90
News etc
DanielDoehring Nov 8, 2024
58211bc
fmt
DanielDoehring Nov 8, 2024
b0e485c
Merge branch 'DoubleFloats' of github.com:DanielDoehring/Trixi.jl int…
DanielDoehring Nov 8, 2024
35f15f5
update test vals to different basis
DanielDoehring Nov 8, 2024
c0c1e2d
try to disable warnings
DanielDoehring Nov 8, 2024
0255baf
fmt
DanielDoehring Nov 8, 2024
7d1c708
CI hazzle
DanielDoehring Nov 8, 2024
2b06798
fun with Ci
DanielDoehring Nov 8, 2024
beae510
more warnings
DanielDoehring Nov 8, 2024
273e384
Compat entries
DanielDoehring Nov 8, 2024
b51a928
Tolerances for quad precision types
DanielDoehring Nov 9, 2024
16abc04
Merge branch 'main' into DoubleFloats
DanielDoehring Nov 9, 2024
4ead514
Comment
DanielDoehring Nov 21, 2024
e6657dd
Merge branch 'DoubleFloats' of github.com:DanielDoehring/Trixi.jl int…
DanielDoehring Nov 21, 2024
804e72c
Merge branch 'main' into DoubleFloats
DanielDoehring Nov 21, 2024
668a283
Merge branch 'main' into DoubleFloats
ranocha Nov 27, 2024
c95a29d
Apply suggestions from code review
DanielDoehring Nov 27, 2024
52ab8f1
comment
DanielDoehring Nov 28, 2024
89bab2b
Merge branch 'DoubleFloats' of github.com:DanielDoehring/Trixi.jl int…
DanielDoehring Nov 28, 2024
3824e16
shorter code for analysis
DanielDoehring Nov 28, 2024
83cdbb3
Merge branch 'main' into DoubleFloats
DanielDoehring Nov 28, 2024
6791e74
Merge branch 'main' into DoubleFloats
sloede Nov 30, 2024
59518f3
Apply suggestions from code review
DanielDoehring Dec 1, 2024
3295d6e
Merge branch 'main' into DoubleFloats
ranocha Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions examples/structured_1d_dgsem/elixir_advection_double_float.jl
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

using OrdinaryDiffEq
using Trixi

using DoubleFloats

###############################################################################
# semidiscretization of the linear advection equation

# See https://github.com/JuliaMath/DoubleFloats.jl
RealT = Double64

advection_velocity = 4 / 3 # Does not need to be in higher precision
equations = LinearScalarAdvectionEquation1D(advection_velocity)

solver = DGSEM(RealT = RealT, polydeg = 7, surface_flux = flux_lax_friedrichs)

# CARE: Important to use higher precision datatype for coordinates
# as these are used for type promotion of the mesh (points etc.)
coordinates_min = (-RealT(1.0),) # minimum coordinate
coordinates_max = (RealT(1.0),) # maximum coordinate
cells_per_dimension = (256,)

# NOTE: StructuredMesh supports higher precision coordinates
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,
solver)

###############################################################################
# ODE solvers, callbacks etc.

# CARE: Important to use higher precision datatype in specification of final time
tspan = (zero(RealT), RealT(1) / 1000)

ode = semidiscretize(semi, tspan);

summary_callback = SummaryCallback()

analysis_callback = AnalysisCallback(semi, interval = 1000,
extra_analysis_errors = (:conservation_error,))

# cfl does not need to be in higher precision
stepsize_callback = StepsizeCallback(cfl = 0.8)

callbacks = CallbackSet(summary_callback,
stepsize_callback,
analysis_callback)

###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(),
dt = 42.0, # `dt` does not need to be in higher precision
save_everystep = false, callback = callbacks);

# Print the timer summary
summary_callback()
58 changes: 58 additions & 0 deletions examples/structured_1d_dgsem/elixir_advection_float128.jl
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

using OrdinaryDiffEq
using Trixi

using Quadmath

###############################################################################
# semidiscretization of the linear advection equation

# See https://github.com/JuliaMath/Quadmath.jl
RealT = Float128

advection_velocity = 4 / 3 # Does not need to be in higher precision
equations = LinearScalarAdvectionEquation1D(advection_velocity)

solver = DGSEM(RealT = RealT, polydeg = 7, surface_flux = flux_lax_friedrichs)

# CARE: Important to use higher precision datatype for coordinates
# as these are used for type promotion of the mesh (points etc.)
coordinates_min = (-RealT(1.0),) # minimum coordinate
coordinates_max = (RealT(1.0),) # maximum coordinate
cells_per_dimension = (256,)

# NOTE: StructuredMesh supports higher precision coordinates
mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max)
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,
solver)

###############################################################################
# ODE solvers, callbacks etc.

# CARE: Important to use higher precision datatype in specification of final time
tspan = (zero(RealT), RealT(1) / 1000)

ode = semidiscretize(semi, tspan);

summary_callback = SummaryCallback()

analysis_callback = AnalysisCallback(semi, interval = 1000,
extra_analysis_errors = (:conservation_error,))

# cfl does not need to be in higher precision
stepsize_callback = StepsizeCallback(cfl = 0.8)

callbacks = CallbackSet(summary_callback,
stepsize_callback,
analysis_callback)

###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(),
dt = 42.0, # `dt` does not need to be in higher precision
save_everystep = false, callback = callbacks);

# Print the timer summary
summary_callback()
16 changes: 10 additions & 6 deletions src/auxiliary/special_elixirs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#! format: noindent

"""
convergence_test([mod::Module=Main,] elixir::AbstractString, iterations; kwargs...)
convergence_test([mod::Module=Main,] elixir::AbstractString, iterations, RealT = Float64; kwargs...)

Run `iterations` Trixi.jl simulations using the setup given in `elixir` and compute
the experimental order of convergence (EOC) in the ``L^2`` and ``L^\\infty`` norm.
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
Use `RealT` as the data type to represent the errors.
In each iteration, the resolution of the respective mesh will be doubled.
Additional keyword arguments `kwargs...` and the optional module `mod` are passed directly
to [`trixi_include`](@ref).
Expand All @@ -18,12 +19,14 @@ This function assumes that the spatial resolution is set via the keywords
`initial_refinement_level` (an integer) or `cells_per_dimension` (a tuple of
integers, one per spatial dimension).
"""
function convergence_test(mod::Module, elixir::AbstractString, iterations; kwargs...)
function convergence_test(mod::Module, elixir::AbstractString, iterations,
RealT = Float64;
kwargs...)
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
@assert(iterations>1,
"Number of iterations must be bigger than 1 for a convergence analysis")

# Types of errors to be calculated
errors = Dict(:l2 => Float64[], :linf => Float64[])
errors = Dict(:l2 => RealT[], :linf => RealT[])

initial_resolution = extract_initial_resolution(elixir, kwargs)

Expand Down Expand Up @@ -105,7 +108,7 @@ function analyze_convergence(errors, iterations,
println("")

# Print mean EOCs
mean_values = zeros(nvariables)
mean_values = zeros(eltype(errors[:l2]), nvariables)
for v in 1:nvariables
mean_values[v] = sum(eocs[kind][:, v]) ./ length(eocs[kind][:, v])
@printf("%-10s", "mean")
Expand All @@ -119,8 +122,9 @@ function analyze_convergence(errors, iterations,
return eoc_mean_values
end

function convergence_test(elixir::AbstractString, iterations; kwargs...)
convergence_test(Main, elixir::AbstractString, iterations; kwargs...)
function convergence_test(elixir::AbstractString, iterations, RealT = Float64;
kwargs...)
convergence_test(Main, elixir::AbstractString, iterations, RealT; kwargs...)
end

# Helper methods used in the functions defined above
Expand Down
5 changes: 4 additions & 1 deletion src/callbacks_step/analysis_dg1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ function calc_error_norms(func, u, t, analyzer,
inv.(view(inverse_jacobian, :, element)))

# Calculate errors at each analysis node
@. jacobian_local = abs(jacobian_local)
#@. jacobian_local = abs(jacobian_local) # Does not work with LoopVectorization and higher precision datatypes
for (index, value) in enumerate(jacobian_local)
jacobian_local[index] = abs(value)
end
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved

for i in eachnode(analyzer)
u_exact = initial_condition(get_node_coords(x_local, equations, dg, i), t,
Expand Down
5 changes: 4 additions & 1 deletion src/callbacks_step/analysis_dg2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ function calc_error_norms(func, u, t, analyzer,
jacobian_tmp1)

# Calculate errors at each analysis node
@. jacobian_local = abs(jacobian_local)
#@. jacobian_local = abs(jacobian_local) # Does not work with LoopVectorization and higher precision datatypes
for (index, value) in enumerate(jacobian_local)
jacobian_local[index] = abs(value)
end

for j in eachnode(analyzer), i in eachnode(analyzer)
u_exact = initial_condition(get_node_coords(x_local, equations, dg, i, j),
Expand Down
5 changes: 4 additions & 1 deletion src/callbacks_step/analysis_dg2d_parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ function calc_error_norms(func, u, t, analyzer,
jacobian_tmp1)

# Calculate errors at each analysis node
@. jacobian_local = abs(jacobian_local)
#@. jacobian_local = abs(jacobian_local) # Does not work with LoopVectorization and higher precision datatypes
for (index, value) in enumerate(jacobian_local)
jacobian_local[index] = abs(value)
end

for j in eachnode(analyzer), i in eachnode(analyzer)
u_exact = initial_condition(get_node_coords(x_local, equations, dg, i, j),
Expand Down
5 changes: 4 additions & 1 deletion src/callbacks_step/analysis_dg3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ function calc_error_norms(func, u, t, analyzer,
jacobian_tmp1, jacobian_tmp2)

# Calculate errors at each analysis node
@. jacobian_local = abs(jacobian_local)
#@. jacobian_local = abs(jacobian_local) # Does not work with LoopVectorization and higher precision datatypes
for (index, value) in enumerate(jacobian_local)
jacobian_local[index] = abs(value)
end

for k in eachnode(analyzer), j in eachnode(analyzer), i in eachnode(analyzer)
u_exact = initial_condition(get_node_coords(x_local, equations, dg, i, j,
Expand Down
5 changes: 4 additions & 1 deletion src/callbacks_step/analysis_dg3d_parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ function calc_error_norms(func, u, t, analyzer,
jacobian_tmp1, jacobian_tmp2)

# Calculate errors at each analysis node
@. jacobian_local = abs(jacobian_local)
#@. jacobian_local = abs(jacobian_local) # Does not work with LoopVectorization and higher precision datatypes
for (index, value) in enumerate(jacobian_local)
jacobian_local[index] = abs(value)
end

for k in eachnode(analyzer), j in eachnode(analyzer), i in eachnode(analyzer)
u_exact = initial_condition(get_node_coords(x_local, equations, dg, i, j,
Expand Down
Loading
Loading