9#include <kernel/geometry/intern/index_representative.hpp>
10#include <kernel/geometry/intern/face_index_mapping.hpp>
11#include <kernel/geometry/index_set.hpp>
29 template<
typename Shape_>
54 Index& operator[](
int i)
59 const Index& operator[](
int i)
const
69 if (idx[i] <
other[i])
73 else if (idx[i] >
other[i])
85 typedef std::set<IndexVector>
RepSet;
125 typename RepSet::const_iterator iter =
_rep_set_vec[i].begin();
126 std::advance(iter, (
typename std::iterator_traits<
decltype(iter)>::difference_type)j);
146 template<
typename IndexVectorType_>
147 std::pair<bool,Index>
find(
const IndexVectorType_& index_vector)
const
151 Intern::IndexRepresentative<Shape_>::compute(representative, index_vector);
157 typename RepSet::const_iterator iter = rep_set.find(representative);
158 if(iter == rep_set.end())
159 return std::make_pair(
false,
Index(0));
161 return std::make_pair(
true,
Index((*iter)[0]));
173 template<
typename IndexVectorType_>
178 Intern::IndexRepresentative<Shape_>::compute(representative, index_vector);
181 Index first_index = representative[0];
184 representative[0] = id;
194 template<
typename IndexSet_>
195 void parse(
const IndexSet_& index_set)
197 static_assert(int(IndexSet_::num_indices) == int(
num_indices),
"index count mismatch");
200 const Index num_entities = index_set.get_num_entities();
203 for(
Index i(0); i < num_entities; ++i)
226 for(
Index i(0); i < n; ++i)
230 for(; it != jt; ++it, ++cur_id)
246 return "IndexTree<" + Shape_::name() +
">";
295 typename IndexSetIn_,
296 typename IndexSetOut_>
299 const IndexSetIn_& index_set_in,
300 IndexSetOut_& index_set_out)
303 typedef typename IndexSetIn_::IndexTupleType IndexTupleTypeIn;
304 typedef Intern::FaceIndexMapping<Shape_, face_dim_, 0> FimType;
307 const Index num_entities = index_set_in.get_num_entities();
312 for(
Index i(0); i < num_entities; ++i)
315 const IndexTupleTypeIn& current_cell_in = index_set_in[i];
318 for(
int j(0); j < IndexSetOut_::num_indices; ++j)
324 current_face_indices[k] = current_cell_in[FimType::map(j, k)];
328 std::pair<bool, Index> bi = index_tree.
find(current_face_indices);
331 index_set_out[i][j] = bi.second;
342 template<
typename IndexSetIn_,
typename IndexSetOut_>
346 typedef Intern::FaceIndexMapping<Shape_, face_dim_, 0> FimType;
348 const Index num_shapes(index_set_in.get_num_entities());
350 const Index num_verts(index_set_in.get_index_bound());
362 for(
Index k(0); k < num_shapes; ++k)
364 for(
int l(0); l < num_subshapes_shape; ++l)
367 for(
int i(0); i < num_verts_subshape; ++i)
368 current_face_indices[i] = index_set_in[k][FimType::map(l,i)];
372 my_index_tree.
insert(current_face_indices, num_verts+1);
382 IndexSetOut_ my_index_set(num_subshapes, num_verts);
383 index_set_out = std::move(my_index_set);
385 for(
Index i(0); i < num_verts; ++i)
391 for(
Index j(0); j < n; ++j)
395 index_set_out[my_index][0] = i;
400 index_set_out[my_index][k] = my_index_tree.
get_index(i, j, k);
410 return "IndexCalculator<" + Shape_::name() +
"," +
stringify(face_dim_) +
">";
417 template<
typename Shape_,
int face_dim_,
int cell_dim_ = Shape_::dimension>
423 static void compute(IndexSetHolder<Shape_>& ish, IndexTree<FaceType>& idx_tree)
426 RisbHelper<Shape_, face_dim_, cell_dim_ - 1>::compute(ish, idx_tree);
429 IndexCalculator<CellType, face_dim_>::compute(
431 ish.template get_index_set<cell_dim_, 0>(),
432 ish.template get_index_set<cell_dim_, face_dim_>());
436 template<
typename Shape_,
int face_dim_>
437 struct RisbHelper<Shape_, face_dim_, face_dim_>
439 typedef typename Shape::FaceTraits<Shape_, face_dim_>::ShapeType FaceType;
441 static void compute(IndexSetHolder<Shape_>&, IndexTree<FaceType>&)
459 template<
typename Shape_,
int face_dim_ = Shape_::dimension - 1>
462 typedef typename Shape::FaceTraits<Shape_, face_dim_>::ShapeType FaceType;
463 static constexpr int num_verts = Shape::FaceTraits<FaceType, 0>::count;
475 static void wrap(IndexSetHolder<Shape_>& ish)
477 auto& vert_at_subshape_index_set(ish.template get_index_set<face_dim_,0>());
480 if(vert_at_subshape_index_set.get_num_entities() == 0)
482 IndexCalculator<Shape_, face_dim_>::compute_vertex_subshape(
483 ish.template get_index_set<Shape_::dimension, 0>(), vert_at_subshape_index_set);
486 IndexSetHolderDimensionUpdater<Shape_::dimension, Shape_::dimension-face_dim_>::update(ish);
490 RisbWrapper<Shape_, face_dim_ - 1>::wrap(ish);
493 IndexSet<num_verts>& vert_adj(vert_at_subshape_index_set);
496 IndexTree<FaceType> idx_tree(vert_adj.get_index_bound());
497 idx_tree.parse(vert_adj);
501 RisbHelper<Shape_, face_dim_>::compute(ish, idx_tree);
505 template<
typename Shape_>
506 struct RisbWrapper<Shape_, 0>
508 static void wrap(IndexSetHolder<Shape_>& )
523 template<
typename Shape_>
528 static void compute(IndexSetHolder<Shape_>& index_set_holder)
530 Intern::RisbWrapper<Shape_>::wrap(index_set_holder);
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
#define XASSERT(expr)
Assertion macro definition.
Calculates the missing index sets if the vertex-at-shape index sets are given.
static void compute_vertex_subshape(const IndexSetIn_ &index_set_in, IndexSetOut_ &index_set_out)
For given vertex@shape information, numbers subshapes and calculates vertex@subshape.
IndexTree< FaceType > IndexTreeType
Type for the IndexTree containing vertex@subshape information.
Shape::FaceTraits< Shape_, face_dim_ >::ShapeType FaceType
Type of the subshape to calculate the missing information at.
static bool compute(const IndexTreeType &index_tree, const IndexSetIn_ &index_set_in, IndexSetOut_ &index_set_out)
Calculates an index set from vertex@shape information.
static String name()
Returns the class name.
Stores the index representatives of an index set.
RepSetVector _rep_set_vec
representative set vector
std::set< IndexVector > RepSet
Set of IndexVector representatives.
void parse(const IndexSet_ &index_set)
Parses an index set into the tree.
int get_num_indices() const
returns number of indices of an index-representative
static constexpr int num_indices
number of indices per index vector
void insert(const IndexVectorType_ &index_vector, Index id)
Inserts an index vector's representative into the index tree.
static String name()
Returns the class name.
Index get_index(Index i, Index j, int k) const
returns the value of the k-th component of the j-th index-representative in the i-th set
virtual ~IndexTree()
Destructor.
Index enumerate()
Enumerates the index vector representatives.
IndexTree(Index num_vertices)
Constructor.
Index get_set_size(Index i) const
returns size of the i-th representative set
std::vector< RepSet > RepSetVector
Vector of IV rep sets.
std::pair< bool, Index > find(const IndexVectorType_ &index_vector) const
Searches for an index vector within the tree.
Builder for redundant index sets.
static void compute(IndexSetHolder< Shape_ > &index_set_holder)
Routine that does the actual work.
String class implementation.
@ other
generic/other permutation strategy
String stringify(const T_ &item)
Converts an item into a String.
std::uint64_t Index
Index data type.
Face traits tag struct template.