Mercurial > repos > public > sbplib
diff +multiblock/evalOn.m @ 806:f779b5aca5eb feature/poroelastic
Add type assertions, fix bug, edit documentation and formatting
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 27 Jul 2018 09:49:24 -0700 |
parents | 1caeb4dffdf9 |
children | cee0b381d714 |
line wrap: on
line diff
--- a/+multiblock/evalOn.m Thu Jul 26 18:34:38 2018 -0700 +++ b/+multiblock/evalOn.m Fri Jul 27 09:49:24 2018 -0700 @@ -1,28 +1,32 @@ -% 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. +% Evaluate different function handle for each block in a multiblock.Grid +% Function handles may optionaly take a time argument +% f -- cell array of function handles +% f{i} = f_i(x,y,...,t) +% t -- optional time point. If not specified, it is assumed that the functions take only spatial arguments. function gf = evalOn(g, f, t) - default_arg('t',[]); + assertType(g, 'multiblock.Grid'); + assertType(f, 'cell'); + + default_arg('t', []); grids = g.grids; nBlocks = length(grids); - gf = cell(nBlocks,1); + gf = cell(nBlocks, 1); if isempty(t) for i = 1:nBlocks - grid.evalOn(grids{i}, f{i} ); + gf{i} = 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) ); + 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) ); + 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) ); + gf{i} = grid.evalOn(grids{i}, @(x,y,z)f{i}(x,y,z,t)); end end end