PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
|
Namespace to group the methods used in testing of the library. More...
Data Structures | |
struct | testNSearchData |
Functions | |
double | getExactIntegrationRefTri (size_t alpha, size_t beta) |
Computes integration of polynomial exactly over reference triangle. | |
double | getExactIntegrationRefQuad (size_t alpha, size_t beta) |
Computes integration of polynomial exactly over reference quadrangle. | |
double | getExactIntegrationRefTet (size_t alpha, size_t beta, size_t theta) |
Computes integration of polynomial exactly over reference tetrahedral. | |
double | getNChooseR (size_t n, size_t r) |
Computes \( {n\choose r}\) "n choose r". | |
void | testGraphPartitioningSimple () |
Tests metis partitioning of graph. | |
void | testGraphPartitioning (size_t nPart=4, size_t nGrid=10, size_t mHorizon=3, size_t testOption=0, std::string meshFilename="") |
Tests metis partitioning of graph from a 2-D mesh with nonlocal interaction. | |
template<int dim = 3> | |
std::string | testNanoflann (size_t N, double L, double dL, int seed) |
Perform test on nsearch. | |
template<int dim = 3> | |
std::string | testNanoflannExcludeInclude (size_t N, double L, double dL, int seed, testNSearchData &data) |
Perform test on nsearch. | |
std::string | testNanoflannClosestPoint (size_t N, double L, double dL, int seed) |
Perform test on nsearch. | |
std::string | testTaskflow (size_t N, int seed) |
Perform test on taskflow. | |
void | testMPI (size_t nGrid=10, size_t mHorizon=3, size_t testOption=0, std::string meshFilename="") |
Perform parallelization test using MPI on mesh partition based on metis. | |
void | testTransform () |
Perform test on Fracture class and check if bitwise functions are working correctly. | |
std::string | testPeriDEM (std::string filepath) |
Tests PeriDEM model class. | |
void | testUtilMethods () |
Test methods | |
void | testLineElem (size_t n, std::string filepath) |
Perform test on quadrature points on line elements (NOT IMPLEMENTED) | |
void | testTriElem (size_t n, std::string filepath) |
Perform test on quadrature points on triangle elements. | |
void | testQuadElem (size_t n, std::string filepath) |
Perform test on quadrature points on quadrangle elements. | |
void | testTetElem (size_t n, std::string filepath) |
Perform test on quadrature points on tetrahedral elements. | |
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. | |
Namespace to group the methods used in testing of the library.
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)} \).
alpha | Polynomial order in variable s |
beta | Polynomial order in variable t |
Definition at line 163 of file testFeLib.cpp.
Referenced by testQuadElem().
double test::getExactIntegrationRefTet | ( | size_t | alpha, |
size_t | beta, | ||
size_t | theta | ||
) |
Computes integration of polynomial exactly over reference tetrahedral.
alpha | Polynomial order in variable s |
beta | Polynomial order in variable t |
theta | Polynomial order in variable r |
Definition at line 172 of file testFeLib.cpp.
References getNChooseR().
Referenced by testTetElem().
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.
alpha | Polynomial order in variable s |
beta | Polynomial order in variable t |
Definition at line 147 of file testFeLib.cpp.
References getNChooseR().
Referenced by testTriElem().
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}. \]
n | Number |
r | Number which is smaller or equal to n |
Definition at line 135 of file testFeLib.cpp.
Referenced by getExactIntegrationRefTet(), and getExactIntegrationRefTri().
void test::testGraphPartitioning | ( | size_t | nPart = 4 , |
size_t | nGrid = 10 , |
||
size_t | mHorizon = 3 , |
||
size_t | testOption = 0 , |
||
std::string | meshFilename = "" |
||
) |
Tests metis partitioning of graph from a 2-D mesh with nonlocal interaction.
nPart | Number of partitions |
nGrid | Number of element along a line (total number of elements is N*N) |
mHorizon | Integer factor that is used to compute nonlocal radius, i.e., horizon (epsilon = m * h, h being mesh size) |
testOption | Test otion flag. 0 - use in-built uniform mesh, 1 - use user-specified mesh |
meshFilename | Mesh filename with relative path from the directory where test command is run |
Definition at line 137 of file testMeshPartitioningLib.cpp.
References geometry::computeNonlocalNeighborhood(), fe::createUniformMesh(), util::io::getFilenameFromPath(), fe::metisGraphPartition(), util::io::removeExtensionFromFile(), and util::methods::timeDiff().
Referenced by main().
void test::testGraphPartitioningSimple | ( | ) |
Tests metis partitioning of graph.
Definition at line 126 of file testMeshPartitioningLib.cpp.
References anonymous_namespace{testMeshPartitioningLib.cpp}::partGraphKwayTestSimple(), and anonymous_namespace{testMeshPartitioningLib.cpp}::partGraphRecursiveTestSimple().
Referenced by main().
void test::testLineElem | ( | size_t | n, |
std::string | filepath | ||
) |
Perform test on quadrature points on line elements (NOT IMPLEMENTED)
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:
Also tests the exactness of the integration of the polynomial upto 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.
\[ 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.n | Order of quadrature point approximation |
filepath | Path where mesh data for test can be found (expects files 'triMesh_nodes.csv' and 'triMesh_elements.csv' inside the filepath) |
Definition at line 198 of file testFeLib.cpp.
Referenced by main().
void test::testMPI | ( | size_t | nGrid = 10 , |
size_t | mHorizon = 3 , |
||
size_t | testOption = 0 , |
||
std::string | meshFilename = "" |
||
) |
Perform parallelization test using MPI on mesh partition based on metis.
nGrid | Number of element along a line (total number of elements is N*N) |
mHorizon | Integer factor that is used to compute nonlocal radius, i.e., horizon (epsilon = m * h, h being mesh size) |
testOption | Test otion flag. 0 - use in-built uniform mesh, 1 - use user-specified mesh |
meshFilename | Mesh filename with relative path from the directory where test command is run |
Definition at line 285 of file testParallelCompLib.cpp.
References geometry::computeNonlocalNeighborhood(), fe::createUniformMesh(), anonymous_namespace{testParallelCompLib.cpp}::exchangeDispData(), util::io::getFilenameFromPath(), fe::metisGraphPartition(), util::io::print(), util::io::print_default_tab, anonymous_namespace{testParallelCompLib.cpp}::printMsg(), util::io::removeExtensionFromFile(), and anonymous_namespace{testParallelCompLib.cpp}::setupOwnerAndGhost().
Referenced by main().
template std::string test::testNanoflann< 3 > | ( | size_t | N, |
double | L, | ||
double | dL, | ||
int | seed | ||
) |
Perform test on nsearch.
N | size of particle cloud in each dimension. total size would be N^3 |
L | Size of unit cell to create crystal lattice point cloud |
dL | Perturbation of lattice sites |
seed | Seed |
dim | Dimension |
Definition at line 494 of file testNSearchLib.cpp.
References anonymous_namespace{testNSearchLib.cpp}::compare_results(), anonymous_namespace{testNSearchLib.cpp}::lattice(), anonymous_namespace{testNSearchLib.cpp}::neighSearchBrute(), and anonymous_namespace{testNSearchLib.cpp}::neighSearchTreeSizet().
std::string test::testNanoflannClosestPoint | ( | size_t | N, |
double | L, | ||
double | dL, | ||
int | seed | ||
) |
Perform test on nsearch.
N | size of particle cloud in each dimension. total size would be N^3 |
L | Size of unit cell to create crystal lattice point cloud |
dL | Perturbation of lattice sites |
seed | Seed |
Definition at line 781 of file testNSearchLib.cpp.
References anonymous_namespace{testNSearchLib.cpp}::compare_closest_point_results(), anonymous_namespace{testNSearchLib.cpp}::lattice(), and anonymous_namespace{testNSearchLib.cpp}::neighSearchTreeClosestPointSizet().
Referenced by main().
template std::string test::testNanoflannExcludeInclude< 3 > | ( | size_t | N, |
double | L, | ||
double | dL, | ||
int | seed, | ||
testNSearchData & | data | ||
) |
Perform test on nsearch.
N | size of particle cloud in each dimension. total size would be N^3 |
L | Size of unit cell to create crystal lattice point cloud |
dL | Perturbation of lattice sites |
seed | Seed |
dim | Dimension |
data | Search data |
Definition at line 625 of file testNSearchLib.cpp.
References anonymous_namespace{testNSearchLib.cpp}::assignRandomTags(), anonymous_namespace{testNSearchLib.cpp}::compare_results(), test::testNSearchData::d_defaultBruteSearchTime, test::testNSearchData::d_defaultNFlannSearchTime, test::testNSearchData::d_excludeBruteSearchTime, test::testNSearchData::d_excludeNFlannSearchTime, test::testNSearchData::d_includeBruteSearchTime, test::testNSearchData::d_includeNFlannSearchTime, test::testNSearchData::d_leafMaxSize, test::testNSearchData::d_numPoints, test::testNSearchData::d_numTags, test::testNSearchData::d_treeBuildTime, anonymous_namespace{testNSearchLib.cpp}::lattice(), anonymous_namespace{testNSearchLib.cpp}::neighSearchBrute(), anonymous_namespace{testNSearchLib.cpp}::neighSearchBruteExcludeInclude(), anonymous_namespace{testNSearchLib.cpp}::neighSearchTreeSizet(), and anonymous_namespace{testNSearchLib.cpp}::neighSearchTreeSizetExcludeInclude().
std::string test::testPeriDEM | ( | std::string | filepath | ) |
Tests PeriDEM model class.
filepath | Path where input file can be found (expects file 'input.yaml' in the filepath) |
Definition at line 23 of file testPeriDEMLib.cpp.
References model::DEMModel::run(), and util::methods::timeDiff().
Referenced by main().
void test::testQuadElem | ( | size_t | n, |
std::string | filepath | ||
) |
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:
Also tests the exactness of the integration of the polynomial upto 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.
\[ 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.n | Order of quadrature point approximation |
filepath | Path where mesh data for test can be found (expects files 'quadMesh_nodes.csv' and 'quadMesh_elements.csv' inside the filepath) |
Definition at line 353 of file testFeLib.cpp.
References anonymous_namespace{testFeLib.cpp}::checkRefIntegration(), getExactIntegrationRefQuad(), anonymous_namespace{testFeLib.cpp}::readElements(), anonymous_namespace{testFeLib.cpp}::readNodes(), anonymous_namespace{testFeLib.cpp}::tol, and util::vtk_type_quad.
Referenced by main().
std::string test::testTaskflow | ( | size_t | N, |
int | seed | ||
) |
Perform test on taskflow.
N | size of vector to profile taskflow |
seed | Seed |
Definition at line 222 of file testParallelCompLib.cpp.
References anonymous_namespace{testParallelCompLib.cpp}::f1(), anonymous_namespace{testParallelCompLib.cpp}::f2(), util::get_rd_gen(), util::parallel::getNThreads(), util::io::print(), and util::methods::timeDiff().
Referenced by main().
void test::testTetElem | ( | size_t | n, |
std::string | filepath | ||
) |
Perform test on quadrature points on tetrahedral elements.
n | Order of quadrature point approximation |
filepath | Path where mesh data for test can be found (expects files 'tetMesh_nodes.csv' and 'tetMesh_elements.csv' inside the filepath) |
Definition at line 577 of file testFeLib.cpp.
References anonymous_namespace{testFeLib.cpp}::checkRefIntegration(), anonymous_namespace{testFeLib.cpp}::debug_id, getExactIntegrationRefTet(), util::io::printStr(), anonymous_namespace{testFeLib.cpp}::readElements(), anonymous_namespace{testFeLib.cpp}::readNodes(), anonymous_namespace{testFeLib.cpp}::tol, and util::vtk_type_tetra.
Referenced by main().
void test::testTransform | ( | ) |
Perform test on Fracture class and check if bitwise functions are working correctly.
Definition at line 19 of file testParticleLib.cpp.
Referenced by main().
void test::testTriElem | ( | size_t | n, |
std::string | filepath | ||
) |
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:
Also tests the exactness of the integration of the polynomial upto 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.
\[ 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.n | Order of quadrature point approximation |
filepath | Path where mesh data for test can be found (expects files 'triMesh_nodes.csv' and 'triMesh_elements.csv' inside the filepath) |
Definition at line 200 of file testFeLib.cpp.
References anonymous_namespace{testFeLib.cpp}::checkRefIntegration(), getExactIntegrationRefTri(), anonymous_namespace{testFeLib.cpp}::readElements(), anonymous_namespace{testFeLib.cpp}::readNodes(), anonymous_namespace{testFeLib.cpp}::tol, and util::vtk_type_triangle.
Referenced by main().
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.
n | Order of quadrature point approximation |
N | Number of elements on which this test is performed |
Definition at line 504 of file testFeLib.cpp.
References fe::QuadData::d_shapes, fe::QuadData::d_w, and util::methods::timeDiff().
Referenced by main().
void test::testUtilMethods | ( | ) |
Test methods
Definition at line 26 of file testUtilLib.cpp.
References util::angle(), anonymous_namespace{testUtilLib.cpp}::errExit(), util::getCenter(), util::getCornerPoints(), util::getEdges(), util::l2Dist(), util::rotate(), util::rotateACW2D(), util::rotateCW2D(), and util::triangleArea().
Referenced by main().