DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
test_Quadrature.cpp File Reference

Comprehensive doctest-based unit tests for numerical quadrature accuracy. More...

#include "doctest.h"
#include "Geom/Quadrature.hpp"
#include "Geom/Elements.hpp"
#include "Geom/BaseFunction.hpp"
#include <cmath>
#include <array>
#include <iostream>
Include dependency graph for test_Quadrature.cpp:

Go to the source code of this file.

Classes

struct  TestConfig
 
struct  TestCase
 

Macros

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
 

Functions

std::vector< std::array< int, 3 > > GetTaylorBasisMonomials (int dim, int maxOrder)
 Get the list of Taylor basis monomial exponents up to given order.
 
t_real EvalMonomial (const tPoint &p, int a, int b=0, int c=0)
 Evaluate a monomial x^a * y^b * z^c at point p.
 
t_real ExactMonomialIntegral (ParamSpace ps, int a, int b=0, int c=0)
 Compute exact integral of monomial over parametric reference element.
 
t_real QuadratureMonomialIntegral (ParamSpace ps, int int_order, int a, int b=0, int c=0)
 Numerically integrate a monomial using quadrature.
 
ParamSpace GetParamSpaceFromElement (ElemType t)
 Get parametric space from element type for testing.
 
 TEST_CASE ("Quadrature: scheme constants are valid")
 
 TEST_CASE ("Quadrature: weight sums equal reference element volumes")
 
 TEST_CASE ("Quadrature: Line integrates polynomials up to expected order")
 
 TEST_CASE ("Quadrature: Quad integrates polynomials up to expected order")
 
 TEST_CASE ("Quadrature: Hex integrates polynomials up to expected order")
 
 TEST_CASE ("Quadrature: Triangle integrates polynomials up to expected order")
 
 TEST_CASE ("Quadrature: Tetrahedron integrates polynomials up to expected order")
 
 TEST_CASE ("Quadrature: Prism integrates polynomials up to expected order")
 
 TEST_CASE ("Quadrature: Pyramid integrates constant and low-degree polynomials")
 
 TEST_CASE ("Quadrature: Quadrature class Integration method works")
 
 TEST_CASE ("Quadrature: GetQuadraturePointInfo returns correct data")
 
 TEST_CASE ("Quadrature: IntegrationSimple overloads work correctly")
 
 for (const auto &cfg :configs)
 
 for (int deg=0;deg<=3;deg++) monomials.push_back(
 
 for (const auto &tc :tests)
 
 TEST_CASE ("Quadrature: FPolynomialFill consistency check")
 

Variables

TestConfig configs []
 
std::vector< std::array< int, 3 > > monomials
 
TestCase tests [] = {{1, 1}, {3, 3}, {5, 5}, {6, 5}}
 

Detailed Description

Comprehensive doctest-based unit tests for numerical quadrature accuracy.

Tests cover:

  1. Polynomial integration accuracy (0th to 6th degree)
    • For each parametric space: Line, Tri, Quad, Tet, Hex, Prism, Pyramid
    • Tests exactness up to the theoretical order of each quadrature scheme
  2. Complete Taylor basis integration (degree <= 3)
    • Uses BaseFunction utilities for systematic testing
    • All monomials: 1, x, y, z, x², xy, y², xz, yz, z², x³, x²y, xy², y³, ...
  3. Weight sum verification (should equal parametric space volume)
  4. Integration scheme selection correctness

Theoretical exactness:

  • Gauss-Legendre on [-1,1]^d: exact for polynomials up to 2n-1
  • Hammer rules on simplex: exactness varies by rule
  • Product rules: exactness determined by component rules

Definition in file test_Quadrature.cpp.

Macro Definition Documentation

◆ DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN

Definition at line 21 of file test_Quadrature.cpp.

Function Documentation

◆ EvalMonomial()

t_real EvalMonomial ( const tPoint p,
int  a,
int  b = 0,
int  c = 0 
)

Evaluate a monomial x^a * y^b * z^c at point p.

Definition at line 83 of file test_Quadrature.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExactMonomialIntegral()

t_real ExactMonomialIntegral ( ParamSpace  ps,
int  a,
int  b = 0,
int  c = 0 
)

Compute exact integral of monomial over parametric reference element.

Reference domains:

  • Line: [-1, 1] integral = 2/(a+1) for x^a (if a even)
  • Quad: [-1, 1]^2 integral = product of 1D integrals
  • Hex: [-1, 1]^3 integral = product of 1D integrals
  • Tri: {xi>=0, et>=0, xi+et<=1} integral = a!*b!/(a+b+2)!
  • Tet: {xi>=0, et>=0, zt>=0, xi+et+zt<=1}
  • Prism: Triangle x [-1,1]
  • Pyramid: Special domain

Definition at line 104 of file test_Quadrature.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ for() [1/3]

for ( const auto &cfg :configs  )

Definition at line 835 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ for() [2/3]

for ( const auto &tc :tests  )

Definition at line 957 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ for() [3/3]

for ( int  deg = 0; deg <= 3; deg++)

Definition at line 950 of file test_Quadrature.cpp.

◆ GetParamSpaceFromElement()

ParamSpace GetParamSpaceFromElement ( ElemType  t)

Get parametric space from element type for testing.

Definition at line 244 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ GetTaylorBasisMonomials()

std::vector< std::array< int, 3 > > GetTaylorBasisMonomials ( int  dim,
int  maxOrder 
)

Get the list of Taylor basis monomial exponents up to given order.

Uses BaseFunction's diffOperatorOrderList to get exponents (nx, ny, nz) for each polynomial basis function.

Parameters
dimDimension (2 or 3)
maxOrderMaximum polynomial order (0-3)
Returns
Vector of {nx, ny, nz} exponent triplets

Definition at line 49 of file test_Quadrature.cpp.

Here is the caller graph for this function:

◆ QuadratureMonomialIntegral()

t_real QuadratureMonomialIntegral ( ParamSpace  ps,
int  int_order,
int  a,
int  b = 0,
int  c = 0 
)

Numerically integrate a monomial using quadrature.

Definition at line 225 of file test_Quadrature.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TEST_CASE() [1/13]

TEST_CASE ( "Quadrature: FPolynomialFill consistency check"  )

Definition at line 1024 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [2/13]

TEST_CASE ( "Quadrature: GetQuadraturePointInfo returns correct data"  )

Definition at line 756 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [3/13]

TEST_CASE ( "Quadrature: Hex integrates polynomials up to expected order"  )

Definition at line 483 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [4/13]

TEST_CASE ( "Quadrature: IntegrationSimple overloads work correctly"  )

Definition at line 783 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [5/13]

TEST_CASE ( "Quadrature: Line integrates polynomials up to expected order"  )

Definition at line 420 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [6/13]

TEST_CASE ( "Quadrature: Prism integrates polynomials up to expected order"  )

Definition at line 611 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [7/13]

TEST_CASE ( "Quadrature: Pyramid integrates constant and low-degree polynomials"  )

Definition at line 646 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [8/13]

TEST_CASE ( "Quadrature: Quad integrates polynomials up to expected order"  )

Definition at line 449 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [9/13]

TEST_CASE ( "Quadrature: Quadrature class Integration method works"  )

Definition at line 720 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [10/13]

TEST_CASE ( "Quadrature: scheme constants are valid"  )

Definition at line 254 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [11/13]

TEST_CASE ( "Quadrature: Tetrahedron integrates polynomials up to expected order"  )

Definition at line 570 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [12/13]

TEST_CASE ( "Quadrature: Triangle integrates polynomials up to expected order"  )

Definition at line 515 of file test_Quadrature.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [13/13]

TEST_CASE ( "Quadrature: weight sums equal reference element volumes"  )

Definition at line 296 of file test_Quadrature.cpp.

Here is the call graph for this function:

Variable Documentation

◆ configs

TestConfig configs
Initial value:
= {
{TriSpace, 2, 3, {{1, 1}, {2, 2}, {4, 4}, {5, 5}, {6, 6}}},
{QuadSpace, 2, 3, {{1, 1}, {3, 3}, {5, 5}, {6, 5}}},
}

Definition at line 828 of file test_Quadrature.cpp.

◆ monomials

auto monomials
Initial value:
{
constexpr t_real tol = 1e-12
double t_real
Definition Geometric.hpp:8

Definition at line 949 of file test_Quadrature.cpp.

◆ tests

TestCase tests = {{1, 1}, {3, 3}, {5, 5}, {6, 5}}

Definition at line 955 of file test_Quadrature.cpp.