NLMech  0.1.0
test Namespace Reference

Namespace to group the methods used in testing of the library. More...

Functions

double getExactIntegrationRefQuad (size_t alpha, size_t beta)
 Computes integration of polynomial exactly over reference quadrangle. More...
 
double getExactIntegrationRefTet (size_t alpha, size_t beta, size_t theta)
 Computes integration of polynomial exactly over reference tetrahedral. More...
 
double getExactIntegrationRefTri (size_t alpha, size_t beta)
 Computes integration of polynomial exactly over reference triangle. More...
 
double getNChooseR (size_t n, size_t r)
 Computes $ {n\choose r}$ "n choose r". More...
 
void testFracture ()
 Perform test on Fracture class and check if bit-wise functions are working correctly.
 
void testLineElem (size_t n)
 Perform test on quadrature points on line elements. More...
 
void testQuadElem (size_t n)
 Perform test on quadrature points on quadrangle elements. More...
 
void testTetElem (size_t n)
 Perform test on quadrature points on tetrahedral elements. More...
 
void testTriElem (size_t n)
 Perform test on quadrature points on triangle elements. More...
 
void testTriElemTime (size_t n, size_t N)
 Computes the time needed when quad data for elements are stored and when they are computed as and when needed. More...
 

Detailed Description

Namespace to group the methods used in testing of the library.

Function Documentation

◆ getExactIntegrationRefQuad()

double test::getExactIntegrationRefQuad ( size_t  alpha,
size_t  beta 
)

Computes integration of polynomial exactly over reference quadrangle.

Given $ f(s,t) = s^\alpha\, t^\beta $, the exact integration is given by

\[ I_{exact} = \int_0^1 \int_0^{1-s} s^\alpha\, t^\beta \, dt\, ds. \]

If either $ \alpha$ or $ \beta$ are odd number then $ I_{exact} = 0$. Otherwise, $ I_{exact} = \frac{4}{(\alpha +1) (\beta+1)} $.

Parameters
alphaPolynomial order in variable s
betaPolynomial order in variable t
Returns
I Exact integration of $ f(s,t) = s^\alpha\, t^\beta $

Referenced by testQuadElem().

Here is the caller graph for this function:

◆ getExactIntegrationRefTet()

double test::getExactIntegrationRefTet ( size_t  alpha,
size_t  beta,
size_t  theta 
)

Computes integration of polynomial exactly over reference tetrahedral.

Parameters
alphaPolynomial order in variable s
betaPolynomial order in variable t
thetaPolynomial order in variable r
Returns
I Exact integration of $ f(s,t) = s^\alpha\, t^\beta \, r^\theta $

Referenced by testTetElem().

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

◆ getExactIntegrationRefTri()

double test::getExactIntegrationRefTri ( size_t  alpha,
size_t  beta 
)

Computes integration of polynomial exactly over reference triangle.

Given $ f(s,t) = s^\alpha\, t^\beta $, the exact integration is given by

\[ I_{exact} = \int_0^1 \int_0^{1-s} s^\alpha\, t^\beta \, dt\, ds = \sum_{i=0}^{\beta+1} (-1)^i \frac{{{\beta + 1} \choose i}}{(\alpha + i +1) (\beta + 1)}, \]

where

\[ {a \choose b} = \frac{a (a-1) (a-2) ... (a-b+1)}{1*2*3 ... *b}. \]

We have $ {a \choose 0} = 1 $ so that term for $ i=0$ is not zero. Above formula gives the exact value of integral of $ f(s,t) = s^\alpha\, t^\beta $ over reference triangle.

Parameters
alphaPolynomial order in variable s
betaPolynomial order in variable t
Returns
I Exact integration of $ f(s,t) = s^\alpha\, t^\beta $

Referenced by testTriElem().

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

◆ getNChooseR()

double test::getNChooseR ( size_t  n,
size_t  r 
)

