LifeV
DOFLocalPattern.hpp
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 This file contains the definition of the DOFLocalPattern class.
30 
31  @contributor Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32  @mantainer Samuel Quinodoz <samuel.quinodoz@epfl.ch>
33  */
34 
35 #ifndef _LOCAL_DOF_PATTERN_HH
36 #define _LOCAL_DOF_PATTERN_HH
37 
38 #include <lifev/core/LifeV.hpp>
39 
40 #include <utility>
41 
42 namespace LifeV
43 {
44 
45 //! Local pattern type
46 /*!
47  This enum allows to distinguish the normal standard local pattern, which is a full pattern involving all
48  degrees of freedom to special patterns. It is stored in DOFLocalPattern for later use by Dof
49 */
50 
54  };
55 
56 //! DOFLocalPattern - A class to store the "couplings" between the basis functions
57 /*!
58  The aim of this class is to store the way the basis functions couple one with each other. This might seem useless,
59  however, some "advanced" finite elements require this structure.
60 
61  For example, consider the P1-iso-P2 element in 2D. This finite element is composed of 6 basis functions, based on the
62  nodes with the same numbering as the P2 element. The reference triangle is split into 4 subtriangles using the
63  nodes on the faces. Each basis function is build such that it is 1 on its node, 0 on all the other nodes and such that
64  it is linear in each subtriangle.
65 
66  @see in "Numerical Approximation of Partial Differential Equations" by A. Quarteroni and A. Valli, p.311, for an
67  illustration and further informations.
68 
69  With this definition of the P1-iso-P2 finite element, we see that the basis functions 1 and 2 have no common support.
70  So, they are not directly coupled.
71 
72  In order to represent the couplings between the basis functions, we can use a matrix \f$ C \f$ such that
73  \f$ C_{ij} = 1 \f$ if the basis functions \f$ i \f$ and \f$ j \f$ have a common support, otherwise it is \f$ 0 \f$.
74  This matrix is symmetric.
75 
76  For the P1-iso-P2 element, this matrix would be:
77  \f[
78  \begin{array}{|c||cccccc|}
79  \hline
80  & 1 & 2 & 3 & 4 & 5 & 6 \\
81  \hline
82  \hline
83  1 & 1 & 0 & 0 & 1 & 0 & 1 \\
84  2 & 0 & 1 & 0 & 1 & 1 & 0 \\
85  3 & 0 & 0 & 1 & 0 & 1 & 1 \\
86  4 & 1 & 1 & 0 & 1 & 1 & 1 \\
87  5 & 0 & 1 & 1 & 1 & 1 & 1 \\
88  6 & 1 & 0 & 1 & 1 & 1 & 1 \\
89  \hline
90  \end{array}
91  \f]
92 
93  When references to diagonal or upper part are made, it is with respect to this matrix. For most of the finite
94  elements, this matrix is full (lagrangian FE, lagrangian FE with bubbles,...).
95 
96  Instead of this representation with a matrix, we usually prefer to get the DoFs that are coupled in a list. This
97  is the implemented in this class and the list of pairs (patternFirst(i),patternSecond(i)) represents all the DoFs
98  that are coupled.
99 
100 
101  Note: The documentation of this class (and some improvements) has been done by Samuel Quinodoz (15.01.2010),
102  but its original implementation was prior the documentation and no name of author or date was available.
103  */
104 
105 
107 {
108 
109 public:
110 
111  //! @name Constructor & Destructor
112  //@{
113 
114  //! Full constructor
115  DOFLocalPattern ( const UInt& nbLocalDof, const UInt& nbDofPerVertex, const UInt& nbDofPerEdge,
116  const UInt& nbDofPerFace, const UInt& nbDofPerVolume, const DofPatternType& patternType, UInt nbLocalCoor );
117 
118  //! Simple copy constructor
119  DOFLocalPattern ( const DOFLocalPattern& localDofPattern);
120 
121  //! Empty destructor
122  virtual ~DOFLocalPattern()
123  {};
124 
125  //@}
126 
127 
128  //! @name Methods
129  //@{
130 
131  //! patternFirst(i): row index in the element matrix of the i-th term of the pattern (the index starts from 0, not from 1 !).
132  const UInt& patternFirst (const UInt& i ) const
133  {
134  ASSERT_BD ( i < M_nbPattern );
135  return M_pattern[i].first;
136  }
137 
138  //! patternSecond(i): column index in the element matrix of the i-th term of the pattern (the index starts from 0, not from 1 !).
139  const UInt& patternSecond (const UInt& i ) const
140  {
141  ASSERT_BD ( i < M_nbPattern );
142  return M_pattern[i].second;
143  }
144 
145  //! The showMe method for the pattern
146  void showMe ( std::ostream& output = std::cout ) const;
147 
148  //@}
149 
150 
151  //! @name Get Methods
152  //@{
153 
154  //! Number of non-zero terms in the element matrix
155  const UInt& nbPattern() const
156  {
157  return M_nbPattern;
158  }
159 
160  //! Number of diagonal terms in the element matrix
161  const UInt& nbDiag() const
162  {
163  return M_nbDiag;
164  }
165 
166  //! Number of upper terms in the element matrix
167  const UInt& nbUpper() const
168  {
169  return M_nbUpper;
170  }
171 
172  //! Return the number of local degrees of freedom
173  const UInt& nbLocalDof() const
174  {
175  return M_nbLocalDof;
176  };
177 
178  //! Return the number of degrees of freedom located on the vertices (0D structures)
179  const UInt& nbDofPerVertex() const
180  {
181  return M_nbDofPerDimEntity[0];
182  };
183 
184  //! Return the number of degrees of freedom located on the edges (1D structures)
185  const UInt& nbDofPerEdge() const
186  {
187  return M_nbDofPerDimEntity[1];
188  };
189 
190  //! Return the number of degrees of freedom located on the peak (vertex in 3D).
192  {
193  return (M_dim >= 3) ? M_nbDofPerDimEntity[M_dim - 3] : 0;
194  };
195 
196  //! Return the number of degrees of freedom located on the ridge. (edge in 3D)
198  {
199  return (M_dim >= 2) ? M_nbDofPerDimEntity[M_dim - 2] : 0;
200  };
201 
202  //! Return the number of degrees of freedom located on the facet. (face in 3D)
204  {
205  return (M_dim >= 1) ? M_nbDofPerDimEntity[M_dim - 1] : 0;
206  };
207 
208  //! Return the number of degrees of freedom located on the element. (volume in 3D)
209  const UInt& nbDofPerElement() const
210  {
211  return M_nbDofPerDimEntity[M_dim];
212  };
213 
214  //! Return the number of degrees of freedom located on the faces (2D structures).
215  /*!Beware that in the 2D case, the face of a triangle is the triangle itself
216  (use edges or vertices if you want to access substructures).
217  */
218  const UInt& nbDofPerFace() const
219  {
220  return M_nbDofPerDimEntity[2];
221  };
222 
223  //! Return the number of degrees of freedom located in the volume (3D structures).
224  const UInt& nbDofPerVolume() const
225  {
226  return M_nbDofPerDimEntity[3];
227  };
228 
229  //! Return the number of degrees of freedom located per structDim object.
230  /*! For example, if we want to access the vertices, structDim should be 0,
231  if we want the edges, then it should be 1,...
232  */
233  const UInt& nbDofPerDimStrut (const UInt& structDim) const
234  {
235  ASSERT (structDim <= M_dim, "No structure with this dimension");
236  return M_nbDofPerDimEntity[structDim];
237  };
238 
239  //! Return the number of degrees of freedom located per structCodim object.
240  /*! The codimension of a structure is the full dimension of the element
241  minus the dimension of the structure. For example, in 3D, faces have codimension
242  1, edges 2 and vertices 3. This method could be useful to code "dimension-free" code.
243  (for example, IP is built on edges in 2D, faces in 3D, so on objects with codimension 1).
244  */
245  const UInt& nbDofPerCodimStrut (const UInt& structCodim) const
246  {
247  ASSERT (structCodim <= M_dim, "No structure with this codimension");
248  return M_nbDofPerDimEntity[M_dim - structCodim];
249  };
250 
251 
252  //@}
253 
254 
255 private:
256 
257  //! @name Private Methods
258  //@{
259 
260  //! Default constructor disabled (because there is no setup/set method)
261  DOFLocalPattern();
262 
263  //! Method to setup the standard pattern, i.e. with all degrees of freedom coupled.
264  void setupStandardPattern();
265 
266  //! Method for the P1isoP2 pattern for the segments (1D)
267  void setupP1isoP2SegPattern();
268 
269  //! Method for the P1isoP2 pattern for the triangles (2D)
271 
272  //@}
273 
274 
275  //! dimension of the element (3 for a tetrahedra for example).
277 
278  //! Total number of degrees of freedom (equal to refEle::nbDof)
280 
281  //! Number of degrees of freedom per geometric entity
282  /*! In this vector, we store all the number of degrees of freedom
283  sorted by the dimension of the object where they lie.
284  For example, the number of DoF per vertex (dimension 0)
285  is stored as the 0th element. Then, for edges (dimension 1), it is
286  stored in the 1st element of the vector,...
287  This enables a n-dimensional implementation (not only 3D)
288  */
290 
291 
292  //! Type of the pattern stored
294 
295  //! Pairs of couplings to appear in the pattern
297 
298  //! Number of non-zero terms in the element matrix
300 
301  //! Number of diagonal terms in the element matrix
303 
304  //! Number of upper terms in the element matrix
306 
307 };
308 
309 
310 }
311 #endif
std::vector< UInt > M_nbDofPerDimEntity
Number of degrees of freedom per geometric entity.
const UInt & patternFirst(const UInt &i) const
patternFirst(i): row index in the element matrix of the i-th term of the pattern (the index starts fr...
UInt nbDofPerFacet() const
Return the number of degrees of freedom located on the facet. (face in 3D)
#define ASSERT_BD(X)
Definition: LifeAssert.hpp:114
UInt M_nbDiag
Number of diagonal terms in the element matrix.
DofPatternType M_patternType
Type of the pattern stored.
UInt M_dim
dimension of the element (3 for a tetrahedra for example).
const UInt & nbDofPerCodimStrut(const UInt &structCodim) const
Return the number of degrees of freedom located per structCodim object.
DofPatternType
Local pattern type.
DOFLocalPattern(const UInt &nbLocalDof, const UInt &nbDofPerVertex, const UInt &nbDofPerEdge, const UInt &nbDofPerFace, const UInt &nbDofPerVolume, const DofPatternType &patternType, UInt nbLocalCoor)
Full constructor.
void showMe(std::ostream &output=std::cout) const
The showMe method for the pattern.
const UInt & nbDofPerVertex() const
Return the number of degrees of freedom located on the vertices (0D structures)
virtual ~DOFLocalPattern()
Empty destructor.
const UInt & nbDofPerElement() const
Return the number of degrees of freedom located on the element. (volume in 3D)
void updateInverseJacobian(const UInt &iQuadPt)
void setupP1isoP2SegPattern()
Method for the P1isoP2 pattern for the segments (1D)
const UInt & nbDofPerDimStrut(const UInt &structDim) const
Return the number of degrees of freedom located per structDim object.
std::vector< std::pair< UInt, UInt > > M_pattern
Pairs of couplings to appear in the pattern.
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
const UInt & nbDiag() const
Number of diagonal terms in the element matrix.
void setupStandardPattern()
Method to setup the standard pattern, i.e. with all degrees of freedom coupled.
DOFLocalPattern - A class to store the "couplings" between the basis functions.
const UInt & nbUpper() const
Number of upper terms in the element matrix.
UInt nbDofPerPeak() const
Return the number of degrees of freedom located on the peak (vertex in 3D).
void setupP1isoP2TriaPattern()
Method for the P1isoP2 pattern for the triangles (2D)
UInt M_nbLocalDof
Total number of degrees of freedom (equal to refEle::nbDof)
UInt M_nbUpper
Number of upper terms in the element matrix.
const UInt & nbPattern() const
Number of non-zero terms in the element matrix.
const UInt & nbDofPerVolume() const
Return the number of degrees of freedom located in the volume (3D structures).
const UInt & nbDofPerEdge() const
Return the number of degrees of freedom located on the edges (1D structures)
DOFLocalPattern(const DOFLocalPattern &localDofPattern)
Simple copy constructor.
const UInt & nbLocalDof() const
Return the number of local degrees of freedom.
const UInt & patternSecond(const UInt &i) const
patternSecond(i): column index in the element matrix of the i-th term of the pattern (the index start...
DOFLocalPattern()
Default constructor disabled (because there is no setup/set method)
UInt M_nbPattern
Number of non-zero terms in the element matrix.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
UInt nbDofPerRidge() const
Return the number of degrees of freedom located on the ridge. (edge in 3D)
const UInt & nbDofPerFace() const
Return the number of degrees of freedom located on the faces (2D structures).