9#include <kernel/assembly/base.hpp>
10#include <kernel/analytic/function.hpp>
11#include <kernel/lafem/unit_filter.hpp>
12#include <kernel/lafem/unit_filter_blocked.hpp>
13#include <kernel/lafem/dense_vector.hpp>
14#include <kernel/geometry/mesh_part.hpp>
29 template<
int shape_dim_>
30 struct UnitAsmWrapper;
42 template<
typename Mesh_>
51 static constexpr int shape_dim = MeshType::shape_dim;
75 Intern::UnitAsmWrapper<shape_dim>::merge(
_cells, mesh_part);
90 template<
typename DataType_,
typename IndexType_,
typename Space_>
94 std::set<Index> idx_set;
95 Intern::UnitAsmWrapper<shape_dim>::assemble(idx_set, space,
_cells);
98 if(filter.size() ==
Index(0))
104 typename std::set<Index>::const_iterator it(idx_set.begin());
105 typename std::set<Index>::const_iterator jt(idx_set.end());
106 for(
Index i(0); it != jt; ++it, ++i)
109 filter.add(IndexType_(*it), DataType_(0));
128 template<
typename DataType_,
typename IndexType_,
typename Space_>
135 std::set<Index> idx_set;
136 Intern::UnitAsmWrapper<shape_dim>::assemble(idx_set, space,
_cells);
139 if(filter.size() ==
Index(0))
145 typename std::set<Index>::const_iterator it(idx_set.begin());
146 typename std::set<Index>::const_iterator jt(idx_set.end());
147 for(
Index i(0); it != jt; ++it, ++i)
150 filter.add(IndexType_(*it), vector_(IndexType_(*it)));
178 const Function_& function)
const
181 typedef typename Function_::ImageType FuncImageType;
182 static_assert(FuncImageType::is_scalar,
"only scalar functions are supported");
185 std::map<Index, DataType_> idx_map;
186 Intern::UnitAsmWrapper<shape_dim>::assemble(idx_map, space,
_cells, function);
189 if(filter.size() ==
Index(0))
195 typename std::map<Index, DataType_>::const_iterator it(idx_map.begin());
196 typename std::map<Index, DataType_>::const_iterator jt(idx_map.end());
197 for(
Index i(0); it != jt; ++it, ++i)
200 filter.add(IndexType_(it->first), it->second);
215 template<
typename DataType_,
typename IndexType_,
int BlockSize_,
typename Space_>
218 const Space_& space)
const
221 std::set<Index> idx_set;
222 Intern::UnitAsmWrapper<shape_dim>::assemble(idx_set, space,
_cells);
225 if (filter.size() ==
Index(0))
231 typename std::set<Index>::const_iterator it(idx_set.begin());
232 typename std::set<Index>::const_iterator jt(idx_set.end());
234 for(
Index i(0); it != jt; ++it, ++i)
237 filter.add(IndexType_(*it), tmp);
256 template<
typename DataType_,
typename IndexType_,
int BlockSize_,
typename Space_,
typename Function_>
260 const Function_& function)
const
263 typedef typename Function_::ImageType FuncImageType;
264 static_assert(FuncImageType::is_vector,
"only vector fields are supported");
265 static_assert(FuncImageType::image_dim == BlockSize_,
"invalid filter block size");
271 std::map<Index, ValueType> idx_map;
272 Intern::UnitAsmWrapper<shape_dim>::assemble(idx_map, space,
_cells, function);
275 if (filter.size() ==
Index(0))
281 auto it(idx_map.begin());
282 auto jt(idx_map.end());
283 for(
Index i(0); it != jt; ++it, ++i)
286 filter.add(IndexType_(it->first), it->second);
305 template<
typename DTF_,
typename ITF_,
typename DTV_,
typename ITV_,
int BlockSize_,
typename Space_>
312 std::set<Index> idx_set;
313 Intern::UnitAsmWrapper<shape_dim>::assemble(idx_set, space,
_cells);
316 if (filter.size() ==
Index(0))
322 typename std::set<Index>::const_iterator it(idx_set.begin());
323 typename std::set<Index>::const_iterator jt(idx_set.end());
324 for(
Index i(0); it != jt; ++it, ++i)
327 filter.add(ITF_(*it), vector_(ITV_(*it)));
336 template<
int shape_dim_>
339 template<
typename MeshPart_>
340 static void merge(std::set<Index>& idx,
const MeshPart_& mesh_part)
343 const typename MeshPart_::template TargetSet<shape_dim_>::Type&
344 target_set(mesh_part.template get_target_set<shape_dim_>());
347 const Index num_entities = target_set.get_num_entities();
348 for(
Index i(0); i < num_entities; ++i)
350 idx.insert(target_set[i]);
355 template<
typename Space_>
356 static void assemble(std::set<Index>& idx,
const Space_& space,
const std::set<Index>& cells)
359 typename Space_::template DofAssignment<shape_dim_>::Type dof_assign(space);
362 std::set<Index>::const_iterator it(cells.begin());
363 std::set<Index>::const_iterator jt(cells.end());
364 for(; it != jt; ++it)
366 dof_assign.prepare(*it);
367 const int num_assign(dof_assign.get_num_assigned_dofs());
368 for(
int j(0); j < num_assign; ++j)
370 idx.insert(dof_assign.get_index(j));
381 static void assemble(
382 std::map<Index, DataType_>& idx,
384 const std::set<Index>& cells,
385 const Function_& function)
388 typedef typename Space_::template NodeFunctional<shape_dim_, DataType_>::Type NodeFunc;
391 static constexpr Index max_dofs = NodeFunc::max_assigned_dofs;
396 NodeFunc node_func(space);
399 typename Space_::template DofAssignment<shape_dim_, DataType_>::Type dof_assign(space);
402 Tiny::Vector<DataType_, max_dofs+1> node_data;
405 std::set<Index>::const_iterator it(cells.begin());
406 std::set<Index>::const_iterator jt(cells.end());
407 for(; it != jt; ++it)
409 node_func.prepare(*it);
410 node_func(node_data, function);
413 dof_assign.prepare(*it);
415 const int num_assign(dof_assign.get_num_assigned_dofs());
416 for(
int j(0); j < num_assign; ++j)
418 idx.insert(std::make_pair(dof_assign.get_index(j), node_data[j]));
431 static void assemble(
432 std::map<Index, Tiny::Vector<DataType_, dim_, s_>>& idx,
434 const std::set<Index>& cells,
435 const Function_& function)
438 typedef typename Space_::template NodeFunctional<shape_dim_, DataType_>::Type NodeFunc;
441 static constexpr Index max_dofs = NodeFunc::max_assigned_dofs;
446 NodeFunc node_func(space);
449 typename Space_::template DofAssignment<shape_dim_, DataType_>::Type dof_assign(space);
451 typedef Tiny::Vector<DataType_, dim_, s_> ValueType;
454 Tiny::Vector<ValueType, max_dofs+1> node_data;
457 std::set<Index>::const_iterator it(cells.begin());
458 std::set<Index>::const_iterator jt(cells.end());
459 for(; it != jt; ++it)
461 node_func.prepare(*it);
462 node_func(node_data, function);
465 dof_assign.prepare(*it);
467 const int num_assign(dof_assign.get_num_assigned_dofs());
468 for(
int j(0); j < num_assign; ++j)
470 idx.insert(std::make_pair(dof_assign.get_index(j), node_data[j]));
478 template<
int shape_dim_>
479 struct UnitAsmWrapper
481 template<
typename MeshPart_>
482 static void merge(std::set<Index>* idx,
const MeshPart_& mesh_part)
484 UnitAsmWrapper<shape_dim_ - 1>::merge(idx, mesh_part);
485 UnitAsmHelper<shape_dim_>::merge(idx[shape_dim_], mesh_part);
488 template<
typename Space_>
489 static void assemble(std::set<Index>& idx,
const Space_& space,
const std::set<Index>* cells)
491 UnitAsmWrapper<shape_dim_ - 1>::assemble(idx, space, cells);
492 UnitAsmHelper<shape_dim_>::assemble(idx, space, cells[shape_dim_]);
499 static void assemble(
500 std::map<Index, DataType_>& idx,
502 const std::set<Index>* cells,
503 const Function_& function)
505 UnitAsmWrapper<shape_dim_ - 1>::assemble(idx, space, cells, function);
506 UnitAsmHelper<shape_dim_>::assemble(idx, space, cells[shape_dim_], function);
511 struct UnitAsmWrapper<0>
513 template<
typename MeshPart_>
514 static void merge(std::set<Index>* idx,
const MeshPart_& mesh_part)
516 UnitAsmHelper<0>::merge(idx[0], mesh_part);
519 template<
typename Space_>
520 static void assemble(std::set<Index>& idx,
const Space_& space,
const std::set<Index>* cells)
522 UnitAsmHelper<0>::assemble(idx, space, cells[0]);
529 static void assemble(
530 std::map<Index, DataType_>& idx,
532 const std::set<Index>* cells,
533 const Function_& function)
535 UnitAsmHelper<0>::assemble(idx, space, cells[0], function);
Unit-Filter assembly class template.
void add_mesh_part(const Geometry::MeshPart< MeshType > &mesh_part)
Adds the dofs on a mesh-part to the dof-set.
void assemble(LAFEM::UnitFilter< DataType_, IndexType_ > &filter, const Space_ &space) const
Builds a homogeneous unit-filter.
IdxSet _cells[shape_dim+1]
dof-index set
std::set< Index > IdxSet
dof-index set typedef
void assemble(LAFEM::UnitFilterBlocked< DTF_, ITF_, BlockSize_ > &filter, const Space_ &space, const LAFEM::DenseVectorBlocked< DTV_, ITV_, BlockSize_ > &vector_) const
Builds an inhomogeneous blocked unit filter.
void assemble(LAFEM::UnitFilter< DataType_, IndexType_ > &filter, const Space_ &space, const Function_ &function) const
Builds an (inhomogeneous) unit-filter.
void assemble(LAFEM::UnitFilterBlocked< DataType_, IndexType_, BlockSize_ > &filter, const Space_ &space, const Function_ &function) const
Builds an inhomogeneous blocked unit filter.
void assemble(LAFEM::UnitFilter< DataType_, IndexType_ > &filter, const Space_ &space, const LAFEM::DenseVector< DataType_, IndexType_ > &vector_) const
Builds an inhomogeneous unit-filter.
static constexpr int shape_dim
shape dimension
void assemble(LAFEM::UnitFilterBlocked< DataType_, IndexType_, BlockSize_ > &filter, const Space_ &space) const
Builds a homogeneous blocked unit filter.
Class template for partial meshes.
Blocked Dense data vector class template.
Dense data vector class template.
Unit Filter Blocked class template.
Unit Filter class template.
Tiny Vector class template.
IntersectionData< DT_ > merge(const IntersectionData< DT_ > &a, const IntersectionData< DT_ > &b)
Merge two intersection datas.
std::uint64_t Index
Index data type.