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

quick type fixes to allow f32 computing #195

Merged
merged 2 commits into from
Mar 10, 2025
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ Manifest.toml
# Documenter files
docs/src/tutorials
docs/src/howto

.vscode
42 changes: 21 additions & 21 deletions src/solver/time/integrator/operatorsplitting-interface.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
struct DummyODESolution <: SciMLBase.AbstractODESolution{Float64, 2, Vector{Float64}}
struct DummyODESolution <: SciMLBase.AbstractODESolution{Float64,2,Vector{Float64}}
retcode::SciMLBase.ReturnCode.T
end
DummyODESolution() = DummyODESolution(SciMLBase.ReturnCode.Default)
Expand All @@ -15,15 +15,15 @@ function OS.build_subintegrator_tree_with_cache(
t0, dt, tf,
tstops, saveat, d_discontinuities, callback,
adaptive, verbose,
save_end = false,
controller = nothing,
save_end=false,
controller=nothing,
)
uprev = @view uprevouter[solution_indices]
u = @view uouter[solution_indices]
u = @view uouter[solution_indices]

dt > zero(dt) || error("dt must be positive")
_dt = dt
tdir = tf > t0 ? 1.0 : -1.0
tdir = tf > t0 ? one(dt) : -one(dt)
tType = typeof(dt)

