FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
patch_meshpart_factory.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
9#include <kernel/adjacency/graph.hpp>
10#include <kernel/geometry/mesh_part.hpp>
11
12namespace FEAT
13{
14 namespace Geometry
15 {
25 template<typename MeshType_>
26 class PatchMeshPartFactory : public Factory< MeshPart<MeshType_> >
27 {
28 public:
30 typedef typename MeshType_::ShapeType ShapeType;
34 typedef typename MeshType_::VertexSetType::CoordType AttributeDataType;
42 static constexpr int shape_dim = ShapeType::dimension;
43
44 private:
46 std::vector<Index> _cells_patch;
47
48 public:
58 explicit PatchMeshPartFactory(Index my_rank, const Adjacency::Graph& elems_at_rank)
59 {
60 XASSERT(my_rank < elems_at_rank.get_num_nodes_domain());
61
62 // extract the elements of our rank
63 _cells_patch.reserve(elems_at_rank.degree(my_rank));
64 for(auto it = elems_at_rank.image_begin(my_rank); it != elems_at_rank.image_end(my_rank); ++it)
65 _cells_patch.push_back(*it);
66 }
67
68 explicit PatchMeshPartFactory(std::vector<Index>&& cells_patch) :
69 _cells_patch(std::forward<std::vector<Index>>(cells_patch))
70 {
71 }
72
75 {
76 }
77
81 bool empty() const
82 {
83 return _cells_patch.empty();
84 }
85
95 virtual Index get_num_entities(int dim) override
96 {
97 XASSERT(dim >= 0);
98 XASSERT(dim <= shape_dim);
99 return (dim < shape_dim ? Index(0) : Index(_cells_patch.size()));
100 }
101
110 virtual void fill_attribute_sets(AttributeSetContainer& DOXY(attribute_set_holder)) override
111 {
112 // Do nothing
113 return;
114 }
115
124 virtual void fill_index_sets(std::unique_ptr<IndexSetHolderType>& DOXY(index_set_holder)) override
125 {
126 // Do nothing
127 return;
128 }
129
138 virtual void fill_target_sets(TargetSetHolderType& target_set_holder) override
139 {
140 TargetSet& target_set = target_set_holder.template get_target_set<shape_dim>();
141 for(Index k(0); k < Index(_cells_patch.size()); ++k)
142 target_set[k] = _cells_patch[k];
143 }
144 }; // class PatchMeshPartFactory<MeshPart<...>>
145 } // namespace Geometry
146} // namespace FEAT
#define XASSERT(expr)
Assertion macro definition.
Definition: assertion.hpp:262
Adjacency Graph implementation.
Definition: graph.hpp:34
ImageIterator image_begin(Index domain_node) const
Returns an iterator for the first adjacent image node.
Definition: graph.hpp:958
ImageIterator image_end(Index domain_node) const
Returns an iterator for the first position past the last adjacent image node.
Definition: graph.hpp:966
Index degree(Index domain_node) const
Returns the degree of a domain node.
Definition: graph.hpp:333
Mesh Factory class template.
Definition: factory.hpp:33
Class template for partial meshes.
Definition: mesh_part.hpp:90
TargetSetHolder< ShapeType > TargetSetHolderType
Target set holder type.
Definition: mesh_part.hpp:101
IndexSetHolder< ShapeType > IndexSetHolderType
Index set holder type.
Definition: mesh_part.hpp:99
std::map< String, std::unique_ptr< AttributeSetType > > AttributeSetContainer
submesh node bin container type
Definition: mesh_part.hpp:138
Factory for building a PatchBaseMesh from a given partitioning.
bool empty() const
Checks whether the patch is empty.
MeshPartType::TargetSetHolderType TargetSetHolderType
Target set holder type.
virtual void fill_attribute_sets(AttributeSetContainer &attribute_set_holder) override
Pretends to fill the attribute sets.
virtual void fill_target_sets(TargetSetHolderType &target_set_holder) override
Fills the target sets.
MeshPartType::IndexSetHolderType IndexSetHolderType
Index set holder type.
virtual Index get_num_entities(int dim) override
Returns the number of entities.
MeshType_::VertexSetType::CoordType AttributeDataType
Data type for attributes.
static constexpr int shape_dim
The shape dimension.
MeshPartType::AttributeSetContainer AttributeSetContainer
Mesh attribute holder type.
std::vector< Index > _cells_patch
This will hold all BaseMesh cell numbers of cells present in the patch.
PatchMeshPartFactory(Index my_rank, const Adjacency::Graph &elems_at_rank)
Builds a factory from a given partitioning.
virtual void fill_index_sets(std::unique_ptr< IndexSetHolderType > &index_set_holder) override
Pretends to fill the index sets (=topology)
MeshType_::ShapeType ShapeType
The shape type of the mesh.
virtual ~PatchMeshPartFactory()
virtual destructor
MeshPart< MeshType_ > MeshPartType
Mesh typedef.
Target set class.
Definition: target_set.hpp:27
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.