Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::qrule Namespace Reference

Classes

class  QuadratureLibrary
 A library for managing and generating quadrature rules for numerical integration. More...
struct  QuadraturePoint
 Represents a single quadrature point in a specified dimension. More...
struct  QuadratureRule
 Represents a quadrature rule consisting of a set of points and associated weights. More...

Typedefs

using QuadratureRule1Dmp = QuadratureRule1D<mpf_class>
template<typename T>
using QuadratureRule1D = QuadratureRule<T, 1>
 Alias for a 1-dimensional quadrature rule.

Enumerations

enum  QuadratureElemType : uint8_t { Simplex , TensorLegendre , TensorLobatto }
 Enum representing the type of quadrature element. More...

Functions

QuadratureRule1Dmp gmpGaussLegendreQuadrature (std::size_t n, std::size_t precision=256)
 Computes a Gauss-Legendre quadrature rule with arbitrary precision.
QuadratureRule1Dmp gmpGaussLobattoQuadrature (std::size_t n, std::size_t precision=256)
 Generates a Gauss-Lobatto quadrature rule in 1D with arbitrary-precision arithmetic.
template<std::size_t dim, typename T>
QuadratureRule< T, dim > buildTensorQuadrature (const QuadratureRule1D< T > &rule1d)
 Constructs a tensor-product quadrature rule from a 1D quadrature rule.
template<typename V, typename U, std::size_t Dim>
QuadratureRule< V, Dim > castRule (const QuadratureRule< U, Dim > &rule_src)
 Casts a quadrature rule from one data type to another.
template<typename T, std::size_t Dim>
QuadratureRule< T, Dim - 1 > baricentrycToCartesian (const QuadratureRule< T, Dim > &rule_bary)
 Converts a barycentric quadrature rule to a Cartesian representation.
template<std::size_t Dim>
QuadratureRule< mpf_class, Dim+1 > mpfGrundammMoellerQuadrature (std::size_t deg, std::size_t precision)
 Generates Grundamm-Moller quadrature rules in barycentric coordinates.
const QuadratureRule< mpf_class, 2 > & getTriangleTabledQuadrature (std::size_t deg)
 Retrieves a precomputed quadrature rule for a triangle.
const QuadratureRule< mpf_class, 3 > & getTetrahedronTabledQuadrature (std::size_t deg)
 Retrieves a precomputed quadrature rule for a tetrahedron.

Variables

static constexpr std::size_t num_triangle_tabled_rules = 20
 Number of precomputed quadrature rules for triangles.
static constexpr std::size_t num_tetrahedron_tabled_rules = 20
 Number of precomputed quadrature rules for tetrahedra.

Typedef Documentation

◆ QuadratureRule1D

template<typename T>
using vulpes::qrule::QuadratureRule1D = QuadratureRule<T, 1>

Alias for a 1-dimensional quadrature rule.

Template Parameters
TThe data type for the quadrature rule.

◆ QuadratureRule1Dmp

Alias for 1D quadrature rule using mpf_class for arbitrary-precision arithmetic.

Enumeration Type Documentation

◆ QuadratureElemType

Enum representing the type of quadrature element.

Enumerator
Simplex 

Quadrature over a simplex (e.g., triangles, tetrahedra).

TensorLegendre 

Tensor-product Gauss-Legendre quadrature.

TensorLobatto 

Tensor-product Gauss-Lobatto quadrature.

Function Documentation

◆ baricentrycToCartesian()

template<typename T, std::size_t Dim>
QuadratureRule< T, Dim - 1 > vulpes::qrule::baricentrycToCartesian ( const QuadratureRule< T, Dim > & rule_bary)

Converts a barycentric quadrature rule to a Cartesian representation.

This method transforms a quadrature rule defined in barycentric coordinates of a Dim-dimensional simplex into Cartesian coordinates of a (Dim - 1)-dimensional space.

