1 function res = ldg_evaluate_basis_derivative(lcoord,params)
2 %
function res = ldg_evaluate_basis_derivative(lcoord,params)
4 % evaluation of ldg reference basis
5 % derivatives `D(\hat \phi_i), i=1,...,m` in point
6 % `\hat x` =
'lcoord'. The argument params is a structure with fields
'pdeg' and
'dimrange'.
7 % Res is a cell array,
'res{i}' = `D \hat \phi_i`
8 % and `D \hat \phi_i` is a
'dimrange x 2' (==ndimworld) array
9 %
'lcoord' is a 2-vector with the barycentric coordinates in the
12 % with V being the ldg_weight_matrix and W=V
' we have
15 % (\hat phi_1, ... \hat phi_nbasefct) =
17 % (c_1(x),0 ,0 ,c_2(x),0 ,0 ,... c_k(x), 0, 0)
18 % (0 ,c_1(x),0 ,0 ,c_2(x),0 ,... 0 ,c_k(x), 0 )
19 % (0 ,0 ,c_1(x),0 , 0,c_2(x),... 0 , 0 , c_k(x))
22 % and `c_i(x)= w_i * p(x)`
24 % with `w_i` = i-th row of 'W
' (i-th column of 'V
') and `p(x)` the powervector
26 % with k = number of scalar base functions = dim('powervector2
')
28 % Hence the derivatives also have similar repeating structure.
30 % D \hat \phi_1 = \left[\begin{array}{cc} \multicolumn{2}{c}{w_1 \cdot D p(x) } \\
32 % 0 & 0 \end{array}\right]
34 % D \hat \phi_2 = \left[ \begin{array}{cc} 0 & 0 \\
35 % \multicolumn{2}{c}{w_1 \cdot D p(x) } \\
36 % 0 & 0 \end{array}\right]
40 % In the vectorial case, this computation is very storage redundant, as
41 % most of the `D\hat \phi_i` are zeros, only one nonzero line...
42 % definitely space for improvement.
44 % Bernard Haasdonk 28.8.2009
47 case 0 % piecewise constant => zero derivative
48 res = cell(1,params.dimrange);
49 for i=1:params.dimrange
50 res{i}= zeros(params.dimrange,2);
54 % res = [sqrt(2) * eye(df.dimrange), ...
55 % 6 *(lcoord(1)-1/3) * eye(df.dimrange),...
56 % 6 / sqrt(3)*(2 * lcoord(2)+lcoord(1)-1) * eye(df.dimrange)];
57 V = ldg_basis_weight_matrix(params.pdeg);
59 nbasefct = params.dimrange*nrep(params.pdeg);
60 res = cell(1,nbasefct);
61 Dp = power_vector2_derivative(lcoord,params.pdeg);
63 for i=1:nrep(params.pdeg)
64 for j = 1:params.dimrange
65 res{(i-1)*params.dimrange+j}= zeros(params.dimrange,2);
66 res{(i-1)*params.dimrange+j}(j,:) = WDp(i,:);
70 error(
'pdeg not yet supported!');