view +multiblock/evalOn.m @ 1031:2ef20d00b386 feature/advectionRV

For easier comparison, return both the first order and residual viscosity when evaluating the residual. Add the first order and residual viscosity to the state of the RungekuttaRV time steppers
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 17 Jan 2019 10:25:06 +0100
parents 442ec6c77c3f
children 92dc0a3b5d5d
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
            gf{i} = grid.evalOn(grids{i}, f{i});
        end
    else
        for i = 1:nBlocks
            gf{i} = grid.evalOn(grids{i}, @(varargin)f{i}(t,varargin{:}));
        end
    end

    gf = blockmatrix.toMatrix(gf);
end