rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
fv_frechet_operators_diff_implicit_gradient.m
Go to the documentation of this file.
1 function [L_I_diff_jac, bdir_I_diff_jac] = fv_frechet_operators_diff_implicit_gradient(...
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_I_diff, bdirU_I_diff] = fv_operators_diff_implicit_gradient(tmpmodel, ...
45  model_data, U, NU_ind);
46 clear_all_caches;
47 [n,m] = size(LU_I_diff);
48 % Note: This only works when diffusivity is averaged on edge points by
49 % arithmetic mean, adapt the next two lines, if you want to use geometric
50 % or harmonic mean functions.
51 tmp = LU_I_diff * U;
52 L_I_diff = sparse([1:n,2:n,1:(n-1)],...
53  [tmpNU(1:n), tmpNU(1:(n-1)), tmpNU(2:n)],...
54  [1/4 * tmp', 1/2 * tmp(2:n)', 1/4*tmp(1:(n-1))'],...
55  n, m);
56 %L_I_diff = spdiags(LU_I_diff * U,0,n,n);
57 bdir_I_diff = bdirU_I_diff;
58 
59 tmpmodel.diffusivity_ptr = model.diffusivity_ptr;
61 [LV_I_diff, bdirV_I_diff] = fv_operators_diff_implicit_gradient(tmpmodel, ...
62  model_data, U, NU_ind);
64 
65 bdir_I_diff_jac = bdir_I_diff + bdirV_I_diff;
66 L_I_diff_jac = L_I_diff + LV_I_diff;
67 
68 
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 [ L_I_diff_jac , bdir_I_diff_jac ] = fv_frechet_operators_diff_implicit_gradient(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...