Mercurial > repos > public > sbplib
comparison +multiblock/evalOn.m @ 804:1f1d2a271d61 feature/poroelastic
Move blockEvalOn to multiblock package
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 26 Jul 2018 18:33:01 -0700 |
parents | +grid/blockEvalOn.m@d991f8a0b61c |
children | 1caeb4dffdf9 |
comparison
equal
deleted
inserted
replaced
803:031d6db97270 | 804:1f1d2a271d61 |
---|---|
1 % Useful for evaulating forcing functions with different functional expressions for each block | |
2 % f: cell array of function handles fi | |
3 % f_i = f_i(x1,y,...,t) | |
4 % t: time point. If not specified, it is assumed that the functions take only spatial arguments. | |
5 function gf = evalOn(g, f, t) | |
6 default_arg('t',[]); | |
7 | |
8 grids = g.grids; | |
9 nBlocks = length(grids); | |
10 gf = cell(nBlocks,1); | |
11 | |
12 if isempty(t) | |
13 for i = 1:nBlocks | |
14 grid.evalOn(grids{i}, f{i} ); | |
15 end | |
16 else | |
17 dim = nargin(f{1}) - 1; | |
18 for i = 1:nBlocks | |
19 switch dim | |
20 case 1 | |
21 gf{i} = grid.evalOn(grids{i}, @(x)f{i}(x,t) ); | |
22 case 2 | |
23 gf{i} = grid.evalOn(grids{i}, @(x,y)f{i}(x,y,t) ); | |
24 case 3 | |
25 gf{i} = grid.evalOn(grids{i}, @(x,y,z)f{i}(x,y,z,t) ); | |
26 end | |
27 end | |
28 end | |
29 | |
30 gf = blockmatrix.toMatrix(gf); |