Mercurial > repos > public > sbplib
view +grid/blockEvalOn.m @ 885:18e10217dca9 feature/d1_staggered
Generalize Staggered1DAcoustics to handle variable coefficients defined by both function handles and vectors.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Sun, 04 Nov 2018 12:36:30 -0800 |
parents | 179f234f6cbf |
children |
line wrap: on
line source
% 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);