diff --git a/src/Bifurcations.jl b/src/Bifurcations.jl index 58837a8..30bbd55 100644 --- a/src/Bifurcations.jl +++ b/src/Bifurcations.jl @@ -12,8 +12,8 @@ import .Continuations: get_prob_cache, get_u0, residual!, residual_jacobian!, const _C = AbstractProblemCache include("codim1/codim1.jl") -using .Codim1: TimeKind, Continuous, Discrete -import .Codim1: timekind +using .Codim1: timekind, Continuous, Discrete +import .Codim1: TimeKind include("fixedpoint.jl") include("interface.jl") diff --git a/src/codim1/base.jl b/src/codim1/base.jl index b0acc95..5363111 100644 --- a/src/codim1/base.jl +++ b/src/codim1/base.jl @@ -69,7 +69,7 @@ Codim1Sweep{tkind, S, JType, eType, pType}(super::S) where{ pType[], ) -timekind(::Codim1Sweep{tkind}) where tkind = tkind() +TimeKind(::Type{<: Codim1Sweep{tkind}}) where tkind = tkind() eigvals_prototpye(cache::ContinuationCache) = cache.u[1:end - 1] # TODO: improve it for SVector @@ -98,7 +98,8 @@ Codim1Solution(super::ContinuationSolution, mutable struct Codim1Cache{P, C <: ContinuationCache{P}, - JType, eType} + JType, eType, + } <: AbstractContinuationCache{P} # TODO: declare types super::C J::JType @@ -122,9 +123,6 @@ Codim1Cache(super::ContinuationCache) = copy(eigvals_prototpye(super)), ) -timekind(cache::Codim1Cache) = timekind(as(cache, ContinuationCache)) -timekind(cache::ContinuationCache) = timekind(cache.prob_cache) - struct Codim1Solver{R <: ContinuationSolver, P <: AbstractContinuationProblem, C <: Codim1Cache, diff --git a/src/codim1/traits.jl b/src/codim1/traits.jl index 5bed650..34d81b9 100644 --- a/src/codim1/traits.jl +++ b/src/codim1/traits.jl @@ -3,3 +3,7 @@ struct Discrete <: TimeKind end struct Continuous <: TimeKind end timekind(::T) where T = TimeKind(T) + + +using ..Continuations: AbstractContinuationCache +TimeKind(::Type{<: AbstractContinuationCache{PC}}) where PC = TimeKind(PC) diff --git a/src/continuations/base.jl b/src/continuations/base.jl index 1a365af..e75f51e 100644 --- a/src/continuations/base.jl +++ b/src/continuations/base.jl @@ -92,3 +92,6 @@ function get_prob_cache end get_u0(prob::AbstractContinuationProblem) ↦ u0 """ function get_u0 end + + +abstract type AbstractContinuationCache{PC <: AbstractProblemCache} end diff --git a/src/continuations/euler_newton.jl b/src/continuations/euler_newton.jl index ade22d0..7441ff8 100644 --- a/src/continuations/euler_newton.jl +++ b/src/continuations/euler_newton.jl @@ -28,7 +28,8 @@ See [`AbstractContinuationProblem`](@ref) for the mathematical setup. - `simple_bifurcation::Bool` """ mutable struct ContinuationCache{PC <: AbstractProblemCache, - uType, HType, JType, QType, hType} + uType, HType, JType, QType, hType, + } <: AbstractContinuationCache{PC} prob_cache::PC u::uType H::HType diff --git a/src/fixedpoint.jl b/src/fixedpoint.jl index e287d97..2f738ba 100644 --- a/src/fixedpoint.jl +++ b/src/fixedpoint.jl @@ -28,7 +28,8 @@ struct FixedPointBifurcationProblem{iip, end end -timekind(::FixedPointBifurcationProblem{_, tkind}) where {_, tkind} = tkind() +TimeKind(::Type{<: FixedPointBifurcationProblem{_, tkind}}) where {_, tkind} = + tkind() const FPBPWithHJac{iip, tkind} = FixedPointBifurcationProblem{iip, tkind, <: Function} @@ -81,7 +82,7 @@ struct FixedPointBifurcationCache{P, C} <: AbstractProblemCache{P} end end -timekind(cache::FixedPointBifurcationCache) = timekind(cache.prob) +TimeKind(::Type{<: FixedPointBifurcationCache{P}}) where P = TimeKind(P) get_prob_cache(prob::FixedPointBifurcationProblem) = FixedPointBifurcationCache(prob)