2 model,model_data, S, U, S_ind, U_ind)
4 % model,model_data, P, S, P_ind, S_ind)
5 % computes convection contribution to finite volume time evolution matrices,
6 % <b> or their Frechet derivative </b>
11 if ~isempty(model_data)
12 grid = model_data.grid;
15 real_NB_ind = find(grid.NBI>0);
16 NBIind = grid.NBI(real_NB_ind);
17 INBind = grid.INB(real_NB_ind);
18 % NB_real_ind comprises comprises some kind of inverse cell-neighbour
19 % relation that leads back to the original cell from where we started
21 % [i,j]=ind2sub(size(grid.NBI),NB_real_NB_ind(sub2ind(size(grid.NBI),k,l)))
24 NB_real_NB_ind = sub2ind(size(grid.NBI),NBIind,INBind);
26 dir_NB_ind = find(grid.NBI == -1);
42 % matrix evaluating the flux by quadratures over all edges
43 Sn = repmat(S, 1, size(grid.ECX,2));
44 [elids, edgeids] = ind2sub(size(grid.VI),1:length(grid.VI(:)));
45 PP = edge_quad_points(grid,elids, edgeids, model.flux_quad_degree);
46 fs = model.two_phase.waterflow(PP,repmat(Sn(:), model.flux_quad_degree, 1)', model);
47 dfs = model.two_phase.waterflow_derivative(PP,repmat(Sn(:), model.flux_quad_degree, 1)', model);
48 FS = reshape(fs,size(grid.NBI));
49 DFS = reshape(dfs, size(grid.NBI));