1#include "check_mesh_completeness.h"
3#include <gtest/gtest.h>
4#include <lf/mesh/mesh.h>
5#include <spdlog/fmt/ostr.h>
6#include <spdlog/spdlog.h>
10#include "lf/mesh/hybrid2d/mesh.h"
18 const dim_t dim_mesh = mesh.
DimMesh();
20 for (size_type co_dim = 0; co_dim < dim_mesh; ++co_dim) {
23 std::vector<size_type> entity_link_cnt(mesh.
NumEntities(co_dim + 1), 0);
35 auto sub_ent_range = e->SubEntities(1);
36 for (
const Entity* sub_ent : sub_ent_range) {
40 entity_link_cnt[mesh.
Index(*sub_ent)]++;
52 size_type max_subent_cnt =
53 *std::max_element(entity_link_cnt.begin(), entity_link_cnt.end());
57 std::vector<size_type> occurrence_cnt(max_subent_cnt + 1, 0);
58 size_type entity_index = 0;
59 for (size_type i : entity_link_cnt) {
61 EXPECT_GT(i, 0) <<
"Entity " << entity_index <<
", co-dimension "
62 << co_dim + 1 <<
"not linked";
70 std::cout <<
"Enties of dimension " << dim_mesh - co_dim - 1 <<
": "
72 for (
int l = 0; l <= max_subent_cnt; l++) {
73 std::cout << l <<
" times linked: " << occurrence_cnt[l] <<
" entities"
87 const Mesh& mesh,
bool vertices_only) {
89 std::vector<std::pair<lf::base::RefEl, base::glb_idx_t>> ret_vals{};
92 Eigen::Matrix<double, 0, 1> pt_ref_coord;
95 for (
int co_dim = dim_mesh; co_dim > 0; co_dim--) {
100 const Eigen::MatrixXd& ref_el_corners(e_refel.
NodeCoords());
101 const Eigen::MatrixXd vertex_coords(
102 e->Geometry()->Global(ref_el_corners));
103 const double approx_area =
104 (e->Geometry()->IntegrationElement(ref_el_corners))[0];
106 auto sub_ents = e->SubEntities(codim_pt);
108 const Eigen::VectorXd node_coords(
109 sub_ents[j]->Geometry()->Global(pt_ref_coord));
111 if ((vertex_coords.col(j) - node_coords).squaredNorm() >
112 1.0E-8 * approx_area) {
113 ret_vals.emplace_back(e_refel, mesh.
Index(*e));
116 "Node {} of {} ({}): position mismatch", j,
117 e_refel, mesh.
Index(*e));
123 if (!vertices_only) {
Represents a reference element with all its properties.
constexpr RefEl(RefElType type) noexcept
Create a RefEl from a lf::base::RefElType enum.
const Eigen::MatrixXd & NodeCoords() const
Get the coordinates of the nodes of this reference element.
constexpr size_type NumNodes() const
The number of nodes of this reference element.
Interface class representing a topological entity in a cellular complex
Abstract interface for objects representing a single mesh.
lf::base::size_type size_type
virtual std::span< const Entity *const > Entities(unsigned codim) const =0
All entities of a given codimension.
virtual size_type NumEntities(unsigned codim) const =0
The number of Entities that have the given codimension.
virtual unsigned DimMesh() const =0
The dimension of the manifold described by the mesh, or equivalently the maximum dimension of the ref...
virtual size_type Index(const Entity &e) const =0
Acess to the index of a mesh entity of any co-dimension.
unsigned int sub_idx_t
type for local indices of sub-entities
unsigned int dim_t
type for dimensions and co-dimensions and numbers derived from them
std::shared_ptr< spdlog::logger > InitLogger(const std::string &name)
Create a spdlog logger, register it in the spdlog registry and initialize it with LehrFEM++ specific ...
Utilities for testing sanity of mesh data structures and tests involving meshes.
bool checkMeshCompleteness(const Mesh &mesh)
Function testing topological completeness of a mesh.
std::vector< std::pair< lf::base::RefEl, base::glb_idx_t > > isWatertightMesh(const Mesh &mesh, bool vertices_only)
check for match of entity geometries
std::shared_ptr< spdlog::logger > & WatertightLogger()
Logger that is used by isWatertightMesh() to output additional information.