Mercurial > repos > public > sbplib_julia
view src/Grids/timedependent.jl @ 1385:896d978725fa feature/grids/timedependent_gridfunctions
Start sketching implementation of a wrapper for marking things as timedependent
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 26 Jul 2023 22:50:58 +0200 |
parents | |
children |
line wrap: on
line source
IsTimedependent(::Type{<:Any}) = Val(false) IsTimedependent(f) = IsTimedependent(typeof(f)) ## If IsTimedependent is true the type should support the function `wrapped_value` struct Timedependent{T} a::T end wrapped_value(a::Timedependent) = a.a IsTimedependent(::Type{<:Timedependent}) = Val(true) (tf::Timedependent)(x...) = tf.f(x...) eval_on(g, f) = eval_on(g, f, IsTimedependent(f)) function eval_on(g,f,::Val{false}) ## Same as current end function eval_on(g,f,::Val{true}) return t->eval_on(g, x̄->wrapped_value(f)(t,x̄)) end