rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
diffusivity_richards_nonlinear.m
1 function diffusivity = diffusivity_richards_nonlinear(glob, ~, params)
2 % function diffusivity = diffusivity_richards_nonlinear(glob, U, params)
3 %
4 % function computing the nonlinear diffusivity tensor of a richards problem by
5 % pointwise evaluation in the point sequences indicated by global coordinates
6 % in the columns of the matrix glob.
7 % It returns a gradient tensor for the Richards equation.
8 %
9 % required fields of params:
10 % k : scalar scaling factor for diffusivity
11 % gravity : scalar modelling the physical gravity
12 % richards_perm_ptr : function pointer for permeability function
13 % richards_retention_ptr : function pointer evaluating the retention curve
14 % U : DoF vector of discrete solution
15 %
16 % generated fields of diffusivity:
17 % epsilon: upper bound on diffusivity value
18 % K: vector with diffusivity values
19 
20 % glob column check
21 if params.debug
22  if ~isempty(glob) && size(glob,1) < size(glob,2)
23  warning('coordinates in variable glob are given row-wise, but expected them to be column-wise');
24  if params.debug > 2
25  keyboard;
26  end
27  end
28 end
29 X=glob(:,1);
30 Y=glob(:,2);
31 U = params.U;
32 %vlen = size(U,1);
33 p_mu = spline_select(params);
34 U = U - params.gravity * Y.*(1+ppval(p_mu, X));
35 Kaval = params.k * real(params.richards_perm_ptr(U)) .* real(params.richards_retention_ptr(U));
36 diffusivity.K = Kaval;
37 diffusivity.epsilon = max(Kaval);
38 % Utemp = U' * params.k + 0.0004;
39 % diffusivity.K = spdiags(reshape([Utemp;zeros(1,vlen)],2*vlen,1),0,2*vlen,2*vlen);
40 % diffusivity.epsilon = max(Utemp);
41 
42 decomp_mode = params.decomp_mode;
43 if decomp_mode>0 && respected_decomp_mode==0
44  error('function is nonlinear and does not support affine decomposition!');
45 end;
46 %| \docupdate