annotate +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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
757
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
1 % Useful for evaulating forcing functions with different functional expressions for each block
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
2 % f: cell array of function handles fi
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
3 % f_i = f_i(x1,y,...,t)
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
4 % t: time point. If not specified, it is assumed that the functions take only spatial arguments.
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
5 function gf = blockEvalOn(g, f, t)
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
6 default_arg('t',[]);
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
7
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
8 grids = g.grids;
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
9 nBlocks = length(grids);
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
10 gf = cell(nBlocks,1);
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
11
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
12 if isempty(t)
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
13 for i = 1:nBlocks
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
14 grid.evalOn(grids{i}, f{i} );
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
15 end
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
16 else
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
17 dim = nargin(f{1}) - 1;
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
18 for i = 1:nBlocks
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
19 switch dim
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
20 case 1
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
21 gf{i} = grid.evalOn(grids{i}, @(x)f{i}(x,t) );
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
22 case 2
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
23 gf{i} = grid.evalOn(grids{i}, @(x,y)f{i}(x,y,t) );
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
24 case 3
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
25 gf{i} = grid.evalOn(grids{i}, @(x,y,z)f{i}(x,y,z,t) );
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
26 end
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
27 end
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
28 end
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
29
179f234f6cbf Merge with poroelastic to get blockEvalOn.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
30 gf = blockmatrix.toMatrix(gf);