9#include <kernel/geometry/boundary_factory.hpp> 
   10#include <kernel/geometry/mesh_part.hpp> 
   33      template<
typename MeshType>
 
   34      void validate_neighbors(
const MeshType& mesh)
 
   36        static constexpr int facet_dim = MeshType::shape_dim-1;
 
   37        const auto& neigh = mesh.get_neighbors();
 
   38        const auto& facet_idx = mesh.template get_index_set<MeshType::shape_dim, facet_dim>();
 
   40        Geometry::BoundaryFactory<MeshType> boundary_factory(mesh);
 
   41        Geometry::MeshPart<MeshType> boundary(boundary_factory);
 
   43        Index num_facets(mesh.get_num_entities(MeshType::shape_dim-1));
 
   45        bool* at_boundary(
new bool[num_facets]);
 
   47        for(
Index l(0); l < num_facets; ++l)
 
   48          at_boundary[l] = 
false;
 
   51        const auto& facet_trg = boundary.template get_target_set<MeshType::shape_dim-1>();
 
   52        for(
Index l(0); l < facet_trg.get_num_entities(); ++l)
 
   54          at_boundary[facet_trg[l]] = 
true;
 
   58        for(
Index k(0); k < mesh.get_num_entities(MeshType::shape_dim); ++k)
 
   60          for(
int j(0); j < facet_idx.num_indices; ++j)
 
   62            Index other_cell(neigh(k,j));
 
   64            if(other_cell != ~
Index(0))
 
   68              if(at_boundary[facet_idx(k,j)])
 
   69                throw String(
"Facet "+
stringify(facet_idx(k,j))+
 
   70                    " is at the boundary, but the _neighborinformation says it is not!");
 
   73              for(
int i(0); i < facet_idx.num_indices; ++i)
 
   75                if(neigh(other_cell,i) == k)
 
   82                throw String(
"Cell "+
stringify(k)+
" has neighbor "+
stringify(other_cell)+
" but not vice versa!");
 
   87              if(!at_boundary[facet_idx(k,j)])
 
   88               throw String(
"Facet "+
stringify(facet_idx(k,j))+
 
   89                   " is not at the boundary, but the _neighbor information says it is!");
 
String stringify(const T_ &item)
Converts an item into a String.
std::uint64_t Index
Index data type.