Mercurial > repos > public > sbplib_julia
view src/Grids/timedependent.jl @ 1865:99541220b8bd feature/grids/timedependent_gridfunctions
Close branch
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 20 Jan 2025 23:06:18 +0100 |
parents | 896d978725fa |
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