rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
ldg_evaluate_basis_derivative.m
1 function res = ldg_evaluate_basis_derivative(lcoord,params)
2 %function res = ldg_evaluate_basis_derivative(lcoord,params)
3 %
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
10 % triangle
11 %
12 % with V being the ldg_weight_matrix and W=V' we have
13 %
14 % @code
15 % (\hat phi_1, ... \hat phi_nbasefct) =
16 %
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))
20 % @endcode
21 %
22 % and `c_i(x)= w_i * p(x)`
23 %
24 % with `w_i` = i-th row of 'W' (i-th column of 'V') and `p(x)` the powervector
25 %
26 % with k = number of scalar base functions = dim('powervector2')
27 %
28 % Hence the derivatives also have similar repeating structure.
29 % ``
30 % D \hat \phi_1 = \left[\begin{array}{cc} \multicolumn{2}{c}{w_1 \cdot D p(x) } \\
31 % 0 & 0 \\
32 % 0 & 0 \end{array}\right]
33 % `` ``
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]
37 % ``
38 % etc.
39 %
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.
43 
44 % Bernard Haasdonk 28.8.2009
45 
46 switch params.pdeg
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);
51  end;
52  case {1,2,3,4}
53  % case 1:
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);
58  nrep=[3,6,10,15];
59  nbasefct = params.dimrange*nrep(params.pdeg);
60  res = cell(1,nbasefct);
61  Dp = power_vector2_derivative(lcoord,params.pdeg);
62  WDp = V'*Dp;
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,:);
67  end;
68  end;
69  otherwise
70  error('pdeg not yet supported!');
71 end;
72 %| \docupdate