Mercurial > repos > public > sbplib
comparison +multiblock/evalOn.m @ 832:5573913a0949 feature/burgers1d
Merged with default, and updated +scheme/Burgers1D accordingly
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 11 Sep 2018 15:58:35 +0200 |
parents | 442ec6c77c3f |
children | 92dc0a3b5d5d |
comparison
equal
deleted
inserted
replaced
831:d0934d1143b7 | 832:5573913a0949 |
---|---|
1 % Evaluate different function handle for each block in a multiblock.Grid | |
2 % Function handles may optionaly take a time argument | |
3 % f -- cell array of function handles | |
4 % f{i} = f_i(t,x,y,...) | |
5 % t -- optional time point. If not specified, it is assumed that the functions take only spatial arguments. | |
6 function gf = evalOn(g, f, t) | |
7 assertType(g, 'multiblock.Grid'); | |
8 assertType(f, 'cell'); | |
9 | |
10 default_arg('t', []); | |
11 | |
12 grids = g.grids; | |
13 nBlocks = length(grids); | |
14 gf = cell(nBlocks, 1); | |
15 | |
16 if isempty(t) | |
17 for i = 1:nBlocks | |
18 gf{i} = grid.evalOn(grids{i}, f{i}); | |
19 end | |
20 else | |
21 for i = 1:nBlocks | |
22 gf{i} = grid.evalOn(grids{i}, @(varargin)f{i}(t,varargin{:})); | |
23 end | |
24 end | |
25 | |
26 gf = blockmatrix.toMatrix(gf); | |
27 end |