if tstops isa AbstractArray || tstops isa Tuple || tstops isa Number
Expand All @@ -41,8 +41,8 @@ function OS.build_subintegrator_tree_with_cache(
cache = setup_solver_cache(f, alg, t0; uprev=uprev, u=u)

# Setup solution buffers
uType = typeof(u)
uBottomEltype = OrdinaryDiffEqCore.recursive_bottom_eltype(u)
uType = typeof(u)
uBottomEltype = OrdinaryDiffEqCore.recursive_bottom_eltype(u)
uBottomEltypeNoUnits = OrdinaryDiffEqCore.recursive_unitless_bottom_eltype(u)

# Setup callbacks
Expand All @@ -54,8 +54,8 @@ function OS.build_subintegrator_tree_with_cache(
# callback_cache = SciMLBase.CallbackCache(u, max_len_cb, uBottomEltypeReal,
# uBottomEltypeReal)
# else
callback_cache = SciMLBase.CallbackCache(max_len_cb, uBottomEltypeReal,
uBottomEltypeReal)
callback_cache = SciMLBase.CallbackCache(max_len_cb, uBottomEltypeReal,
uBottomEltypeReal)
# end
else
callback_cache = nothing
Expand Down Expand Up @@ -107,19 +107,19 @@ function OS.build_subintegrator_tree_with_cache(
adaptive ? controller : nothing,
IntegratorStats(),
IntegratorOptions(
dtmin = zero(tType),
dtmax = tType(tf-t0),
verbose = verbose,
adaptive = adaptive,
dtmin=zero(tType),
dtmax=tType(tf - t0),
verbose=verbose,
adaptive=adaptive,
# maxiters = maxiters,
callback = callbacks_internal,
save_end = save_end,
tstops = tstops_internal,
saveat = saveat_internal,
d_discontinuities = d_discontinuities_internal,
tstops_cache = tstops,
saveat_cache = saveat,
d_discontinuities_cache = d_discontinuities,
callback=callbacks_internal,
save_end=save_end,
tstops=tstops_internal,
saveat=saveat_internal,
d_discontinuities=d_discontinuities_internal,
tstops_cache=tstops,
saveat_cache=saveat,
d_discontinuities_cache=d_discontinuities,
),
false,
0,
Expand Down
88 changes: 44 additions & 44 deletions src/solver/time/integrator/type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ mutable struct IntegratorStats
# TODO inner solver stats
end

IntegratorStats() = IntegratorStats(0,0)
IntegratorStats() = IntegratorStats(0, 0)

Base.@kwdef mutable struct IntegratorOptions{tType, F1, F2, F3, F4, F5, progressMonitorType, SType, tstopsType, saveatType, discType, tcache, savecache, disccache}
Base.@kwdef mutable struct IntegratorOptions{tType,fType,F1,F2,F3,F4,F5,progressMonitorType,SType,tstopsType,saveatType,discType,tcache,savecache,disccache}
force_dtmin::Bool = false
dtmin::tType = eps(tType)
dtmax::tType = Inf
failfactor::tType = 4.0
failfactor::fType = 4.0
verbose::Bool = false
adaptive::Bool = false # Redundant with the dispatch on SciMLBase.isadaptive below (alg adaptive + controller not nothing)
maxiters::Int = 1000000
Expand Down Expand Up @@ -57,7 +57,7 @@ mutable struct ThunderboltTimeIntegrator{
callbackcacheType,
solType,
controllerType,
} <: SciMLBase.DEIntegrator{algType, true, uType, tType}
} <: SciMLBase.DEIntegrator{algType,true,uType,tType}
alg::algType
const f::fType # Right hand side
u::uType # Current local solution
Expand Down Expand Up @@ -95,7 +95,7 @@ end

# Interpolation
function (integrator::ThunderboltTimeIntegrator)(tmp, t)
OS.linear_interpolation!(tmp, t, integrator.uprev, integrator.u, integrator.t-integrator.dt, integrator.t)
OS.linear_interpolation!(tmp, t, integrator.uprev, integrator.u, integrator.t - integrator.dt, integrator.t)
end

# CommonSolve interface
Expand All @@ -118,26 +118,26 @@ function SciMLBase.__init(
alg::AbstractSolver,
args...;
dt,
saveat = (),
tstops = (),
d_discontinuities = (),
ts_init = (),
ks_init = (),
save_end = nothing,
save_everystep = false,
save_idxs = nothing,
callback = nothing,
advance_to_tstop = false,
adaptive = SciMLBase.isadaptive(alg),
verbose = false,
alias_u0 = true,
saveat=(),
tstops=(),
d_discontinuities=(),
ts_init=(),
ks_init=(),
save_end=nothing,
save_everystep=false,
save_idxs=nothing,
callback=nothing,
advance_to_tstop=false,
adaptive=SciMLBase.isadaptive(alg),
verbose=false,
alias_u0=true,
# alias_du0 = false,
controller = nothing,
maxiters = 1000000,
dense = save_everystep &&
!(alg isa DAEAlgorithm) && !(prob isa DiscreteProblem),
dtmin = nothing,
dtmax = nothing,
controller=nothing,
maxiters=1000000,
dense=save_everystep &&
!(alg isa DAEAlgorithm) && !(prob isa DiscreteProblem),
dtmin=nothing,
dtmax=nothing,
kwargs...,
)
(; f, u0, p) = prob
Expand All @@ -151,7 +151,7 @@ function SciMLBase.__init(
dtchangeable = DiffEqBase.isadaptive(alg)

dtmin = dtmin === nothing ? tType(0.0) : tType(dtmin)
dtmax = dtmax === nothing ? tType(tf-t0) : tType(dtmax)
dtmax = dtmax === nothing ? tType(tf - t0) : tType(dtmax)

if tstops isa AbstractArray || tstops isa Tuple || tstops isa Number
_tstops = nothing
Expand All @@ -168,9 +168,9 @@ function SciMLBase.__init(
save_end = save_end === nothing ? save_everystep || isempty(saveat) || saveat isa Number || tf in saveat : save_end

# Setup solution buffers
u = setup_u(prob, alg, alias_u0)
uType = typeof(u)
uBottomEltype = OrdinaryDiffEqCore.recursive_bottom_eltype(u)
u = setup_u(prob, alg, alias_u0)
uType = typeof(u)
uBottomEltype = OrdinaryDiffEqCore.recursive_bottom_eltype(u)
uBottomEltypeNoUnits = OrdinaryDiffEqCore.recursive_unitless_bottom_eltype(u)

# Setup callbacks
Expand Down Expand Up @@ -206,12 +206,12 @@ function SciMLBase.__init(

sol = SciMLBase.build_solution(
prob, alg, ts, uType[],
dense = dense, k = ks, saved_subsystem = saved_subsystem,
calculate_error = false
dense=dense, k=ks, saved_subsystem=saved_subsystem,
calculate_error=false
)

# Setup algorithm cache
cache = init_cache(prob, alg; dt = dt, u = u)
cache = init_cache(prob, alg; dt=dt, u=u)

# Setup controller
if controller === nothing && adaptive
Expand All @@ -236,19 +236,19 @@ function SciMLBase.__init(
adaptive ? controller : nothing,
IntegratorStats(),
IntegratorOptions(
dtmin = dtmin,
dtmax = dtmax,
verbose = verbose,
adaptive = adaptive,
maxiters = maxiters,
callback = callbacks_internal,
save_end = save_end,
tstops = tstops_internal,
saveat = saveat_internal,
d_discontinuities = d_discontinuities_internal,
tstops_cache = tstops,
saveat_cache = saveat,
d_discontinuities_cache = d_discontinuities,
dtmin=dtmin,
dtmax=dtmax,
verbose=verbose,
adaptive=adaptive,
maxiters=maxiters,
callback=callbacks_internal,
save_end=save_end,
tstops=tstops_internal,
saveat=saveat_internal,
d_discontinuities=d_discontinuities_internal,
tstops_cache=tstops,
saveat_cache=saveat,
d_discontinuities_cache=d_discontinuities,
),
false,
0,
Expand Down
Loading