9#include <kernel/geometry/index_set.hpp>
10#include <kernel/shape.hpp>
16 namespace VoxelAssembly
21 template<
typename SpaceType_,
int target_dim_>
24 template<
int target_dim>
27 static constexpr int dof_per_entity = 1;
30 template<
int target_dim>
33 static constexpr int dof_per_entity = 1;
36 template<
int num_indices>
42 std::sort(begin, end);
52 template<
typename Space_,
typename IT_,
int tar_dim = 0,
int prior_ents = 0>
55 constexpr int dim = Space_::shape_dim;
56 constexpr int dof_per_cell = Space_::DofMappingType::dof_count;
58 const auto& mesh = space.get_mesh();
59 const auto& index_set = mesh.template get_index_set<dim, tar_dim>();
63 for(
Index ent = 0; ent < index_set.get_num_entities(); ++ent)
65 const auto ind_arr = index_set[ent];
66 IT_* tmp_ctd = ctd + ent * dof_per_cell;
67 for(
Index i = 0; i < ind_arr.num_indices; ++i)
69 for(IT_ j = 0; j < IT_(dof_per_entity); ++j)
71 tmp_ctd[i*IT_(dof_per_entity) + j + IT_(prior_ents)] = offset + IT_(dof_per_entity) * IT_(ind_arr[
int(i)]) + j;
75 offset += IT_(mesh.get_num_entities(tar_dim)*dof_per_entity);
76 if constexpr(tar_dim < (dim-1))
78 constexpr int new_prior_ents = prior_ents + num_indices*dof_per_entity;
79 fill_cell_to_dof<Space_, IT_, tar_dim+1, new_prior_ents>(ctd, space, offset);
81 else if constexpr(tar_dim == (dim-1))
84 for(
Index ent = 0; ent < index_set.get_num_entities(); ++ent)
86 IT_* tmp_ctd = ctd + (ent+1)*dof_per_cell - shape_dim_dofs_per;
87 for(
int j = 0; j < shape_dim_dofs_per; ++j)
88 tmp_ctd[j] = IT_(ent)*IT_(shape_dim_dofs_per) + IT_(j) + offset;
93 XABORTM(
"Thou shallt not arrive here!");
97 template<
typename Space_,
typename IT_>
98 void fill_sorter(IT_* sorter,
const IT_* mapping,
const Space_& space)
100 constexpr int num_loc_dofs = Space_::DofMappingType::dof_count;
101 for(
Index cell = 0; cell < space.get_mesh().get_num_entities(Space_::world_dim); ++cell)
104 const Index begin = cell*num_loc_dofs;
105 const Index end = (cell+1)*num_loc_dofs;
106 const IT_* loc_map = mapping + begin;
107 std::generate(sorter+begin, sorter+end, [n=0]()
mutable{
return n++;});
108 std::sort(sorter+begin, sorter+end, [loc_map](IT_ va, IT_ vb){
return loc_map[va] < loc_map[vb];});
#define XABORTM(msg)
Abortion macro definition with custom message.
Standard Lagrange-2 Finite-Element space class template.
void fill_cell_to_dof(IT_ *ctd, const Space_ &space, IT_ offset=0)
Computes a sequentialized dof mapping for the given space.
std::uint64_t Index
Index data type.
Index Tuple class template.
Index indices[num_indices]
indices array
Face traits tag struct template.
Prescribes the number of dofs per dimension for a given space.