MueLu Version of the Day
Loading...
Searching...
No Matches
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
65namespace 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 bool singleCoarsePoint_;
92 const int numDimensions;
94
95 Array<int> coarseRate;
96 Array<int> endRate;
97
100 const Array<GO> gFineNodesPerDir;
101
104 const Array<LO> lFineNodesPerDir;
105
109
113
118
120 Array<LO> offsets;
122 Array<GO> startIndices;
124
125 bool meshEdge[6] = {false};
126 bool ghostInterface[6] = {false};
127 bool ghostedDir[6] = {false};
128
129 public:
130
131 IndexManager() = default;
132
133 IndexManager(const RCP<const Teuchos::Comm<int> > comm, const bool coupled,
134 const bool singleCoarsePoint, const int NumDimensions,
135 const int interpolationOrder, const Array<GO> GFineNodesPerDir,
136 const Array<LO> LFineNodesPerDir);
137
138 virtual ~IndexManager() {}
139
143
145
146 virtual void getGhostedNodesData(const RCP<const Map> fineMap,
147 Array<LO>& ghostedNodeCoarseLIDs,
148 Array<int>& ghostedNodeCoarsePIDs,
149 Array<GO>& ghostedNodeCoarseGIDs) const = 0;
150
151 virtual void getCoarseNodesData(const RCP<const Map> fineCoordinatesMap,
152 Array<GO>& coarseNodeCoarseGIDs,
153 Array<GO>& coarseNodeFineGIDs) const = 0;
154
155 bool isAggregationCoupled() const {return coupled_;}
156
158
159 int getNumDimensions() const {return numDimensions;}
160
162
164
166
168
170
172
173 Array<int> getCoarseningRates() const {return coarseRate;}
174
175 int getCoarseningRate(const int dim) const {return coarseRate[dim];}
176
177 Array<int> getCoarseningEndRates() const {return endRate;}
178
179 int getCoarseningEndRate(const int dim) const {return endRate[dim];}
180
181 bool getMeshEdge(const int dir) const {return meshEdge[dir];}
182
183 bool getGhostInterface(const int dir) const {return ghostInterface[dir];}
184
185 Array<LO> getOffsets() const {return offsets;}
186
187 LO getOffset(int const dim) const {return offsets[dim];}
188
189 Array<LO> getCoarseNodeOffsets() const {return coarseNodeOffsets;}
190
191 LO getCoarseNodeOffset(int const dim) const {return coarseNodeOffsets[dim];}
192
193 Array<GO> getStartIndices() const {return startIndices;}
194
195 GO getStartIndex(int const dim) const {return startIndices[dim];}
196
198
199 GO getStartGhostedCoarseNode(int const dim) const {return startGhostedCoarseNode[dim];}
200
201 Array<LO> getLocalFineNodesPerDir() const {return lFineNodesPerDir;}
202
203 LO getLocalFineNodesInDir(const int dim) const {return lFineNodesPerDir[dim];}
204
205 Array<GO> getGlobalFineNodesPerDir() const {return gFineNodesPerDir;}
206
207 GO getGlobalFineNodesInDir(const int dim) const {return gFineNodesPerDir[dim];}
208
210
211 LO getLocalCoarseNodesInDir(const int dim) const {return lCoarseNodesPerDir[dim];}
212
214
215 GO getGlobalCoarseNodesInDir(const int dim) const {return gCoarseNodesPerDir[dim];}
216
217 Array<LO> getGhostedNodesPerDir() const {return ghostedNodesPerDir;}
218
219 LO getGhostedNodesInDir(const int dim) const {return ghostedNodesPerDir[dim];}
220
221 virtual std::vector<std::vector<GO> > getCoarseMeshData() const = 0;
222
223 virtual void getFineNodeGlobalTuple(const GO myGID, GO& i, GO& j, GO& k) const = 0;
224
225 virtual void getFineNodeLocalTuple(const LO myLID, LO& i, LO& j, LO& k) const = 0;
226
227 virtual void getFineNodeGhostedTuple(const LO myLID, LO& i, LO& j, LO& k) const = 0;
228
229 virtual void getFineNodeGID(const GO i, const GO j, const GO k, GO& myGID) const = 0;
230
231 virtual void getFineNodeLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
232
233 virtual void getCoarseNodeGlobalTuple(const GO myGID, GO& i, GO& j, GO& k) const = 0;
234
235 virtual void getCoarseNodeLocalTuple(const LO myLID, LO& i, LO& j, LO& k) const = 0;
236
237 virtual void getCoarseNodeGID(const GO i, const GO j, const GO k, GO& myGID) const = 0;
238
239 virtual void getCoarseNodeLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
240
241 virtual void getCoarseNodeGhostedLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
242
243 virtual void getCoarseNodeFineLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
244
245 virtual void getGhostedNodeFineLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
246
247 virtual void getGhostedNodeCoarseLID(const LO i, const LO j, const LO k, LO& myLID) const = 0;
248
249 };
250
251} //namespace MueLu
252
253#define MUELU_INDEXMANAGER_SHORT
254#endif // MUELU_INDEXMANAGER_DECL_HPP
Base class for MueLu classes.
Container class for mesh layout and indices calculation.
Array< LO > offsets
distance between lowest (resp. highest) index to the lowest (resp. highest) ghostedNodeIndex in that ...
virtual void getFineNodeGlobalTuple(const GO myGID, GO &i, GO &j, GO &k) const =0
GO gNumCoarseNodes
global number of nodes remaining after coarsening.
virtual void getCoarseNodeLID(const LO i, const LO j, const LO k, LO &myLID) const =0
Array< int > getCoarseningEndRates() const
virtual void getCoarseNodesData(const RCP< const Map > fineCoordinatesMap, Array< GO > &coarseNodeCoarseGIDs, Array< GO > &coarseNodeFineGIDs) const =0
Array< LO > coarseNodeOffsets
distance between lowest (resp. highest) index to the lowest (resp. highest) coarseNodeIndex in that d...
virtual void getGhostedNodesData(const RCP< const Map > fineMap, Array< LO > &ghostedNodeCoarseLIDs, Array< int > &ghostedNodeCoarsePIDs, Array< GO > &ghostedNodeCoarseGIDs) const =0
virtual void getCoarseNodeGlobalTuple(const GO myGID, GO &i, GO &j, GO &k) const =0
GO getStartGhostedCoarseNode(int const dim) const
virtual void getFineNodeLocalTuple(const LO myLID, LO &i, LO &j, LO &k) const =0
Array< GO > getGlobalFineNodesPerDir() const
const int interpolationOrder_
Interpolation order used by grid transfer operators using these aggregates.
Array< GO > getGlobalCoarseNodesPerDir() const
const bool coupled_
Flag for coupled vs uncoupled aggregation mode, if true aggregation is coupled.
GO gNumFineNodes
global number of nodes.
GO minGlobalIndex
lowest GID of any node in the local process
virtual void computeGlobalCoarseParameters()=0
virtual void getGhostedNodeCoarseLID(const LO i, const LO j, const LO k, LO &myLID) const =0
GO getGlobalCoarseNodesInDir(const int dim) const
Array< LO > ghostedNodesPerDir
local number of ghosted nodes (i.e. ghost + coarse nodes) per direction
Array< GO > startGhostedCoarseNode
lowest coarse global tuple (i,j,k) of a node remaing on the local process after coarsening.
const Array< LO > lFineNodesPerDir
local number of nodes per direction.
virtual void getFineNodeGhostedTuple(const LO myLID, LO &i, LO &j, LO &k) const =0
virtual void getCoarseNodeFineLID(const LO i, const LO j, const LO k, LO &myLID) const =0
virtual void getCoarseNodeGhostedLID(const LO i, const LO j, const LO k, LO &myLID) const =0
Array< LO > getCoarseNodeOffsets() const
virtual std::vector< std::vector< GO > > getCoarseMeshData() const =0
LO numGhostedNodes10
local number of ghosted nodes (i.e. ghost + coarse nodes) per 0-1 slice.
Array< GO > gCoarseNodesPerDir
global number of nodes per direction remaining after coarsening.
int getCoarseningRate(const int dim) const
Array< LO > getGhostedNodesPerDir() const
Array< GO > startIndices
lowest global tuple (i,j,k) of a node on the local process
LO lNumCoarseNodes
local number of nodes remaining after coarsening.
GO gNumFineNodes10
global number of nodes per 0-1 slice.
Array< int > coarseRate
coarsening rate in each direction
virtual void getCoarseNodeGID(const GO i, const GO j, const GO k, GO &myGID) const =0
Array< GO > getStartGhostedCoarseNodes() const
LO getLocalCoarseNodesInDir(const int dim) const
bool getGhostInterface(const int dir) const
Array< LO > getLocalFineNodesPerDir() const
GO getStartIndex(int const dim) const
bool ghostedDir[6]
flags indicating if ghost points are needed at ilo, ihi, jlo, jhi, klo and khi boundaries.
IndexManager()=default
LO numGhostNodes
local number of ghost nodes
bool meshEdge[6]
flags indicating if we run into the edge of the mesh in ilo, ihi, jlo, jhi, klo or khi.
virtual void getFineNodeGID(const GO i, const GO j, const GO k, GO &myGID) const =0
virtual void getCoarseNodeLocalTuple(const LO myLID, LO &i, LO &j, LO &k) const =0
bool getMeshEdge(const int dir) const
bool ghostInterface[6]
flags indicating if ghost points are needed at ilo, ihi, jlo, jhi, klo and khi boundaries.
Array< GO > getStartIndices() const
int getCoarseningEndRate(const int dim) const
const bool singleCoarsePoint_
Flag telling us if can reduce dimensions to a single layer.
const int numDimensions
Number of spacial dimensions in the problem.
LO lNumCoarseNodes10
local number of nodes per 0-1 slice remaining after coarsening.
virtual void getGhostedNodeFineLID(const LO i, const LO j, const LO k, LO &myLID) const =0
LO lNumFineNodes10
local number of nodes per 0-1 slice.
GO getGlobalFineNodesInDir(const int dim) const
LO getCoarseNodeOffset(int const dim) const
LO getOffset(int const dim) const
LO lNumFineNodes
local number of nodes.
virtual void getFineNodeLID(const LO i, const LO j, const LO k, LO &myLID) const =0
const RCP< const Teuchos::Comm< int > > comm_
Communicator used by uncoupled aggregation.
Array< LO > getLocalCoarseNodesPerDir() const
GO gNumCoarseNodes10
global number of nodes per 0-1 slice remaining after coarsening.
Array< int > endRate
adapted coarsening rate at the edge of the mesh in each direction.
LO numGhostedNodes
local number of ghosted nodes (i.e. ghost + coarse nodes).
const Array< GO > gFineNodesPerDir
global number of nodes per direction.
Array< int > getCoarseningRates() const
Array< LO > lCoarseNodesPerDir
local number of nodes per direction remaing after coarsening.
LO getLocalFineNodesInDir(const int dim) const
LO getGhostedNodesInDir(const int dim) const
Namespace for MueLu classes and methods.