Computes $ {n\choose r}$ "n choose r".

Computes formula

\[ {a \choose b} = \frac{a (a-1) (a-2) ... (a-b+1)}{1*2*3 ... *b}. \]

Parameters
nNumber
rNumber which is smaller or equal to n
Returns
Value Value of "n choose r"

Referenced by getExactIntegrationRefTet(), and getExactIntegrationRefTri().

Here is the caller graph for this function:

◆ testLineElem()

void test::testLineElem ( size_t  n)

Perform test on quadrature points on line elements.

This function performs accuracy test of the quadrature points for integration over reference line with vertices at {-1, 1}. List of tests are as follows:

  1. Computes quadrature points of the given order, writes them to the file, and checks if the sum of quadrature weights is equal to 0.5 (area of reference triangle).

Also tests the exactness of the integration of the polynomial up to given order. Suppose $ n$ is the order of quadrature point, then we test if the integration of the function $ f(s,t) = s^\alpha\, t^\beta $ is exact for $ \alpha $ and $ \beta $ such that $ \alpha+\beta \leq n $. The exact integration of function $ f$ over reference triangle is

\[ I_{exact} = \int_0^1 \int_0^{1-s} s^\alpha\, t^\beta \, dt\, ds = \sum_{i=0}^{\beta+1} (-1)^i \frac{{{\beta + 1} \choose i}}{(\alpha + i +1) (\beta + 1)}, \]

where

\[ {a \choose b} = \frac{a (a-1) (a-2) ... (a-b+1)}{1*2*3 ... *b}. \]

We have $ {a \choose 0} = 1 $ so that term for $ i=0$ is not zero. Above formula gives the exact value of integral of $ f(s,t) = s^\alpha\, t^\beta $ over reference triangle. Approximation by quadrature point is as follows

\[ I_{approx} = \sum_{q=1}^{Q} w_q f(s_q, t_q) \]

where $Q$ is the total number of quad points, $ w_q$ and $(s_q, t_q)$ are the $ q^{th} $ quad weight and point. In this test, we compare $ I_{exact} $ and $ I_{approx} $ and report problem if both do not match.

  1. Test the accuracy for simple quadrangle mesh on square domain [0,1]^2. Exact integration of polynomial $ f(x,y) = x^\alpha \, y^\beta $ on $[0,1]^2$ is given by

    \[ I_{exact} = \frac{1}{(\alpha+1) (\beta+1)}. \]

    We compare above with the approximation computed from the quadrature points. We consider $\alpha + \beta \leq n $ where $ n$ is the order of approximation we are testing.
Parameters
nOrder of quadrature point approximation
Todo:
Implement this method!

◆ testQuadElem()

void test::testQuadElem ( size_t  n)

Perform test on quadrature points on quadrangle elements.

This function performs accuracy test of the quadrature points for integration over reference triangle with vertices at {(0,0), (1,0), (0,1)}. List of tests are as follows:

  1. Computes quadrature points of the given order, writes them to the file, and checks if the sum of quadrature weights is equal to 2, i.e. area of reference quadrangle element.

Also tests the exactness of the integration of the polynomial up to given order. Suppose $ n$ is the order of quadrature point, then we test if the integration of the function $ f(s,t) = s^\alpha\, t^\beta $ is exact for $ \alpha $ and $ \beta $ such that $ \alpha+\beta \leq n $. The exact integration of function $ f$ over reference triangle is

\[ I_{exact} = \int_0^1 \int_0^{1-s} s^\alpha\, t^\beta \, dt\, ds = \sum_{i=0}^{\beta+1} (-1)^i \frac{{{\beta + 1} \choose i}}{(\alpha + i +1) (\beta + 1)}, \]

where

\[ {a \choose b} = \frac{a (a-1) (a-2) ... (a-b+1)}{1*2*3 ... *b}. \]

