https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Functions | Variables
MeshTests.C File Reference

Go to the source code of this file.

Functions

void triRodPositionsRef (std::vector< Point > &positions, Real nrings, Real pitch, Point center)
 
bool relativeEq (double x, double y)
 
bool pointLess (const Point &a, const Point &b)
 
 TEST (MeshTests, triRodCoordinates)
 

Variables

const double tol = 1e-8
 
const double eps = 1e-9
 

Function Documentation

◆ pointLess()

bool pointLess ( const Point &  a,
const Point &  b 
)

Definition at line 57 of file MeshTests.C.

58{
59 for (int i = 0; i < LIBMESH_DIM; i++)
60 {
61 if (relativeEq(a(i), b(i)))
62 continue;
63 return a(i) < b(i);
64 }
65 return false;
66}
bool relativeEq(double x, double y)
Definition MeshTests.C:44

Referenced by TEST().

◆ relativeEq()

bool relativeEq ( double  x,
double  y 
)

Definition at line 44 of file MeshTests.C.

45{
46 if (std::abs(x) < eps && std::abs(y) < eps)
47 return true;
48
49 double diff = std::abs(x - y);
50 x = std::abs(x);
51 y = std::abs(y);
52 double largest = (y > x) ? y : x;
53 return diff <= largest * tol;
54}
const std::vector< double > y
const std::vector< double > x
const double eps
Definition MeshTests.C:17
const double tol
Definition MeshTests.C:16

Referenced by pointLess().

◆ TEST()

TEST ( MeshTests  ,
triRodCoordinates   
)

Definition at line 68 of file MeshTests.C.

69{
70
71 int nrings = 4;
72 Real pitch = 1;
73 Point center(0, 0, 0);
74
75 std::vector<Point> positions;
76 triRodPositionsRef(positions, nrings, pitch, center);
77 std::sort(positions.begin(), positions.end(), pointLess);
78
79 std::vector<Point> positions2;
80 TriSubChannelMesh::pinPositions(positions2, nrings, pitch, center);
81 std::sort(positions2.begin(), positions2.end(), pointLess);
82
83 ASSERT_EQ(positions.size(), positions2.size());
84
85 std::stringstream msg;
86 for (size_t i = 0; i < positions.size(); i++)
87 if (!positions[i].absolute_fuzzy_equals(positions2[i]))
88 msg << "point " << i + 1 << " differs: " << positions[i] << " != " << positions2[i] << "\n";
89
90 if (msg.str().size() > 0)
91 FAIL() << msg.str();
92}
bool pointLess(const Point &a, const Point &b)
Definition MeshTests.C:57
void triRodPositionsRef(std::vector< Point > &positions, Real nrings, Real pitch, Point center)
Definition MeshTests.C:20
Point center
static void pinPositions(std::vector< Point > &positions, unsigned int nrings, Real pitch, Point center)
Calculates and stores the pin positions/centers for a hexagonal assembly containing the given number ...
bool absolute_fuzzy_equals(const T &var1, const T2 &var2, const Real tol=TOLERANCE *TOLERANCE)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ triRodPositionsRef()

void triRodPositionsRef ( std::vector< Point > &  positions,
Real  nrings,
Real  pitch,
Point  center 
)

Definition at line 20 of file MeshTests.C.

21{
22 positions.clear();
23
24 const Real start_r = (nrings - 1) * pitch;
25 const Real theta0 = 2 * libMesh::pi / 3;
26 const Real startx = start_r * std::cos(theta0);
27 const Real starty = start_r * std::sin(theta0);
28 for (int i = 0; i < nrings; i++)
29 {
30 int n_rods_in_row = nrings + i;
31 const Real y = starty - i * pitch * std::sin(theta0);
32 const Real x_row = startx + i * pitch * std::cos(theta0);
33 for (int j = 0; j < n_rods_in_row; j++)
34 {
35 const Real x = x_row + j * pitch;
36 positions.emplace_back(center(0) + x, center(1) + y);
37 if (i < nrings - 1)
38 positions.emplace_back(center(0) + x, center(1) - y);
39 }
40 }
41}
const Real pi

Referenced by TEST().

Variable Documentation

◆ eps

const double eps = 1e-9

Definition at line 17 of file MeshTests.C.

Referenced by relativeEq().

◆ tol

const double tol = 1e-8

Definition at line 16 of file MeshTests.C.

Referenced by relativeEq().