41 std::vector<unsigned>& sfc_idx,
42 unsigned const current_index)
44 std::stack<MeshLib::Element const*> elem_stack;
45 elem_stack.push(element);
46 while (!elem_stack.empty())
50 sfc_idx[elem->
getID()] = current_index;
52 for (std::size_t i = 0; i < n_neighbors; ++i)
55 if (neighbor !=
nullptr && sfc_idx[neighbor->
getID()] ==
56 std::numeric_limits<unsigned>::max())
58 elem_stack.push(neighbor);
66 INFO(
"Mesh Quality Control:");
67 INFO(
"Looking for unused nodes...");
75 INFO(
"Found {:d} potentially collapsible nodes.",
78 const std::vector<ElementErrorCode> codes(
80 std::array<std::string,
83 for (
auto& i : output_str)
92 INFO(
"Testing mesh element geometry:");
93 const auto nErrorCodes(
95 unsigned error_count[nErrorCodes];
96 std::fill_n(error_count, 4, 0);
98 const std::vector<MeshLib::Element*>& elements(mesh.
getElements());
99 std::vector<ElementErrorCode> error_code_vector;
100 error_code_vector.reserve(nElements);
102 for (std::size_t i = 0; i < nElements; ++i)
105 error_code_vector.push_back(e);
113 flags(
static_cast<std::bitset<static_cast<std::size_t>(
115 for (
unsigned j = 0; j < nErrorCodes; ++j)
117 error_count[j] += flags[j];
123 if (min_volume > std::numeric_limits<double>::epsilon())
125 for (std::size_t i = 0; i < nElements; ++i)
127 if (elements[i]->getContent() < min_volume)
135 const auto error_sum(
static_cast<unsigned>(
136 std::accumulate(error_count, error_count + nErrorCodes, 0.0)));
142 for (std::size_t i = 0; i < nErrorCodes; ++i)
146 INFO(
"{:d} elements found with {:s}.",
154 INFO(
"No errors found.");
156 return error_code_vector;
161 const std::vector<ElementErrorCode>& error_codes)
163 const auto nErrorFlags(
168 const std::size_t nElements(error_codes.size());
169 std::array<std::string,
173 for (std::size_t i = 0; i < nErrorFlags; ++i)
176 std::string elementIdStr;
178 for (std::size_t j = 0; j < nElements; ++j)
180 if (error_codes[j][flags[i]])
182 elementIdStr += (std::to_string(j) +
", ");
186 const std::string nErrorsStr = (count) ? std::to_string(count) :
"No";
187 output[i] = (nErrorsStr +
" elements found with " +
192 output[i] += (
"ElementIDs: " + elementIdStr +
"\n");
206 mesh,
"bulk_node_ids",
"bulk_element_ids",
"bulk_face_ids");
207 std::vector<MeshLib::Element*>
const& elements(
208 boundary_mesh->getElements());
210 std::vector<unsigned> sfc_idx(elements.size(),
211 std::numeric_limits<unsigned>::max());
212 unsigned current_surface_id(0);
213 auto it = sfc_idx.cbegin();
215 while (it != sfc_idx.cend())
217 std::size_t
const idx =
218 static_cast<std::size_t
>(std::distance(sfc_idx.cbegin(), it));
219 trackSurface(elements[idx], sfc_idx, current_surface_id++);
220 it = std::find(sfc_idx.cbegin(),
222 std::numeric_limits<unsigned>::max());
227 return (--current_surface_id);
ElementErrorFlag
Possible error flags for mesh elements.
Definition of the Element class.
void INFO(char const *fmt, Args const &... args)
Definition of the MeshRevision class.
Definition of the MeshValidation class.
Definition of the Mesh class.
Definition of the Node class.
Collects error flags for mesh elements.
static std::string toString(const ElementErrorFlag e)
Returns a string output for a specific error flag.
virtual const Element * getNeighbor(unsigned i) const =0
Get the specified neighbor.
virtual unsigned getNumberOfNeighbors() const =0
Get the number of neighbors for this element.
virtual std::size_t getID() const final
Returns the ID of the element.
unsigned getNumberOfCollapsableNodes(double eps=std::numeric_limits< double >::epsilon()) const
Returns the number of potentially collapsible nodes.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
std::size_t getNumberOfElements() const
Get the number of elements.
const std::vector< std::size_t > & getSearchedNodeIDs() const
return marked node IDs
std::size_t searchUnused()
Marks all unused nodes.
static void trackSurface(MeshLib::Element const *const element, std::vector< unsigned > &sfc_idx, unsigned const current_index)
static std::vector< ElementErrorCode > testElementGeometry(const MeshLib::Mesh &mesh, double min_volume=std::numeric_limits< double >::epsilon())
MeshValidation(MeshLib::Mesh &mesh)
static std::array< std::string, static_cast< std::size_t >ElementErrorFlag::MaxValue)> ElementErrorCodeOutput(const std::vector< ElementErrorCode > &error_codes)
static unsigned detectHoles(MeshLib::Mesh const &mesh)