Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit 9036932

Browse files
committed
Add missing file
1 parent 3f73643 commit 9036932

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

test/update_coeffs_testutils.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Utilities for testing update coefficient behaviour with state-dependent (i.e. dependent on u/p/t) functions
2+
3+
mutable struct WrapFunc{F,U,P,T}
4+
func::F
5+
u::U
6+
p::P
7+
t::T
8+
end
9+
10+
(w::WrapFunc)(u) = sum(w.u) * w.p * w.t * w.func(u)
11+
function (w::WrapFunc)(v, u)
12+
w.func(v, u)
13+
lmul!(sum(w.u) * w.p * w.t, v)
14+
end
15+
16+
update_coefficients(w::WrapFunc, u, p, t) = WrapFunc(w.func, u, p, t)
17+
function update_coefficients!(w::WrapFunc, u, p, t)
18+
w.u = u
19+
w.p = p
20+
w.t = t
21+
end
22+
23+
# Helper function for testing correct update coefficients behaviour of operators
24+
function update_coefficients_for_test!(L, u, p, t)
25+
update_coefficients!(L, u, p, t)
26+
# Force function hiding inside L to update. Should be a null-op if previous line works correctly
27+
update_coefficients!(L.op.f, u, p, t)
28+
end

0 commit comments

Comments
 (0)