MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
52 
53 #include <Xpetra_Map_fwd.hpp>
54 
55 #include "MueLu_ConfigDefs.hpp"
56 #include "MueLu_BaseClass.hpp"
58 
59 /*****************************************************************************
60 
61 ****************************************************************************/
62 
63 namespace MueLu {
64 
78 template <class LocalOrdinal, class GlobalOrdinal, class Node>
79 class IndexManager : public BaseClass {
80 #undef MUELU_INDEXMANAGER_SHORT
82 
83  private:
84  protected:
86  const bool coupled_;
87  const bool singleCoarsePoint_;
88  const int numDimensions;
89  const int interpolationOrder_;
90 
93 
97 
101 
105 
109 
114 
120 
121  bool meshEdge[6] = {false};
122  bool ghostInterface[6] = {false};
123  bool ghostedDir[6] = {false};
124 
125  public:
126  IndexManager() = default;
127 
128  IndexManager(const RCP<const Teuchos::Comm<int> > comm, const bool coupled,
129  const bool singleCoarsePoint, const int NumDimensions,
130  const int interpolationOrder, const Array<GO> GFineNodesPerDir,
131  const Array<LO> LFineNodesPerDir);
132 
133  virtual ~IndexManager() {}
134 
137  void computeMeshParameters();
138 
139  virtual void computeGlobalCoarseParameters() = 0;
140 
141  virtual void getGhostedNodesData(const RCP<const Map> fineMap,
142  Array<LO>& ghostedNodeCoarseLIDs,
143  Array<int>& ghostedNodeCoarsePIDs,
144  Array<GO>& ghostedNodeCoarseGIDs) const = 0;
145 
146  virtual void getCoarseNodesData(const RCP<const Map> fineCoordinatesMap,
147  Array<GO>& coarseNodeCoarseGIDs,
148  Array<GO>& coarseNodeFineGIDs) const = 0;
149 
150  bool isAggregationCoupled() const { return coupled_; }
151 
152  bool isSingleCoarsePoint() const { return singleCoarsePoint_; }
153 
154  int getNumDimensions() const { return numDimensions; }
155 
157 
159 
161 
163 
165 
167 
169 
170  int getCoarseningRate(const int dim) const { return coarseRate[dim]; }
171 
173 
174  int getCoarseningEndRate(const int dim) const { return endRate[dim]; }
175 
176  bool getMeshEdge(const int dir) const { return meshEdge[dir]; }
177 
178  bool getGhostInterface(const int dir) const { return ghostInterface[dir]; }
179 
180  Array<LO> getOffsets() const { return offsets; }
181 
182  LO getOffset(int const dim) const { return offsets[dim]; }
183 
185 
186  LO getCoarseNodeOffset(int const dim) const { return coarseNodeOffsets[dim]; }
187 
189 
190  GO getStartIndex(int const dim) const { return startIndices[dim]; }
191 
193 
194  GO getStartGhostedCoarseNode(int const dim) const { return startGhostedCoarseNode[dim]; }
195 
197 
198  LO getLocalFineNodesInDir(const int dim) const { return lFineNodesPerDir[dim]; }
199 
201 
202  GO getGlobalFineNodesInDir(const int dim) const { return gFineNodesPerDir[dim]; }
203 
205 
206  LO getLocalCoarseNodesInDir(const int dim) const { return lCoarseNodesPerDir[dim]; }
207 
209 
210  GO getGlobalCoarseNodesInDir(const int dim) const { return gCoarseNodesPerDir[dim]; }
211 
213 
214  LO getGhostedNodesInDir(const int dim) const { return ghostedNodesPerDir[dim]; }
215 
216  virtual std::vector<std::vector<GO> > getCoarseMeshData() const = 0;
217 
218  virtual void getFineNodeGlobalTuple(const GO myGID, GO& i, GO& j, GO& k) const = 0;
219 
220  virtual void getFineNodeLocalTuple(const LO myLID, LO& i, LO& j, LO& k) const = 0;
221 
222  virtual void getFineNodeGhostedTuple(const LO myLID, LO& i, LO& j, LO& k) const = 0;
223 
224  virtual void getFineNodeGID(const GO i, const GO j, const GO k, GO& myGID) const = 0;
225 
226  virtual void getFineNodeLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
227 
228  virtual void getCoarseNodeGlobalTuple(const GO myGID, GO& i, GO& j, GO& k) const = 0;
229 
230  virtual void getCoarseNodeLocalTuple(const LO myLID, LO& i, LO& j, LO& k) const = 0;
231 
232  virtual void getCoarseNodeGID(const GO i, const GO j, const GO k, GO& myGID) const = 0;
233 
234  virtual void getCoarseNodeLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
235 
236  virtual void getCoarseNodeGhostedLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
237 
238  virtual void getCoarseNodeFineLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
239 
240  virtual void getGhostedNodeFineLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
241 
242  virtual void getGhostedNodeCoarseLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
243 };
244 
245 } // namespace MueLu
246 
247 #define MUELU_INDEXMANAGER_SHORT
248 #endif // MUELU_INDEXMANAGER_DECL_HPP
const bool coupled_
Flag for coupled vs uncoupled aggregation mode, if true aggregation is coupled.
GO getStartIndex(int const dim) const
LO getLocalCoarseNodesInDir(const int dim) const
virtual void getFineNodeGhostedTuple(const LO myLID, LO &i, LO &j, LO &k) const =0
LO numGhostedNodes
local number of ghosted nodes (i.e. ghost + coarse nodes).
bool getMeshEdge(const int dir) const
LO numGhostNodes
local number of ghost nodes
Array< int > getCoarseningEndRates() const
Array< GO > getStartIndices() const
Array< GO > gCoarseNodesPerDir
global number of nodes per direction remaining after coarsening.
LO getGhostedNodesInDir(const int dim) const
GlobalOrdinal GO
virtual void getCoarseNodeLocalTuple(const LO myLID, LO &i, LO &j, LO &k) const =0
Array< GO > startIndices
lowest global tuple (i,j,k) of a node on the local process
GO getStartGhostedCoarseNode(int const dim) const
GO gNumFineNodes10
global number of nodes per 0-1 slice.
virtual void getCoarseNodeGlobalTuple(const GO myGID, GO &i, GO &j, GO &k) const =0
int getCoarseningRate(const int dim) const
Array< GO > startGhostedCoarseNode
lowest coarse global tuple (i,j,k) of a node remaing on the local process after coarsening.
LocalOrdinal LO
Array< GO > getGlobalFineNodesPerDir() const
bool getGhostInterface(const int dir) const
virtual void getGhostedNodesData(const RCP< const Map > fineMap, Array< LO > &ghostedNodeCoarseLIDs, Array< int > &ghostedNodeCoarsePIDs, Array< GO > &ghostedNodeCoarseGIDs) const =0
Array< LO > offsets
distance between lowest (resp. highest) index to the lowest (resp. highest) ghostedNodeIndex in that ...
const Array< GO > gFineNodesPerDir
global number of nodes per direction.
virtual void getFineNodeGlobalTuple(const GO myGID, GO &i, GO &j, GO &k) const =0
const Array< LO > lFineNodesPerDir
local number of nodes per direction.
virtual void getFineNodeGID(const GO i, const GO j, const GO k, GO &myGID) const =0
Array< LO > ghostedNodesPerDir
local number of ghosted nodes (i.e. ghost + coarse nodes) per direction
LO lNumCoarseNodes
local number of nodes remaining after coarsening.
GO getGlobalFineNodesInDir(const int dim) const
virtual void getFineNodeLocalTuple(const LO myLID, LO &i, LO &j, LO &k) const =0
LO numGhostedNodes10
local number of ghosted nodes (i.e. ghost + coarse nodes) per 0-1 slice.
Array< int > coarseRate
coarsening rate in each direction
Array< LO > getLocalFineNodesPerDir() const
Array< GO > getGlobalCoarseNodesPerDir() const
GO gNumFineNodes
global number of nodes.
const int interpolationOrder_
Interpolation order used by grid transfer operators using these aggregates.
virtual void computeGlobalCoarseParameters()=0
virtual void getCoarseNodeGhostedLID(const LO i, const LO j, const LO k, LO &myLID) const =0
LO lNumFineNodes
local number of nodes.
virtual void getCoarseNodeLID(const LO i, const LO j, const LO k, LO &myLID) const =0
virtual void getCoarseNodeFineLID(const LO i, const LO j, const LO k, LO &myLID) const =0
IndexManager()=default
Array< GO > getStartGhostedCoarseNodes() const
virtual void getCoarseNodesData(const RCP< const Map > fineCoordinatesMap, Array< GO > &coarseNodeCoarseGIDs, Array< GO > &coarseNodeFineGIDs) const =0
const int numDimensions
Number of spacial dimensions in the problem.
Array< LO > lCoarseNodesPerDir
local number of nodes per direction remaing after coarsening.
Array< int > endRate
adapted coarsening rate at the edge of the mesh in each direction.
bool ghostInterface[6]
flags indicating if ghost points are needed at ilo, ihi, jlo, jhi, klo and khi boundaries.
const RCP< const Teuchos::Comm< int > > comm_
Communicator used by uncoupled aggregation.
bool ghostedDir[6]
flags indicating if ghost points are needed at ilo, ihi, jlo, jhi, klo and khi boundaries.
bool meshEdge[6]
flags indicating if we run into the edge of the mesh in ilo, ihi, jlo, jhi, klo or khi...
Array< LO > getCoarseNodeOffsets() const
GO minGlobalIndex
lowest GID of any node in the local process
const bool singleCoarsePoint_
Flag telling us if can reduce dimensions to a single layer.
LO lNumCoarseNodes10
local number of nodes per 0-1 slice remaining after coarsening.
LO getLocalFineNodesInDir(const int dim) const
virtual void getGhostedNodeFineLID(const LO i, const LO j, const LO k, LO &myLID) const =0
virtual std::vector< std::vector< GO > > getCoarseMeshData() const =0
Array< LO > getGhostedNodesPerDir() const
Array< int > getCoarseningRates() const
Base class for MueLu classes.
virtual void getGhostedNodeCoarseLID(const LO i, const LO j, const LO k, LO &myLID) const =0
LO getOffset(int const dim) const
GO getGlobalCoarseNodesInDir(const int dim) const
Array< LO > getOffsets() const
virtual void getCoarseNodeGID(const GO i, const GO j, const GO k, GO &myGID) const =0
LO getCoarseNodeOffset(int const dim) const
GO gNumCoarseNodes10
global number of nodes per 0-1 slice remaining after coarsening.
int getCoarseningEndRate(const int dim) const
LO lNumFineNodes10
local number of nodes per 0-1 slice.
virtual void getFineNodeLID(const LO i, const LO j, const LO k, LO &myLID) const =0
Array< LO > coarseNodeOffsets
distance between lowest (resp. highest) index to the lowest (resp. highest) coarseNodeIndex in that d...
GO gNumCoarseNodes
global number of nodes remaining after coarsening.
Container class for mesh layout and indices calculation.
Array< LO > getLocalCoarseNodesPerDir() const