Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "OrdinaryDiffEqOperatorSplitting"
uuid = "760fc936-9fa0-4281-9c1a-468957eedc89"
version = "0.4.3"
version = "0.4.4"
authors = ["Dennis Ogiermann <termi-official@users.noreply.github.com> and contributors"]

[deps]
Expand Down
10 changes: 10 additions & 0 deletions src/OrdinaryDiffEqOperatorSplitting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ end
_inner_verbose(verbose) = verbose
_process_verbose(verbose) = verbose

"""
inner_verbosity(verbose)

The verbosity a leaf integrator under a splitting node runs with: the `inner_verbosity`
of an [`OperatorSplittingVerbosity`](@ref), or `verbose` itself where it already is a
leaf setting. A leaf integrator built from `config.values.verbose` passes it through
here; the splitting toggles live on the node, not on its leaves.
"""
inner_verbosity(verbose) = _inner_verbose(verbose)

# `verbose` reaches us either as a Bool or, through DiffEqBase v7's `init`, as a
# verbosity specifier whose first type parameter is the on/off flag. Neither can be
# used in a boolean context directly.
Expand Down
16 changes: 12 additions & 4 deletions src/config_tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,17 @@ const SPLIT_OPTION_KEYS = (
function split_integrator_options(values::NamedTuple)
inner = inner_values(values)
known = filter(in(SPLIT_OPTION_KEYS), keys(inner))
return IntegratorOptions(;
verbose = values.verbose,
adaptive = values.adaptive,
NamedTuple{known}(inner)...
opts = NamedTuple{known}(inner)
# `dtmin` and `dtmax` share the node's time type: a `Float32` time span with the
# default `dtmin` would otherwise leave the two with no common type parameter.
T = typeof(values.dt)
opts = merge(
opts, (;
dtmin = T(get(opts, :dtmin, default_dtmin(T))),
dtmax = T(get(opts, :dtmax, typemax(T))),
)
)
return IntegratorOptions(; verbose = values.verbose, adaptive = values.adaptive, opts...)
end
default_dtmin(::Type{T}) where {T <: AbstractFloat} = eps(T)
default_dtmin(::Type{T}) where {T} = zero(T)
4 changes: 2 additions & 2 deletions src/integrator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ IntegratorStats() = IntegratorStats(0, 0)

Base.@kwdef mutable struct IntegratorOptions{tType, fType, vbType, F3, atolType, rtolType, normType}
adaptive::Bool
dtmin::tType = eps(Float64)
dtmax::tType = Inf
dtmin::tType
dtmax::tType
failfactor::fType = 4.0
verbose::vbType = DEFAULT_VERBOSITY
isoutofdomain::F3 = DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN
Expand Down
28 changes: 28 additions & 0 deletions test/precision.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using OrdinaryDiffEqLowOrderRK
using OrdinaryDiffEqOperatorSplitting
using Test

@testset "Float32 time span" begin
f(du, u, p, t) = @. du = -u
split_f = GenericSplitFunction((ODEFunction(f),), (1:1,))
prob = OperatorSplittingProblem(split_f, Float32[1.0], (0.0f0, 1.0f0))
alg = LieTrotterGodunov((Euler(),))

integrator = init(prob, alg; dt = 0.1f0)
@test integrator.opts.dtmin === eps(Float32)
@test integrator.opts.dtmax === 1.0f0
step!(integrator)
@test integrator.t === 0.1f0
@test integrator.u ≈ Float32[0.9]

# An explicitly given bound is converted to the time type.
integrator = init(prob, alg; dt = 0.1f0, dtmin = 1.0e-3)
@test integrator.opts.dtmin === 1.0f-3
end

@testset "inner_verbosity" begin
@test OrdinaryDiffEqOperatorSplitting.inner_verbosity(true) isa OrdinaryDiffEqOperatorSplitting.DiffEqBase.DEVerbosity
v = OrdinaryDiffEqOperatorSplitting.OperatorSplittingVerbosity(OrdinaryDiffEqOperatorSplitting.SciMLLogging.Standard())
@test OrdinaryDiffEqOperatorSplitting.inner_verbosity(v) === v.inner_verbosity
@test OrdinaryDiffEqOperatorSplitting.inner_verbosity(v.inner_verbosity) === v.inner_verbosity
end
Loading