9#include <kernel/geometry/factory.hpp> 
   10#include <kernel/geometry/conformal_mesh.hpp> 
   11#include <kernel/geometry/structured_mesh.hpp> 
   12#include <kernel/geometry/index_calculator.hpp> 
   13#include <kernel/geometry/attribute_set.hpp> 
   14#include <kernel/geometry/intern/simple_target_refiner.hpp> 
   15#include <kernel/geometry/intern/standard_target_refiner.hpp> 
   16#include <kernel/geometry/intern/structured_target_refiner.hpp> 
   17#include <kernel/geometry/intern/standard_attrib_refiner.hpp> 
   18#include <kernel/geometry/intern/standard_index_refiner.hpp> 
   19#include <kernel/geometry/intern/standard_vertex_refiner.hpp> 
   20#include <kernel/geometry/intern/index_set_filler.hpp> 
   21#include <kernel/geometry/intern/target_set_computer.hpp> 
   88    template<
typename MeshType_>
 
  114      template<
int cell_dim_, 
int face_dim_>
 
  117        static_assert(cell_dim_ <= 
shape_dim, 
"invalid cell dimension");
 
  118        static_assert(face_dim_ < cell_dim_, 
"invalid face/cell dimension");
 
  119        static_assert(face_dim_ >= 0, 
"invalid face dimension");
 
  155      template<
int cell_dim_>
 
  183      explicit MeshPart(
const Index num_entities[], 
bool create_topology = 
false) :
 
  188        for(std::size_t i(0); i <= 
shape_dim; ++i)
 
  207        Intern::NumEntitiesWrapper<shape_dim>::apply(factory, 
_num_entities);
 
  245        this->_num_entities = 
other._num_entities;
 
  247        if(
other._index_set_holder)
 
  249          if(this->_index_set_holder)
 
  250            this->_index_set_holder->clone(*
other._index_set_holder);
 
  254        else if(this->_index_set_holder)
 
  256          this->_index_set_holder.reset();
 
  259        this->_target_set_holder.clone(
other._target_set_holder);
 
  261        this->_mesh_attributes.clear();
 
  263        for(
auto it = 
other._mesh_attributes.begin(); it != 
other._mesh_attributes.end(); ++it)
 
  270        MeshPart mp(this->_num_entities.data(), this->_index_set_holder.get() != 
nullptr);
 
  271        if(this->_index_set_holder)
 
  274        for(
auto it = this->_mesh_attributes.begin(); it != this->_mesh_attributes.end(); ++it)
 
  282        std::size_t my_bytes(0);
 
  286          if(it.second != 
nullptr)
 
  287            my_bytes += it.second->bytes();
 
  376        XASSERTM(
bool(attribute), 
"cannot add empty attribute set");
 
  393      template<
int cell_dim_, 
int face_dim_>
 
  397        return _index_set_holder->template get_index_set_wrapper<cell_dim_>().template get_index_set<face_dim_>();
 
  401      template<
int cell_dim_, 
int face_dim_>
 
  405        return _index_set_holder->template get_index_set_wrapper<cell_dim_>().template get_index_set<face_dim_>();
 
  432      template<
int cell_dim_>
 
  435        static_assert(cell_dim_ >= 0, 
"invalid cell dimension");
 
  436        static_assert(cell_dim_ <= 
shape_dim, 
"invalid cell dimension");
 
  441      template<
int cell_dim_>
 
  444        static_assert(cell_dim_ >= 0, 
"invalid cell dimension");
 
  445        static_assert(cell_dim_ <= 
shape_dim, 
"invalid cell dimension");
 
  474        return "MeshPart<...>";
 
  485        this->_target_set_holder.permute_map(mesh_perm.
get_inv_perms());
 
  503      template<
int end_dim_, 
int current_dim_ = ShapeType::dimension>
 
  506        Intern::template TargetSetComputer<end_dim_, current_dim_>::bottom_to_top(
_target_set_holder, parent_ish);
 
  509        for(
int i(end_dim_); i <= current_dim_; ++i)
 
  528      template<
