Skip to content
Snippets Groups Projects
Commit f9743fd3 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add tests for MeshLineNodeBoundary

parent c425c436
No related branches found
No related tags found
1 merge request!140Change referenced item list policy
...@@ -15,21 +15,21 @@ MeshLineNodeBoundary<Dimension>::_checkBoundaryIsLine(const TinyVector<Dimension ...@@ -15,21 +15,21 @@ MeshLineNodeBoundary<Dimension>::_checkBoundaryIsLine(const TinyVector<Dimension
const NodeValue<const Rd>& xr = mesh.xr(); const NodeValue<const Rd>& xr = mesh.xr();
Rdxd P = Rdxd{identity} - tensorProduct(direction, direction); const Rdxd P = Rdxd{identity} - tensorProduct(direction, direction);
bool is_bad = false; bool is_bad = false;
parallel_for(this->m_node_list.size(), [=, &is_bad](int node_id) { parallel_for(this->m_node_list.size(), [=, &is_bad](int i_node) {
const Rd& x = xr[this->m_node_list[node_id]]; const Rd& x = xr[this->m_node_list[i_node]];
const Rd delta = x - origin; const Rd delta = P * (x - origin);
if (dot(P * delta, direction) > 1E-13 * length) { if (dot(delta, delta) > 1E-13 * length) {
is_bad = true; is_bad = true;
} }
}); });
if (parallel::allReduceOr(is_bad)) { if (parallel::allReduceOr(is_bad)) {
std::ostringstream ost; std::ostringstream ost;
ost << "invalid boundary " << rang::fgB::yellow << this->m_boundary_name << rang::style::reset ost << "invalid boundary \"" << rang::fgB::yellow << this->m_boundary_name << rang::style::reset
<< ": boundary is not a line!"; << "\": boundary is not a line!";
throw NormalError(ost.str()); throw NormalError(ost.str());
} }
} }
...@@ -48,8 +48,8 @@ MeshLineNodeBoundary<2>::_getDirection(const Mesh<Connectivity<2>>& mesh) ...@@ -48,8 +48,8 @@ MeshLineNodeBoundary<2>::_getDirection(const Mesh<Connectivity<2>>& mesh)
if (xmin == xmax) { if (xmin == xmax) {
std::ostringstream ost; std::ostringstream ost;
ost << "invalid boundary " << rang::fgB::yellow << this->m_boundary_name << rang::style::reset ost << "invalid boundary \"" << rang::fgB::yellow << this->m_boundary_name << rang::style::reset
<< ": unable to compute direction"; << "\": unable to compute direction";
throw NormalError(ost.str()); throw NormalError(ost.str());
} }
...@@ -92,6 +92,12 @@ MeshLineNodeBoundary<3>::_getDirection(const Mesh<Connectivity<3>>& mesh) ...@@ -92,6 +92,12 @@ MeshLineNodeBoundary<3>::_getDirection(const Mesh<Connectivity<3>>& mesh)
} }
const double length = l2Norm(direction); const double length = l2Norm(direction);
if (length == 0) {
std::ostringstream ost;
ost << "invalid boundary \"" << rang::fgB::yellow << this->m_boundary_name << rang::style::reset
<< "\": unable to compute direction";
throw NormalError(ost.str());
}
direction *= 1. / length; direction *= 1. / length;
this->_checkBoundaryIsLine(direction, xmin, length, mesh); this->_checkBoundaryIsLine(direction, xmin, length, mesh);
......
...@@ -178,6 +178,7 @@ add_executable (mpi_unit_tests ...@@ -178,6 +178,7 @@ add_executable (mpi_unit_tests
test_MeshFaceBoundary.cpp test_MeshFaceBoundary.cpp
test_MeshFlatFaceBoundary.cpp test_MeshFlatFaceBoundary.cpp
test_MeshFlatNodeBoundary.cpp test_MeshFlatNodeBoundary.cpp
test_MeshLineNodeBoundary.cpp
test_MeshNodeBoundary.cpp test_MeshNodeBoundary.cpp
test_Messenger.cpp test_Messenger.cpp
test_OFStream.cpp test_OFStream.cpp
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment