comparison +grid/blockEvalOn.m @ 757:179f234f6cbf feature/d1_staggered

Merge with poroelastic to get blockEvalOn.
author Martin Almquist <malmquist@stanford.edu>
date Sun, 17 Jun 2018 14:44:05 -0700
parents
children
comparison
equal deleted inserted replaced
756:f891758ad7a4 757:179f234f6cbf
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 = blockEvalOn(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);