rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
ldg_evaluate_scalar_basis_derivative.m
1 function res = ldg_evaluate_scalar_basis_derivative(lcoord,df)
2 %function res = ldg_evaluate_scalar_basis_derivative(lcoord,df)
3 %
4 % evaluation of scalar ldg reference basis
5 % derivatives `\nabla(\hat \phi_i), i=1,\ldots,m` in point
6 % `\hat x` = 'lcoord'. The argument 'df' can either be a ldg discfunc or
7 % a structure with fields pdeg and dimrange.
8 % Res is a nbasefunctions x dimworld array, 'Res(i,:)' = `\nabla \hat \phi_i`
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 % ``(\hat \phi_1, \ldots, \hat \phi_{\mbox{nbasefct}}) =
15 %
16 % (c_1(x),c_2(x),c_k(x)) ``
17 %
18 % and `c_i(x)= w_i p(x) `
19 %
20 % with `w_i` = i-th row of W (i-th column of V) and p(x) the powervector
21 %
22 % with k = number of scalar base functions = dim(powervector2)
23 %
24 % Hence the derivatives also have similar repeating structure.
25 %
26 % `\nabla \hat \phi_1 = [w_1 * D p(x)]' `
27 % etc.
28 %
29 % perhaps the general vectorial case (tensor-product basis) can be
30 % generalized from this version later...
31 
32 % Bernard Haasdonk 28.8.2009
33 
34 if (df.dimrange~=1)
35  warning('caution: scalar basis evaluated, but df is vectorial!');
36 end;
37 
38 switch df.pdeg
39  case 0 % piecewise constant => zero gradient
40  res = zeros(1,2); % 1 base function scalar, constant case.
41  case {1,2,3,4}
42  % case 1:
43  % res = [sqrt(2) * eye(df.dimrange), ...
44  % 6 *(lcoord(1)-1/3) * eye(df.dimrange),...
45  % 6 / sqrt(3)*(2 * lcoord(2)+lcoord(1)-1) * eye(df.dimrange)];
46  V = ldg_basis_weight_matrix(df.pdeg);
47  nrep=[3,6,10,15];
48  nbasefct = df.dimrange*nrep(df.pdeg);
49  %res = zeros(2,nbasefct);
50  Dp = power_vector2_derivative(lcoord,df.pdeg);
51  res = Dp' * V;
52  res = res';
53  % WDp = V'*Dp;
54  % for i=1:nrep(df.pdeg)
55  % for j = 1:df.dimrange
56  % res{(i-1)*df.dimrange+j}= zeros(df.dimrange,2);
57  % res{(i-1)*df.dimrange+j}(j,:) = WDp(i,:);
58  % end;
59  % end;
60  otherwise
61  error('pdeg not yet supported!');
62 end;
63 %| \docupdate