rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
fem_basis_weight_matrix.m
1 function V = fem_basis_weight_matrix(pdeg)
2 %function V = fem_basis_weight_matrix(pdeg)
3 %
4 % function returning the weight matrix for a lagrange basis on the
5 % reference triangle used by fem_evaluate_basis
6 % l(x) = V * p(x)
7 % with p(x) the monomial basis, i.e. power_vector2
8 %
9 % for pdeg = 1 the matrix is explicitly given
10 % for higher pdegs it is computed, hence expensive. Simply insert
11 % the obtained matrices hardcode into this file, if your pdeg is
12 % not yet available.
13 
14 % Bernard Haasdonk 12.1.2011
15 
16 switch pdeg
17  case 1
18  V = [1,-1,-1 ; ...
19  0, 1, 0; ...
20  0, 0, 1];
21  case 2
22  V = [1 -3 -3 2 4 2
23  0 4 0 -4 -4 0
24  0 -1 0 2 0 0
25  0 0 4 0 -4 -4
26  0 0 0 0 4 0
27  0 0 -1 0 0 2
28  ];
29  case 3
30  V = [
31  2 -11 -11 18 36 18 -9 -27 -27 -9
32  0 18 0 -45 -45 0 27 54 27 0
33  0 -9 0 36 9 0 -27 -27 0 0
34  0 2 0 -9 0 0 9 0 0 0
35  0 0 18 0 -45 -45 0 27 54 27
36  0 0 0 0 54 0 0 -54 -54 0
37  0 0 0 0 -9 0 0 27 0 0
38  0 0 -9 0 9 36 0 0 -27 -27
39  0 0 0 0 -9 0 0 0 27 0
40  0 0 2 0 0 -9 0 0 0 9
41  ] / 2;
42  case 4
43  V = [
44  3 -25 -25 70 140 70 -80 -240 -240 -80 32 128 192 128 32
45  0 48 0 -208 -208 0 288 576 288 0 -128 -384 -384 -128 0
46  0 -36 0 228 84 0 -384 -432 -48 0 192 384 192 0 0
47  0 16 0 -112 -16 0 224 96 0 0 -128 -128 0 0 0
48  0 -3 0 22 0 0 -48 0 0 0 32 0 0 0 0
49  0 0 48 0 -208 -208 0 288 576 288 0 -128 -384 -384 -128
50  0 0 0 0 288 0 0 -672 -672 0 0 384 768 384 0
51  0 0 0 0 -96 0 0 480 96 0 0 -384 -384 0 0
52  0 0 0 0 16 0 0 -96 0 0 0 128 0 0 0
53  0 0 -36 0 84 228 0 -48 -432 -384 0 0 192 384 192
54  0 0 0 0 -96 0 0 96 480 0 0 0 -384 -384 0
55  0 0 0 0 12 0 0 -48 -48 0 0 0 192 0 0
56  0 0 16 0 -16 -112 0 0 96 224 0 0 0 -128 -128
57  0 0 0 0 16 0 0 0 -96 0 0 0 0 128 0
58  0 0 -3 0 0 22 0 0 0 -48 0 0 0 0 32
59  ]/3;
60  otherwise
61  % these computations should not be done everytime!
62  % for higher pdeg, perhaps also use higher accuracy!!!
63  disp(['please hardcode the following matrix into' ...
64  ' fem_basis_weight_matrix:']);
65  % V = inv(P) where P = (p(l1),...p(lm)) powervector of lagrange-nodes
66  lagrange_nodes = lagrange_nodes_lcoord(pdeg);
67  P = zeros(size(lagrange_nodes,1));
68  for i = 1: size(lagrange_nodes,1)
69  P(:,i) = power_vector2(lagrange_nodes(i,:),pdeg);
70  end;
71  V = inv(P);
72 end;