LifeV
|
QuadratureRule - The basis class for storing and accessing quadrature rules. More...
#include <QuadratureRule.hpp>
Private Attributes | |
std::vector< QuadraturePoint > | M_pt |
ReferenceShapes | M_shape |
geometrical shape of the domain on which the quadrature rule can be used More... | |
std::string | M_name |
name of the quadrature rule More... | |
UInt | M_nbQuadPt |
number of quadrature points More... | |
UInt | M_degOfExact |
degree of exactness More... | |
UInt | M_dimension |
Dimension in which the quadrature is stored. More... | |
Static Private Attributes | |
static Real | S_exactnessTol = 1e-8 |
Tolerance for the test of exactness. More... | |
Constructor & Destructor | |
QuadratureRule () | |
Empty constructor. More... | |
QuadratureRule (const QuadraturePoint *pt, int id, std::string name, ReferenceShapes shape, UInt nbQuadPt, UInt degOfExact) | |
Full constructor using pointers. More... | |
QuadratureRule (std::string name, ReferenceShapes shape, UInt dimension, UInt degreeOfExactness, UInt nbQuadPt,...) | |
Full constructor. More... | |
QuadratureRule (const QuadratureRule &qr) | |
Copy constructor. More... | |
QuadratureRule (const QuadratureRule &qr, const UInt dim) | |
Copy constructor using a different dimension. More... | |
virtual | ~QuadratureRule () |
Destructor. More... | |
Operators | |
std::ostream & | operator<< (std::ostream &c, const QuadratureRule &qr) |
Output operator. More... | |
Methods | |
void | addPoint (const QuadraturePoint &qp) |
Method to add a point to an existing quadrature rule. More... | |
void | showMe (std::ostream &output=std::cout) const |
ShowMe method. More... | |
UInt | checkExactness () const |
Check for the exactness of the quadrature. More... | |
void | vtkExport (const std::string &filename) const |
VTK export for the quadrature. More... | |
template<typename QRType > | |
void | import (const QRType &qr) |
Method for importing the quadrature rule from another class. More... | |
Set methods | |
void | setPoints (const std::vector< QuadraturePoint > &pts) |
Change the quadrature points for the ones given here. More... | |
void | setPoints (const std::vector< GeoVector > &coordinates, const std::vector< Real > &weights) |
Change the quadrature points for the one given here. More... | |
void | setName (const std::string &newName) |
Change the name of the quadrature. More... | |
void | setExactness (const UInt &exactness) |
Change the degree of exactness. More... | |
void | setDimensionShape (const UInt &newDim, const ReferenceShapes &newShape) |
Change the dimension and the shape. More... | |
Get methods | |
const QuadraturePoint & | quadPoint (const UInt &ig) const |
quadPoint(ig) is the ig-th quadrature point More... | |
const Real & | weight (const UInt &ig) const |
weight(ig) is the ig-th quadrature weight More... | |
const Real & | quadPointCoor (const UInt &ig, const UInt &icoor) const |
quadPointCoor(ig,icoor) is the coordinate icoor of the quadrature point ig More... | |
const GeoVector & | quadPointCoor (const UInt &ig) const |
quadPointCoor(ig) is the full coordinates of the quadrature point ig More... | |
const UInt & | nbQuadPt () const |
Getter for the number of quadrature points. More... | |
const std::string & | name () const |
Getter for the name of the quadrature. More... | |
const UInt & | degreeOfExactness () const |
Getter for the degree of exactness. More... | |
Private Methods | |
UInt | checkExactnessSegment () const |
Check the exactness for quadrature rules on segments. More... | |
UInt | checkExactnessTriangle () const |
Check the exactness for quadrature rules on triangles. More... | |
UInt | checkExactnessTetra () const |
Check the exactness for quadrature rules on tetrahedra. More... | |
QuadratureRule - The basis class for storing and accessing quadrature rules.
Definition of a quadrature rule
To define a quadrature rule, several constructors have been defined for this class. Besides the classical constructors, one is provided with an arbitrary number of arguements (indicated by "..."). Its usage is quite simple: first of all, one defines the standard arguements (name...) but also the number of quadrature points and their dimension. After that, one add the coordinates and weights of the quadrature points in the order: coordinates for the first point, weight for the first point, coordinates of the second point, weight of the second point,...
For example, if we want to define a Simpson rule in 1D, we can write:
If we want to see this quadrature as a 1D quadrature in a 2D space, the code would have been:
The following code would have produced the same quadrature:
Basic Use
A quadrature rule consists mainly in a container of quadrature points. The stored quadrature points can be accessed through accessors to the quadrature points or through specific accessors for the coordinates and the weight of the quadrature points.
Degree of exactness
The quadrature rules store the degree of exactness that they are supposed to achieve. It can be specified when building the quadrature rule. No test is performed automatically to check the order and when the quadrature rule is modified (with the addPoint method for example), the order of exactness is kept unchanged.
However, the QuadratureRule class provides a test for the degree of exactness. When called, this test returns the degree of exactness that has been found by trying to perform several integrals, but it does not change the stored degree of exactness.
Dimension and Shape
For some problems, it makes sens to use quadrature rules outside their "original" space, e.g. one could need a quadrature rule for the triangles in a 3D space (when integrating on a surface). The QuadratureRule class provides the possibility of changing the dimension in which a quadrature rule in defined (i.e. how many coordinates are used for the coordinates of the quadrature points).
When using a quadrature rule in a space with higher dimension, 0 coordinates are added to fill the missing coordinates. The shape of the quadrature (i.e. the geometric shape where it is defined) remains the same.
It is currently not possible to move a quadrature to a lower space dimension (than the one defined by its shape): the problem resides in the area of the quadrature: a quadrature rule for tetrahedra has a total weight of 1/6 while a quadrature rule for triangles has a total weight of 1/2 (in general for simplexes, the area is 1/n!). If such change would be allowed, one would have to implement all the changes of weight depending on the shape (there is no such phenomena between hexahedra and quadrangles for example). Moreover, it makes very little sense to downgrade a quadrature (use a specific quadrature rule which will have very likely less quadrature nodes).
Definition at line 111 of file QuadratureRule.hpp.
QuadratureRule | ( | ) |
Empty constructor.
Definition at line 51 of file QuadratureRule.cpp.
QuadratureRule | ( | const QuadraturePoint * | pt, |
int | id, | ||
std::string | name, | ||
ReferenceShapes | shape, | ||
UInt | nbQuadPt, | ||
UInt | degOfExact | ||
) |
Full constructor using pointers.
With this constructor, the dimension is supposed to be 3 (old style).
pt | The set of quadrature points |
id | Backward compatibility arguement |
name | The name of the quadrature rule |
shape | The shape of the element to be used with |
nbQuadPt | The number of quadrature points defined |
degOfExact | The degree of exactness of the quadrature rule |
Definition at line 55 of file QuadratureRule.cpp.
QuadratureRule | ( | std::string | name, |
ReferenceShapes | shape, | ||
UInt | dimension, | ||
UInt | degreeOfExactness, | ||
UInt | nbQuadPt, | ||
... | |||
) |
Full constructor.
This constructor enables to use as many arguments as needed for the declaration of the quadrature rules (the number of quadrature points is not known a priori).
The last arguements are the coordinates and the weights of the points, in the order: coordinates of the first point, weight of the first point, coordinates of the second point, weight of the second point,...
name | The name of the quadrature |
shape | The shape were the quadrature is originally defined |
dimension | The dimension of the space in which the quadrature is defined |
degreeOfExactness | The degree of exactness of the quadrature |
nbQuadPt | The number of quadrature points |
Definition at line 87 of file QuadratureRule.cpp.
QuadratureRule | ( | const QuadratureRule & | qr | ) |
Copy constructor.
qr | The quadrature rule that we want to copy. |
Definition at line 68 of file QuadratureRule.cpp.
QuadratureRule | ( | const QuadratureRule & | qr, |
const UInt | dim | ||
) |
Copy constructor using a different dimension.
This can be used to export a quadrature rule from a space dimension to another one.
qr | The quadrature rule to export |
dim | The new dimension to be used with the quadrature rule. |
Definition at line 74 of file QuadratureRule.cpp.
|
virtual |
Destructor.
Definition at line 111 of file QuadratureRule.cpp.
|
inline |
Method to add a point to an existing quadrature rule.
Beware to have set the dimension and the shape before calling this method.
qp | The quadrature point to add. |
Definition at line 198 of file QuadratureRule.hpp.
void showMe | ( | std::ostream & | output = std::cout | ) | const |
ShowMe method.
Definition at line 138 of file QuadratureRule.cpp.
UInt checkExactness | ( | ) | const |
Check for the exactness of the quadrature.
The quadrature rule is used to performed intergrals whose values are known. The degree of exactness is evaluated using these results.
Definition at line 150 of file QuadratureRule.cpp.
void vtkExport | ( | const std::string & | filename | ) | const |
VTK export for the quadrature.
Creates a file with the positions of the quadrature points in a VTK format. No extension is added to the name of the file, please provide a name ending by ".vtk".
filename | The name of the file to be created. |
Definition at line 172 of file QuadratureRule.cpp.
void import | ( | const QRType & | qr | ) |
Method for importing the quadrature rule from another class.
Definition at line 367 of file QuadratureRule.hpp.
void setPoints | ( | const std::vector< QuadraturePoint > & | pts | ) |
Change the quadrature points for the ones given here.
Beware to have set the dimension (default: 0!) before calling this method (use the QuadratureRule::setDimensionShape method for example).
Definition at line 203 of file QuadratureRule.cpp.
void setPoints | ( | const std::vector< GeoVector > & | coordinates, |
const std::vector< Real > & | weights | ||
) |
Change the quadrature points for the one given here.
Use coordinates and weights separetly. The two vectors given in argument must have the same length. The quadrature points are then given by (coorindates[i],weights[i]).
Beware to have set the dimension (default: 0!) before calling this method (use the QuadratureRule::setDimensionShape method for example).
coordinates | An array containing the coordinates of the points |
weights | An array containing the weights of the points |
Definition at line 215 of file QuadratureRule.cpp.
void setName | ( | const std::string & | newName | ) |
Change the name of the quadrature.
Definition at line 229 of file QuadratureRule.cpp.
void setExactness | ( | const UInt & | exactness | ) |
Change the degree of exactness.
Definition at line 234 of file QuadratureRule.cpp.
void setDimensionShape | ( | const UInt & | newDim, |
const ReferenceShapes & | newShape | ||
) |
Change the dimension and the shape.
Definition at line 239 of file QuadratureRule.cpp.
|
inline |
quadPoint(ig) is the ig-th quadrature point
Definition at line 277 of file QuadratureRule.hpp.
weight(ig) is the ig-th quadrature weight
Definition at line 284 of file QuadratureRule.hpp.
quadPointCoor(ig,icoor) is the coordinate icoor of the quadrature point ig
Definition at line 291 of file QuadratureRule.hpp.
quadPointCoor(ig) is the full coordinates of the quadrature point ig
Definition at line 298 of file QuadratureRule.hpp.
|
inline |
Getter for the number of quadrature points.
Definition at line 305 of file QuadratureRule.hpp.
|
inline |
Getter for the name of the quadrature.
Definition at line 311 of file QuadratureRule.hpp.
|
inline |
Getter for the degree of exactness.
Definition at line 317 of file QuadratureRule.hpp.
|
private |
Check the exactness for quadrature rules on segments.
Definition at line 429 of file QuadratureRule.cpp.
|
private |
Check the exactness for quadrature rules on triangles.
Definition at line 333 of file QuadratureRule.cpp.
|
private |
Check the exactness for quadrature rules on tetrahedra.
Definition at line 256 of file QuadratureRule.cpp.
|
friend |
Output operator.
Definition at line 120 of file QuadratureRule.cpp.
|
staticprivate |
Tolerance for the test of exactness.
Definition at line 342 of file QuadratureRule.hpp.
|
private |
Definition at line 345 of file QuadratureRule.hpp.
|
private |
geometrical shape of the domain on which the quadrature rule can be used
Definition at line 348 of file QuadratureRule.hpp.
|
private |
name of the quadrature rule
Definition at line 351 of file QuadratureRule.hpp.
|
private |
number of quadrature points
Definition at line 354 of file QuadratureRule.hpp.
|
private |
degree of exactness
Definition at line 357 of file QuadratureRule.hpp.
|
private |
Dimension in which the quadrature is stored.
Definition at line 360 of file QuadratureRule.hpp.