Mercurial > repos > public > sbplib_julia
changeset 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 | 851d1e4ab3de |
children | 99541220b8bd |
files | src/Grids/timedependent.jl |
diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Grids/timedependent.jl Wed Jul 26 22:50:58 2023 +0200 @@ -0,0 +1,24 @@ +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