GEOS
DofManager.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2019 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2019 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2019 Total, S.A
8  * Copyright (c) 2019- GEOS/GEOSX Contributors
9  * All right reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOS_LINEARALGEBRA_MULTISCALE_DOFMANAGER_HPP
20 #define GEOS_LINEARALGEBRA_MULTISCALE_DOFMANAGER_HPP
21 
23 
24 namespace geos
25 {
26 namespace multiscale
27 {
28 
29 class MeshObjectManager;
30 
37 {
38 public:
39 
45  explicit DofManager( string name );
46 
50  DofManager( DofManager const & ) = delete;
51 
55  DofManager( DofManager && ) = default;
56 
61  DofManager & operator=( DofManager const & ) = delete;
62 
67  DofManager & operator=( DofManager && ) = default;
68 
72  void clear();
73 
79 
86  void addField( string const & fieldName,
87  integer const components,
89 
93  void reorderByRank();
94 
99  {
100  return m_fields.size();
101  }
102 
108  bool fieldExists( string const & name ) const;
109 
115  string const & key( string const & fieldName ) const;
116 
121  globalIndex numGlobalDofs( string const & fieldName ) const;
122 
127 
132  localIndex numLocalDofs( string const & fieldName ) const;
133 
138 
143  localIndex localOffset( string const & fieldName ) const;
144 
149  globalIndex rankOffset( string const & fieldName ) const;
150 
155 
160  integer numComponents( string const & fieldName ) const;
161 
166 
171  globalIndex globalOffset( string const & fieldName ) const;
172 
177  MeshObjectManager const & manager( string const & fieldName ) const;
178 
182  DomainPartition & domain() { return *m_domain; }
183 
195  template< typename MATRIX >
196  void makeRestrictor( string const & fieldName,
197  MPI_Comm const & comm,
198  bool transpose,
199  MATRIX & restrictor ) const;
200 
201 private:
202 
206  struct FieldDescription
207  {
208  string name;
209  string key;
211  integer numComponents = 1;
212  localIndex numLocalDof = 0;
213  localIndex localOffset = 0;
214  globalIndex numGlobalDof = 0;
215  globalIndex blockOffset = 0;
216  globalIndex rankOffset = 0;
218  };
219 
223  FieldDescription const & getField( string const & name ) const;
224 
229  void createIndexArray( FieldDescription const & field );
230 
232  string m_name;
233 
235  DomainPartition * m_domain = nullptr;
236 
238  std::vector< FieldDescription > m_fields;
239 
241  bool m_reordered = false;
242 };
243 
244 } // multiscale
245 } // geos
246 
247 #endif //GEOS_LINEARALGEBRA_MULTISCALE_DOFMANAGER_HPP
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
Degree-of-freedom manager that works with multiscale mesh levels.
Definition: DofManager.hpp:37
integer numComponents(string const &fieldName) const
DofManager(DofManager const &)=delete
Deleted copy constructor.
globalIndex numGlobalDofs(string const &fieldName) const
string const & key(string const &fieldName) const
Return the key used to record the field in the DofManager.
globalIndex rankOffset() const
integer numComponents() const
globalIndex globalOffset(string const &fieldName) const
void reorderByRank()
Finish populating fields and apply appropriate dof renumbering.
void clear()
Remove all previously added fields.
std::size_t numFields() const
Definition: DofManager.hpp:98
void makeRestrictor(string const &fieldName, MPI_Comm const &comm, bool transpose, MATRIX &restrictor) const
Create a matrix that restricts vectors and matrices to a subset of DOFs.
MeshObjectManager const & manager(string const &fieldName) const
DofManager & operator=(DofManager &&)=default
Defaulted move assignment.
void setDomain(DomainPartition &domain)
Assign a domain.
localIndex localOffset(string const &fieldName) const
DofManager(DofManager &&)=default
Move constructor.
globalIndex rankOffset(string const &fieldName) const
void addField(string const &fieldName, integer const components, MeshObjectManager &manager)
Add a field.
localIndex numLocalDofs() const
localIndex numLocalDofs(string const &fieldName) const
bool fieldExists(string const &name) const
Check if string key is already being used.
DofManager(string name)
Constructor.
DofManager & operator=(DofManager const &)=delete
Deleted copy assignment.
DomainPartition & domain()
Definition: DofManager.hpp:182
globalIndex numGlobalDofs() const
Mesh object manager used in multiscale preconditioners to keep a simplified (node/cell only) represen...
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
std::size_t size_t
Unsigned size type.
Definition: DataTypes.hpp:78
int integer
Signed integer type.
Definition: DataTypes.hpp:81