PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
anonymous_namespace{testFeLib.cpp} Namespace Reference

Functions

void readNodes (const std::string &filename, std::vector< util::Point > &nodes)
 
size_t readElements (const std::string &filename, const size_t &elem_type, std::vector< size_t > &elements)
 
bool checkRefIntegration (const size_t &n, const size_t &i, const size_t &j, const std::vector< fe::QuadData > &qds, double &I_exact)
 
bool checkRefIntegration (const size_t &n, const size_t &i, const size_t &j, const size_t &k, const std::vector< fe::QuadData > &qds, double &I_exact)
 

Variables

int debug_id = -1
 
const double tol = 1.0E-12
 

Function Documentation

◆ checkRefIntegration() [1/2]

bool anonymous_namespace{testFeLib.cpp}::checkRefIntegration ( const size_t &  n,
const size_t &  i,
const size_t &  j,
const size_t &  k,
const std::vector< fe::QuadData > &  qds,
double &  I_exact 
)

Definition at line 100 of file testFeLib.cpp.

103 {
104
105 double I_approx = 0.;
106 for (auto qd: qds)
107 I_approx += qd.d_w * std::pow(qd.d_p.d_x, i) * std::pow(qd.d_p.d_y, j) *
108 std::pow(qd.d_p.d_z, k);
109
110 if (std::abs(I_exact - I_approx) > tol) {
111 std::cout << "Error in order = " << n << ". Exact integration = " << I_exact
112 << " and approximate integration = " << I_approx
113 << " of polynomial of order (i = " << i << " + j = " << j
114 << " + k = " << k << ") = " << i + j + k
115 << " over reference element "
116 << "is not matching using quadrature points.\n";
117
118 std::cout << "Print " << i << " " << j << " " << k
119 << " debug id = " << debug_id << "\n";
120 for (auto qd: qds)
121 std::cout << qd.printStr() << "\n";
122
123 return false;
124 }
125
126 return true;
127 }

References debug_id, and tol.

◆ checkRefIntegration() [2/2]

bool anonymous_namespace{testFeLib.cpp}::checkRefIntegration ( const size_t &  n,
const size_t &  i,
const size_t &  j,
const std::vector< fe::QuadData > &  qds,
double &  I_exact 
)

Definition at line 78 of file testFeLib.cpp.

81 {
82
83 double I_approx = 0.;
84 for (auto qd: qds)
85 I_approx += qd.d_w * std::pow(qd.d_p.d_x, i) * std::pow(qd.d_p.d_y, j);
86
87 if (std::abs(I_exact - I_approx) > tol) {
88 std::cout << "Error in order = " << n << ". Exact integration = " << I_exact
89 << " and approximate integration = " << I_approx
90 << " of polynomial of order (i = " << i << " + j = " << j
91 << ") = " << i + j << " over reference element "
92 << "is not matching using quadrature points.\n";
93
94 return false;
95 }
96
97 return true;
98 }

References tol.

Referenced by test::testQuadElem(), test::testTetElem(), and test::testTriElem().

Here is the caller graph for this function:

◆ readElements()

size_t anonymous_namespace{testFeLib.cpp}::readElements ( const std::string &  filename,
const size_t &  elem_type,
std::vector< size_t > &  elements 
)

Definition at line 39 of file testFeLib.cpp.

40 {
41
42 if (elem_type == util::vtk_type_triangle) {
43 io::CSVReader<3> in(filename);
44 std::vector<size_t> ids(3, 0);
45 while (in.read_row(ids[0], ids[1], ids[2])) {
46 for (auto id: ids)
47 elements.emplace_back(id);
48 }
49
50 size_t num_vertex = util::vtk_map_element_to_num_nodes[elem_type];
51 return elements.size() / num_vertex;
52 } else if (elem_type == util::vtk_type_quad) {
53 io::CSVReader<4> in(filename);
54 std::vector<size_t> ids(4, 0);
55 while (in.read_row(ids[0], ids[1], ids[2], ids[3])) {
56 for (auto id: ids)
57 elements.emplace_back(id);
58 }
59
60 size_t num_vertex = util::vtk_map_element_to_num_nodes[elem_type];
61 return elements.size() / num_vertex;
62 } else if (elem_type == util::vtk_type_tetra) {
63 io::CSVReader<4> in(filename);
64 std::vector<size_t> ids(4, 0);
65 while (in.read_row(ids[0], ids[1], ids[2], ids[3])) {
66 for (auto id: ids)
67 elements.emplace_back(id);
68 }
69
70 size_t num_vertex = util::vtk_map_element_to_num_nodes[elem_type];
71 return elements.size() / num_vertex;
72 } else {
73 std::cerr << "Error: readElements() only supports vtk_type_triangle, vtk_type_quad, and vtk_type_tetra elem_type in testing.\n";
74 exit(1);
75 }
76 }
static int vtk_map_element_to_num_nodes[16]
Map from element type to number of nodes (for vtk)
static const int vtk_type_triangle
Integer flag for triangle element.
static const int vtk_type_quad
Integer flag for quad element.
static const int vtk_type_tetra
Integer flag for tetrahedron element.

References util::vtk_map_element_to_num_nodes, util::vtk_type_quad, util::vtk_type_tetra, and util::vtk_type_triangle.

Referenced by test::testQuadElem(), test::testTetElem(), and test::testTriElem().

Here is the caller graph for this function:

◆ readNodes()

void anonymous_namespace{testFeLib.cpp}::readNodes ( const std::string &  filename,
std::vector< util::Point > &  nodes 
)

Definition at line 29 of file testFeLib.cpp.

30 {
31
32 // csv reader
33 io::CSVReader<3> in(filename);
34 double x, y, z;
35 while (in.read_row(x, y, z))
36 nodes.emplace_back(x, y, z);
37 }

Referenced by test::testQuadElem(), test::testTetElem(), and test::testTriElem().

Here is the caller graph for this function:

Variable Documentation

◆ debug_id

int anonymous_namespace{testFeLib.cpp}::debug_id = -1

Definition at line 26 of file testFeLib.cpp.

Referenced by checkRefIntegration(), and test::testTetElem().

◆ tol

const double anonymous_namespace{testFeLib.cpp}::tol = 1.0E-12