Template Parameters
TThe data type of the coordinates and weights (e.g., float, double).
DimThe dimension of the barycentric simplex (must be > 2).
Parameters
rule_baryThe input quadrature rule in barycentric coordinates.
Returns
The quadrature rule in Cartesian coordinates for (Dim - 1) dimensions.

◆ buildTensorQuadrature()

template<std::size_t dim, typename T>
QuadratureRule< T, dim > vulpes::qrule::buildTensorQuadrature ( const QuadratureRule1D< T > & rule1d)

Constructs a tensor-product quadrature rule from a 1D quadrature rule.

This function generates a multidimensional quadrature rule by creating the tensor product of a given 1D quadrature rule. The weights are computed as the product of the weights from the 1D rule, and the points are determined by interpreting the multidimensional indices.

Template Parameters
dimThe number of dimensions (tensor rank). Must be compile-time constant.
TThe type of weights and points, typically a floating-point or arbitrary-precision type.
Parameters
rule1dA 1D quadrature rule to be used as the base for the tensor product.
Returns
A tensor-product quadrature rule of type QuadratureRule<T, dim>.

◆ castRule()

template<typename V, typename U, std::size_t Dim>
QuadratureRule< V, Dim > vulpes::qrule::castRule ( const QuadratureRule< U, Dim > & rule_src)

Casts a quadrature rule from one data type to another.

Converts a quadrature rule's weights and points from one data type to another, while preserving the rule's degree and structure. This is useful for adapting rules to different precision levels (e.g., from float to double or vice versa). The cast is done via vmath::to<U, V>, thus the typing must be supported by that function

Template Parameters
VThe target data type for the weights and points.
UThe source data type for the weights and points.
DimThe spatial dimension of the quadrature rule.
Parameters
rule_srcThe input quadrature rule to be cast.
Returns
A new quadrature rule with the weights and points converted to type V.

◆ getTetrahedronTabledQuadrature()

const QuadratureRule< mpf_class, 3 > & vulpes::qrule::getTetrahedronTabledQuadrature ( std::size_t deg)

Retrieves a precomputed quadrature rule for a tetrahedron.

Get the tabled quadrature rule of selected degree for a tetrahedron.

Provides quadrature rules for a tetrahedra for a specified degree. We employ Jaskowiec and Sukumar with 20 digits

Parameters
degThe degree of the quadrature rule (up to 20).
Returns
A reference to the precomputed quadrature rule.

For the tetrahedron we employ the Jaskowiec-Sukumar rules up to degree 20. Jaskowiec, Jan, and N. Sukumar. 'High-order cubature rules for tetrahedra.' International Journal for Numerical Methods in Engineering 121.11 (2020): 2418-2436. DOI 10.1002/nme.6313

◆ getTriangleTabledQuadrature()

const QuadratureRule< mpf_class, 2 > & vulpes::qrule::getTriangleTabledQuadrature ( std::size_t deg)

Retrieves a precomputed quadrature rule for a triangle.

Get the tabled quadrature rule of selected degree for a triangle.

Provides quadrature rule for the triangles for a specified degree. We employ Witherden and Vincent with 38 digits apart for degree 3 where we employ Hillion I with 17 digits

Parameters
degThe degree of the quadrature rule (up to 20).
Returns
A reference to the precomputed quadrature rule.

We mainly use the Witherden-Vincent rules due to their high numerical precision. Values are computed using Polyquad. Tables are available as supplementary data to the paper link. All the rules are PI.

We tested them with all the monomials, they are accurate up to 38 digits.

F.D: Witherden, P.E. Vincent. the identification of symmetric quadrature rules for finite element methods'. Computers and Mathematics with Applications 69 (2015) 1232-1241. DOI 10.1016/j.camwa.2015.03.017

Since the Witherden-Vincent rules lack a formula of order three, for this specific case we use the (internal) Hillion rule. To ensure the best accuracy we apply few iterations of gradient descent in arbitrary precision to the rule (the loss function is the error on the integrations of the monomials, symmetry of the formula is preserved).

