LifeV
DOFLocalPattern.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 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 #include <lifev/core/fem/DOFLocalPattern.hpp>
36 
37 namespace LifeV
38 {
39 
40 // ===================================================
41 // Constructors & Destructor
42 // ===================================================
43 
44 // constructor
45 DOFLocalPattern::DOFLocalPattern ( const UInt& nbLocalDof, const UInt& nbDofPerVertex,
46  const UInt& nbDofPerEdge, const UInt& nbDofPerFace,
47  const UInt& nbDofPerVolume, const DofPatternType& patternType, UInt nbLocalCoor ) :
48  M_dim (nbLocalCoor), M_nbLocalDof ( nbLocalDof ), M_nbDofPerDimEntity (std::vector< UInt> (4) ),
49  M_patternType ( patternType )
50 {
51  // Store the location of the dofs
52  M_nbDofPerDimEntity[0] = nbDofPerVertex;
53  M_nbDofPerDimEntity[1] = nbDofPerEdge;
54  M_nbDofPerDimEntity[2] = nbDofPerFace;
55  M_nbDofPerDimEntity[3] = nbDofPerVolume;
56 
57  // Decide the pattern depending on the type
58  switch ( M_patternType )
59  {
60  case STANDARD_PATTERN:
61  {
63  break;
64  }
65  default:
66  {
67  std::ostringstream errorMessage;
68  errorMessage << "Pattern " << M_patternType << " not available for " << M_dim << "D. ";
69  ERROR_MSG ( errorMessage.str().c_str() );
70  }
71  }
72 }
73 
74 
75 
76 // The copy constructor
77 
78 DOFLocalPattern::DOFLocalPattern ( const DOFLocalPattern& localDofPattern) :
79  M_dim (localDofPattern.M_dim),
80  M_nbLocalDof (localDofPattern.M_nbLocalDof ),
82  M_patternType (localDofPattern.M_patternType ),
84  M_nbPattern (localDofPattern.M_nbPattern),
85  M_nbDiag (localDofPattern.M_nbDiag ),
86  M_nbUpper (localDofPattern.M_nbUpper )
87 {}
88 
89 // ===================================================
90 // Methods
91 // ===================================================
92 
93 void DOFLocalPattern::showMe ( std::ostream& output) const
94 {
95  output << " Size of the pattern : " << M_nbPattern << std::endl;
96  output << " Diag: " << M_nbDiag << " Upper: " << M_nbUpper << std::endl;
97  output << " Pattern type: " << M_patternType << std::endl;
98 
99  for (UInt iter (0); iter < M_nbPattern; ++iter)
100  {
101  output << iter << " : " << M_pattern[iter].first << " - " << M_pattern[iter].second << std::endl;
102  }
103 }
104 
105 // ===================================================
106 // Private Methods
107 // ===================================================
108 
110 {
111 
112  // This is the standard pattern with all the
113  // degrees of freedom coupled together.
114 
115  // Number of couplings
118  M_nbUpper = M_nbLocalDof * ( M_nbLocalDof - 1 ) / 2;
119 
120  // initialization of the pattern
121  M_pattern = std::vector< std::pair< UInt, UInt > > (M_nbPattern);
122 
123  // First, put the diagonal entries
124  for ( UInt i = 0; i < M_nbLocalDof; i++ )
125  {
126  M_pattern[i] = std::pair<UInt, UInt> (i, i);
127  }
128 
129  // Upper diagonal entries
130  int ip ( M_nbLocalDof );
131  for ( UInt i = 0; i < M_nbLocalDof - 1; i++ )
132  {
133  for ( UInt j = i + 1; j < M_nbLocalDof; j++ )
134  {
135  M_pattern[ip] = std::pair<UInt, UInt> (i, j);
136  ip++;
137  }
138  }
139 
140  // Lower diagonal entries
141  for ( UInt i = 1; i < M_nbLocalDof; i++ )
142  {
143  for ( UInt j = 0; j < i; j++ )
144  {
145  M_pattern[ip] = std::pair<UInt, UInt> (i, j);
146  ip++;
147  }
148  }
149 }
150 
151 
153 {
154  // Some check to ensure consistency
155  ASSERT (M_nbDofPerDimEntity[0] == 1, " Inconsistent P1 iso P2 (Vertices)");
156  ASSERT (M_nbDofPerDimEntity[1] == 1, " Inconsistent P1 iso P2 (Edges)");
157  ASSERT (M_nbDofPerDimEntity[2] == 0, " Inconsistent P1 iso P2 (Faces)");
158 
159  M_nbPattern = 7;
160  M_nbDiag = 3;
161  M_nbUpper = 2;
162  M_pattern = std::vector< std::pair < UInt, UInt > > (M_nbPattern);
163 
164  // Diagonal entries
165  for (UInt diag (0); diag < 3; ++diag)
166  {
167  M_pattern[diag] = std::pair<UInt, UInt> (diag, diag);
168  }
169 
170  // Upper diagonal entries
171  M_pattern[3] = std::pair<UInt, UInt> (0, 2);
172  M_pattern[4] = std::pair<UInt, UInt> (1, 2);
173 
174  // Lower diagonal entries
175  M_pattern[5] = std::pair<UInt, UInt> (2, 0);
176  M_pattern[6] = std::pair<UInt, UInt> (2, 1);
177 }
178 
179 
181 {
182  // Some check to ensure consistency
183  ASSERT (M_nbDofPerDimEntity[0] == 1, " Inconsistent P1 iso P2 (Vertices)");
184  ASSERT (M_nbDofPerDimEntity[1] == 1, " Inconsistent P1 iso P2 (Edges)");
185  ASSERT (M_nbDofPerDimEntity[2] == 0, " Inconsistent P1 iso P2 (Faces)");
186 
187  M_nbPattern = 24;
188  M_nbDiag = 6;
189  M_nbUpper = 9;
190  M_pattern = std::vector< std::pair < UInt, UInt > > (M_nbPattern);
191 
192  // Diagonal entries
193  for (UInt diag (0); diag < 6; ++diag)
194  {
195  M_pattern[diag] = std::pair<UInt, UInt> (diag, diag);
196  };
197 
198  // Upper diagonal entries
199  M_pattern[6] = std::pair<UInt, UInt> (0, 3);
200  M_pattern[7] = std::pair<UInt, UInt> (0, 5);
201  M_pattern[8] = std::pair<UInt, UInt> (1, 3);
202  M_pattern[9] = std::pair<UInt, UInt> (1, 4);
203  M_pattern[10] = std::pair<UInt, UInt> (2, 4);
204  M_pattern[11] = std::pair<UInt, UInt> (2, 5);
205  M_pattern[12] = std::pair<UInt, UInt> (3, 4);
206  M_pattern[13] = std::pair<UInt, UInt> (3, 5);
207  M_pattern[14] = std::pair<UInt, UInt> (4, 5);
208 
209  // Lower diagonal entries
210  M_pattern[15] = std::pair<UInt, UInt> (3, 0);
211  M_pattern[16] = std::pair<UInt, UInt> (3, 1);
212  M_pattern[17] = std::pair<UInt, UInt> (4, 1);
213  M_pattern[18] = std::pair<UInt, UInt> (4, 2);
214  M_pattern[19] = std::pair<UInt, UInt> (4, 3);
215  M_pattern[20] = std::pair<UInt, UInt> (5, 0);
216  M_pattern[21] = std::pair<UInt, UInt> (5, 2);
217  M_pattern[22] = std::pair<UInt, UInt> (5, 3);
218  M_pattern[23] = std::pair<UInt, UInt> (5, 4);
219 }
220 
221 } // end of the namespace LifeV
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).
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.
void updateInverseJacobian(const UInt &iQuadPt)
void setupP1isoP2SegPattern()
Method for the P1isoP2 pattern for the segments (1D)
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
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.
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.
DOFLocalPattern(const DOFLocalPattern &localDofPattern)
Simple copy constructor.
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