LifeV
CurrentFEManifold.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 class for a finite element living on a manifold
30 
31  @author Jean-Frederic Gerbeau
32  Vincent Martin
33  @date 00-09-2002
34 
35  @refactoring Luca Bertagna <lbertag@emory.edu>
36  @date Sept 2012
37 
38  @contributor Luca Bertagna <lbertag@emory.edu>
39  @contributor Samuel Quinodoz <samuel.quinodoz@epfl.ch>
40  @mantainer Luca Bertagna <lbertag@emory.edu>
41  */
42 
43 #ifndef CURRENT_FE_MANIFOLD_HPP
44 #define CURRENT_FE_MANIFOLD_HPP 1
45 
46 #include <boost/multi_array.hpp>
47 #include <lifev/core/fem/CurrentFE.hpp>
48 
49 namespace LifeV
50 {
51 
52 /* A few more update flags specific for the boundary elements.
53  For more info about how update flags work, see CurrentFE.hpp
54 */
55 
56 const flag_Type UPDATE_ONLY_TANGENTS (16384);
57 const flag_Type UPDATE_ONLY_NORMALS (32768);
58 const flag_Type UPDATE_ONLY_METRIC (65536);
59 const flag_Type UPDATE_ONLY_DET_METRIC (131072);
61 const flag_Type UPDATE_ONLY_INV_METRIC (524288);
62 
77 
78 /*!
79  \class CurrentFEManifold
80  \brief A class for a finite element on a manifold
81 
82  This class inherits from CurrentFE and adds some functionality related
83  to the manifold, like normals, tangents, etc.
84 */
85 
87 {
88 
89 public:
90  //! @name Constructor(s) & Destructor
91  //@{
92 
93  //! Constructor without quadrature specification
94  /*!
95  If you use this constructor, you have to use the method CurrentFE::setQuadRule before
96  using any update method!
97 
98  @param refFE Reference finite element used
99  @param geoMap Geometric mapping used
100  */
101  CurrentFEManifold (const ReferenceFE& refFE, const GeometricMap& geoMap);
102 
103  //! Full constructor with default quadrature
104  /*!
105  @param refFE Reference finite element used
106  @param geoMap Geometric mapping used
107  @param qr Quadrature rule for the computations
108  */
109  CurrentFEManifold (const ReferenceFE& refFE, const GeometricMap& geoMap, const QuadratureRule& qr);
110 
111  //! Constructor used to create a static reference FE for hybrid elements
112  CurrentFEManifold (const ReferenceFE& refFE, const GeometricMap& geoMap, const QuadratureRule& qr,
113  const Real* refCoor, UInt currentId, Real invArea = 1. );
114 
115  //! Copy constructor
116  CurrentFEManifold (const CurrentFEManifold& feManifold);
117 
118  // Virtual destructor (does not do anything)
119  virtual ~CurrentFEManifold () {}
120  //@}
121 
122  //! @name Methods
123  //@{
124 
125  // The update method which takes the geometric element is inherited from the base class
126  using CurrentFE::update;
127 
128  //! Update method using only point coordinates.
129  /*!
130  Overrides the method of base class CurrentFE. Actually, it calls the method of the base
131  class and then performs some extra updates if upFlag contains also some boundary updates
132  @param pts The coordinates of the points defining the current element
133  @param upFlag The update flag which determines what kind of update has to be done (see top of the file)
134  */
135  virtual void update (const std::vector<std::vector<Real> >& pts, flag_Type upFlag);
136 
137  //! Maps a point from the reference element to the current element
138  /*!
139  return the coordinate (x,y,z)= F(xi,eta), (F: geo mappping)
140  where (xi,eta) are the coordinates in the reference element
141  and (x,y,z) are the coor in the current element
142  (if the code is compiled in 2D mode then z=0 and eta is disgarded)
143  */
144  void coorMap (Real& x, Real& y, Real& z, Real xi, Real eta) const;
145 
146  //! Compute the measure of the current element
147  /*!
148  Overrides the corresponding method in the mother class
149  */
150  Real measure () const;
151 
152  //! Compute the integral of a function f over the current element
153  /*!
154  @param f The function to be integrated. It must have the signature
155  Real f(Real x, Real y, Real z)
156  */
157  template <typename FunctorType>
158  Real integral (const FunctorType& f) const;
159 
160  //! Compute the integral of the normal component of a vector function f over the current element
161  /*!
162  @param f The function to be integrated. It must have the signature
163  void f(Real x, Real y, Real z, Real* result)
164  where result is an array of size equal to the dimension of the ambient space.
165  The function should NOT create the array, but instead should assume that
166  the array is already created. The dimension of the ambient spase should be
167  equal to M_nbLocalCoor+1
168  */
169  template <typename FunctorType>
170  Real normalIntegral (const FunctorType& f) const;
171  //@}
172 
173 
174  //! @name Get Methods
175  //@{
176 
177  //! Values of the geometric basis functions on quadrature points (different from M_phi(iGeoNode,quadNode) only for Hybrid elements)
178  Real phiGeo (UInt iGeoNode, UInt quadNode) const
179  {
180  return M_phiGeo[iGeoNode][quadNode];
181  }
182 
183  //! Values of the tangents on the quadrature points
184  Real tangent (UInt tangent, UInt coordinate, UInt quadNode) const
185  {
186  ASSERT (M_tangentsUpdated, "Tangents are not updated!\n");
187  return M_tangents[tangent][coordinate][quadNode];
188  }
189 
190  //! Values of the normal on the quadrature points
191  Real normal (UInt coordinate, UInt quadNode) const
192  {
193  ASSERT (M_normalUpdated, "Normals are not updated!\n");
194  return M_normal[coordinate][quadNode];
195  }
196 
197  //! Metric tensor on the quadrature points
198  Real metric (UInt iCoor, UInt jCoor, UInt quadNode) const
199  {
200  ASSERT (M_metricUpdated, "Metric is not updated!\n");
201  return M_metric[iCoor][jCoor][quadNode];
202  }
203 
204  //! Determinant of the metric tensor on the quadrature points
205  Real detMetric (UInt quadNode)
206  {
207  ASSERT (M_detMetricUpdated, "Determinant of the metric is not updated!\n");
208  return M_detMetric[quadNode];
209  }
210 
211  //! Inverse of the metric tensor on the quadrature points
212  Real inverseMetric (UInt iCoor, UInt jCoor, UInt quadNode) const
213  {
214  ASSERT (M_inverseMetricUpdated, "Inverse metric is not updated!\n");
215  return M_inverseMetric[iCoor][jCoor][quadNode];
216  }
217 
218  //! Square root of the determinant of the metric times the weight on the quadrature points
219  Real wRootDetMetric (UInt quadNode) const
220  {
221  ASSERT (M_wRootDetMetricUpdated, "Weighted metric determinant is not updated!\n");
222  return M_wRootDetMetric[quadNode];
223  }
224 
225 protected:
226 
227  //! Computes the tangent vectors in the quadrature nodes
228  void computeTangents ();
229 
230  //! Computes the normal vectors in the quadrature nodes
231  void computeNormal ();
232 
233  //! Computes the metric in the quadrature nodes
234  void computeMetric ();
235 
236  //! Computes the determinant of the metric tensor in the quadrature nodes
237  void computeDetMetric ();
238 
239  //! Computes the inverse of the metric tensor in the quadrature nodes
240  void computeInverseMetric ();
241 
242  //! Computes the square root of the determinant of the metric times the weight in the quadrature nodes
243  void computeWRootDetMetric ();
244 
245  //! Geometric map in the geometric nodes (different from M_phi only for Hybrid elements)
247 
248  //! Normal and tangent vectors, metric tensor and weighted measure in the quadrature nodes
255 
256  //! Check variables
263 };
264 
265 template <typename FunctorType>
266 Real CurrentFEManifold::integral (const FunctorType& f) const
267 {
268  ASSERT (M_quadNodesUpdated && M_wRootDetMetricUpdated, "Error! Quadrature nodes and Jacobian Determinant have not been updated yet.\n");
269  Real result = 0.0;
270  for (UInt iq (0); iq < M_nbQuadPt; ++iq)
271  {
272  result += f (M_quadNodes[iq][0], M_quadNodes[iq][1], M_quadNodes[iq][2]) * M_wRootDetMetric[iq];
273  }
274 
275  return result;
276 }
277 
278 template <typename FunctorType>
279 Real CurrentFEManifold::normalIntegral (const FunctorType& f) const
280 {
281  ASSERT (M_quadNodesUpdated && M_normalUpdated && M_wRootDetMetricUpdated, "Error! Normal and Jacobian Determinant have not been updated yet.\n");
282  Real result = 0.0;
283 
284  Real tmp;
285  Real* returnValues = new Real[M_nbLocalCoor + 1];
286  for (UInt iq (0); iq < M_nbQuadPt; ++iq)
287  {
288  tmp = 0;
289  f (M_quadNodes[iq][0], M_quadNodes[iq][1], M_quadNodes[iq][2], returnValues);
290  for (UInt iCoor (0); iCoor <= M_nbLocalCoor; ++iCoor)
291  {
292  tmp += returnValues[iCoor] * M_normal[iCoor][iq];
293  }
294  result += tmp * M_wRootDetMetric[iq];
295  }
296  delete[] returnValues;
297  return result;
298 }
299 
300 } // Namespace LifeV
301 
302 #endif // CURRENT_FE_MANIFOLD_HPP
const flag_Type UPDATE_NORMALS(UPDATE_ONLY_NORMALS|UPDATE_ONLY_TANGENTS|UPDATE_ONLY_CELL_NODES)
GeometricMap - Structure for the geometrical mapping.
void computeNormal()
Computes the normal vectors in the quadrature nodes.
Real metric(UInt iCoor, UInt jCoor, UInt quadNode) const
Metric tensor on the quadrature points.
uint32_type flag_Type
bit-flag with up to 32 different flags
Definition: LifeV.hpp:197
Real measure() const
Compute the measure of the current element.
Real tangent(UInt tangent, UInt coordinate, UInt quadNode) const
Values of the tangents on the quadrature points.
A class for a finite element on a manifold.
CurrentFEManifold(const ReferenceFE &refFE, const GeometricMap &geoMap)
Constructor without quadrature specification.
Real inverseMetric(UInt iCoor, UInt jCoor, UInt quadNode) const
Inverse of the metric tensor on the quadrature points.
void computeDetMetric()
Computes the determinant of the metric tensor in the quadrature nodes.
const flag_Type UPDATE_ONLY_METRIC(65536)
const flag_Type UPDATE_ONLY_NORMALS(32768)
void updateInverseJacobian(const UInt &iQuadPt)
void computeWRootDetMetric()
Computes the square root of the determinant of the metric times the weight in the quadrature nodes...
CurrentFEManifold(const ReferenceFE &refFE, const GeometricMap &geoMap, const QuadratureRule &qr, const Real *refCoor, UInt currentId, Real invArea=1.)
Constructor used to create a static reference FE for hybrid elements.
void computeInverseMetric()
Computes the inverse of the metric tensor in the quadrature nodes.
const UInt M_nbLocalCoor
Definition: CurrentFE.hpp:612
const flag_Type UPDATE_ONLY_INV_METRIC(524288)
boost::multi_array< Real, 1 > M_wRootDetMetric
boost::multi_array< Real, 3 > M_metric
boost::multi_array< Real, 3 > M_tangents
Normal and tangent vectors, metric tensor and weighted measure in the quadrature nodes.
const flag_Type UPDATE_ONLY_W_ROOT_DET_METRIC(262144)
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
Real normal(UInt coordinate, UInt quadNode) const
Values of the normal on the quadrature points.
virtual void update(const std::vector< std::vector< Real > > &pts, flag_Type upFlag)
Update method using only point coordinates.
void computeMetric()
Computes the metric in the quadrature nodes.
const flag_Type UPDATE_INV_METRIC(UPDATE_ONLY_INV_METRIC|UPDATE_METRIC|UPDATE_ONLY_DET_METRIC)
boost::multi_array< Real, 2 > M_normal
const flag_Type UPDATE_ONLY_TANGENTS(16384)
Real detMetric(UInt quadNode)
Determinant of the metric tensor on the quadrature points.
Real phiGeo(UInt iGeoNode, UInt quadNode) const
Values of the geometric basis functions on quadrature points (different from M_phi(iGeoNode,quadNode) only for Hybrid elements)
Real wRootDetMetric(UInt quadNode) const
Square root of the determinant of the metric times the weight on the quadrature points.
double Real
Generic real data.
Definition: LifeV.hpp:175
CurrentFE - A primordial class for the assembly of the local matrices/vectors retaining the values on...
Definition: CurrentFE.hpp:243
const flag_Type UPDATE_METRIC(UPDATE_ONLY_METRIC|UPDATE_ONLY_TANGENTS|UPDATE_ONLY_CELL_NODES)
CurrentFEManifold(const ReferenceFE &refFE, const GeometricMap &geoMap, const QuadratureRule &qr)
Full constructor with default quadrature.
The class for a reference Lagrangian finite element.
const flag_Type UPDATE_W_ROOT_DET_METRIC(UPDATE_ONLY_W_ROOT_DET_METRIC|UPDATE_METRIC|UPDATE_ONLY_DET_METRIC)
boost::multi_array< Real, 2 > M_phiGeo
Geometric map in the geometric nodes (different from M_phi only for Hybrid elements) ...
const flag_Type UPDATE_ONLY_DET_METRIC(131072)
CurrentFEManifold(const CurrentFEManifold &feManifold)
Copy constructor.
void computeTangents()
Computes the tangent vectors in the quadrature nodes.
boost::multi_array< Real, 3 > M_inverseMetric
QuadratureRule - The basis class for storing and accessing quadrature rules.
const flag_Type UPDATE_TANGENTS(UPDATE_ONLY_TANGENTS|UPDATE_ONLY_CELL_NODES)
bool M_tangentsUpdated
Check variables.
void coorMap(Real &x, Real &y, Real &z, Real xi, Real eta) const
Maps a point from the reference element to the current element.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
Real normalIntegral(const FunctorType &f) const
Compute the integral of the normal component of a vector function f over the current element...
Real integral(const FunctorType &f) const
Compute the integral of a function f over the current element.
boost::multi_array< Real, 1 > M_detMetric
const flag_Type UPDATE_ONLY_CELL_NODES(1)