CMP++: Uncertainty Quantification & Bayesian Calibration
Loading...
Searching...
No Matches
cmp::TensorIntegrator< BasisType > Class Template Reference

Multi-dimensional tensor product quadrature integrator. More...

#include <integrator.h>

Public Member Functions

 TensorIntegrator (int dim, int pointsPerDim)
 
double integrate (const std::function< double(const Eigen::VectorXd &)> &f) const
 
double integrate (const std::function< double(const Eigen::VectorXd &)> &f, const Eigen::VectorXd &p1, const Eigen::VectorXd &p2) const
 

Public Attributes

Eigen::MatrixXd gridNodes
 Matrix of joint tensor product quadrature nodes (totalPoints x dim).
 
Eigen::VectorXd gridWeights
 Vector of joint tensor product weights (totalPoints).
 

Detailed Description

template<typename BasisType>
class cmp::TensorIntegrator< BasisType >

Multi-dimensional tensor product quadrature integrator.

Mathematical Formulation: A multi-dimensional integral over a tensor-product domain $\Omega = [a_1, b_1] \times \dots \times [a_d, b_d]$ is approximated by the tensor product of 1D quadrature rules:

\[ \int_{\Omega} f(\mathbf{x}) \, d\mathbf{x} \approx \sum_{i_1=0}^{N-1} \dots \sum_{i_d=0}^{N-1} \left( \prod_{j=1}^{d} w_{i_j} \right) f(x_{i_1}, \dots, x_{i_d}) \]

where $w_{i_j}$ and $x_{i_j}$ are the 1D quadrature weights and nodes along dimension $j$. For physical domain integration over custom bounds $[p_{1,d}, p_{2,d}]$, a coordinate transformation maps the canonical nodes $\xi \in [-1, 1]$ (or the canonical domain of the basis) to $x \in [p_{1,d}, p_{2,d}]$ via:

\[ x = \text{mapToPhysical}(\xi, p_{1,d}, p_{2,d}) \]

The integration automatically incorporates any scaling factors (Jacobian of the transformation) if required by the basis.

Implementation Algorithm:

  1. Instantiates a 1D quadrature rule Quadrature1D<BasisType> with the specified pointsPerDim.
  2. Allocates a grid node matrix of size $N^d \times d$ and a weight vector of size $N^d$, where $N$ is pointsPerDim and $d$ is dim.
  3. Iterates through all $N^d$ combinations using base-$N$ digit decomposition to reconstruct the index tuple $(i_0, \dots, i_{d-1})$.
  4. For each joint grid point $i$, assigns the $d$-th dimension coordinate to the corresponding 1D node, and multiplies the 1D weights to form the joint weight $W_i = \prod_{j=0}^{d-1} w_{i_j}$.
  5. Provides two integrate overloads:
    • Canonical integrate(f): computes $\sum_{i} W_i f(\mathbf{x}_i)$.
    • Physical integrate(f, p1, p2): maps canonical nodes to physical coordinates using BasisType::mapToPhysical for each dimension before evaluating $f$ and summing with weights.

Constructor & Destructor Documentation

◆ TensorIntegrator()

template<typename BasisType >
cmp::TensorIntegrator< BasisType >::TensorIntegrator ( int  dim,
int  pointsPerDim 
)
inline

Member Function Documentation

◆ integrate() [1/2]

template<typename BasisType >
double cmp::TensorIntegrator< BasisType >::integrate ( const std::function< double(const Eigen::VectorXd &)> &  f) const
inline

Canonical Integration: Integrates a function defined in the canonical domain using tensor product quadrature.

Parameters
fFunction to integrate, defined in the canonical domain.
Returns
: The integral of the function over the canonical domain.

◆ integrate() [2/2]

template<typename BasisType >
double cmp::TensorIntegrator< BasisType >::integrate ( const std::function< double(const Eigen::VectorXd &)> &  f,
const Eigen::VectorXd &  p1,
const Eigen::VectorXd &  p2 
) const
inline

Physical Integration: Integrates a function defined in the physical domain by automatically mapping to the canonical domain.

Parameters
fFunction to integrate, defined in the physical domain.
p1Lower bounds of the physical domain for each dimension.
p2Upper bounds of the physical domain for each dimension.
Returns
: The integral of the function over the specified physical domain.

Member Data Documentation

◆ gridNodes

template<typename BasisType >
Eigen::MatrixXd cmp::TensorIntegrator< BasisType >::gridNodes

Matrix of joint tensor product quadrature nodes (totalPoints x dim).

◆ gridWeights

template<typename BasisType >
Eigen::VectorXd cmp::TensorIntegrator< BasisType >::gridWeights

Vector of joint tensor product weights (totalPoints).


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