int end_dim_, 
int current_dim_ = 0>
 
  531        Intern::template TargetSetComputer<end_dim_, current_dim_>::top_to_bottom(
_target_set_holder, parent_ish);
 
  534        for(
int i(current_dim_); i <= end_dim_; ++i)
 
  552        Intern::IndexSetFiller<ShapeType::dimension>::fill_ish(
 
  565    template<
typename MeshType_>
 
  613      virtual void fill_index_sets(std::unique_ptr<IndexSetHolderType>& index_set_holder) = 0;
 
  640        return std::unique_ptr<MeshPartType>(
new MeshPartType(*
this));
 
  647      template<
typename ParentMesh_>
 
  648      struct TargetSetRefineParentWrapper;
 
  658    template<
typename ParentMesh_>
 
  660      public Factory< MeshPart<ParentMesh_> >
 
  677      static constexpr int shape_dim = ShapeType::dimension;
 
  687      Index _num_entities_coarse[shape_dim + 1];
 
  689      Index _num_entities_fine[shape_dim + 1];
 
  705        _coarse_meshpart(coarse_meshpart),
 
  706        _parent_mesh(&parent_mesh),
 
  707        _parent_meshpart(nullptr)
 
  710        for(
int i(0); i <= shape_dim; ++i)
 
  712          _num_entities_fine[i] = _num_entities_coarse[i] = coarse_meshpart.
get_num_entities(i);
 
  716        Intern::EntityCountWrapper<Intern::StandardRefinementTraits, ShapeType>::query(_num_entities_fine);
 
  732        _coarse_meshpart(coarse_meshpart),
 
  733        _parent_mesh(nullptr),
 
  734        _parent_meshpart(&parent_meshpart)
 
  737        for(
int i(0); i <= shape_dim; ++i)
 
  739          _num_entities_fine[i] = _num_entities_coarse[i] = coarse_meshpart.
get_num_entities(i);
 
  743        Intern::EntityCountWrapper<Intern::StandardRefinementTraits, ShapeType>::query(_num_entities_fine);
 
  762        return _num_entities_fine[dim];
 
  781        for(; it != jt; ++it)
 
  784          std::unique_ptr<AttributeType> refined_attribute(
new AttributeType(
 
  785            get_num_entities(0), it->second->get_dimension()));
 
  788          Intern::StandardAttribRefineWrapper<ShapeType, AttributeType>
 
  789            ::refine(*refined_attribute, *(it->second), *_coarse_meshpart.get_topology());
 
  792          XASSERTM(attribute_container.emplace(it->first, std::move(refined_attribute)).second, 
"Error refining attribute " + it->first);
 
  802      virtual void fill_index_sets(std::unique_ptr<IndexSetHolderType>& index_set_holder)
 override 
  804        XASSERT(index_set_holder.get() == 
nullptr);
 
  813        Intern::IndexRefineWrapper<ShapeType>::refine(
 
  814          *index_set_holder, _num_entities_coarse, *_coarse_meshpart.get_topology());
 
  828        if(_parent_mesh != 
nullptr)
 
  831          Intern::TargetSetRefineParentWrapper<ParentMesh_>::fill_target_sets(target_set_holder,
 
  832            _coarse_meshpart.get_target_set_holder(), _coarse_meshpart.get_topology(), *_parent_mesh);
 
  834        else if(_parent_meshpart != 
nullptr)
 
  837          Intern::TargetSetRefineParentWrapper<ParentMesh_>::fill_target_sets(target_set_holder,
 
  838            _coarse_meshpart.get_target_set_holder(), _coarse_meshpart.get_topology(), *_parent_meshpart);
 
  852      template<
typename Shape_, 
int num_coords_, 
typename Coord_>
 
  853      struct TargetSetRefineParentWrapper<ConformalMesh<Shape_, num_coords_, Coord_>>
 
  855        static constexpr int shape_dim = Shape_::dimension;
 
  858        template<
typename TargetSetHolderType_, 
typename IndexSetHolder_, 
typename Parent_>
 
  859        static void fill_target_sets(
 
  860          TargetSetHolderType_& target_set_holder,
 
  861          const TargetSetHolderType_& coarse_target_set_holder,
 
  862          const IndexSetHolder_* coarse_ish,
 
  863          const Parent_& parent)
 
  866          Index num_entities_parent[shape_dim+1];
 
  867          for(
int i(0); i <= shape_dim; ++i)
 
  868            num_entities_parent[i] = parent.get_num_entities(i);
 
  870          if(coarse_ish != 
nullptr)
 
  875            const auto* parent_topo = parent.get_topology();
 
  876            XASSERTM(parent_topo != 
nullptr, 
"mesh-part has topology, but parent doesn't");
 
  877            Intern::TargetRefineWrapper<Shape_>::refine(target_set_holder,
 
  878              num_entities_parent, coarse_target_set_holder, *coarse_ish, *parent_topo);
 
  883            Intern::SimpleTargetRefineWrapper<Shape_>::refine(
 
  884              target_set_holder, num_entities_parent, coarse_target_set_holder);
 
  892      template<
int shape_dim_, 
int num_coords_, 
typename Coord_>
 
  893      struct TargetSetRefineParentWrapper<StructuredMesh<shape_dim_, num_coords_, Coord_>>
 
  895        typedef Shape::Hypercube<shape_dim_> ShapeType;
 
  897        template<
typename TargetSetHolderType_, 
typename IndexSetHolder_>
 
  898        static void fill_target_sets(
 
  899          TargetSetHolderType_& target_set_holder,
 
  900          const TargetSetHolderType_& coarse_target_set_holder,
 
  901          const IndexSetHolder_* coarse_ish,
 
  902          const StructuredMesh<shape_dim_, num_coords_, Coord_>& parent)
 
  905          Index num_slices_c[shape_dim_], num_slices_f[shape_dim_];
 
  906          for(
int i(0); i < shape_dim_; ++i)
 
  908            num_slices_c[i] = 
parent.get_num_slices(i);
 
  909            num_slices_f[i] = 
Index(2) * num_slices_c[i];
 
  912          if(coarse_ish != 
nullptr)
 
  914            XABORTM(
"TargetSetRefineParentWrapper not implemented");
 
  920            Intern::StructuredTargetRefineWrapper<shape_dim_>::refine_simple(
 
  921              target_set_holder, coarse_target_set_holder, num_slices_c, num_slices_f);
 
  929        template<
typename TargetSetHolderType_, 
typename IndexSetHolder_>
 
  930        static void fill_target_sets(
 
  931          TargetSetHolderType_& target_set_holder,
 
  932          const TargetSetHolderType_& coarse_target_set_holder,
 
  933          const IndexSetHolder_* coarse_ish,
 
  934          const MeshPart<StructuredMesh<shape_dim_, num_coords_, Coord_>>& parent)
 
  937          Index num_entities_parent[shape_dim_+1];
 
  938          for(
int i(0); i <= shape_dim_; ++i)
 
  939            num_entities_parent[i] = 
parent.get_num_entities(i);
 
  941          if(coarse_ish != 
nullptr)
 
  946            const auto* parent_topo = 
parent.get_topology();
 
  947            XASSERTM(parent_topo != 
nullptr, 
"mesh-part has topology, but parent doesn't");
 
  948            Intern::TargetRefineWrapper<ShapeType>::refine(target_set_holder,
 
  949              num_entities_parent, coarse_target_set_holder, *coarse_ish, *parent_topo);
 
  954            Intern::SimpleTargetRefineWrapper<ShapeType>::refine(
 
  955              target_set_holder, num_entities_parent, coarse_target_set_holder);
 
  963    extern template class MeshPart<ConformalMesh<Shape::Simplex<2>, 2, 
Real>>;
 
  964    extern template class MeshPart<ConformalMesh<Shape::Simplex<3>, 3, 
Real>>;
 
  965    extern template class MeshPart<ConformalMesh<Shape::Hypercube<2>, 2, 
Real>>;
 
  966    extern template class MeshPart<ConformalMesh<Shape::Hypercube<3>, 3, 
Real>>;
 
  968    extern template class StandardRefinery<MeshPart<ConformalMesh<Shape::Simplex<2>, 2, 
Real>>>;
 
  969    extern template class StandardRefinery<MeshPart<ConformalMesh<Shape::Simplex<3>, 3, 
Real>>>;
 
  970    extern template class StandardRefinery<MeshPart<ConformalMesh<Shape::Hypercube<2>, 2, 
Real>>>;
 
  971    extern template class StandardRefinery<MeshPart<ConformalMesh<Shape::Hypercube<3>, 3, 
Real>>>;
 
#define XABORTM(msg)
Abortion macro definition with custom message.
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Container for saving data related to mesh entities.
MeshPartType make()
Creates a new mesh part and returns it.
virtual ~Factory()
virtual destructor
MeshPartType::AttributeSetContainer AttributeSetContainer
Mesh attribute holder type.
MeshType_::VertexSetType::CoordType AttributeDataType
Data type for attributes.
MeshPartType::IndexSetHolderType IndexSetHolderType
index set holder type
std::unique_ptr< MeshPartType > make_unique()
Creates a new mesh part on the heap and returns a unique pointer to it.
virtual Index get_num_entities(int dim)=0
Returns the number of entities.
MeshPartType::TargetSetHolderType TargetSetHolderType
target set holder type
virtual void fill_target_sets(TargetSetHolderType &target_set_holder)=0
Fills the target sets.
virtual void fill_attribute_sets(AttributeSetContainer &attribute_set_holder)=0
Fills the attribute sets.
virtual void fill_index_sets(std::unique_ptr< IndexSetHolderType > &index_set_holder)=0
Fills the index sets.
MeshPart< MeshType_ > MeshPartType
Mesh typedef.
MeshType_::ShapeType ShapeType
The shape type of the mesh.
Mesh Factory class template.
Conformal Index-Set class template.
Class template for partial meshes.
AttributeSetContainer::iterator AttributeSetIterator
submesh node iterator type
MeshPart(MeshPart &&other)=default
move constructor
AttributeSetContainer::reverse_iterator AttributeSetReverseIterator
submesh node reverse-iterator type
static constexpr int shape_dim
Shape dimension.
AttributeSetType * find_attribute(const String &identifier)
Finds an Attribute by its identifier String and returns a pointer to it.
TargetSet< cell_dim_ >::Type & get_target_set()
Return the reference to a target set.
TargetSetHolderType _target_set_holder
The target sets of the mesh.
MeshPart(Factory< MeshPart > &factory)
Factory constructor.
MeshType::ShapeType ShapeType
Shape type.
int get_num_attributes() const
Returns the total number of Attributes in this MeshPart.
const AttributeSetContainer & get_mesh_attributes() const
Returns a const reference to the mesh attributes container.
void deduct_target_sets_from_bottom(const ParentIndexSetHolderType &parent_ish)
Deducts the target sets from bottom to top.
void deduct_topology(const ParentIndexSetHolderType &parent_ish)
Fills the mesh topology from parent information.
bool has_topology() const
Checks if this MeshPart has a mesh topology.
std::unique_ptr< IndexSetHolderType > _index_set_holder
The index sets of the mesh.
MeshType::IndexSetHolderType ParentIndexSetHolderType
Topology (aka IndexSetHolder) of parent mesh type.
MeshPart(const MeshPart &other)=delete
deleted copy constructor
MeshPart & operator=(const MeshPart &)=delete
deleted copy-assignment operator
TargetSetHolder< ShapeType > TargetSetHolderType
Target set holder type.
MeshPart(const Index num_entities[], bool create_topology=false)
Constructor.
AttributeSet< AttributeDataType > AttributeSetType
Type for mesh attributes.
AttributeSetContainer _mesh_attributes
The attribute sets of the mesh.
MeshType_ MeshType
parent Mesh type
std::array< Index, shape_dim+1 > _num_entities
Number of entities for each shape dimension.
static String name()
Returns the name of the class.
IndexSet< cell_dim_, face_dim_ >::Type & get_index_set()
Returns the reference to an index set.
IndexSetHolder< ShapeType > IndexSetHolderType
Index set holder type.
const AttributeSetType * find_attribute(const String &identifier) const
Finds an Attribute by its identifier String and returns a pointer to it.
AttributeSetContainer::const_iterator AttributeSetConstIterator
submesh node const-iterator type
Index get_num_entities(int dim) const
Returns the number of entities.
virtual ~MeshPart()
Virtual destructor.
const IndexSet< cell_dim_, face_dim_ >::Type & get_index_set() const
Returns the reference to an index set.
std::map< String, std::unique_ptr< AttributeSetType > > AttributeSetContainer
submesh node bin container type
MeshType::VertexSetType::CoordType AttributeDataType
Data type for attributes.
std::size_t bytes() const
const TargetSet< cell_dim_ >::Type & get_target_set() const
Return the reference to a target set.
virtual bool add_attribute(std::unique_ptr< AttributeSetType > attribute, const String &identifier)
Copies one attribute to this MeshPart's AttributeHolder.
void deduct_target_sets_from_top(const ParentIndexSetHolderType &parent_ish)
Deducts the target sets from top to bottom.
void clone(const MeshPart &other)
Clones another mesh part object into this object.
MeshPart & operator=(MeshPart &&other)=default
move-assignment operator
void permute(const MeshPermutation< ShapeType > &mesh_perm)
Applies a mesh permutation onto this mesh part's target sets.
Mesh permutation class template.
const PermArray & get_inv_perms() const
static void compute(IndexSetHolder< Shape_ > &index_set_holder)
Routine that does the actual work.
StandardRefinery(const MeshType &coarse_meshpart, const MeshPart< ParentMesh_ > &parent_meshpart)
Constructor.
MeshPart< ParentMesh_ > MeshType
mesh type
virtual void fill_attribute_sets(AttributeSetContainer &attribute_container) override
Fills attribute sets where applicable.
StandardRefinery(const MeshType &coarse_meshpart, const ParentMesh_ &parent_mesh)
Constructor.
virtual ~StandardRefinery()
virtual destructor
MeshType::TargetSetHolderType TargetSetHolderType
target set holder type
virtual Index get_num_entities(int dim) override
Returns the number of entities of the refined mesh.
virtual void fill_index_sets(std::unique_ptr< IndexSetHolderType > &index_set_holder) override
Fills the index sets.
MeshType::ShapeType ShapeType
shape type
MeshType::AttributeSetType AttributeType
Attribute set type.
virtual void fill_target_sets(TargetSetHolderType &target_set_holder) override
Fills the target sets.
MeshType::IndexSetHolderType IndexSetHolderType
index set holder type
const MeshType * _parent_meshpart
coarse parent mesh-part reference
MeshType::AttributeSetContainer AttributeSetContainer
index set holder type
const ParentMesh_ * _parent_mesh
coarse parent mesh reference
const MeshType & _coarse_meshpart
coarse mesh reference
Standard Refinery class template.
String class implementation.
@ parent
indicates that the level is a parent level
@ other
generic/other permutation strategy
double Real
Real data type.
std::uint64_t Index
Index data type.
Index set type class template.
FEAT::Geometry::IndexSet< Shape::FaceTraits< typename Shape::FaceTraits< ShapeType, cell_dim_ >::ShapeType, face_dim_ >::count > Type
Index set type.
Target set type class template.
FEAT::Geometry::TargetSet Type
Target set type.
Face traits tag struct template.