OGS
MeshComponentMap.h
Go to the documentation of this file.
1 
13 #pragma once
14 
16 #include "MeshLib/MeshSubset.h"
17 #include "numlib_export.h"
18 
19 namespace NumLib
20 {
22 enum class ComponentOrder
23 {
24  BY_COMPONENT,
26 };
27 
29 class MeshComponentMap final
30 {
31 public:
33 
34 public:
37  MeshComponentMap(std::vector<MeshLib::MeshSubset> const& components,
38  ComponentOrder order);
39 
53  std::vector<MeshLib::MeshSubset> const& bulk_mesh_subsets,
54  MeshLib::MeshSubset const& new_mesh_subset,
55  std::vector<int> const& new_global_component_ids) const;
56 
58  std::size_t dofSizeWithGhosts() const { return _dict.size(); }
59 
67  std::vector<int> getComponentIDs(const Location& l) const;
68 
74  GlobalIndexType getGlobalIndex(Location const& l, int const comp_id) const;
75 
86  std::vector<GlobalIndexType> getGlobalIndices(const Location& l) const;
87 
101  std::vector<GlobalIndexType> getGlobalIndicesByLocation(
102  const std::vector<Location>& ls) const;
103 
116  std::vector<GlobalIndexType> getGlobalIndicesByComponent(
117  const std::vector<Location>& ls) const;
118 
121  std::size_t dofSizeWithoutGhosts() const { return _num_local_dof; }
122 
124  std::vector<GlobalIndexType> const& getGhostIndices() const
125  {
126  return _ghosts_indices;
127  }
128 
134  GlobalIndexType getLocalIndex(Location const& l, int const comp_id,
135  std::size_t const range_begin,
136  std::size_t const range_end) const;
137 
141 
142 #ifndef NDEBUG
144  {
145  return _dict;
146  }
147 
148  friend std::ostream& operator<<(std::ostream& os, MeshComponentMap const& m)
149  {
150  os << "Dictionary size: " << m._dict.size() << "\n";
151  for (auto l : m._dict)
152  os << l << "\n";
153  return os;
154  }
155 #endif // NDEBUG
156 
157 private:
160  : _dict(dict)
161  {
162  }
163 
168  detail::Line getLine(Location const& l, int const comp_id) const;
169 
170  void renumberByLocation(GlobalIndexType offset = 0);
171 
173 
176  std::size_t _num_local_dof = 0;
177 
178 #ifdef USE_PETSC
180  std::size_t _num_global_dof = 0;
181 #endif
182 
184  std::vector<GlobalIndexType> _ghosts_indices;
185 
189  std::vector<MeshLib::MeshSubset> const& components,
190  ComponentOrder order);
191 
192 #ifdef USE_PETSC
196  std::vector<MeshLib::MeshSubset> const& components,
197  ComponentOrder order);
198 #endif
199 };
200 
201 } // namespace NumLib
GlobalMatrix::IndexType GlobalIndexType
A subset of nodes on a single mesh.
Definition: MeshSubset.h:26
Multidirectional mapping between mesh entities and degrees of freedom.
std::size_t dofSizeWithoutGhosts() const
void createParallelMeshComponentMap(std::vector< MeshLib::MeshSubset > const &components, ComponentOrder order)
std::vector< int > getComponentIDs(const Location &l) const
MeshLib::Location Location
friend std::ostream & operator<<(std::ostream &os, MeshComponentMap const &m)
std::size_t _num_global_dof
Number of global unknowns. Used internally only.
MeshComponentMap(std::vector< MeshLib::MeshSubset > const &components, ComponentOrder order)
GlobalIndexType getGlobalIndex(Location const &l, int const comp_id) const
detail::Line getLine(Location const &l, int const comp_id) const
GlobalIndexType getLocalIndex(Location const &l, int const comp_id, std::size_t const range_begin, std::size_t const range_end) const
detail::ComponentGlobalIndexDict _dict
std::vector< GlobalIndexType > getGlobalIndices(const Location &l) const
std::vector< GlobalIndexType > const & getGhostIndices() const
Get ghost indices (for DDC).
MeshComponentMap getSubset(std::vector< MeshLib::MeshSubset > const &bulk_mesh_subsets, MeshLib::MeshSubset const &new_mesh_subset, std::vector< int > const &new_global_component_ids) const
MeshComponentMap(detail::ComponentGlobalIndexDict &dict)
Private constructor used by internally created mesh component maps.
void renumberByLocation(GlobalIndexType offset=0)
static NUMLIB_EXPORT GlobalIndexType const nop
std::size_t dofSizeWithGhosts() const
The number of dofs including the those located in the ghost nodes.
std::vector< GlobalIndexType > _ghosts_indices
Global ID for ghost entries.
std::vector< GlobalIndexType > getGlobalIndicesByComponent(const std::vector< Location > &ls) const
void createSerialMeshComponentMap(std::vector< MeshLib::MeshSubset > const &components, ComponentOrder order)
const detail::ComponentGlobalIndexDict & getDictionary() const
std::vector< GlobalIndexType > getGlobalIndicesByLocation(const std::vector< Location > &ls) const
Location
Definition: Polyline.h:33
boost::multi_index::multi_index_container< Line, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< ByLocationAndComponent >, boost::multi_index::identity< Line >, LineByLocationAndComponentComparator >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ByLocation >, boost::multi_index::identity< Line >, LineByLocationComparator >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ByComponent >, boost::multi_index::member< Line, int, &Line::comp_id > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ByGlobalIndex >, boost::multi_index::member< Line, GlobalIndexType, &Line::global_index > >> > ComponentGlobalIndexDict
ComponentOrder
Ordering of components in global matrix/vector.
@ BY_LOCATION
Ordering data by spatial location.
@ BY_COMPONENT
Ordering data by component type.
#define NUMLIB_EXPORT
Definition: numlib_export.h:15