LifeV
QuadraturePoint.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 Definition of the quadPoint class, usefull for the quadrature rules.
30 
31  @author Jean-Frederic Gerbeau
32  Samuel Quinodoz <samuel.quinodoz@epfl.ch>
33  @date 18-05-2010
34 
35  @contributor Samuel Quinodoz <samuel.quinodoz@epfl.ch>
36  @mantainer Samuel Quinodoz <samuel.quinodoz@epfl.ch>
37  */
38 
39 #ifndef QUADPOINT_H
40 #define QUADPOINT_H 1
41 
42 
43 #include <boost/array.hpp>
44 
45 
46 #include <lifev/core/LifeV.hpp>
47 
48 namespace LifeV
49 {
50 //! @name Public typedefs
51 //@{
53 //@}
54 
55 //! QuadraturePoint - Simple container for a point of a quadrature rule.
56 /*!
57  @author Samuel Quinodoz
58  @date 05/2010
59  @version 2.0
60  @note This class is based on a previous implementation, due to J.-F. Gerbeau (04/2002).
61 
62  <b> Definition </b>
63 
64  The QuadraturePoint class consists basically in a real number (the weight of the point) and a vector of real numbers (the coordinates of the point). To enable fast computations if needed, blas vectors (look in the file /lifearray/tab.hpp to know precisely the type) are used internally.
65 
66  <b> Create a QuadraturePoint </b>
67 
68  A QuadraturePoint can be defined using directly 1,2 or 3 coordinates and the weight.
69 
70  \code
71  QuadraturePoint myPoint(1,0,1,0.5); // Point(1,0,1) with weight 0.5
72  \endcode
73 
74  However, this use should be avoided if possible, because it assumes (for backward compatibility purpose) that the dimension of the QuadraturePoint is 3, even if only 1 or 2 coordinates are passed!
75 
76  \code
77  QuadraturePoint myPoint(1,0.3); // Point(1,0,0) with weight 0.3
78  \endcode
79 
80  To create properly a QuadraturePoint, one should use the native vector (GeoVector):
81 
82  \code
83  GeoVector myCoordinates(1); // Create a vector with 1 component
84  myCoordinates[0]=1; // Put 1 in the first component
85  QuadraturePoint myPoint(myCoordinates,0.3); // Point(1) with weight 0.3
86  \endcode
87 
88  This makes the code "surprise-free" and also easier to generalize to any dimension.
89 
90  <b> Dimension of the QuadraturePoint </b>
91 
92  The QuadraturePoint has naturally a dimension, the number of coordinates of the point. To change the dimension of the QuadraturePoint, use the copy constructor where you can specify the new dimension.
93 
94  If you intend to use your code for different dimensions, take care of the methods that you call: avoid using x(),y(),z() and replace them by the coor() method.
95 
96 
97  */
99 {
100 public:
101 
102  //! @name Constructor & Destructor
103  //@{
104 
105  //! Empty constructor (all zero data).
106  /*!
107  This constructor builds a QuadraturePoint with
108  3 components (for the location) and a weight
109  that are all set to zero
110  */
111  QuadraturePoint();
112 
113  //! Full constructor for 3D
114  /*!
115  This builds a quadrature with 3D coordinates.
116  @param x First coordinate of the point
117  @param y Second coordinate of the point
118  @param z Third coordinate of the point
119  @param weight Weight of the point
120  */
121  QuadraturePoint ( Real x, Real y, Real z, Real weight );
122 
123  //! Full constructor for 2D
124  /*!
125  @param x First coordinate of the point
126  @param y Second coordinate of the point
127  @param weight Weight of the point
128  */
129  QuadraturePoint ( Real x, Real y, Real weight );
130 
131  //! Full constructor for 1D
132  /*!
133  @param x First coordinate of the point
134  @param weight Weight of the point
135  */
136  QuadraturePoint ( Real x, Real weight );
137 
138  //! Full multidimension constructor
139  /*!
140  @param coor Coordinates of the point
141  @param weight Weight of the point
142  */
143  QuadraturePoint (const GeoVector& coor, const Real& weight);
144 
145  //! Multidimension constructor with specified dimension
146  /*!
147  With this constructor, one can specify the dimension
148  of the QuadraturePoint (that can therefore be different from
149  coor.size()).
150 
151  @param coor Coordinates of the point
152  @param weight Weight of the point
153  @param spaceDim The new dimension of the point
154  */
155  QuadraturePoint (const GeoVector& coor, const Real& weight, const UInt& spaceDim);
156 
157 
158  //! Simple copy constructor
159  /*!
160  @param qp The quadrature point to copy
161  */
162  QuadraturePoint (const QuadraturePoint& qp);
163 
164  //! Import from another dimension
165  /*!
166  With this constructor, one can change the dimension of the
167  space where the quadrature point is living. For example, we can see a
168  2D quadrature point as a 3D quadrature point with 0 for the third component.
169  @param qp The quadrature point to import
170  @param spaceDim The dimension of the space where the quadrature point is defined
171  */
172  QuadraturePoint (const QuadraturePoint& qp, const UInt spaceDim);
173 
174  //! Destructor
175  virtual ~QuadraturePoint() {};
176 
177  //@}
178 
179 
180  //! @name Methods
181  //@{
182 
183  //! Returns the dimension of the quadPoint
184  Real dimension() const
185  {
186  return M_coor.size();
187  }
188 
189  //@}
190 
191 
192  //! @name Operator
193  //@{
194 
195  //! Output operator
196  friend std::ostream& operator << ( std::ostream& out, const QuadraturePoint& qp )
197  {
198  out << " Coordinates = ";
199  for (UInt i (0); i < qp.M_coor.size(); ++i)
200  {
201  out << qp.M_coor[i] << ", ";
202  };
203  out << " Weight = " << qp.M_weight;
204  return out;
205  }
206 
207  //@}
208 
209 
210  //! @name Get Methods
211  //@{
212 
213  //! Getter for the weight
214  const Real& weight() const
215  {
216  return M_weight;
217  }
218 
219  //! Getter for the first coordinate
220  const Real& x() const
221  {
222  ASSERT (0 < M_coor.size(), " No x coordinate for this quadrature point");
223  return M_coor[ 0 ];
224  }
225 
226  //! Getter for the second coordinate
227  const Real& y() const
228  {
229  ASSERT (1 < M_coor.size(), " No y coordinate for this quadrature point");
230  return M_coor[ 1 ];
231  }
232 
233  //! Getter for the third coordinate
234  const Real& z() const
235  {
236  ASSERT (2 < M_coor.size(), " No z coordinate for this quadrature point");
237  return M_coor[ 2 ];
238  }
239 
240  //! Getter for the coordinate (0<=i)
241  const Real& coor (const UInt& i ) const
242  {
243  ASSERT (i < M_coor.size(), " Error in the coordinate for this quadrature point");
244  return M_coor[ i ];
245  }
246 
247  //! Getter for the full vector of coordinates
248  const GeoVector& coor() const
249  {
250  return M_coor;
251  }
252 
253  //@}
254 
255 private:
257  GeoVector M_coor;
258 };
259 
260 
261 } // Namespace LifeV
262 
263 #endif /* QUADPOINT_H */
QuadraturePoint(Real x, Real weight)
Full constructor for 1D.
const Real & z() const
Getter for the third coordinate.
const GeoVector & coor() const
Getter for the full vector of coordinates.
QuadraturePoint(Real x, Real y, Real weight)
Full constructor for 2D.
QuadraturePoint(const GeoVector &coor, const Real &weight, const UInt &spaceDim)
Multidimension constructor with specified dimension.
QuadraturePoint()
Empty constructor (all zero data).
boost::numeric::ublas::vector< Real > GeoVector
virtual ~QuadraturePoint()
Destructor.
void updateInverseJacobian(const UInt &iQuadPt)
const Real & y() const
Getter for the second coordinate.
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
const Real & weight() const
Getter for the weight.
QuadraturePoint - Simple container for a point of a quadrature rule.
QuadraturePoint(Real x, Real y, Real z, Real weight)
Full constructor for 3D.
QuadraturePoint(const QuadraturePoint &qp)
Simple copy constructor.
double Real
Generic real data.
Definition: LifeV.hpp:175
const Real & x() const
Getter for the first coordinate.
QuadraturePoint(const GeoVector &coor, const Real &weight)
Full multidimension constructor.
QuadraturePoint(const QuadraturePoint &qp, const UInt spaceDim)
Import from another dimension.
const Real & coor(const UInt &i) const
Getter for the coordinate (0<=i)
Real dimension() const
Returns the dimension of the quadPoint.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191