Skip to content

Commit

Permalink
Cleanup TimeKind usage
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jun 19, 2018
1 parent 50fff43 commit bba809b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Bifurcations.jl
Expand Up @@ -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")
Expand Down
8 changes: 3 additions & 5 deletions src/codim1/base.jl
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/codim1/traits.jl
Expand Up @@ -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)
3 changes: 3 additions & 0 deletions src/continuations/base.jl
Expand Up @@ -92,3 +92,6 @@ function get_prob_cache end
get_u0(prob::AbstractContinuationProblem) ↦ u0
"""
function get_u0 end


abstract type AbstractContinuationCache{PC <: AbstractProblemCache} end
3 changes: 2 additions & 1 deletion src/continuations/euler_newton.jl
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/fixedpoint.jl
Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bba809b

Please sign in to comment.