Mercurial > repos > public > sbplib
view +multiblock/evalOn.m @ 1133:92dc0a3b5d5d feature/laplace_curvilinear_test
Generalize multiblock.evalOn() to work for a mix of function handles and grid functions
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Mon, 27 May 2019 16:52:28 -0700 |
parents | 442ec6c77c3f |
children |
line wrap: on
line source
% 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(t,x,y,...) % t -- optional time point. If not specified, it is assumed that the functions take only spatial arguments. function gf = evalOn(g, f, t) assertType(g, 'multiblock.Grid'); assertType(f, 'cell'); default_arg('t', []); grids = g.grids; nBlocks = length(grids); gf = cell(nBlocks, 1); if isempty(t) for i = 1:nBlocks if isa(f{i}, 'function_handle') gf{i} = grid.evalOn(grids{i}, f{i}); else gf{i} = f{i}; end end else for i = 1:nBlocks if isa(f{i}, 'function_handle') gf{i} = grid.evalOn(grids{i}, @(varargin)f{i}(t,varargin{:})); else gf{i} = f{i}; end end end gf = blockmatrix.toMatrix(gf); end