9#include <kernel/space/dof_mapping_base.hpp>
31 int dofs_per_cell_ = 1>
46 return dofs_per_cell_;
52 return this->
_space.get_trafo().get_mesh().get_num_entities(Space_::shape_dim) *
Index(dofs_per_cell_);
82 int dofs_per_cell_ = 1>
93 static constexpr int shape_dim = ShapeType::dimension;
98 static_assert((codim_ >= 0) && (codim_ <=
shape_dim),
"invalid co-dimension");
106 typedef typename MeshType::template IndexSet<shape_dim, dof_dim>::Type
IndexSetType;
123 return IndexSetType::num_indices * dofs_per_cell_;
129 return this->
_space.get_trafo().get_mesh().get_num_entities(dof_dim) *
Index(dofs_per_cell_);
135 int ldi_q = local_dof_idx / dofs_per_cell_;
136 int ldi_r = local_dof_idx % dofs_per_cell_;
165 template<
typename,
int>
class Traits_,
167 int cell_dim_ = Shape_::dimension,
168 int shape_dim_ = Shape_::dimension>
169 struct UniformDofMappingHelper;
189 template<
typename Tag_,
int dim_>
class DofTraits_,
203 static constexpr int dof_count = Intern::UniformDofMappingHelper<ShapeType, DofTraits_, DofTag_>::dof_count;
220 Intern::UniformDofMappingHelper<ShapeType, DofTraits_, DofTag_>
221 ::assemble(
dof_idx, this->
_space.get_mesh(), cell_index, count);
234 return Intern::UniformDofMappingHelper<ShapeType, DofTraits_, DofTag_>::global_count(this->
_space.get_mesh());
240 ASSERTM((local_dof_idx >= 0) && (local_dof_idx < dof_count),
"local dof-index out-of-range");
248 template<
typename Shape_,
template<
typename,
int>
class Traits_,
typename Tag_,
int cell_dim_,
int shape_dim_>
249 struct UniformDofMappingHelper
251 static_assert(cell_dim_ < shape_dim_,
"invalid cell dimension");
255 static constexpr int dofs_per_cell = Traits_<Tag_, cell_dim_>::count;
257 static constexpr int dof_cell_count = cell_count * dofs_per_cell;
259 static constexpr int dof_count = UniformDofMappingHelper<Shape_, Traits_, Tag_, cell_dim_-1>::dof_count + dof_cell_count;
261 template<
typename MeshType_>
264 Index offs(UniformDofMappingHelper<Shape_, Traits_, Tag_, cell_dim_-1>::assemble(dof_idx, mesh, cell, k));
266 const auto& index_set(mesh.template get_index_set<shape_dim_, cell_dim_>());
267 for(
int i(0); i < cell_count; ++i)
269 for(
int j(0); j < dofs_per_cell; ++j, ++k)
271 dof_idx[k] = offs + index_set(cell,i) *
Index(dofs_per_cell) +
Index(j);
274 return offs +
Index(dofs_per_cell) * mesh.get_num_entities(cell_dim_);
277 template<
typename MeshType_>
278 static Index global_count(
const MeshType_& mesh)
280 return UniformDofMappingHelper<Shape_, Traits_, Tag_, cell_dim_-1>::global_count(mesh) +
281 Index(Traits_<Tag_, cell_dim_>::count) * mesh.get_num_entities(cell_dim_);
286 template<
typename Shape_,
template<
typename,
int>
class Traits_,
typename Tag_,
int cell_dim_>
287 struct UniformDofMappingHelper<Shape_, Traits_, Tag_, cell_dim_, cell_dim_>
290 static constexpr int dofs_per_cell = Traits_<Tag_, cell_dim_>::count;
292 static constexpr int dof_cell_count = dofs_per_cell;
294 static constexpr int dof_count = UniformDofMappingHelper<Shape_, Traits_, Tag_, cell_dim_-1>::dof_count + dof_cell_count;
296 template<
typename MeshType_>
297 static Index assemble(Index dof_idx[],
const MeshType_& mesh, Index cell, Index& k)
299 Index offs(UniformDofMappingHelper<Shape_, Traits_, Tag_, cell_dim_-1>::assemble(dof_idx, mesh, cell, k));
301 for(
int j(0); j < dofs_per_cell; ++j, ++k)
303 dof_idx[k] = offs + cell * dofs_per_cell +
Index(j);
305 return offs +
Index(dofs_per_cell) * mesh.get_num_entities(cell_dim_);
308 template<
typename MeshType_>
309 static Index global_count(
const MeshType_& mesh)
311 return UniformDofMappingHelper<Shape_, Traits_, Tag_, cell_dim_-1>::global_count(mesh) +
312 Index(Traits_<Tag_, cell_dim_>::count) * mesh.get_num_entities(cell_dim_);
317 template<
typename Shape_,
template<
typename,
int>
class Traits_,
typename Tag_,
int shape_dim_>
318 struct UniformDofMappingHelper<Shape_, Traits_, Tag_, 0, shape_dim_>
320 static constexpr int cell_count = Shape::FaceTraits<Shape_, 0>::count;
322 static constexpr int dofs_per_cell = Traits_<Tag_, 0>::count;
324 static constexpr int dof_cell_count = cell_count * dofs_per_cell;
326 static constexpr int dof_count = dof_cell_count;
328 template<
typename MeshType_>
329 static Index assemble(Index dof_idx[],
const MeshType_& mesh, Index cell, Index& k)
331 const auto& index_set(mesh.template get_index_set<shape_dim_, 0>());
334 for(
int i(0); i < cell_count; ++i)
336 for(
int j(0); j < dofs_per_cell; ++j, ++k)
338 dof_idx[k] = index_set(cell,i) * dofs_per_cell +
Index(j);
341 return Index(dofs_per_cell) * mesh.get_num_entities(0);
344 template<
typename MeshType_>
345 static Index global_count(
const MeshType_& mesh)
347 return Index(Traits_<Tag_, 0>::count) * mesh.get_num_entities(0);
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Mapping from mesh cells to Dof that have support on them.
const SpaceType & _space
space reference
void prepare(Index cell_index)
Prepares the dof-mapping for a given cell.
Index _cell_index
currently active cell index
Identity-Dof-Mapping base-class template.
Index get_index(int local_dof_idx) const
Returns the mapped dof index.
int get_num_local_dofs() const
Returns the number of local dofs.
DofMappingIdentity(const Space_ &space)
constructor
Index get_num_global_dofs() const
Return the number of global dofs.
DofMappingSingleEntity(const Space_ &space)
constructor
Single-Entity Dof-Mapping class template.
const IndexSetType & _index_set
dofs-at-cell index set reference
int get_num_local_dofs() const
Returns the number of local dofs.
SpaceType::TrafoType TrafoType
trafo type
Space_ SpaceType
space typedef
MeshType::template IndexSet< shape_dim, dof_dim >::Type IndexSetType
index-set type
SpaceType::ShapeType ShapeType
shape type
static constexpr int shape_dim
shape dimension
static constexpr int dof_dim
dof dimension
TrafoType::MeshType MeshType
mesh type
Index get_index(int local_dof_idx) const
Returns the mapped dof index.
DofMappingSingleEntity(const Space_ &space)
constructor
Index get_num_global_dofs() const
Return the number of global dofs.
std::uint64_t Index
Index data type.
Face traits tag struct template.