LifeV
MeshElementBare.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 Special routines to read meshes and special structures for
30  sides and faces handling
31 
32  Classes BareFace and BareEdge have been created to give an UNIQUE
33  Representation for mesh faces and edges and thus allow the construction
34  of global tables or fields.
35 
36  @author Luca Formaggia <luca.formaggia@polimi.it>
37  @contributor Luca Bertagna <lbertag@emory.edu>
38  @contributor Lucia Mirabella <lucia.mirabell@gmail.com>
39  @maintainer Lucia Mirabella <lucia.mirabell@gmail.com>
40 
41  @date 19-08-1999
42 
43  Classes BareFace and BareEdge have been created to give an UNIQUE internal
44  representation for mesh faces and edges, allowing thus the construction of
45  DOF objects (which are naturally linked to mesh entities).
46 
47  \par Introduction
48 
49  One of the paradigms chosen for the development of this library is the fact
50  that degrees of freedom (DOF) are linked to geometrical entities. Now if
51  we have degrees of freedom associated, for instance, to an Edge (like in
52  a P2 Tetra) in order to build the global numbering of the DOF and the
53  association between local (element-wise) and global numbering, we need to
54  identify edges and give them a unique ID. Yet, we may not want to
55  build a full Edge (MeshElementMarked2D) object: we only need
56  the ID of the edge and a way of computing the ID's of the degrees of
57  freedom on the edge, all the remaining data of a full Edge object is not
58  necessarily needed.
59 
60  Another related problem is how to uniquely identify a face or an edge in the mesh.
61 
62  The dilemma has been resolved by creating the concept of a BareEdge and
63  BareFace (bare geometry items). A bare geometry item is formed by the
64  minimal information required to uniquely identify it, namely 2
65  <tt>Point</tt>'s ID 's for an edge and 3 <tt>Point</tt>'s ID 's for the
66  Faces (it is enough also for Quad faces!). We build the bare items by
67  looping through the elements and obviously we make sure that the BareItem
68  ID is consistent with that of the corresponding ``full item'' if the latter
69  has been instantiated.
70 
71  Another <em>very important</em> issue is that of orientation. There are
72  different ways of considering orientation of a Face or an Edge. The first is
73  the <em>local</em> orientation of a Face or Edge of the reference finite
74  element. This is conventionally chosen when designing the finite
75  elements. For the faces, we have adopted the convention that the local
76  positive orientation is such that the face normal calculated with the right
77  hand rule is <em>outwardly</em> oriented. As for the edges, the local
78  orientation for a 3D element is more arbitrary.
79 
80  However, for a 2D element, the positive orientation of an Edge is the one
81  which is in accordance with the right hand rule applied to that element.
82 
83  When a Face or an edge is <em>active</em>, i.e. is effectively stored in
84  the mesh, then there is another obvious orientation, of global rather than
85  local nature: that induced by the way the edge or face is stored. For
86  boundary elements (faced in 3D or edges in 2D) it is compulsory that the
87  orientation of the stored item be consistent with the convention chosen for
88  the orientation of the domain boundary. More precisely, boundary elements
89  are stored so that the normal (always calculated following the right hand
90  rule) is outward with respect to the domain.
91 
92  However, there is the need of defining a <em>global</em> orientation also
93  for <em>non active</em> entities. This because we do not always store all
94  faces and all edges. We need then to choose a unique way to identify the
95  orientation of an Edge or of a Face <em>independently </em> from the fact
96  that they are active or not. We will call this orientation the <em>natural </em>
97  orientation. We have chosen the following convention for natural orientation
98  of faces and edges
99 
100  <ul>
101  <li>The positive natural orientation of an <em>Edge</em> is given by \f$V_{min} \rightarrow V_{max} \f$,
102  \f$V_{min}\f$ being the Edge Vertex with smallest ID</li>
103 
104  <li>The positive natural orientation of a <em>Face</em> is given by the cicle
105  \f$V_{min} \rightarrow V_2\rightarrow V_3 \f$,
106  \f$V_{min}\f$ being the Face Vertex with smallest ID, \f$V_2\f$ the second smallest
107  and \f$V_2\f$ the thirsd smallest.</li>
108  </ul>
109 
110  Note that the latter definition applies both to triangular and to quad faces.
111 
112  \warning If I want to associate boundary conditions I need the active
113  entity, since BareEdges do not store Marker data. (This is why the
114  RegionMesh classes treat boundary items in a rather special way).
115 
116 
117  */
118 
119 #include <lifev/core/LifeV.hpp>
120 #include <lifev/core/mesh/MeshElementBare.hpp>
121 
122 namespace LifeV
123 {
124 std::pair<BareFace, bool>
125 makeBareFace ( ID const i, ID const j, ID const k )
126 {
127  if ( i < j && i < k )
128  {
129  if ( j < k )
130  {
131  return std::make_pair ( BareFace ( i, j, k ), true );
132  }
133  else
134  {
135  return std::make_pair ( BareFace ( i, k, j ), false );
136  }
137  }
138  else if ( j < k && j < i )
139  {
140  if ( k < i )
141  {
142  return std::make_pair ( BareFace ( j, k, i ), true );
143  }
144  else
145  {
146  return std::make_pair ( BareFace ( j, i, k ), false );
147  }
148  }
149  else
150  {
151  if ( i < j )
152  {
153  return std::make_pair ( BareFace ( k, i, j ), true );
154  }
155  else
156  {
157  return std::make_pair ( BareFace ( k, j, i ), false );
158  }
159  }
160 }
161 
162 
163 std::pair<BareFace, bool>
164 makeBareFace ( ID const i, ID const j, ID const k, ID const l )
165 {
166  std::vector<ID> helper ( 4 );
167  helper[ 0 ] = i;
168  helper[ 1 ] = j;
169  helper[ 2 ] = k;
170  helper[ 3 ] = l;
171  std::vector<ID>::iterator vi = std::max_element ( helper.begin(), helper.end() );
172  std::rotate ( helper.begin(), vi, helper.end() );
173  return makeBareFace ( helper[ 1 ], helper[ 2 ], helper[ 3 ] );
174 }
175 }
The base Face class.
void updateInverseJacobian(const UInt &iQuadPt)
uint32_type ID
IDs.
Definition: LifeV.hpp:194
std::pair< BareFace, bool > makeBareFace(ID const i, ID const j, ID const k, ID const l)
It creates Bare Face objects from four Point ID&#39;s. To be used with Quad faces.
std::pair< BareFace, bool > makeBareFace(ID const i, ID const j, ID const k)
It creates Bare Face objects from three Point ID&#39;s.