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 #include <Xpetra_Vector_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 
90  const bool coupled_;
91  const int numDimensions;
92  const int interpolationOrder_;
93 
96 
100 
104 
108 
112 
117 
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 
164 
166 
168 
170 
171  int getCoarseningRate(const int dim) const {return coarseRate[dim];}
172 
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 
186 
187  LO getCoarseNodeOffset(int const dim) const {return coarseNodeOffsets[dim];}
188 
190 
191  GO getStartIndex(int const dim) const {return startIndices[dim];}
192 
194 
195  GO getStartGhostedCoarseNode(int const dim) const {return startGhostedCoarseNode[dim];}
196 
198 
199  LO getLocalFineNodesInDir(const int dim) const {return lFineNodesPerDir[dim];}
200 
202 
203  GO getGlobalFineNodesInDir(const int dim) const {return gFineNodesPerDir[dim];}
204 
206 
207  LO getLocalCoarseNodesInDir(const int dim) const {return lCoarseNodesPerDir[dim];}
208 
210 
211  GO getGlobalCoarseNodesInDir(const int dim) const {return gCoarseNodesPerDir[dim];}
212 
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
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
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