rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
fv_frechet_operators_diff_implicit_gradient2.m
Go to the documentation of this file.
2  model, model_data, U, NU_ind)
3 %function [L_I_diff, bdir_I_diff] = ...
4 % fv_operators_diff_implicit_gradient(model,model_data, U, ...
5 % [NU_ind])
6 % computes a jacobian of implicit non-linear diffusion contributions to time
7 % evolution matrices at a point 'U'.
8 %
9 % function computing the jacobian in 'U' of the implicit diffusion contribution
10 % of `L_I` and `b_I` to the time evolution matrices for a finite volume time
11 % step
12 % `L_I U^{k+1} = L_E U^k + b_E + b_I`.
13 % With the help of the returned Jacobian 'L_I_diff_jac' the Frechet derivative
14 % `DL_I ({U})` is approximated.
15 %
16 % \note The *_implicit functions perform a 'dt' increase in 'model' \em before
17 % evaluating the data functions.
18 %
19 % Return values:
20 % L_I_diff_jac : a sparse matrix with jacobian of diffusion contributions to
21 % `L_I`.
22 % bdir_I_diff_jac: and offset vector containing the Dirichlet value
23 % contributions of the diffusion parts.
24 %
25 % Note: This only works when diffusivity is averaged on edge points by
26 % arithmetic mean, adapt the function, if you want to use geometric
27 % or harmonic mean functions.
28 
29 
30 tmpmodel = model;
31 
32 if nargin < 4
33  NU_ind = [];
34 end
35 if isempty(NU_ind)
36  tmpNU = 1:length(U);
37 else
38  tmpNU = NU_ind';
39 end
40 
41 tmpmodel.diffusivity_ptr = model.diffusivity_derivative_ptr;
42 
43 clear_all_caches;
44 LU_diff_sm = fv_operators_diff_implicit_gradient2(tmpmodel, ...
45  model_data, U, NU_ind);
46 clear_all_caches;
47 n = LU_diff_sm.sm;
48 m = LU_diff_sm.sn;
49 LU_I_diff = sparse(LU_diff_sm.si, LU_diff_sm.sj, LU_diff_sm.svals, n, m);
50 % Note: This only works when diffusivity is averaged on edge points by
51 % arithmetic mean, adapt the next two lines, if you want to use geometric
52 % or harmonic mean functions.
53 tmp = LU_I_diff * U;
54 %L_I_diff = sparse([1:n,2:n,1:(n-1)],...
55 % [tmpNU(1:n), tmpNU(1:(n-1)), tmpNU(2:n)],...
56 % [1/4 * tmp', 1/2 * tmp(2:n)', 1/4*tmp(1:(n-1))'],...
57 % n, m);
58 %L_I_diff = spdiags(LU_I_diff * U,0,n,n);
59 
60 tmpmodel.diffusivity_ptr = model.diffusivity_ptr;
62 LV_sm = fv_operators_diff_implicit_gradient2(tmpmodel, ...
63  model_data, U, NU_ind);
65 
66 sm.sn = n;
67 sm.sm = m;
68 sm.si = [1:n, 2:n, 1:(n-1), LV_sm.si];
69 sm.sj = [tmpNU(1:n), tmpNU(1:(n-1)), tmpNU(2:n), LV_sm.sj];
70 sm.svals = [1/4*tmp', 1/2*tmp(2:n)', 1/4*tmp(1:(n-1))', LV_sm.svals(:)'];
71 
72 
function [ L_I_diff , bdir_I_diff ] = fv_operators_diff_implicit_gradient(model, model_data, U, NU_ind)
computes diffusion contributions to finite volume time evolution matrices, or their Frechet derivati...
function spm = fv_operators_diff_implicit_gradient2(model, model_data, U, NU_ind)
computes diffusion contributions to finite volume time evolution matrices, or their Frechet derivati...
function sm = fv_frechet_operators_diff_implicit_gradient2(model, model_data, U, NU_ind)
computes a jacobian of implicit non-linear diffusion contributions to time evolution matrices at a po...
function clear_all_caches()
This function clears the caches generated for caching of gradient data in evolution schemes...