LifeV
QuadratureRule Class Reference

QuadratureRule - The basis class for storing and accessing quadrature rules. More...

#include <QuadratureRule.hpp>

+ Collaboration diagram for QuadratureRule:

Private Attributes

std::vector< QuadraturePointM_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 QuadraturePointquadPoint (const UInt &ig) const
 quadPoint(ig) is the ig-th quadrature point More...
 
const Realweight (const UInt &ig) const
 weight(ig) is the ig-th quadrature weight More...
 
const RealquadPointCoor (const UInt &ig, const UInt &icoor) const
 quadPointCoor(ig,icoor) is the coordinate icoor of the quadrature point ig More...
 
const GeoVectorquadPointCoor (const UInt &ig) const
 quadPointCoor(ig) is the full coordinates of the quadrature point ig More...
 
const UIntnbQuadPt () const
 Getter for the number of quadrature points. More...
 
const std::string & name () const
 Getter for the name of the quadrature. More...
 
const UIntdegreeOfExactness () 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...
 

Detailed Description

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:

QuadratureRule simpson1D ("Simpson 1D",LINE,1,3,3, // name,shape,dimension,exactness,number of points
0.0, 1.0/6.0, // first point: x=0 with weight 1/6
0.5, 2.0/3.0, // second point: x=0.5, weight 2/3
1.0, 1.0/6.0); // third point: x=1, weight 1/6

If we want to see this quadrature as a 1D quadrature in a 2D space, the code would have been:

QuadratureRule simpson2D ("Simpson 2D",LINE,2,3,3, // name,shape,dimension,exactness,number of points
0.0,0.0, 1.0/6.0, // first point: (0,0) with weight 1/6
0.5,0.0, 2.0/3.0, // second point: (0.5,0) weight 2/3
1.0,0.0, 1.0/6.0); // third point: (1,0) weight 1/6

The following code would have produced the same quadrature:

QuadratureRule simpson2D (simpson1D,2);

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).

Author
Samuel Quinodoz samue.nosp@m.l.qu.nosp@m.inodo.nosp@m.z@ep.nosp@m.fl.ch
Date
1 June 2010
Version
2.0
Note
The previous version was due to J.-F. Gerbeau (04/2002). Many ideas were taken from that version.

Definition at line 111 of file QuadratureRule.hpp.

Constructor & Destructor Documentation

◆ QuadratureRule() [1/5]

Empty constructor.

Definition at line 51 of file QuadratureRule.cpp.

+ Here is the caller graph for this function:

◆ QuadratureRule() [2/5]

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).

Parameters
ptThe set of quadrature points
idBackward compatibility arguement
nameThe name of the quadrature rule
shapeThe shape of the element to be used with
nbQuadPtThe number of quadrature points defined
degOfExactThe degree of exactness of the quadrature rule

Definition at line 55 of file QuadratureRule.cpp.

+ Here is the caller graph for this function:

◆ QuadratureRule() [3/5]

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,...

Parameters
nameThe name of the quadrature
shapeThe shape were the quadrature is originally defined
dimensionThe dimension of the space in which the quadrature is defined
degreeOfExactnessThe degree of exactness of the quadrature
nbQuadPtThe number of quadrature points

Definition at line 87 of file QuadratureRule.cpp.

+ Here is the caller graph for this function:

◆ QuadratureRule() [4/5]

QuadratureRule ( const QuadratureRule qr)

Copy constructor.

Parameters
qrThe quadrature rule that we want to copy.

Definition at line 68 of file QuadratureRule.cpp.

+ Here is the caller graph for this function:

◆ QuadratureRule() [5/5]

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.

Parameters
qrThe quadrature rule to export
dimThe new dimension to be used with the quadrature rule.

Definition at line 74 of file QuadratureRule.cpp.

+ Here is the caller graph for this function:

◆ ~QuadratureRule()

~QuadratureRule ( )
virtual

Destructor.

Definition at line 111 of file QuadratureRule.cpp.

Member Function Documentation

◆ addPoint()

void addPoint ( const QuadraturePoint qp)
inline

Method to add a point to an existing quadrature rule.

Beware to have set the dimension and the shape before calling this method.

Note
: the degree of exactness is not changed, it is up to the user to take care of it.
Parameters
qpThe quadrature point to add.

Definition at line 198 of file QuadratureRule.hpp.

+ Here is the caller graph for this function:

◆ showMe()

void showMe ( std::ostream &  output = std::cout) const

ShowMe method.

Definition at line 138 of file QuadratureRule.cpp.

◆ checkExactness()

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.

