Flow123d  jenkins-Flow123d-linux-release-multijob-282
fe_p.cc
Go to the documentation of this file.
1 /*
2  * fe_p.cc
3  *
4  * Created on: Sep 3, 2012
5  * Author: jb
6  */
7 
8 
9 // !! implementation of specializations has to be i *.cc file to avoid multiple definition error during linking
10 #include "fe_p.hh"
11 
12 /****** Template specializations ******/
13 
14 /*** 1D finite elements ***/
15 
16 // P0 constant element
17 template<>
19 {
20  number_of_dofs = 1;
21 
22  number_of_single_dofs[1] = 1;
23 
24  unit_support_points.push_back(arma::zeros<arma::vec>(1));
25 }
26 
27 // P1 linear element
28 template<>
30 {
31  number_of_dofs = 2;
32 
33  number_of_single_dofs[0] = 2;
34 
35  unit_support_points.push_back(arma::vec::fixed<1>("0"));
36  unit_support_points.push_back(arma::vec::fixed<1>("1"));
37 }
38 
39 // P2 quadratic element
40 template<>
42 {
43  number_of_dofs = 3;
44 
45  number_of_single_dofs[0] = 2;
46  number_of_single_dofs[1] = 1;
47 
48  unit_support_points.push_back(arma::vec::fixed<1>("0"));
49  unit_support_points.push_back(arma::vec::fixed<1>("1"));
50  unit_support_points.push_back(arma::vec::fixed<1>("0.5"));
51 }
52 
53 // P3 cubic element
54 template<>
56 {
57  number_of_dofs = 4;
58 
59  number_of_single_dofs[0] = 2;
60  number_of_pairs[1] = 1;
61 
62  unit_support_points.push_back(arma::vec::fixed<1>("0"));
63  unit_support_points.push_back(arma::vec::fixed<1>("1"));
64  unit_support_points.push_back({1./3.});
65  unit_support_points.push_back({2./3.});
66 }
67 
68 
69 /*** 2D finite elements ***/
70 
71 // P0 constant element
72 template<>
74 {
75  number_of_dofs = 1;
76 
77  number_of_single_dofs[2] = 1;
78 
79  unit_support_points.push_back(arma::vec2("0 0"));
80 }
81 
82 
83 // P1 linear element
84 template<>
86 {
87  number_of_dofs = 3;
88 
89  number_of_single_dofs[0] = 3;
90 
91  unit_support_points.push_back(arma::vec2("0 0"));
92  unit_support_points.push_back(arma::vec2("1 0"));
93  unit_support_points.push_back(arma::vec2("0 1"));
94 }
95 
96 // P2 quadratic element
97 template<>
99 {
100  number_of_dofs = 6;
101 
102  number_of_single_dofs[0] = 3;
103  number_of_single_dofs[1] = 3;
104 
105  unit_support_points.push_back(arma::vec2("0 0"));
106  unit_support_points.push_back(arma::vec2("1 0"));
107  unit_support_points.push_back(arma::vec2("0 1"));
108  unit_support_points.push_back(arma::vec2("0.5 0"));
109  unit_support_points.push_back(arma::vec2("0 0.5"));
110  unit_support_points.push_back(arma::vec2("0.5 0.5"));
111 }
112 
113 // P3 cubic element
114 template<>
116 {
117  number_of_dofs = 10;
118 
119  number_of_single_dofs[0] = 3;
120  number_of_pairs[1] = 3;
121  number_of_single_dofs[2] = 1;
122 
123  unit_support_points.push_back(arma::vec2("0 0"));
124  unit_support_points.push_back(arma::vec2("1 0"));
125  unit_support_points.push_back(arma::vec2("0 1"));
126  unit_support_points.push_back({1./3., 0});
127  unit_support_points.push_back({2./3., 0});
128  unit_support_points.push_back({0, 1./3.});
129  unit_support_points.push_back({0, 2./3.});
130  unit_support_points.push_back({2./3., 1./3.});
131  unit_support_points.push_back({1./3., 2./3.});
132  unit_support_points.push_back({1./3., 1./3.});
133 }
134 
135 
136 
137 /*** 3D finite elements ***/
138 
139 // P0 constant element
140 template<>
142 {
143  number_of_dofs = 1;
144 
145  number_of_single_dofs[3] = 1;
146 
147  unit_support_points.push_back(arma::vec3("0 0 0"));
148 }
149 
150 
151 // P1 linear element
152 template<>
154 {
155  number_of_dofs = 4;
156 
157  number_of_single_dofs[0] = 4;
158 
159  unit_support_points.push_back(arma::vec3("0 0 0"));
160  unit_support_points.push_back(arma::vec3("1 0 0"));
161  unit_support_points.push_back(arma::vec3("0 1 0"));
162  unit_support_points.push_back(arma::vec3("0 0 1"));
163 }
164 
165 // P2 quadratic element
166 template<>
168 {
169  number_of_dofs = 10;
170 
171  number_of_single_dofs[0] = 4;
172  number_of_single_dofs[1] = 6;
173 
174  unit_support_points.push_back(arma::vec3("0 0 0"));
175  unit_support_points.push_back(arma::vec3("1 0 0"));
176  unit_support_points.push_back(arma::vec3("0 1 0"));
177  unit_support_points.push_back(arma::vec3("0 0 1"));
178  unit_support_points.push_back(arma::vec3("0.5 0 0"));
179  unit_support_points.push_back(arma::vec3("0 0.5 0"));
180  unit_support_points.push_back(arma::vec3("0 0 0.5"));
181  unit_support_points.push_back(arma::vec3("0.5 0.5 0"));
182  unit_support_points.push_back(arma::vec3("0.5 0 0.5"));
183  unit_support_points.push_back(arma::vec3("0 0.5 0.5"));
184 }
185 
186 // P3 cubic element
187 template<>
189 {
190  number_of_dofs = 20;
191 
192  number_of_single_dofs[0] = 4;
193  number_of_pairs[1] = 6;
194  number_of_single_dofs[2] = 4;
195 
196  unit_support_points.push_back(arma::vec3("0 0 0"));
197  unit_support_points.push_back(arma::vec3("1 0 0"));
198  unit_support_points.push_back(arma::vec3("0 1 0"));
199  unit_support_points.push_back(arma::vec3("0 0 1"));
200  unit_support_points.push_back({1./3., 0, 0});
201  unit_support_points.push_back({2./3., 0, 0});
202  unit_support_points.push_back({0, 1./3., 0});
203  unit_support_points.push_back({0, 2./3., 0});
204  unit_support_points.push_back({0, 0, 1./3.});
205  unit_support_points.push_back({0, 0, 2./3.});
206  unit_support_points.push_back({1./3., 2./3., 0});
207  unit_support_points.push_back({2./3., 1./3., 0});
208  unit_support_points.push_back({1./3., 0, 2./3.});
209  unit_support_points.push_back({2./3., 0, 1./3.});
210  unit_support_points.push_back({0, 1./3., 2./3.});
211  unit_support_points.push_back({0, 2./3., 1./3.});
212  unit_support_points.push_back({1./3., 1./3., 0});
213  unit_support_points.push_back({1./3., 0, 1./3.});
214  unit_support_points.push_back({0, 1./3., 1./3.});
215  unit_support_points.push_back({1./3., 1./3., 1./3.});
216 }
217 
218 
219 
Definitions of basic Lagrangean finite elements with polynomial shape functions.
DofDistribution()
Constructor.