Mercurial > repos > public > sbplib_julia
comparison 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 |
comparison
equal
deleted
inserted
replaced
1384:851d1e4ab3de | 1385:896d978725fa |
---|---|
1 IsTimedependent(::Type{<:Any}) = Val(false) | |
2 IsTimedependent(f) = IsTimedependent(typeof(f)) | |
3 | |
4 ## If IsTimedependent is true the type should support the function `wrapped_value` | |
5 | |
6 struct Timedependent{T} | |
7 a::T | |
8 end | |
9 | |
10 wrapped_value(a::Timedependent) = a.a | |
11 IsTimedependent(::Type{<:Timedependent}) = Val(true) | |
12 | |
13 (tf::Timedependent)(x...) = tf.f(x...) | |
14 | |
15 | |
16 eval_on(g, f) = eval_on(g, f, IsTimedependent(f)) | |
17 | |
18 function eval_on(g,f,::Val{false}) | |
19 ## Same as current | |
20 end | |
21 | |
22 function eval_on(g,f,::Val{true}) | |
23 return t->eval_on(g, x̄->wrapped_value(f)(t,x̄)) | |
24 end |