1 function [INC, J] = fv_two_phase_imp(model, model_data, S, CU, NU_ind)
2 %
function INC = fv_two_phase_imp(model, model_data, S, CU, NU_ind)
4 grid = model_data.grid;
6 if nargin <= 4 || isempty(NU_ind)
8 NU_ind{1} = (1:grid.nelements)
';
9 NU_ind{2} = (1:model_data.gn_edges)';
10 NU_ind{3} = (1:grid.nelements)
';
13 Slength = grid.nelements;
14 Ulength = model_data.gn_edges;
16 P = CU(Ulength+1:end);
18 % model.diffusivity_ptr = @(glob, U, model) struct('K
', 1, 'epsilon
', 0);%model.two_phase.phi(glob, U, model);
19 % model.diffusivity_derivative_ptr = @(glob, U, model) struct('K
', 0, 'epsilon
', 0);%model.two_phase.phi_derivative(glob, U, model);
20 % model.laplacian_ptr = @(glob, U, model) -getfield(model.two_phase.Phi(glob, U, model), 'K
')';
21 % model.laplacian_derivative_ptr = @(glob, U, model) -getfield(model.two_phase.phi(glob, U, model),
'K');
25 tmppar.local_mass_matrix = @fv_local_mass_matrix_rect;
27 tmppar.evaluate_basis = @fv_evaluate_basis;
29 S_upper = grid.A(NU_ind{1}).*l2project(@(elemin, loc, grid) model.two_phase.upper_source(elemin, loc, grid), 2, model_data.grid, tmppar);
30 S_lower = grid.A(NU_ind{1}).*l2project(@(elemin, loc, grid) model.two_phase.lower_source(elemin, loc, grid), 2, model_data.grid, tmppar);
32 % S_upper = grid.A(NU_ind{1}) .* model.two_phase.upper_source([grid.CX(NU_ind{1}), grid.CY(NU_ind{1})], model);
33 % S_lower = grid.A(NU_ind{1}) .* model.two_phase.lower_source([grid.CX(NU_ind{1}), grid.CY(NU_ind{1})], model);
35 INC = zeros(Slength+Ulength+1, 1);
37 UKL = -num_diff_flux_u.G(NU_ind{2});
39 INC(1:Ulength) = UKL - U;
41 % eventuell + S_upper - S_lower
42 INC(Ulength+1:end-1) = sum(U(model_data.gEI).*(grid.NX+grid.NY), 2) ...
46 % INC(end) = sum(grid.A(NU_ind{3}, :) .* P);
52 n = Slength+Ulength+1;
55 sp2 = -sparse(u_diff_p_s.pi, u_diff_p_s.pj+Ulength, u_diff_p_s.pvals, n, m);
57 sp3i = repmat(1:Slength, 1, 4)+Ulength;
58 sp3j = model_data.gEI(:);
59 sp3vals = grid.NX+grid.NY;
60 sp3 = sparse(sp3i,sp3j,sp3vals, n, m);
62 sp4 = sparse(Slength+Ulength+1, Ulength+1, 1, n, m);
63 % sp4 = sparse(Slength+Ulength+1*ones(1,Slength), Ulength+1:Slength+Ulength, grid.A(:), n, m);
65 sp5 = sparse((1:Ulength), (1:Ulength), -1, n,m);
67 J = sp2 + sp3 + sp4 + sp5;
function spm = fv_frechet_operators_diff_flux_pressure_gradient(model, model_data, P, S, NU_ind)
computes a jacobian of implicit non-linear convective contributions to time evolution matrices at a p...
function res = cubequadrature(poldeg, func, varargin)
integration of function func over reference cube == unit cube. by Gaussian quadrature exactly integra...
function num_flux_mat = fv_num_diff_flux_pressure_gradient(model, model_data, P, S)
computes a numerical diffusive flux for a diffusion problem