We have $ {a \choose 0} = 1 $ so that term for $ i=0$ is not zero. Above formula gives the exact value of integral of $ f(s,t) = s^\alpha\, t^\beta $ over reference triangle. Approximation by quadrature point is as follows

\[ I_{approx} = \sum_{q=1}^{Q} w_q f(s_q, t_q) \]

where $Q$ is the total number of quad points, $ w_q$ and $(s_q, t_q)$ are the $ q^{th} $ quad weight and point. In this test, we compare $ I_{exact} $ and $ I_{approx} $ and report problem if both do not match.

  1. Test the accuracy for simple quadrangle mesh on square domain [0,1]^2. Exact integration of polynomial $ f(x,y) = x^\alpha \, y^\beta $ on $[0,1]^2$ is given by

    \[ I_{exact} = \frac{1}{(\alpha+1) (\beta+1)}. \]

    We compare above with the approximation computed from the quadrature points. We consider $\alpha + \beta \leq n $ where $ n$ is the order of approximation we are testing.
Parameters
nOrder of quadrature point approximation
Here is the call graph for this function:

◆ testTetElem()

void test::testTetElem ( size_t  n)

Perform test on quadrature points on tetrahedral elements.

Parameters
nOrder of quadrature point approximation
Here is the call graph for this function:

◆ testTriElem()

void test::testTriElem ( size_t  n)

Perform test on quadrature points on triangle elements.

This function performs accuracy test of the quadrature points for integration over reference triangle with vertices at {(0,0), (1,0), (0,1)}. List of tests are as follows:

  1. Computes quadrature points of the given order, writes them to the file, and checks if the sum of quadrature weights is equal to 0.5, i.e. area of reference triangle.

Also tests the exactness of the integration of the polynomial up to given order. Suppose $ n$ is the order of quadrature point, then we test if the integration of the function $ f(s,t) = s^\alpha\, t^\beta $ is exact for $ \alpha $ and $ \beta $ such that $ \alpha+\beta \leq n $. The exact integration of function $ f$ over reference triangle is

\[ I_{exact} = \int_0^1 \int_0^{1-s} s^\alpha\, t^\beta \, dt\, ds = \sum_{i=0}^{\beta+1} (-1)^i \frac{{{\beta + 1} \choose i}}{(\alpha + i +1) (\beta + 1)}, \]

where

\[ {a \choose b} = \frac{a (a-1) (a-2) ... (a-b+1)}{1*2*3 ... *b}. \]

We have $ {a \choose 0} = 1 $ so that term for $ i=0$ is not zero. Above formula gives the exact value of integral of $ f(s,t) = s^\alpha\, t^\beta $ over reference triangle. Approximation by quadrature point is as follows

\[ I_{approx} = \sum_{q=1}^{Q} w_q f(s_q, t_q) \]

where $Q$ is the total number of quad points, $ w_q$ and $(s_q, t_q)$ are the $ q^{th} $ quad weight and point. In this test, we compare $ I_{exact} $ and $ I_{approx} $ and report problem if both do not match.

  1. Test the accuracy for simple triangular mesh on square domain [0,1]^2. Exact integration of polynomial $ f(x,y) = x^\alpha \, y^\beta $ on $[0,1]^2$ is given by

    \[ I_{exact} = \frac{1}{(\alpha+1) (\beta+1)}. \]

    We compare above with the approximation computed from the quadrature points. We consider $\alpha + \beta \leq n $ where $ n$ is the order of approximation we are testing.
Parameters
nOrder of quadrature point approximation
Here is the call graph for this function:

◆ testTriElemTime()

void test::testTriElemTime ( size_t  n,
size_t  N 
)

Computes the time needed when quad data for elements are stored and when they are computed as and when needed.

This function allocates dummy elements and test how much time it is required to do computation when the quad data are stored for each element and when the quad data are computed.

Parameters
nOrder of quadrature point approximation
NNumber of elements on which this test is performed