G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsGaussRule< T > Class Template Reference

Detailed Description

template<class T>
class gismo::gsGaussRule< T >

Class that represents the (tensor) Gauss-Legendre quadrature rule.

+ Inheritance diagram for gsGaussRule< T >:
+ Collaboration diagram for gsGaussRule< T >:

Public Member Functions

index_t dim () const
 Dimension of the rule.
 
 gsGaussRule ()
 Default empty constructor.
 
 gsGaussRule (gsVector< index_t > const &numNodes, const unsigned digits=0)
 Initialize a tensor-product Gauss quadrature rule with numNodes (direction-wise)
 
 gsGaussRule (index_t numNodes, const unsigned digits=0)
 Initialize a 1D Gauss quadrature rule with numNodes.
 
 gsGaussRule (const gsBasis< T > &basis, const T quA, const index_t quB, short_t fixDir=-1)
 
 gsGaussRule (const gsBasis< T > &basis, const gsOptionList &options, short_t fixDir=-1)
 
virtual void mapTo (const gsVector< T > &lower, const gsVector< T > &upper, gsMatrix< T > &nodes, gsVector< T > &weights) const
 Maps quadrature rule (i.e., points and weights) from the reference domain to an element. More...
 
virtual void mapTo (T startVal, T endVal, gsMatrix< T > &nodes, gsVector< T > &weights) const
 Maps a univariate quadrature rule (i.e., points and weights) from the reference interval to an arbitrary interval.
 
void mapToAll (const std::vector< T > &breaks, gsMatrix< T > &nodes, gsVector< T > &weights) const
 Maps a univariate quadrature rule (i.e., points and weights) from the reference interval to a number of intervals, implied by the breaks.
 
index_t numNodes () const
 Number of nodes in the currently kept rule.
 
const gsMatrix< T > & referenceNodes () const
 Returns reference nodes for the currently kept rule. More...
 
const gsVector< T > & referenceWeights () const
 Returns reference weights for the currently kept rule. More...
 
void setNodes (gsVector< index_t > const &numNodes, unsigned digits=0)
 Initialize quadrature rule with numNodes number of quadrature points per integration variable. More...
 
void setNodes (index_t numNodes, unsigned digits=0)
 Initialize a univariate quadrature rule with numNodes quadrature points. More...
 

Static Public Member Functions

static uPtr make (gsVector< index_t > const &numNodes, const unsigned digits=0)
 Make function returning a smart pointer.
 

Protected Member Functions

void computeTensorProductRule (const std::vector< gsVector< T > > &nodes, const std::vector< gsVector< T > > &weights)
 Computes the tensor product rule from coordinate-wise 1D nodes and weights.
 

Protected Attributes

gsMatrix< T > m_nodes
 Reference quadrature nodes (on the interval [-1,1]).
 
gsVector< T > m_weights
 Reference quadrature weights (corresponding to interval [-1,1]).
 

Static Private Member Functions

static void computeReference (index_t n, gsVector< T > &x, gsVector< T > &w, unsigned digits=0)
 Computes the Gauss quadrature rule with n nodes in the interval [-1,1]. More...
 
static bool lookupReference (index_t n, gsVector< T > &x, gsVector< T > &w)
 Look up function for the Gauss quadrature rule in the interval [-1,1]. More...
 

Constructor & Destructor Documentation

gsGaussRule ( const gsBasis< T > &  basis,
const T  quA,
const index_t  quB,
short_t  fixDir = -1 
)

Initialize a tensor-product Gauss quadrature rule for basis using quA *deg_i + quB nodes (direction-wise)

gsGaussRule ( const gsBasis< T > &  basis,
const gsOptionList options,
short_t  fixDir = -1 
)

Initialize a tensor-product Gauss quadrature rule for basis using quA *deg_i + quB nodes (direction-wise). Values of quA and quB are taken from the options

Member Function Documentation

void computeReference ( index_t  n,
gsVector< T > &  x,
gsVector< T > &  w,
unsigned  digits = 0 
)
staticprivate

Computes the Gauss quadrature rule with n nodes in the interval [-1,1].

This function is called by setNodes(), if lookupReference() (which is called first) returned false.

bool lookupReference ( index_t  n,
gsVector< T > &  x,
gsVector< T > &  w 
)
staticprivate

Look up function for the Gauss quadrature rule in the interval [-1,1].

When the member function setNodes() is called, it will first try to look up the corresponding Gauss rule. If this look up was not successful, the function computeReference() will be called.

Returns
true if the look up was successful
void mapTo ( const gsVector< T > &  lower,
const gsVector< T > &  upper,
gsMatrix< T > &  nodes,
gsVector< T > &  weights 
) const
inlinevirtualinherited

Maps quadrature rule (i.e., points and weights) from the reference domain to an element.

The currently kept rule (which is initialized on the reference hypercube [-1,1]^d by calling setNodes()) is mapped to the d-dimensional hypercube specified by lower and upper.
For example, for d=2, the square [a,b]x[c,d] is defined by lower = [a,c], upper = [b,d].

Parameters
[in]lowervector of length d, defining the coordinates of the lower corner of the hypercube.
[in]uppervector of length d, defining the coordinates of the upper corner of the hypercube.
[in,out]nodeswill be overwritten with the coordinates of the quadrature nodes.
Size of the matrix nodes = d x n, where
d is the dimension of the element, and
n is the number of quadrature points.
[in,out]weightswill be overwritten with the corresponding Gauss quadrature weights.
Length of the vector weights = number of quadrature nodes.

Reimplemented in gsPatchRule< T >, and gsOverIntegrateRule< T >.

const gsMatrix<T>& referenceNodes ( ) const
inlineinherited

Returns reference nodes for the currently kept rule.

Returns
v Vector of length d = dim(), where each entry v_i of v is again a vector. v_i contains the reference quadrature points for the i-th coordinate direction.
const gsVector<T>& referenceWeights ( ) const
inlineinherited

Returns reference weights for the currently kept rule.

Returns
v Vector of length d = dim(), where each entry v_i of v is again a vector. v_i contains the reference quadrature weights for the i-th coordinate direction.
void setNodes ( gsVector< index_t > const &  ,
unsigned  = 0 
)
virtual

Initialize quadrature rule with numNodes number of quadrature points per integration variable.

The call of this function initializes the quadrature rule for further use, i.e., the quadrature points and weights on the reference cube are set up and stored. The dimension d of the reference cube is specified by the length of the vector numNodes.

Example: numNodes = [2,5] corresponds to quadrature in 2D where two quadrature points are used for the first coordinate and five quadrature points for the second coordinate. In this case, 2*5 = 10 quadrature nodes and weights are set up.


Parameters
numNodes vector of length digits containing numbers of nodes to be used (per integration variable).
digits accuracy of nodes and weights. If 0, the quadrature rule will use precomputed tables if possible. If greater then 0, it will force to compute it everytime.

Reimplemented from gsQuadRule< T >.

void setNodes ( index_t  numNodes,
unsigned  digits = 0 
)
inlineinherited

Initialize a univariate quadrature rule with numNodes quadrature points.

Parameters
numNodesquadrature point
digitsaccuracy of nodes and weights. If 0, the quadrature rule will use precomputed tables if possible. If greater then 0, it will force to compute it everytime.