Flow123d  release_2.2.1-10-gb9fad4d
fe_p.cc
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file fe_p.cc
15  * @brief
16  */
17 
18 // !! implementation of specializations has to be i *.cc file to avoid multiple definition error during linking
19 #include "fe_p.hh"
20 #include "mesh/ref_element.hh"
21 
22 /****** Template specializations ******/
23 
24 /*** 1D finite elements ***/
25 
26 // P0 constant element
27 template<>
29 {
30  number_of_dofs = 1;
31 
32  number_of_single_dofs[1] = 1;
33 
34  unit_support_points.push_back(arma::zeros<arma::vec>(1));
35 }
36 
37 // P1 linear element
38 template<>
40 {
41  number_of_dofs = 2;
42 
43  number_of_single_dofs[0] = 2;
44 
45  unit_support_points.push_back(RefElement<1>::node_coords(0));
46  unit_support_points.push_back(RefElement<1>::node_coords(1));
47 }
48 
49 // P2 quadratic element
50 template<>
52 {
53  number_of_dofs = 3;
54 
55  number_of_single_dofs[0] = 2;
56  number_of_single_dofs[1] = 1;
57 
58  unit_support_points.push_back(RefElement<1>::node_coords(0));
59  unit_support_points.push_back(RefElement<1>::node_coords(1));
60  unit_support_points.push_back(
62 }
63 
64 // P3 cubic element
65 template<>
67 {
68  number_of_dofs = 4;
69 
70  number_of_single_dofs[0] = 2;
71  number_of_pairs[1] = 1;
72 
73  unit_support_points.push_back(RefElement<1>::node_coords(0));
74  unit_support_points.push_back(RefElement<1>::node_coords(1));
75  unit_support_points.push_back(
77  unit_support_points.push_back(
79 }
80 
81 
82 /*** 2D finite elements ***/
83 
84 // P0 constant element
85 template<>
87 {
88  number_of_dofs = 1;
89 
90  number_of_single_dofs[2] = 1;
91 
92  unit_support_points.push_back(RefElement<2>::node_coords(0));
93 }
94 
95 
96 // P1 linear element
97 template<>
99 {
100  number_of_dofs = 3;
101 
102  number_of_single_dofs[0] = 3;
103 
104  unit_support_points.push_back(RefElement<2>::node_coords(0));
105  unit_support_points.push_back(RefElement<2>::node_coords(1));
106  unit_support_points.push_back(RefElement<2>::node_coords(2));
107 }
108 
109 // P2 quadratic element
110 template<>
112 {
113  number_of_dofs = 6;
114 
115  number_of_single_dofs[0] = 3;
116  number_of_single_dofs[1] = 3;
117 
118  unit_support_points.push_back(RefElement<2>::node_coords(0));
119  unit_support_points.push_back(RefElement<2>::node_coords(1));
120  unit_support_points.push_back(RefElement<2>::node_coords(2));
121  unit_support_points.push_back(
123  unit_support_points.push_back(
125  unit_support_points.push_back(
127 }
128 
129 // P3 cubic element
130 template<>
132 {
133  number_of_dofs = 10;
134 
135  number_of_single_dofs[0] = 3;
136  number_of_pairs[1] = 3;
137  number_of_single_dofs[2] = 1;
138 
139  unit_support_points.push_back(RefElement<2>::node_coords(0));
140  unit_support_points.push_back(RefElement<2>::node_coords(1));
141  unit_support_points.push_back(RefElement<2>::node_coords(2));
142  unit_support_points.push_back(
144  unit_support_points.push_back(
146  unit_support_points.push_back(
148  unit_support_points.push_back(
150  unit_support_points.push_back(
152  unit_support_points.push_back(
154  unit_support_points.push_back(
156 }
157 
158 
159 
160 /*** 3D finite elements ***/
161 
162 // P0 constant element
163 template<>
165 {
166  number_of_dofs = 1;
167 
168  number_of_single_dofs[3] = 1;
169 
170  unit_support_points.push_back(RefElement<3>::node_coords(0));
171 }
172 
173 
174 // P1 linear element
175 template<>
177 {
178  number_of_dofs = 4;
179 
180  number_of_single_dofs[0] = 4;
181 
182  unit_support_points.push_back(RefElement<3>::node_coords(0));
183  unit_support_points.push_back(RefElement<3>::node_coords(1));
184  unit_support_points.push_back(RefElement<3>::node_coords(2));
185  unit_support_points.push_back(RefElement<3>::node_coords(3));
186 }
187 
188 // P2 quadratic element
189 template<>
191 {
192  number_of_dofs = 10;
193 
194  number_of_single_dofs[0] = 4;
195  number_of_single_dofs[1] = 6;
196 
197  unit_support_points.push_back(RefElement<3>::node_coords(0));
198  unit_support_points.push_back(RefElement<3>::node_coords(1));
199  unit_support_points.push_back(RefElement<3>::node_coords(2));
200  unit_support_points.push_back(RefElement<3>::node_coords(3));
201  unit_support_points.push_back(
203  unit_support_points.push_back(
205  unit_support_points.push_back(
207  unit_support_points.push_back(
209  unit_support_points.push_back(
211  unit_support_points.push_back(
213 }
214 
215 // P3 cubic element
216 template<>
218 {
219  number_of_dofs = 20;
220 
221  number_of_single_dofs[0] = 4;
222  number_of_pairs[1] = 6;
223  number_of_single_dofs[2] = 4;
224 
225  unit_support_points.push_back(RefElement<3>::node_coords(0));
226  unit_support_points.push_back(RefElement<3>::node_coords(1));
227  unit_support_points.push_back(RefElement<3>::node_coords(2));
228  unit_support_points.push_back(RefElement<3>::node_coords(3));
229  unit_support_points.push_back(
231  unit_support_points.push_back(
233  unit_support_points.push_back(
235  unit_support_points.push_back(
237  unit_support_points.push_back(
239  unit_support_points.push_back(
241  unit_support_points.push_back(
243  unit_support_points.push_back(
245  unit_support_points.push_back(
247  unit_support_points.push_back(
249  unit_support_points.push_back(
251  unit_support_points.push_back(
253  unit_support_points.push_back(
255  unit_support_points.push_back(
257  unit_support_points.push_back(
259  unit_support_points.push_back(
261 }
262 
263 
264 
Definitions of basic Lagrangean finite elements with polynomial shape functions.
DofDistribution()
Constructor.
Class RefElement defines numbering of vertices, sides, calculation of normal vectors etc...