MueLu  Version of the Day
MueLu_IndexManager_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Ray Tuminaro (rstumin@sandia.gov)
41 // Luc Berger-Vergiat (lberge@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef MUELU_INDEXMANAGER_DECL_HPP
47 #define MUELU_INDEXMANAGER_DECL_HPP
48 
49 // use for Teuchos:Comm<T>
50 #include "Teuchos_CommHelpers.hpp"
51 #include "Teuchos_OrdinalTraits.hpp"
52 
53 #include <Xpetra_Map_fwd.hpp>
54 #include <Xpetra_Vector_fwd.hpp>
55 #include <Xpetra_VectorFactory_fwd.hpp>
56 
57 #include "MueLu_ConfigDefs.hpp"
58 #include "MueLu_BaseClass.hpp"
60 
61 /*****************************************************************************
62 
63 ****************************************************************************/
64 
65 namespace MueLu {
66 
80  template <class LocalOrdinal, class GlobalOrdinal, class Node>
81  class IndexManager : public BaseClass {
82 #undef MUELU_INDEXMANAGER_SHORT
84 
85  private:
86 
87  protected:
88 
89  const RCP<const Teuchos::Comm<int> > comm_;
90  const bool coupled_;
91  const int numDimensions;
92  const int interpolationOrder_;
93 
94  Array<int> coarseRate;
95  Array<int> endRate;
96 
99  const Array<GO> gFineNodesPerDir;
100 
103  const Array<LO> lFineNodesPerDir;
104 
107  Array<GO> gCoarseNodesPerDir;
108 
111  Array<LO> lCoarseNodesPerDir;
112 
116  Array<LO> ghostedNodesPerDir;
117 
119  Array<LO> offsets;
120  Array<LO> coarseNodeOffsets;
121  Array<GO> startIndices;
123 
124  bool meshEdge[6] = {false};
125  bool ghostInterface[6] = {false};
126  bool ghostedDir[6] = {false};
127 
128  public:
129 
130  IndexManager() = default;
131 
132  IndexManager(const RCP<const Teuchos::Comm<int> > comm, const bool coupled, const int NumDimensions,
133  const int interpolationOrder, const Array<GO> GFineNodesPerDir,
134  const Array<LO> LFineNodesPerDir);
135 
136  virtual ~IndexManager() {}
137 
140  void computeMeshParameters();
141 
142  virtual void computeGlobalCoarseParameters() = 0;
143 
144  virtual void getGhostedNodesData(const RCP<const Map> fineMap,
145  Array<LO>& ghostedNodeCoarseLIDs,
146  Array<int>& ghostedNodeCoarsePIDs,
147  Array<GO>& ghostedNodeCoarseGIDs) const = 0;
148 
149  virtual void getCoarseNodesData(const RCP<const Map> fineCoordinatesMap,
150  Array<GO>& coarseNodeCoarseGIDs,
151  Array<GO>& coarseNodeFineGIDs) const = 0;
152 
153  bool isAggregationCoupled() const {return coupled_;}
154 
155  int getNumDimensions() const {return numDimensions;}
156 
158 
160 
162 
163  LO getNumLocalFineNodes() const {return lNumFineNodes;}
164 
166 
168 
169  Array<int> getCoarseningRates() const {return coarseRate;}
170 
171  int getCoarseningRate(const int dim) const {return coarseRate[dim];}
172 
173  Array<int> getCoarseningEndRates() const {return endRate;}
174 
175  int getCoarseningEndRate(const int dim) const {return endRate[dim];}
176 
177  bool getMeshEdge(const int dir) const {return meshEdge[dir];}
178 
179  bool getGhostInterface(const int dir) const {return ghostInterface[dir];}
180 
181  Array<LO> getOffsets() const {return offsets;}
182 
183  LO getOffset(int const dim) const {return offsets[dim];}
184 
185  Array<LO> getCoarseNodeOffsets() const {return coarseNodeOffsets;}
186 
187  LO getCoarseNodeOffset(int const dim) const {return coarseNodeOffsets[dim];}
188 
189  Array<GO> getStartIndices() const {return startIndices;}
190 
191  GO getStartIndex(int const dim) const {return startIndices[dim];}
192 
194 
195  GO getStartGhostedCoarseNode(int const dim) const {return startGhostedCoarseNode[dim];}
196 
197  Array<LO> getLocalFineNodesPerDir() const {return lFineNodesPerDir;}
198 
199  LO getLocalFineNodesInDir(const int dim) const {return lFineNodesPerDir[dim];}
200 
201  Array<GO> getGlobalFineNodesPerDir() const {return gFineNodesPerDir;}
202 
203  GO getGlobalFineNodesInDir(const int dim) const {return gFineNodesPerDir[dim];}
204 
205  Array<LO> getLocalCoarseNodesPerDir() const {return lCoarseNodesPerDir;}
206 
207  LO getLocalCoarseNodesInDir(const int dim) const {return lCoarseNodesPerDir[dim];}
208 
209  Array<GO> getGlobalCoarseNodesPerDir() const {return gCoarseNodesPerDir;}
210 
211  GO getGlobalCoarseNodesInDir(const int dim) const {return gCoarseNodesPerDir[dim];}
212 
213  Array<LO> getGhostedNodesPerDir() const {return ghostedNodesPerDir;}
214 
215  LO getGhostedNodesInDir(const int dim) const {return ghostedNodesPerDir[dim];}
216 
217  virtual std::vector<std::vector<GO> > getCoarseMeshData() const = 0;
218 
219  virtual void getFineNodeGlobalTuple(const GO myGID, GO& i, GO& j, GO& k) const = 0;
220 
221  virtual void getFineNodeLocalTuple(const LO myLID, LO& i, LO& j, LO& k) const = 0;
222 
223  virtual void getFineNodeGhostedTuple(const LO myLID, LO& i, LO& j, LO& k) const = 0;
224 
225  virtual void getFineNodeGID(const GO i, const GO j, const GO k, GO& myGID) const = 0;
226 
227  virtual void getFineNodeLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
228 
229  virtual void getCoarseNodeGlobalTuple(const GO myGID, GO& i, GO& j, GO& k) const = 0;
230 
231  virtual void getCoarseNodeLocalTuple(const LO myLID, LO& i, LO& j, LO& k) const = 0;
232 
233  virtual void getCoarseNodeGID(const GO i, const GO j, const GO k, GO& myGID) const = 0;
234 
235  virtual void getCoarseNodeLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
236 
237  virtual void getCoarseNodeGhostedLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
238 
239  virtual void getCoarseNodeFineLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
240 
241  virtual void getGhostedNodeFineLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
242 
243  virtual void getGhostedNodeCoarseLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
244 
245  };
246 
247 } //namespace MueLu
248 
249 #define MUELU_INDEXMANAGER_SHORT
250 #endif // MUELU_INDEXMANAGER_DECL_HPP
MueLu_ConfigDefs.hpp
MueLu::IndexManager::endRate
Array< int > endRate
adapted coarsening rate at the edge of the mesh in each direction.
Definition: MueLu_IndexManager_decl.hpp:95
MueLu::IndexManager::gFineNodesPerDir
const Array< GO > gFineNodesPerDir
global number of nodes per direction.
Definition: MueLu_IndexManager_decl.hpp:99
MueLu::IndexManager::lNumFineNodes
LO lNumFineNodes
local number of nodes.
Definition: MueLu_IndexManager_decl.hpp:101
MueLu::IndexManager::gNumCoarseNodes
GO gNumCoarseNodes
global number of nodes remaining after coarsening.
Definition: MueLu_IndexManager_decl.hpp:105
MueLu::IndexManager::getFineNodeGID
virtual void getFineNodeGID(const GO i, const GO j, const GO k, GO &myGID) const =0
MueLu::IndexManager::ghostInterface
bool ghostInterface[6]
flags indicating if ghost points are needed at ilo, ihi, jlo, jhi, klo and khi boundaries.
Definition: MueLu_IndexManager_decl.hpp:125
MueLu::IndexManager::getMeshEdge
bool getMeshEdge(const int dir) const
Definition: MueLu_IndexManager_decl.hpp:177
MueLu::IndexManager::ghostedDir
bool ghostedDir[6]
flags indicating if ghost points are needed at ilo, ihi, jlo, jhi, klo and khi boundaries.
Definition: MueLu_IndexManager_decl.hpp:126
MueLu::IndexManager::getNumGlobalCoarseNodes
GO getNumGlobalCoarseNodes() const
Definition: MueLu_IndexManager_decl.hpp:161
MueLu::IndexManager::getLocalCoarseNodesInDir
LO getLocalCoarseNodesInDir(const int dim) const
Definition: MueLu_IndexManager_decl.hpp:207
MueLu_IndexManager_fwd.hpp
MueLu::IndexManager::getLocalFineNodesInDir
LO getLocalFineNodesInDir(const int dim) const
Definition: MueLu_IndexManager_decl.hpp:199
MueLu::IndexManager::getGhostInterface
bool getGhostInterface(const int dir) const
Definition: MueLu_IndexManager_decl.hpp:179
MueLu::IndexManager::getCoarseNodeGlobalTuple
virtual void getCoarseNodeGlobalTuple(const GO myGID, GO &i, GO &j, GO &k) const =0
MueLu::IndexManager::numGhostNodes
LO numGhostNodes
local number of ghost nodes
Definition: MueLu_IndexManager_decl.hpp:113
MueLu::IndexManager::IndexManager
IndexManager()=default
MueLu::IndexManager::startGhostedCoarseNode
Array< GO > startGhostedCoarseNode
lowest coarse global tuple (i,j,k) of a node remaing on the local process after coarsening.
Definition: MueLu_IndexManager_decl.hpp:122
MueLu::IndexManager::getStartIndices
Array< GO > getStartIndices() const
Definition: MueLu_IndexManager_decl.hpp:189
MueLu::IndexManager::getStartGhostedCoarseNodes
Array< GO > getStartGhostedCoarseNodes() const
Definition: MueLu_IndexManager_decl.hpp:193
MueLu::IndexManager::getStartIndex
GO getStartIndex(int const dim) const
Definition: MueLu_IndexManager_decl.hpp:191
MueLu::IndexManager::lNumFineNodes10
LO lNumFineNodes10
local number of nodes per 0-1 slice.
Definition: MueLu_IndexManager_decl.hpp:102
MueLu::IndexManager::getFineNodeGlobalTuple
virtual void getFineNodeGlobalTuple(const GO myGID, GO &i, GO &j, GO &k) const =0
MueLu::IndexManager::meshEdge
bool meshEdge[6]
flags indicating if we run into the edge of the mesh in ilo, ihi, jlo, jhi, klo or khi.
Definition: MueLu_IndexManager_decl.hpp:124
MueLu::IndexManager::minGlobalIndex
GO minGlobalIndex
lowest GID of any node in the local process
Definition: MueLu_IndexManager_decl.hpp:118
MueLu::IndexManager::lFineNodesPerDir
const Array< LO > lFineNodesPerDir
local number of nodes per direction.
Definition: MueLu_IndexManager_decl.hpp:103
MueLu::IndexManager::lCoarseNodesPerDir
Array< LO > lCoarseNodesPerDir
local number of nodes per direction remaing after coarsening.
Definition: MueLu_IndexManager_decl.hpp:111
MueLu::IndexManager::getCoarseningRate
int getCoarseningRate(const int dim) const
Definition: MueLu_IndexManager_decl.hpp:171
MueLu::IndexManager::getGhostedNodesInDir
LO getGhostedNodesInDir(const int dim) const
Definition: MueLu_IndexManager_decl.hpp:215
MueLu::IndexManager::getStartGhostedCoarseNode
GO getStartGhostedCoarseNode(int const dim) const
Definition: MueLu_IndexManager_decl.hpp:195
MueLu
Namespace for MueLu classes and methods.
Definition: MueLu_BrickAggregationFactory_decl.hpp:76
MueLu::IndexManager::coupled_
const bool coupled_
Flag for coupled vs uncoupled aggregation mode, if true aggregation is coupled.
Definition: MueLu_IndexManager_decl.hpp:90
MueLu::IndexManager::coarseRate
Array< int > coarseRate
coarsening rate in each direction
Definition: MueLu_IndexManager_decl.hpp:94
MueLu::IndexManager::isAggregationCoupled
bool isAggregationCoupled() const
Definition: MueLu_IndexManager_decl.hpp:153
MueLu::IndexManager::gCoarseNodesPerDir
Array< GO > gCoarseNodesPerDir
global number of nodes per direction remaining after coarsening.
Definition: MueLu_IndexManager_decl.hpp:107
MueLu::BaseClass
Base class for MueLu classes.
Definition: MueLu_BaseClass.hpp:61
MueLu::IndexManager::getCoarseNodeGID
virtual void getCoarseNodeGID(const GO i, const GO j, const GO k, GO &myGID) const =0
MueLu::IndexManager::computeGlobalCoarseParameters
virtual void computeGlobalCoarseParameters()=0
MueLu::IndexManager::getCoarseMeshData
virtual std::vector< std::vector< GO > > getCoarseMeshData() const =0
MueLu::IndexManager::getGhostedNodesPerDir
Array< LO > getGhostedNodesPerDir() const
Definition: MueLu_IndexManager_decl.hpp:213
MueLu::IndexManager::getCoarseningRates
Array< int > getCoarseningRates() const
Definition: MueLu_IndexManager_decl.hpp:169
MueLu::IndexManager::coarseNodeOffsets
Array< LO > coarseNodeOffsets
distance between lowest (resp. highest) index to the lowest (resp. highest) coarseNodeIndex in that d...
Definition: MueLu_IndexManager_decl.hpp:120
MueLu::IndexManager::getGlobalCoarseNodesInDir
GO getGlobalCoarseNodesInDir(const int dim) const
Definition: MueLu_IndexManager_decl.hpp:211
MueLu::IndexManager::getNumLocalFineNodes
LO getNumLocalFineNodes() const
Definition: MueLu_IndexManager_decl.hpp:163
MueLu::IndexManager::comm_
const RCP< const Teuchos::Comm< int > > comm_
Communicator used by uncoupled aggregation.
Definition: MueLu_IndexManager_decl.hpp:89
MueLu::IndexManager::getFineNodeLID
virtual void getFineNodeLID(const LO i, const LO j, const LO k, LO &myLID) const =0
MueLu::IndexManager::computeMeshParameters
void computeMeshParameters()
Definition: MueLu_IndexManager_def.hpp:86
MueLu::IndexManager::getCoarseNodeOffsets
Array< LO > getCoarseNodeOffsets() const
Definition: MueLu_IndexManager_decl.hpp:185
MueLu::IndexManager::getNumLocalCoarseNodes
LO getNumLocalCoarseNodes() const
Definition: MueLu_IndexManager_decl.hpp:165
MueLu::IndexManager::getCoarseningEndRates
Array< int > getCoarseningEndRates() const
Definition: MueLu_IndexManager_decl.hpp:173
MueLu::IndexManager::getOffsets
Array< LO > getOffsets() const
Definition: MueLu_IndexManager_decl.hpp:181
MueLu::IndexManager::~IndexManager
virtual ~IndexManager()
Definition: MueLu_IndexManager_decl.hpp:136
MueLu::IndexManager::getGhostedNodesData
virtual void getGhostedNodesData(const RCP< const Map > fineMap, Array< LO > &ghostedNodeCoarseLIDs, Array< int > &ghostedNodeCoarsePIDs, Array< GO > &ghostedNodeCoarseGIDs) const =0
MueLu::IndexManager::getOffset
LO getOffset(int const dim) const
Definition: MueLu_IndexManager_decl.hpp:183
MueLu::IndexManager::numDimensions
const int numDimensions
Number of spacial dimensions in the problem.
Definition: MueLu_IndexManager_decl.hpp:91
MueLu::IndexManager::getGlobalFineNodesInDir
GO getGlobalFineNodesInDir(const int dim) const
Definition: MueLu_IndexManager_decl.hpp:203
MueLu::IndexManager::getCoarseNodeLID
virtual void getCoarseNodeLID(const LO i, const LO j, const LO k, LO &myLID) const =0
MueLu::IndexManager::getCoarseNodeFineLID
virtual void getCoarseNodeFineLID(const LO i, const LO j, const LO k, LO &myLID) const =0
MueLu::IndexManager::getCoarseNodeLocalTuple
virtual void getCoarseNodeLocalTuple(const LO myLID, LO &i, LO &j, LO &k) const =0
MueLu::IndexManager::getNumDimensions
int getNumDimensions() const
Definition: MueLu_IndexManager_decl.hpp:155
MueLu::IndexManager::lNumCoarseNodes
LO lNumCoarseNodes
local number of nodes remaining after coarsening.
Definition: MueLu_IndexManager_decl.hpp:109
MueLu::IndexManager::getNumGlobalFineNodes
GO getNumGlobalFineNodes() const
Definition: MueLu_IndexManager_decl.hpp:159
MueLu::IndexManager::lNumCoarseNodes10
LO lNumCoarseNodes10
local number of nodes per 0-1 slice remaining after coarsening.
Definition: MueLu_IndexManager_decl.hpp:110
MueLu::IndexManager::startIndices
Array< GO > startIndices
lowest global tuple (i,j,k) of a node on the local process
Definition: MueLu_IndexManager_decl.hpp:121
MueLu::IndexManager::gNumFineNodes10
GO gNumFineNodes10
global number of nodes per 0-1 slice.
Definition: MueLu_IndexManager_decl.hpp:98
MueLu::IndexManager::numGhostedNodes
LO numGhostedNodes
local number of ghosted nodes (i.e. ghost + coarse nodes).
Definition: MueLu_IndexManager_decl.hpp:114
MueLu::IndexManager::getFineNodeLocalTuple
virtual void getFineNodeLocalTuple(const LO myLID, LO &i, LO &j, LO &k) const =0
MueLu::IndexManager::numGhostedNodes10
LO numGhostedNodes10
local number of ghosted nodes (i.e. ghost + coarse nodes) per 0-1 slice.
Definition: MueLu_IndexManager_decl.hpp:115
MueLu::IndexManager::getNumLocalGhostedNodes
LO getNumLocalGhostedNodes() const
Definition: MueLu_IndexManager_decl.hpp:167
MueLu::IndexManager::interpolationOrder_
const int interpolationOrder_
Interpolation order used by grid transfer operators using these aggregates.
Definition: MueLu_IndexManager_decl.hpp:92
MueLu::IndexManager::getCoarseningEndRate
int getCoarseningEndRate(const int dim) const
Definition: MueLu_IndexManager_decl.hpp:175
MueLu::IndexManager::getGhostedNodeCoarseLID
virtual void getGhostedNodeCoarseLID(const LO i, const LO j, const LO k, LO &myLID) const =0
MueLu::IndexManager::offsets
Array< LO > offsets
distance between lowest (resp. highest) index to the lowest (resp. highest) ghostedNodeIndex in that ...
Definition: MueLu_IndexManager_decl.hpp:119
MueLu::IndexManager
Container class for mesh layout and indices calculation.
Definition: MueLu_IndexManager_decl.hpp:81
MueLu::IndexManager::getInterpolationOrder
int getInterpolationOrder() const
Definition: MueLu_IndexManager_decl.hpp:157
MueLu::IndexManager::getGlobalCoarseNodesPerDir
Array< GO > getGlobalCoarseNodesPerDir() const
Definition: MueLu_IndexManager_decl.hpp:209
MueLu::IndexManager::gNumCoarseNodes10
GO gNumCoarseNodes10
global number of nodes per 0-1 slice remaining after coarsening.
Definition: MueLu_IndexManager_decl.hpp:106
MueLu::IndexManager::getLocalCoarseNodesPerDir
Array< LO > getLocalCoarseNodesPerDir() const
Definition: MueLu_IndexManager_decl.hpp:205
Teuchos::Comm
Definition: MueLu_Memory.hpp:52
MueLu_UseShortNamesOrdinal.hpp
MueLu::IndexManager::getCoarseNodeGhostedLID
virtual void getCoarseNodeGhostedLID(const LO i, const LO j, const LO k, LO &myLID) const =0
MueLu::IndexManager::gNumFineNodes
GO gNumFineNodes
global number of nodes.
Definition: MueLu_IndexManager_decl.hpp:97
MueLu::IndexManager::getGhostedNodeFineLID
virtual void getGhostedNodeFineLID(const LO i, const LO j, const LO k, LO &myLID) const =0
MueLu::IndexManager::ghostedNodesPerDir
Array< LO > ghostedNodesPerDir
local number of ghosted nodes (i.e. ghost + coarse nodes) per direction
Definition: MueLu_IndexManager_decl.hpp:116
MueLu::IndexManager::getLocalFineNodesPerDir
Array< LO > getLocalFineNodesPerDir() const
Definition: MueLu_IndexManager_decl.hpp:197
MueLu_BaseClass.hpp
MueLu::IndexManager::getFineNodeGhostedTuple
virtual void getFineNodeGhostedTuple(const LO myLID, LO &i, LO &j, LO &k) const =0
MueLu::IndexManager::getGlobalFineNodesPerDir
Array< GO > getGlobalFineNodesPerDir() const
Definition: MueLu_IndexManager_decl.hpp:201
MueLu::IndexManager::getCoarseNodeOffset
LO getCoarseNodeOffset(int const dim) const
Definition: MueLu_IndexManager_decl.hpp:187
MueLu::IndexManager::getCoarseNodesData
virtual void getCoarseNodesData(const RCP< const Map > fineCoordinatesMap, Array< GO > &coarseNodeCoarseGIDs, Array< GO > &coarseNodeFineGIDs) const =0