Mercurial > repos > public > sbplib
changeset 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 | f891758ad7a4 |
children | 0ef96fcdc028 |
files | +grid/blockEvalOn.m +multiblock/Grid.m |
diffstat | 2 files changed, 31 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
diff -r f891758ad7a4 -r 179f234f6cbf +grid/blockEvalOn.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/+grid/blockEvalOn.m Sun Jun 17 14:44:05 2018 -0700 @@ -0,0 +1,30 @@ +% Useful for evaulating forcing functions with different functional expressions for each block +% f: cell array of function handles fi +% f_i = f_i(x1,y,...,t) +% t: time point. If not specified, it is assumed that the functions take only spatial arguments. +function gf = blockEvalOn(g, f, t) +default_arg('t',[]); + +grids = g.grids; +nBlocks = length(grids); +gf = cell(nBlocks,1); + +if isempty(t) + for i = 1:nBlocks + grid.evalOn(grids{i}, f{i} ); + end +else + dim = nargin(f{1}) - 1; + for i = 1:nBlocks + switch dim + case 1 + gf{i} = grid.evalOn(grids{i}, @(x)f{i}(x,t) ); + case 2 + gf{i} = grid.evalOn(grids{i}, @(x,y)f{i}(x,y,t) ); + case 3 + gf{i} = grid.evalOn(grids{i}, @(x,y,z)f{i}(x,y,z,t) ); + end + end +end + +gf = blockmatrix.toMatrix(gf); \ No newline at end of file
diff -r f891758ad7a4 -r 179f234f6cbf +multiblock/Grid.m --- a/+multiblock/Grid.m Sat Jun 16 14:30:45 2018 -0700 +++ b/+multiblock/Grid.m Sun Jun 17 14:44:05 2018 -0700 @@ -77,7 +77,7 @@ % Collect number of points in each block N = zeros(1,nBlocks); for i = 1:nBlocks - N(i) = obj.grids{i}.N(); + N(i) = obj.grids{i}.N()*nComponents; end gfs = blockmatrix.fromMatrix(gf, {N,1});