Note
The degree of exactness stored internally is not changed when calling this method.

Definition at line 150 of file QuadratureRule.cpp.

◆ vtkExport()

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".

Parameters
filenameThe name of the file to be created.

Definition at line 172 of file QuadratureRule.cpp.

◆ import()

void import ( const QRType &  qr)

Method for importing the quadrature rule from another class.

Definition at line 367 of file QuadratureRule.hpp.

◆ setPoints() [1/2]

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.

◆ setPoints() [2/2]

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).

Parameters
coordinatesAn array containing the coordinates of the points
weightsAn array containing the weights of the points

Definition at line 215 of file QuadratureRule.cpp.

◆ setName()

void setName ( const std::string &  newName)

Change the name of the quadrature.

Definition at line 229 of file QuadratureRule.cpp.

◆ setExactness()

void setExactness ( const UInt exactness)

Change the degree of exactness.

Definition at line 234 of file QuadratureRule.cpp.

◆ setDimensionShape()

void setDimensionShape ( const UInt newDim,
const ReferenceShapes newShape 
)

Change the dimension and the shape.

Definition at line 239 of file QuadratureRule.cpp.

+ Here is the caller graph for this function:

◆ quadPoint()

const QuadraturePoint& quadPoint ( const UInt ig) const
inline

quadPoint(ig) is the ig-th quadrature point

Definition at line 277 of file QuadratureRule.hpp.

◆ weight()

const Real& weight ( const UInt ig) const
inline

weight(ig) is the ig-th quadrature weight

Definition at line 284 of file QuadratureRule.hpp.

+ Here is the caller graph for this function:

◆ quadPointCoor() [1/2]

const Real& quadPointCoor ( const UInt ig,
const UInt icoor 
) const
inline

quadPointCoor(ig,icoor) is the coordinate icoor of the quadrature point ig

Definition at line 291 of file QuadratureRule.hpp.

+ Here is the caller graph for this function:

◆ quadPointCoor() [2/2]

const GeoVector& quadPointCoor ( const UInt ig) const
inline

quadPointCoor(ig) is the full coordinates of the quadrature point ig

Definition at line 298 of file QuadratureRule.hpp.

+ Here is the caller graph for this function:

◆ nbQuadPt()

const UInt& nbQuadPt ( ) const
inline

Getter for the number of quadrature points.

Definition at line 305 of file QuadratureRule.hpp.

◆ name()

const std::string& name ( ) const
inline

Getter for the name of the quadrature.

Definition at line 311 of file QuadratureRule.hpp.

◆ degreeOfExactness()

const UInt& degreeOfExactness ( ) const
inline

Getter for the degree of exactness.

Definition at line 317 of file QuadratureRule.hpp.

◆ checkExactnessSegment()

UInt checkExactnessSegment ( ) const
private

Check the exactness for quadrature rules on segments.

Definition at line 429 of file QuadratureRule.cpp.

+ Here is the caller graph for this function:

◆ checkExactnessTriangle()

UInt checkExactnessTriangle ( ) const
private

Check the exactness for quadrature rules on triangles.

Definition at line 333 of file QuadratureRule.cpp.

+ Here is the caller graph for this function:

◆ checkExactnessTetra()

UInt checkExactnessTetra ( ) const
private

Check the exactness for quadrature rules on tetrahedra.

Definition at line 256 of file QuadratureRule.cpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  c,
const QuadratureRule qr 
)
friend

Output operator.

Definition at line 120 of file QuadratureRule.cpp.

Field Documentation

◆ S_exactnessTol

Real S_exactnessTol = 1e-8
staticprivate

Tolerance for the test of exactness.

Definition at line 342 of file QuadratureRule.hpp.

◆ M_pt

std::vector<QuadraturePoint> M_pt
private

Definition at line 345 of file QuadratureRule.hpp.

◆ M_shape

ReferenceShapes M_shape
private

geometrical shape of the domain on which the quadrature rule can be used

Definition at line 348 of file QuadratureRule.hpp.

◆ M_name

std::string M_name
private

name of the quadrature rule

Definition at line 351 of file QuadratureRule.hpp.

◆ M_nbQuadPt

UInt M_nbQuadPt
private

number of quadrature points

Definition at line 354 of file QuadratureRule.hpp.

◆ M_degOfExact

UInt M_degOfExact
private

degree of exactness

Definition at line 357 of file QuadratureRule.hpp.

◆ M_dimension

UInt M_dimension
private

Dimension in which the quadrature is stored.

Definition at line 360 of file QuadratureRule.hpp.


The documentation for this class was generated from the following files: