diff --git a/src/mesh/MeshNodeBoundary.hpp b/src/mesh/MeshNodeBoundary.hpp index 3e23be7469ac6034dc1d82d23d983d72a6c44ae7..c6f126b5be3f64451c895c96baae16bf1b26f56d 100644 --- a/src/mesh/MeshNodeBoundary.hpp +++ b/src/mesh/MeshNodeBoundary.hpp @@ -36,16 +36,21 @@ class MeshNodeBoundary // clazy:exclude=copyable-polymorphic const auto& face_to_cell_matrix = mesh.connectivity().faceToCellMatrix(); const Array<const FaceId>& face_list = ref_face_list.list(); - parallel_for( - face_list.size(), PUGS_LAMBDA(int l) { - const auto& face_cells = face_to_cell_matrix[face_list[l]]; - if (face_cells.size() > 1) { - std::ostringstream ost; - ost << "invalid boundary " << rang::fgB::yellow << this->m_boundary_name << rang::style::reset - << ": inner faces cannot be used to define mesh boundaries"; - throw NormalError(ost.str()); - } - }); + + bool is_bad = false; + parallel_for(face_list.size(), [=, &is_bad](int l) { + const auto& face_cells = face_to_cell_matrix[face_list[l]]; + if (face_cells.size() > 1) { + is_bad = true; + } + }); + + if (parallel::allReduceOr(is_bad)) { + std::ostringstream ost; + ost << "invalid boundary " << rang::fgB::yellow << this->m_boundary_name << rang::style::reset + << ": inner faces cannot be used to define mesh boundaries"; + throw NormalError(ost.str()); + } Kokkos::vector<unsigned int> node_ids; // not enough but should reduce significantly the number of resizing @@ -109,16 +114,21 @@ class MeshFlatNodeBoundary : public MeshNodeBoundary<Dimension> // clazy:exclu const NodeValue<const Rd>& xr = mesh.xr(); - parallel_for( - this->m_node_list.size(), PUGS_LAMBDA(const size_t r) { - const Rd& x = xr[this->m_node_list[r]]; - if (dot(x - origin, normal) > 1E-13 * length) { - std::ostringstream ost; - ost << "invalid boundary " << rang::fgB::yellow << this->m_boundary_name << rang::style::reset - << ": boundary is not flat!"; - throw NormalError(ost.str()); - } - }); + bool is_bad = false; + + parallel_for(this->m_node_list.size(), [=, &is_bad](int r) { + const Rd& x = xr[this->m_node_list[r]]; + if (dot(x - origin, normal) > 1E-13 * length) { + is_bad = true; + } + }); + + if (parallel::allReduceOr(is_bad)) { + std::ostringstream ost; + ost << "invalid boundary " << rang::fgB::yellow << this->m_boundary_name << rang::style::reset + << ": boundary is not flat!"; + throw NormalError(ost.str()); + } } template <typename MeshType>