Skip to content

Commit

Permalink
Run JuliaFormatter.format() (#282)
Browse files Browse the repository at this point in the history
Using JuliaFormatter v1.0.47
  • Loading branch information
LilithHafner committed Feb 15, 2024
1 parent 4843213 commit 4a63b84
Show file tree
Hide file tree
Showing 31 changed files with 703 additions and 630 deletions.
4 changes: 2 additions & 2 deletions src/alg_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ iscomposite(alg::AbstractMethodOfStepsAlgorithm) = iscomposite(alg.alg)

function DiffEqBase.prepare_alg(alg::MethodOfSteps, u0, p, prob)
MethodOfSteps(DiffEqBase.prepare_alg(alg.alg, u0, p, prob);
constrained = isconstrained(alg),
fpsolve = alg.fpsolve)
constrained = isconstrained(alg),
fpsolve = alg.fpsolve)
end
28 changes: 15 additions & 13 deletions src/fpsolve/functional.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function OrdinaryDiffEq.compute_step!(fpsolver::FPSolver{<:NLFunctional},
integrator::DDEIntegrator)
integrator::DDEIntegrator)
# update ODE integrator to next time interval together with correct interpolation
if fpsolver.iter == 1
advance_ode_integrator!(integrator)
Expand All @@ -11,7 +11,7 @@ function OrdinaryDiffEq.compute_step!(fpsolver::FPSolver{<:NLFunctional},
end

function OrdinaryDiffEq.compute_step!(fpsolver::FPSolver{<:NLAnderson, false},
integrator::DDEIntegrator)
integrator::DDEIntegrator)
@unpack cache, iter = fpsolver
@unpack aa_start = cache

Expand Down Expand Up @@ -40,7 +40,7 @@ function OrdinaryDiffEq.compute_step!(fpsolver::FPSolver{<:NLAnderson, false},
end

function OrdinaryDiffEq.compute_step!(fpsolver::FPSolver{<:NLAnderson, true},
integrator::DDEIntegrator)
integrator::DDEIntegrator)
@unpack cache, iter = fpsolver
@unpack aa_start = cache

Expand Down Expand Up @@ -68,9 +68,10 @@ function OrdinaryDiffEq.compute_step!(fpsolver::FPSolver{<:NLAnderson, true},
compute_step_fixedpoint!(fpsolver, integrator)
end

function compute_step_fixedpoint!(fpsolver::FPSolver{<:Union{NLFunctional, NLAnderson},
false},
integrator::DDEIntegrator)
function compute_step_fixedpoint!(
fpsolver::FPSolver{<:Union{NLFunctional, NLAnderson},
false},
integrator::DDEIntegrator)
@unpack t, opts = integrator
@unpack cache = fpsolver
ode_integrator = integrator.integrator
Expand All @@ -81,8 +82,8 @@ function compute_step_fixedpoint!(fpsolver::FPSolver{<:Union{NLFunctional, NLAnd
# compute residuals
dz = integrator.u .- ode_integrator.u
atmp = OrdinaryDiffEq.calculate_residuals(dz, ode_integrator.u, integrator.u,
opts.abstol, opts.reltol, opts.internalnorm,
t)
opts.abstol, opts.reltol, opts.internalnorm,
t)

# cache results
if isdefined(cache, :dz)
Expand All @@ -92,9 +93,10 @@ function compute_step_fixedpoint!(fpsolver::FPSolver{<:Union{NLFunctional, NLAnd
opts.internalnorm(atmp, t)
end

function compute_step_fixedpoint!(fpsolver::FPSolver{<:Union{NLFunctional, NLAnderson},
true},
integrator::DDEIntegrator)
function compute_step_fixedpoint!(
fpsolver::FPSolver{<:Union{NLFunctional, NLAnderson},
true},
integrator::DDEIntegrator)
@unpack t, opts = integrator
@unpack cache = fpsolver
@unpack dz, atmp = cache
Expand All @@ -106,7 +108,7 @@ function compute_step_fixedpoint!(fpsolver::FPSolver{<:Union{NLFunctional, NLAnd
# compute residuals
@.. dz = integrator.u - ode_integrator.u
OrdinaryDiffEq.calculate_residuals!(atmp, dz, ode_integrator.u, integrator.u,
opts.abstol, opts.reltol, opts.internalnorm, t)
opts.abstol, opts.reltol, opts.internalnorm, t)

opts.internalnorm(atmp, t)
end
Expand All @@ -120,7 +122,7 @@ function Base.resize!(fpcache::FPFunctionalCache, i::Int)
end

function Base.resize!(fpcache::FPAndersonCache, fpsolver::FPSolver{<:NLAnderson},
integrator::DDEIntegrator, i::Int)
integrator::DDEIntegrator, i::Int)
resize!(fpcache, fpsolver.alg, i)
end

Expand Down
29 changes: 15 additions & 14 deletions src/fpsolve/utils.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# construct solver for fixed-point iterations
function build_fpsolver(alg, fpalg::Union{NLFunctional, NLAnderson}, u, uEltypeNoUnits,
uBottomEltypeNoUnits, ::Val{true})
uBottomEltypeNoUnits, ::Val{true})
# no fixed-point iterations if the algorithm is constrained
isconstrained(alg) && return

Expand All @@ -24,22 +24,23 @@ function build_fpsolver(alg, fpalg::Union{NLFunctional, NLAnderson}, u, uEltypeN
dzold = zero(u)
z₊old = zero(u)

fpcache = FPAndersonCache(atmp, dz, dzold, z₊old, Δz₊s, Q, R, γs, 0, fpalg.aa_start,
fpalg.droptol)
fpcache = FPAndersonCache(
atmp, dz, dzold, z₊old, Δz₊s, Q, R, γs, 0, fpalg.aa_start,
fpalg.droptol)
end

# build solver
ηold = one(uTolType)

FPSolver{typeof(fpalg), true, uTolType, typeof(fpcache)}(fpalg, uTolType(fpalg.κ),
uTolType(fpalg.fast_convergence_cutoff),
ηold, 10000,
fpalg.max_iter,
SlowConvergence, fpcache, 0)
uTolType(fpalg.fast_convergence_cutoff),
ηold, 10000,
fpalg.max_iter,
SlowConvergence, fpcache, 0)
end

function build_fpsolver(alg, fpalg::Union{NLFunctional, NLAnderson}, u, uEltypeNoUnits,
uBottomEltypeNoUnits, ::Val{false})
uBottomEltypeNoUnits, ::Val{false})
# no fixed-point iterations if the algorithm is constrained
isconstrained(alg) && return

Expand All @@ -61,18 +62,18 @@ function build_fpsolver(alg, fpalg::Union{NLFunctional, NLAnderson}, u, uEltypeN
z₊old = u

fpcache = FPAndersonConstantCache(dz, dzold, z₊old, Δz₊s, Q, R, γs, 0,
fpalg.aa_start,
fpalg.droptol)
fpalg.aa_start,
fpalg.droptol)
end

# build solver
ηold = one(uTolType)

FPSolver{typeof(fpalg), false, uTolType, typeof(fpcache)}(fpalg, uTolType(fpalg.κ),
uTolType(fpalg.fast_convergence_cutoff),
ηold, 10_000,
fpalg.max_iter,
SlowConvergence, fpcache, 0)
uTolType(fpalg.fast_convergence_cutoff),
ηold, 10_000,
fpalg.max_iter,
SlowConvergence, fpcache, 0)
end

## resize
Expand Down
28 changes: 14 additions & 14 deletions src/functionwrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ function ODEFunctionWrapper(f::DiffEqBase.AbstractDDEFunction, h)
Wfact_t = @wrap_h Wfact_t(W, u, h, p, dtgamma, t)

ODEFunctionWrapper{isinplace(f), typeof(f.f), typeof(h), typeof(f.mass_matrix),
typeof(f.analytic), typeof(f.tgrad), typeof(jac),
typeof(f.jac_prototype), typeof(f.sparsity),
typeof(Wfact), typeof(Wfact_t),
typeof(f.paramjac), typeof(f.sys), typeof(f.colorvec)}(f.f, h,
f.mass_matrix,
f.analytic,
f.tgrad, jac,
f.jac_prototype,
f.sparsity,
Wfact,
Wfact_t,
f.paramjac,
f.sys,
f.colorvec)
typeof(f.analytic), typeof(f.tgrad), typeof(jac),
typeof(f.jac_prototype), typeof(f.sparsity),
typeof(Wfact), typeof(Wfact_t),
typeof(f.paramjac), typeof(f.sys), typeof(f.colorvec)}(f.f, h,
f.mass_matrix,
f.analytic,
f.tgrad, jac,
f.jac_prototype,
f.sparsity,
Wfact,
Wfact_t,
f.paramjac,
f.sys,
f.colorvec)
end

(f::ODEFunctionWrapper{true})(du, u, p, t) = f.f(du, u, f.h, p, t)
Expand Down
4 changes: 2 additions & 2 deletions src/history_function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end
HistoryFunction(h, integrator) = HistoryFunction(h, integrator, false)

function (f::HistoryFunction)(p, t, ::Type{Val{deriv}} = Val{0};
idxs = nothing) where {deriv}
idxs = nothing) where {deriv}
@unpack integrator = f
@unpack tdir, sol = integrator

Expand Down Expand Up @@ -56,7 +56,7 @@ function (f::HistoryFunction)(p, t, ::Type{Val{deriv}} = Val{0};
end

function (f::HistoryFunction)(val, p, t, ::Type{Val{deriv}} = Val{0};
idxs = nothing) where {deriv}
idxs = nothing) where {deriv}
@unpack integrator = f
@unpack tdir, sol = integrator

Expand Down

0 comments on commit 4a63b84

Please sign in to comment.