LifeV
ETCurrentBDFE.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 A short description of the file content
30 
31  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32  @date 21 Feb 2012
33 
34  A more detailed description of the file (if necessary)
35  */
36 
37 #ifndef ETCURRENTBDFE_H
38 #define ETCURRENTBDFE_H 1
39 
40 #include <lifev/core/LifeV.hpp>
41 #include <lifev/eta/fem/ETCurrentFE.hpp>
42 #include <lifev/core/array/MatrixSmall.hpp>
43 #include <lifev/core/array/VectorSmall.hpp>
44 
45 namespace LifeV
46 {
47 
48 //! ETCurrentBDFE - Short description of the class
49 
50 template<UInt spaceDim>
52 {
53  //! @name Friends
54  //@{
55 
56  //!Friend to allow direct access to the raw data
57  template <UInt dim>
58  friend class ExpressionAssembly::EvaluationHK;
59 
60  //!Friend to allow direct access to the raw data
61  template <UInt dim>
62  friend class ExpressionAssembly::EvaluationPosition;
63 
64  //@}
65 
66 public:
67 
68  //! @name Constructors, destructor
69  //@{
70 
71  //! Full constructor
72  /*!
73  @param refFE The reference element for the FE
74  @param geoMap The geometric map from the reference element to the current element
75  @param qr The quadrature rule
76  */
77  ETCurrentBDFE (const GeometricMap& geoMap, const QuadratureRule& qr)
78  : M_geometricMap (&geoMap),
80  M_nbMapDof (geoMap.nbDof() ),
82  {
84  };
85 
86 
87  //! Constructor without quadrature rule
88  /*!
89  @param refFE The reference element for the FE
90  @param geoMap The geometric map from the reference element to the current element
91  */
92  ETCurrentBDFE (const GeometricMap& geoMap)
93  : M_geometricMap (&geoMap),
94  M_nbMapDof (geoMap.nbDof() )
95  {};
96 
97  //! Copy constructor
98  /*!
99  @param otherFE The currentFE to be copied
100  */
101  ETCurrentBDFE (const ETCurrentBDFE<spaceDim>& otherFE)
102  : M_geometricMap (otherFE.M_geometricMap),
103  M_quadrature ( new QuadratureRule (*otherFE.M_quadrature) ),
104 
105  M_nbMapDof ( otherFE.M_nbMapDof),
106  M_nbQuadPt ( otherFE.M_nbQuadPt),
107 
108  M_currentID (otherFE.M_currentID),
109  M_currentLocalID (otherFE.M_currentLocalID),
110 
114 
119 
122 
125  {};
126 
127 
128  //! Destructor
129  virtual ~ETCurrentBDFE()
130  {
131  if (M_quadrature != 0)
132  {
133  delete M_quadrature;
134  }
135  }
136 
137  //@}
138 
140  {
141  if (M_quadrature != 0)
142  {
143  delete M_quadrature;
144  }
147 
149  }
150 
151  void setRefTangents ( std::vector< VectorSmall< spaceDim> > tangents)
152  {
153  M_refTangents = tangents;
154  }
155 
156  template< typename ElementType>
157  void update ( const ElementType& cell)
158  {
159  M_currentID = cell.id();
160  M_currentLocalID = cell.localId();
161 
162  // Cell nodes
163  for (UInt i (0); i < M_nbMapDof; ++i)
164  {
165  for (UInt j (0); j < spaceDim; ++j)
166  {
167  M_cellNode[i][j] = cell.point (i).coordinate (j);
168  }
169  }
170 
171  for (UInt iq (0); iq < M_nbQuadPt; ++iq)
172  {
173  for (UInt iDim (0); iDim < spaceDim; ++iDim)
174  {
175  M_quadNode[iq][iDim] = 0.0;
176 
177  for (UInt iDof (0); iDof < M_nbMapDof; ++iDof)
178  {
179  M_quadNode[iq][iDim] += M_cellNode[iDof][iDim] * M_phiMap[iq][iDof];
180  }
181  }
182  }
183 
184  // Update the jacobian
185  Real partialSum (0.0);
186  for (UInt iq (0); iq < M_nbQuadPt; ++iq)
187  {
188  for (UInt iDim (0); iDim < spaceDim; ++iDim)
189  {
190  for (UInt jDim (0); jDim < spaceDim; ++jDim)
191  {
192  partialSum = 0.0;
193  for (UInt iMap (0); iMap < M_nbMapDof; ++iMap)
194  {
195  partialSum += M_cellNode[iMap][iDim] * M_dphiGeometricMap[iq][iMap][jDim];
196  }
197  M_jacobian[iq][iDim][jDim] = partialSum;
198  }
199  }
200  }
201 
202  // Update the tangents
203  for (UInt iq (0); iq < M_nbQuadPt; ++iq)
204  {
205  for (UInt iDim (0); iDim < spaceDim - 1; ++iDim)
206  {
207  for (UInt jDim (0); jDim < spaceDim; ++jDim)
208  {
209  partialSum = 0.0;
210  for (UInt kDim (0); kDim < spaceDim; ++kDim)
211  {
212  partialSum += M_jacobian[iq][jDim][kDim] * M_refTangents[iDim][kDim]; // jdim<->kdim
213  }
214  M_tangents[iq][iDim][jDim] = partialSum;
215  }
216  }
217  }
218 
219  for (UInt iq (0); iq < M_nbQuadPt; ++iq)
220  {
221  for (UInt iDim (0); iDim < spaceDim - 1; ++iDim)
222  {
223  for (UInt jDim (0); jDim < spaceDim - 1; ++jDim)
224  {
225  partialSum = 0.0;
226  for (UInt kDim (0); kDim < spaceDim; ++kDim)
227  {
228  partialSum += M_tangents[iq][iDim][kDim] * M_tangents[iq][jDim][kDim];
229  }
230  M_metricTensor[iq][iDim][jDim] = partialSum;
231  }
232  }
233  }
234 
235  // SPECIALIZED FOR THE 3D
236  for (UInt iq (0); iq < M_nbQuadPt; ++iq)
237  {
238  M_measure[iq] = std::sqrt ( M_metricTensor[iq][0][0] * M_metricTensor[iq][1][1]
239  - M_metricTensor[iq][0][1] * M_metricTensor[iq][1][0]);
240  }
241 
242  for (UInt iq (0); iq < M_nbQuadPt; ++iq)
243  {
244  M_wMeas[iq] = M_measure[iq] * M_quadrature->weight (iq);
245  }
246 
247  // SPECIALIZED FOR THE 3D
248  Real n0 (0.0);
249  Real n1 (0.0);
250  Real n2 (0.0);
251  Real nnorm (0.0);
252  for (UInt iq (0); iq < M_nbQuadPt; ++iq)
253  {
254  n0 = M_tangents[iq][0][1] * M_tangents[iq][1][2]
255  - M_tangents[iq][0][2] * M_tangents[iq][1][1];
256  n1 = M_tangents[iq][0][2] * M_tangents[iq][1][0]
257  - M_tangents[iq][0][0] * M_tangents[iq][1][2];
258  n2 = M_tangents[iq][0][0] * M_tangents[iq][1][1]
259  - M_tangents[iq][0][1] * M_tangents[iq][1][0];
260  nnorm = std::sqrt (n0 * n0 + n1 * n1 + n2 * n2);
261 
262  M_normal[iq][0] = -n0 / nnorm;
263  M_normal[iq][1] = -n1 / nnorm;
264  M_normal[iq][2] = -n2 / nnorm;
265  }
266  }
267 
268  //private:
269 
271  {
272  M_phiMap.resize (M_nbQuadPt);
273  for (UInt q (0); q < M_nbQuadPt; ++q)
274  {
275  M_phiMap[q].resize (M_nbMapDof);
276  for (UInt i (0); i < M_nbMapDof; ++i)
277  {
278  M_phiMap[q][i] = M_geometricMap->phi (i, M_quadrature->quadPointCoor (q) );
279  }
280  }
281 
282 
283  M_dphiGeometricMap.resize (M_nbQuadPt);
284  for (UInt q (0); q < M_nbQuadPt; ++q)
285  {
286  M_dphiGeometricMap[q].resize (M_nbMapDof);
287  for (UInt i (0); i < M_nbMapDof; ++i)
288  {
289  M_dphiGeometricMap[q][i].resize (spaceDim);
290  for (UInt j (0); j < spaceDim; ++j)
291  {
292  M_dphiGeometricMap[q][i][j] = M_geometricMap->dPhi (i, j, M_quadrature->quadPointCoor (q) );
293  }
294  }
295  }
296 
297  M_cellNode.resize (M_nbMapDof);
298  for (UInt i (0); i < M_nbMapDof; ++i)
299  {
300  M_cellNode[i].resize (spaceDim);
301  }
302 
303  M_quadNode.resize (M_nbQuadPt);
304 
305  M_jacobian.resize (M_nbQuadPt);
306  for (UInt iq (0); iq < M_nbQuadPt; ++iq)
307  {
308  M_jacobian[iq].resize (spaceDim);
309  for (UInt iDim (0); iDim < spaceDim; ++iDim)
310  {
311  M_jacobian[iq][iDim].resize (spaceDim);
312  }
313  }
314 
315  M_refTangents.resize (spaceDim - 1);
316 
317  M_tangents.resize (M_nbQuadPt);
318  for (UInt i (0); i < M_nbQuadPt; ++i)
319  {
320  M_tangents[i].resize (spaceDim - 1);
321  }
322 
323  M_metricTensor.resize (M_nbQuadPt);
324  for (UInt i (0); i < M_nbQuadPt; ++i)
325  {
326  M_metricTensor[i].resize (spaceDim - 1);
327  for (UInt j (0); j < spaceDim - 1; ++j)
328  {
329  M_metricTensor[i][j].resize (spaceDim - 1);
330  }
331  }
332 
333  M_measure.resize (M_nbQuadPt);
334 
335  M_wMeas.resize (M_nbQuadPt);
336 
337  M_normal.resize (M_nbQuadPt);
338 
339  }
340 
341 
344 
347 
348 
351 
354  std::vector < VectorSmall<spaceDim> > M_refTangents; // ASSUME CONSTANT TANGENTS
355 
356 
364 
366 
367 };
368 
369 
370 } // Namespace LifeV
371 
372 #endif /* ETCURRENTBDFE_H */
friend class ExpressionAssembly::EvaluationHK
Friend to allow direct access to the raw data.
GeometricMap - Structure for the geometrical mapping.
std::vector< Real > M_measure
ETCurrentBDFE(const ETCurrentBDFE< spaceDim > &otherFE)
Copy constructor.
ETCurrentBDFE - Short description of the class.
const QuadratureRule * M_quadrature
friend class ExpressionAssembly::EvaluationPosition
Friend to allow direct access to the raw data.
std::vector< std::vector< std::vector< Real > > > M_metricTensor
void setRefTangents(std::vector< VectorSmall< spaceDim > > tangents)
QuadratureRule(const QuadratureRule &qr)
Copy constructor.
void updateInverseJacobian(const UInt &iQuadPt)
std::vector< std::vector< std::vector< Real > > > M_dphiGeometricMap
void setQuadratureRule(const QuadratureRule &qr)
virtual ~ETCurrentBDFE()
Destructor.
std::vector< VectorSmall< spaceDim > > M_quadNode
std::vector< Real > M_wMeas
const UInt & nbDof() const
Return the number of degrees of freedom for this reference element.
const GeometricMap * M_geometricMap
ETCurrentBDFE(const GeometricMap &geoMap)
Constructor without quadrature rule.
std::vector< std::vector< VectorSmall< spaceDim > > > M_tangents
double Real
Generic real data.
Definition: LifeV.hpp:175
std::vector< VectorSmall< spaceDim > > M_normal
std::vector< std::vector< Real > > M_phiMap
std::vector< VectorSmall< spaceDim > > M_refTangents
ETCurrentBDFE(const GeometricMap &geoMap, const QuadratureRule &qr)
Full constructor.
std::vector< std::vector< Real > > M_cellNode
QuadratureRule - The basis class for storing and accessing quadrature rules.
std::vector< std::vector< std::vector< Real > > > M_jacobian
void update(const ElementType &cell)
const UInt & nbQuadPt() const
Getter for the number of quadrature points.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191