LifeV
ElementShapes.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief Contains the basic element shapes, to be used by Geometric
30  and Finite Elements
31 
32  @author Luca Formaggia
33  @contributor Zhen Wang <zwang26@emory.edu>
34  @contributor Tiziano Passerini <tiziano@mathcs.emory.edu>
35 */
36 
37 #include <lifev/core/mesh/ElementShapes.hpp>
38 
39 namespace LifeV
40 {
41 
43 {
44  switch (shape)
45  {
46  case NONE:
47  case POINT:
48  return 0;
49  case LINE:
50  return 1;
51  case TRIANGLE:
52  case QUAD:
53  return 2;
54  case HEXA:
55  case PRISM:
56  case TETRA:
57  return 3;
58  default:
59  ERROR_MSG (" Unknown shape " );
60  }
61  // Avoid warning
62  return 0;
63 }
64 
65 
66 
67 /*******************************************************************
68  IMPLEMENTATION
69 *******************************************************************/
70 
71 /*
72  Tetra
73  */
74 
75 std::pair<ID, bool>
76 Tetra::faceToEdge ( ID const& iFace, ID const& jEdge )
77 // faceToEdge(i,j) = localId of jth edge on ith local face
78 {
79  static const ID _faceToEdge[ 3 * S_numFaces ] =
80  {
81  2, 1, 0,
82  0, 4, 3,
83  1, 5, 4,
84  3, 5, 2
85  };
86 
87  static const bool _orient[ 3 * S_numFaces ] =
88  {
89  0, 0, 0,
90  1, 1, 0,
91  1, 1, 0,
92  1, 0, 1
93  };
94 
95 
96  ASSERT_BD ( jEdge < 3 ) ;
97  ASSERT_BD ( iFace < S_numFaces ) ;
98 
99  return std::make_pair ( _faceToEdge[ 3 * iFace + jEdge ], _orient[ 3 * iFace + jEdge ] );
100 }
101 
102 /*
103  Hexa
104  */
105 
106 std::pair<ID, bool>
107 Hexa::faceToEdge ( ID const& iFace, ID const& jEdge )
108 // faceToEdge(i,j) = localId of jth edge on ith local face
109 {
110  static const ID _faceToEdge[ 4 * S_numFaces ] =
111  {
112  3, 2, 1, 0,
113  4, 11, 7, 3,
114  0, 5, 8, 4,
115  1, 6, 9, 5,
116  2, 7, 10, 6,
117  8, 9, 10, 11
118  };
119 
120  static const bool _orient[ 4 * S_numFaces ] =
121  {
122  0, 0, 0, 0,
123  1, 0, 0, 1,
124  1, 1, 0, 0,
125  1, 1, 0, 0,
126  1, 1, 0, 0,
127  1, 1, 1, 1
128  };
129 
130  ASSERT_BD ( jEdge < 4 ) ;
131  ASSERT_BD ( iFace < S_numFaces ) ;
132 
133  return
134  std::make_pair ( _faceToEdge[ 4 * iFace + jEdge ] , _orient[ 4 * iFace + jEdge ] );
135 }
136 
137 
138 
139 /*
140  -- LinearTriangle
141  2
142  /
143  / \
144  / \
145  / \
146  / \
147  0 ----------1
148 
149 */
150 ID
151 LinearTriangle::edgeToPoint ( ID const& iEdge, ID const& jPoint )
152 // ID edgeToPoint(i,j) = localId of jth point on ith local edge
153 {
154  static const ID _edgeToPoint[ 2 * S_numEdges ] =
155  {
156  1, 2,
157  2, 3,
158  3, 1
159  };
160  ASSERT_BD ( jPoint < 2 ) ;
161  ASSERT_BD ( iEdge < S_numEdges ) ;
162  return _edgeToPoint[ 2 * iEdge + jPoint ] - 1;
163 }
164 
165 
166 /*
167  -- QuadraticTriangle
168  2
169  /
170  / \
171  5 \
172  / 4
173  / \
174  0 -----3----1
175 */
176 ID
177 QuadraticTriangle::edgeToPoint ( ID const& iEdge, ID const& jPoint )
178 // edgeToPoint(i,j) = localId of jth point on ith local edge
179 {
180  static const ID _edgeToPoint[ 3 * S_numEdges ] =
181  {
182  0, 1, 3,
183  1, 2, 4,
184  2, 0, 5
185  };
186  ASSERT_BD ( jPoint < 3 ) ;
187  ASSERT_BD ( iEdge < S_numEdges ) ;
188  return _edgeToPoint[ 3 * iEdge + jPoint ];
189 }
190 
191 
192 /*
193  -- LinearQuad
194 
195  3-------2
196  ! !
197  ! !
198  0-------1
199 
200 
201 */
202 ID
203 LinearQuad::edgeToPoint ( ID const& iEdge, ID const& jPoint )
204 // edgeToPoint(i,j) = localId of jth point on ith local edge
205 {
206  static const ID _edgeToPoint[ 2 * S_numEdges ] =
207  {
208  0, 1,
209  1, 2,
210  2, 3,
211  3, 0
212  };
213  ASSERT_BD ( jPoint < 2 ) ;
214  ASSERT_BD ( iEdge < S_numEdges ) ;
215  return _edgeToPoint[ 2 * iEdge + jPoint];
216 }
217 
218 /*
219  -- QuadraticQuad
220 
221  3---6---2
222  ! !
223  7 8 5
224  ! !
225  0---4---1
226 
227 */
228 ID
229 QuadraticQuad::edgeToPoint ( ID const& iEdge, ID const& jPoint )
230 // edgeToPoint(i,j) = localId of jth point on ith local edge
231 {
232  static const ID _edgeToPoint[ 3 * S_numEdges ] =
233  {
234  0, 1, 4,
235  1, 2, 5,
236  2, 3, 6,
237  3, 0, 7
238  };
239  ASSERT_BD ( jPoint < 3 ) ;
240  ASSERT_BD ( iEdge < S_numEdges ) ;
241  return _edgeToPoint[ 3 * iEdge + jPoint ];
242 }
243 
244 
245 /*
246  -- LinearTetra
247 
248  3
249  / .
250  / \.2
251  / . \\
252  / . \\
253  /. \!
254  0 ----------1
255 
256 
257 */
258 ID
259 LinearTetra::edgeToPoint ( ID const& iEdge, ID const& jPoint )
260 // edgeToPoint(i,j) = localId of jth point on ith local edge
261 {
262  static const ID _edgeToPoint[ 2 * S_numEdges ] =
263  {
264  0, 1,
265  1, 2,
266  2, 0,
267  0, 3,
268  1, 3,
269  2, 3
270  };
271  ASSERT_BD ( jPoint < 2 ) ;
272  ASSERT_BD ( iEdge < S_numEdges ) ;
273  return _edgeToPoint[ 2 * iEdge + jPoint ];
274 }
275 
276 ID
277 LinearTetra::faceToPoint ( ID const& iFace, ID const& jPoint )
278 // faceToPoint(i,j) = localId of jth point on ith local face
279 {
280  static const ID _faceToPoint[ 3 * S_numFaces ] =
281  {
282  0, 2, 1,
283  0, 1, 3,
284  1, 2, 3,
285  0, 3, 2
286  };
287  ASSERT_BD ( jPoint < 3 ) ;
288  ASSERT_BD ( iFace < S_numFaces ) ;
289  return _faceToPoint[ 3 * iFace + jPoint ];
290 }
291 
292 
293 
294 ///////////////////////
295 
296 /*
297  -- LinearTetraBubble
298 
299  3
300  / .
301  / \.2
302  / . \\
303  / . .4 \\
304  /. \!
305  0 ----------1
306 
307 
308 */
309 ID
310 LinearTetraBubble::edgeToPoint ( ID const& iEdge, ID const& jPoint )
311 // edgeToPoint(i,j) = localId of jth point on ith local edge
312 {
313  return LinearTetra::faceToPoint (iEdge, jPoint);
314 }
315 
316 
317 ///////////////////////
318 
319 /*
320  -- QuadraticTetra
321 
322 
323  3
324  / .9
325  / \.2
326  7 . 8\
327  / 6 \5
328  /. \!
329  0 -----4----1
330 */
331 ID
332 QuadraticTetra::edgeToPoint ( ID const& iEdge, ID const& jPoint )
333 // edgeToPoint(i,j) = localId of jth point on ith local edge
334 {
335  static const ID _edgeToPoint[ 3 * S_numEdges ] =
336  {
337  0, 1, 4,
338  1, 2, 5,
339  2, 0, 6,
340  0, 3, 7,
341  1, 3, 8,
342  2, 3, 9
343  };
344  ASSERT_BD ( jPoint < 3 ) ;
345  ASSERT_BD ( iEdge < S_numEdges ) ;
346  return _edgeToPoint[ 3 * iEdge + jPoint ];
347 }
348 
349 ID
350 QuadraticTetra::faceToPoint ( ID const& iFace, ID const& jPoint )
351 // faceToPoint(i,j) = localId of jth point on ith local face
352 {
353  static const ID _faceToPoint[ 6 * S_numFaces ] =
354  {
355  0, 2, 1, 6, 5, 4,
356  0, 1, 3, 4, 8, 7,
357  1, 2, 3, 5, 9, 8,
358  0, 3, 2, 7, 9, 6
359  };
360  ASSERT_BD ( jPoint < 6 ) ;
361  ASSERT_BD ( iFace < S_numFaces ) ;
362  return _faceToPoint[ 6 * iFace + jPoint ];
363 }
364 
365 
366 /*
367  -- LinearHexa
368 
369 
370  7-------6
371  /. /|
372  / . / |
373  4_______5 |
374  | . | |
375  | 3....|..2
376  | . | /
377  |. |/
378  0_______1
379 */
380 ID
381 LinearHexa::edgeToPoint ( ID const& iEdge, ID const& jPoint )
382 // edgeToPoint(i,j) = localId of jth point on ith local edge
383 {
384  static const ID _edgeToPoint[ 2 * S_numEdges ] =
385  {
386  0, 1,
387  1, 2,
388  2, 3,
389  3, 0,
390  0, 4,
391  1, 5,
392  2, 6,
393  3, 7,
394  4, 5,
395  5, 6,
396  6, 7,
397  7, 4
398  };
399  ASSERT_BD ( jPoint < 2 ) ;
400  ASSERT_BD ( iEdge < S_numEdges ) ;
401  return _edgeToPoint[ 2 * iEdge + jPoint ];
402 }
403 
404 ID
405 LinearHexa::faceToPoint ( ID const& iFace, ID const& jPoint )
406 // faceToPoint(i,j) = localId of jth point on ith local face
407 {
408  static const ID _faceToPoint[ 4 * S_numFaces ] =
409  {
410  0, 3, 2, 1,
411  0, 4, 7, 3,
412  0, 1, 5, 4,
413  1, 2, 6, 5,
414  2, 3, 7, 6,
415  4, 5, 6, 7
416  };
417  ASSERT_BD ( jPoint < 4 ) ;
418  ASSERT_BD ( iFace < S_numFaces ) ;
419  return _faceToPoint[ 4 * iFace + jPoint ];
420 }
421 
422 
423 
424 
425 /*
426  -- QuadraticHexa
427 */
428 ID
429 QuadraticHexa::edgeToPoint ( ID const& iEdge, ID const& jPoint )
430 // edgeToPoint(i,j) = localId of jth point on ith local edge
431 {
432  static const ID _edgeToPoint[ 3 * S_numEdges ] =
433  {
434  0, 1, 8,
435  1, 2, 9,
436  2, 3, 10,
437  3, 0, 11,
438  0, 4, 12,
439  1, 5, 13,
440  2, 6, 14,
441  3, 7, 15,
442  4, 5, 16,
443  5, 6, 17,
444  6, 7, 18,
445  7, 4, 19
446  };
447  ASSERT_BD ( ( jPoint < 3 ) ) ;
448  ASSERT_BD ( iEdge < S_numEdges ) ;
449  return _edgeToPoint[ 3 * iEdge + jPoint ];
450 }
451 
452 ID
453 QuadraticHexa::faceToPoint ( ID const& iFace, ID const& jPoint )
454 // faceToPoint(i,j) = localId of jth point on ith local face
455 {
456  static const ID _faceToPoint[ 9 * S_numFaces ] =
457  {
458  0, 3, 2, 1, 11, 10, 9, 8, 20,
459  0, 4, 7, 3, 12, 19, 15, 11, 21,
460  0, 1, 5, 4, 8, 13, 16, 12, 22,
461  1, 2, 6, 5, 9, 14, 17, 13, 23,
462  2, 3, 7, 6, 10, 15, 18, 14, 24,
463  4, 5, 6, 7, 16, 17, 18, 19, 25
464  };
465  ASSERT_BD ( jPoint < 9 ) ;
466  ASSERT_BD ( iFace < S_numFaces ) ;
467  return _faceToPoint[ 9 * iFace + jPoint ];
468 }
469 
470 }
static ID faceToPoint(ID const &iFace, ID const &jPoint)
#define ASSERT_BD(X)
Definition: LifeAssert.hpp:114
A Geometric Shape.
A Geometric Shape.
static ID edgeToPoint(ID const &iEdge, ID const &jPoint)
A Geometric Shape.
static const UInt S_numEdges
Number of edges.
static ID edgeToPoint(ID const &iEdge, ID const &jPoint)
static ID edgeToPoint(ID const &iEdge, ID const &jPoint)
static ID edgeToPoint(ID const &iEdge, ID const &jPoint)
static const UInt S_numFaces
Number of faces.
static ID faceToPoint(ID const &iFace, ID const &jPoint)
static ID edgeToPoint(ID const &iEdge, ID const &jPoint)
void updateInverseJacobian(const UInt &iQuadPt)
static const UInt S_numEdges
Number of edges.
static ID edgeToPoint(ID const &iEdge, ID const &jPoint)
static ID edgeToPoint(ID const &iEdge, ID const &jPoint)
static const UInt S_numEdges
Number of edges.
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
A Geometric Shape.
uint32_type ID
IDs.
Definition: LifeV.hpp:194
static ID edgeToPoint(ID const &iEdge, ID const &jPoint)
A Geometric Shape.
static std::pair< ID, bool > faceToEdge(ID const &iFace, ID const &jEdge)
static const UInt S_numEdges
Number of edges.
A Geometric Shape.
static ID edgeToPoint(ID const &iEdge, ID const &jPoint)
A Geometric Shape.
static ID faceToPoint(ID const &iFace, ID const &jPoint)
A Geometric Shape.
static const UInt S_numFaces
Number of faces.
static std::pair< ID, bool > faceToEdge(ID const &iFace, ID const &jEdge)
static ID faceToPoint(ID const &iFace, ID const &jPoint)
A Geometric Shape.
UInt shapeDimension(const ReferenceShapes &shape)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191