P. Hillion, 'Numerical Integration on a Triangle', International Journal for Numerical Methods in Engineering, Vol. 11, (1977), pp.797-815.

◆ gmpGaussLegendreQuadrature()

QuadratureRule1Dmp vulpes::qrule::gmpGaussLegendreQuadrature ( std::size_t n,
std::size_t precision = 256 )

Computes a Gauss-Legendre quadrature rule with arbitrary precision.

Generates (n) nodes and weights for integrating functions on ([-1, 1]) using Gauss-Legendre quadrature, exact for polynomials up to degree (2n-1). Leverages arbitrary-precision arithmetic to ensure accuracy for large (n).

Key Steps:

  • Legendre Polynomials: Computes the Legendre polynomial (P_n(x)) and its derivative (P_n'(x)) exactly using arbitrary precision rationals.
  • Root Finding: Uses Newton's method to refine nodes (roots of (P_n(x))) to the desired precision using arbitrary precision floats.
  • Symmetry: Exploits symmetry to compute only half the nodes and weights.
  • Odd (n): Handles the central node separately if (n) is odd.
Parameters
nNumber of quadrature points \(\(n \geq 1\)\).
precisionBit precision for computations (default: 256 bits).
Returns
A gmp 1D quadrature rule with n nodes and weights.

◆ gmpGaussLobattoQuadrature()

QuadratureRule1Dmp vulpes::qrule::gmpGaussLobattoQuadrature ( std::size_t n,
std::size_t precision = 256 )

Generates a Gauss-Lobatto quadrature rule in 1D with arbitrary-precision arithmetic.

Gauss-Lobatto quadrature is a variant of Gauss quadrature that includes the endpoints of the interval ([-1, 1]) as nodes. It is exact for polynomials up to degree (2n-3). The nodes and weights are calculated using arbitrary precision.

Key Steps:

  • Legendre Polynomials: Computes the Legendre polynomial (P_n'(x)) and its derivative (P_n''(x)) exactly using arbitrary precision rationals.
  • Root Finding: Uses Newton's method to refine nodes to the desired precision using arbitrary precision floats.
  • Symmetry: Exploits symmetry to compute only half the nodes and weights.
  • Odd (n): Handles the central node separately if (n) is odd.
Parameters
nThe number of quadrature points.
precisionThe bit precision for arbitrary-precision arithmetic. Defaults to 256 bits.
Returns
A gmp 1D quadrature rule with n nodes and weights.

◆ mpfGrundammMoellerQuadrature()

template<std::size_t Dim>
QuadratureRule< mpf_class, Dim+1 > vulpes::qrule::mpfGrundammMoellerQuadrature ( std::size_t deg,
std::size_t precision )

Generates Grundamm-Moller quadrature rules in barycentric coordinates.

Computes a arbitrary-precision quadrature rule for a Dim-dimensional simplex using the Grundamm-Moller method. The rules are defined in barycentric coordinates. The weights may be negative.

A. Grundmann, H. M. Moller, 'Invariant integration formulas for the n-simplex by combinatorial methods', SIAM J. Numer. Anal. 15, 282-290 (1978), DOI 10.1137/0715019.

Template Parameters
DimThe dimension of the simplex (e.g., 2 for triangles, 3 for tetrahedra).
Parameters
degThe degree of the quadrature rule (must be odd; will be adjusted if even).
precisionThe precision used for arbitrary-precision computations (in bits).
Returns
A arbitrary-precision quadrature rule in barycentric coordinates for a (dim + 1)-dimensional simplex.

Variable Documentation

◆ num_tetrahedron_tabled_rules

std::size_t vulpes::qrule::num_tetrahedron_tabled_rules = 20
inlinestaticconstexpr

Number of precomputed quadrature rules for tetrahedra.

◆ num_triangle_tabled_rules

std::size_t vulpes::qrule::num_triangle_tabled_rules = 20
inlinestaticconstexpr

Number of precomputed quadrature rules for triangles.