10 #ifndef MUELU_GLOBALLEXICOGRAPHICINDEXMANAGER_DEF_HPP_
11 #define MUELU_GLOBALLEXICOGRAPHICINDEXMANAGER_DEF_HPP_
14 #include <Xpetra_MapFactory.hpp>
18 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
21 const int NumDimensions,
const int interpolationOrder,
24 const GO MinGlobalIndex)
25 :
IndexManager(comm, coupled, false, NumDimensions, interpolationOrder, GFineNodesPerDir, LFineNodesPerDir) {
27 for (
int dim = 0; dim < 3; ++dim) {
29 if (CoarseRate.
size() == 1) {
46 for (
int dim = 0; dim < 3; ++dim) {
55 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
58 this->gNumCoarseNodes10 = this->gCoarseNodesPerDir[0] * this->gCoarseNodesPerDir[1];
59 this->gNumCoarseNodes = this->gNumCoarseNodes10 * this->gCoarseNodesPerDir[2];
62 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 ghostedNodeCoarseLIDs.
resize(this->getNumLocalGhostedNodes());
67 ghostedNodeCoarsePIDs.
resize(this->getNumLocalGhostedNodes());
68 ghostedNodeCoarseGIDs.
resize(this->numGhostedNodes);
72 Array<GO> lCoarseNodeCoarseGIDs(this->lNumCoarseNodes),
73 lCoarseNodeFineGIDs(this->lNumCoarseNodes);
74 Array<GO> ghostedCoarseNodeFineGIDs(this->numGhostedNodes);
75 Array<LO> ghostedCoarseNodeCoarseIndices(3), ghostedCoarseNodeFineIndices(3), ijk(3);
76 LO currentIndex = -1, currentCoarseIndex = -1;
77 for (ijk[2] = 0; ijk[2] < this->ghostedNodesPerDir[2]; ++ijk[2]) {
78 for (ijk[1] = 0; ijk[1] < this->ghostedNodesPerDir[1]; ++ijk[1]) {
79 for (ijk[0] = 0; ijk[0] < this->ghostedNodesPerDir[0]; ++ijk[0]) {
80 currentIndex = ijk[2] * this->numGhostedNodes10 + ijk[1] * this->ghostedNodesPerDir[0] + ijk[0];
81 ghostedCoarseNodeCoarseIndices[0] = this->startGhostedCoarseNode[0] + ijk[0];
82 ghostedCoarseNodeCoarseIndices[1] = this->startGhostedCoarseNode[1] + ijk[1];
83 ghostedCoarseNodeCoarseIndices[2] = this->startGhostedCoarseNode[2] + ijk[2];
84 GO myCoarseGID = ghostedCoarseNodeCoarseIndices[0] + ghostedCoarseNodeCoarseIndices[1] * this->gCoarseNodesPerDir[0] + ghostedCoarseNodeCoarseIndices[2] * this->gNumCoarseNodes10;
85 ghostedNodeCoarseGIDs[currentIndex] = myCoarseGID;
86 GO myGID = 0, factor[3] = {};
87 factor[2] = this->gNumFineNodes10;
88 factor[1] = this->gFineNodesPerDir[0];
90 for (
int dim = 0; dim < 3; ++dim) {
91 if (dim < this->numDimensions) {
92 if (this->startIndices[dim] - this->offsets[dim] + ijk[dim] * this->coarseRate[dim] < this->gFineNodesPerDir[dim] - 1) {
93 myGID += (this->startIndices[dim] - this->offsets[dim] + ijk[dim] * this->coarseRate[dim]) * factor[dim];
95 myGID += (this->startIndices[dim] - this->offsets[dim] + (ijk[dim] - 1) * this->coarseRate[dim] + this->endRate[dim]) * factor[dim];
103 if ((!this->ghostInterface[0] || ijk[0] != 0) &&
104 (!this->ghostInterface[2] || ijk[1] != 0) &&
105 (!this->ghostInterface[4] || ijk[2] != 0) &&
106 (!this->ghostInterface[1] || ijk[0] != this->ghostedNodesPerDir[0] - 1) &&
107 (!this->ghostInterface[3] || ijk[1] != this->ghostedNodesPerDir[1] - 1) &&
108 (!this->ghostInterface[5] || ijk[2] != this->ghostedNodesPerDir[2] - 1)) {
110 if (this->interpolationOrder_ == 0) {
111 currentCoarseIndex = 0;
112 if (this->ghostInterface[4]) {
113 currentCoarseIndex += (ijk[2] - 1) * this->lNumCoarseNodes10;
115 currentCoarseIndex += ijk[2] * this->lNumCoarseNodes10;
117 if (this->ghostInterface[2]) {
118 currentCoarseIndex += (ijk[1] - 1) * this->getLocalCoarseNodesInDir(0);
120 currentCoarseIndex += ijk[1] * this->getLocalCoarseNodesInDir(0);
122 if (this->ghostInterface[0]) {
123 currentCoarseIndex += ijk[0] - 1;
125 currentCoarseIndex += ijk[0];
128 this->getGhostedNodeCoarseLID(ijk[0], ijk[1], ijk[2], currentCoarseIndex);
131 lCoarseNodeCoarseGIDs[currentCoarseIndex] = myCoarseGID;
132 lCoarseNodeFineGIDs[currentCoarseIndex] = myGID;
134 ghostedCoarseNodeFineGIDs[currentIndex] = myGID;
140 this->gNumCoarseNodes,
141 lCoarseNodeCoarseGIDs(),
142 fineMap->getIndexBase(),
145 coarseMap->getRemoteIndexList(ghostedNodeCoarseGIDs(),
146 ghostedNodeCoarsePIDs(),
147 ghostedNodeCoarseLIDs());
151 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
157 coarseNodeCoarseGIDs.
resize(this->getNumLocalCoarseNodes());
158 coarseNodeFineGIDs.
resize(this->getNumLocalCoarseNodes());
165 for (
int dim = 0; dim < 3; ++dim) {
166 coarseStartIndices[dim] = this->startIndices[dim] / this->coarseRate[dim];
167 tmp = this->startIndices[dim] % this->coarseRate[dim];
169 ++coarseStartIndices[dim];
177 for (
LO coarseLID = 0; coarseLID < this->getNumLocalCoarseNodes(); ++coarseLID) {
178 this->getCoarseNodeLocalTuple(coarseLID,
182 getCoarseNodeFineLID(lCoarseIndices[0], lCoarseIndices[1], lCoarseIndices[2], fineLID);
183 coarseNodeFineGIDs[coarseLID] = fineNodeGIDs[fineLID];
186 for (
int dim = 0; dim < 3; dim++) {
187 gCoarseIndices[dim] = coarseStartIndices[dim] + lCoarseIndices[dim];
189 getCoarseNodeGID(gCoarseIndices[0],
192 coarseNodeCoarseGIDs[coarseLID]);
196 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
199 std::vector<std::vector<GO> > coarseMeshData;
200 return coarseMeshData;
203 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
207 k = myGID / this->gNumFineNodes10;
208 tmp = myGID % this->gNumFineNodes10;
209 j = tmp / this->gFineNodesPerDir[0];
210 i = tmp % this->gFineNodesPerDir[0];
213 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
217 k = myLID / this->lNumFineNodes10;
218 tmp = myLID % this->lNumFineNodes10;
219 j = tmp / this->lFineNodesPerDir[0];
220 i = tmp % this->lFineNodesPerDir[0];
223 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
227 k = myLID / this->lNumFineNodes10;
228 tmp = myLID % this->lNumFineNodes10;
229 j = tmp / this->lFineNodesPerDir[0];
230 i = tmp % this->lFineNodesPerDir[0];
232 k += this->offsets[2];
233 j += this->offsets[1];
234 i += this->offsets[0];
237 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
240 myGID = k * this->gNumFineNodes10 + j * this->gFineNodesPerDir[0] + i;
243 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
246 myLID = k * this->lNumFineNodes10 + j * this->lFineNodesPerDir[0] + i;
249 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
253 k = myGID / this->gNumCoarseNodes10;
254 tmp = myGID % this->gNumCoarseNodes10;
255 j = tmp / this->gCoarseNodesPerDir[0];
256 i = tmp % this->gCoarseNodesPerDir[0];
259 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
263 k = myLID / this->lNumCoarseNodes10;
264 tmp = myLID % this->lNumCoarseNodes10;
265 j = tmp / this->lCoarseNodesPerDir[0];
266 i = tmp % this->lCoarseNodesPerDir[0];
269 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
272 myGID = k * this->gNumCoarseNodes10 + j * this->gCoarseNodesPerDir[0] + i;
275 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
278 myLID = k * this->lNumCoarseNodes10 + j * this->lCoarseNodesPerDir[0] + i;
281 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
284 myLID = k * this->numGhostedNodes10 + j * this->ghostedNodesPerDir[0] + i;
287 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
292 const LO multiplier[3] = {1, this->lFineNodesPerDir[0], this->lNumFineNodes10};
293 const LO indices[3] = {i, j, k};
296 for (
int dim = 0; dim < 3; ++dim) {
297 if ((indices[dim] == this->getLocalCoarseNodesInDir(dim) - 1) && this->meshEdge[2 * dim + 1]) {
300 myLID += (this->getLocalFineNodesInDir(dim) - 1) * multiplier[dim];
302 myLID += (indices[dim] * this->getCoarseningRate(dim) + this->getCoarseNodeOffset(dim)) * multiplier[dim];
307 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
310 LO itmp = i - (this->offsets[0] > 0 ? 1 : 0);
311 LO jtmp = j - (this->offsets[1] > 0 ? 1 : 0);
312 LO ktmp = k - (this->offsets[2] > 0 ? 1 : 0);
314 if (ktmp * this->coarseRate[2] < this->lFineNodesPerDir[2]) {
315 myLID += ktmp * this->coarseRate[2] * this->lNumCoarseNodes10;
317 myLID += (this->lFineNodesPerDir[2] - 1) * this->lNumCoarseNodes10;
320 if (jtmp * this->coarseRate[1] < this->lFineNodesPerDir[1]) {
321 myLID += jtmp * this->coarseRate[1] * this->lFineNodesPerDir[0];
323 myLID += (this->lFineNodesPerDir[1] - 1) * this->lFineNodesPerDir[1];
326 if (itmp * this->coarseRate[0] < this->lFineNodesPerDir[0]) {
327 myLID += itmp * this->coarseRate[0];
329 myLID += this->lFineNodesPerDir[0] - 1;
333 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
336 LO itmp = i - (this->offsets[0] > 0 ? 1 : 0);
337 LO jtmp = j - (this->offsets[1] > 0 ? 1 : 0);
338 LO ktmp = k - (this->offsets[2] > 0 ? 1 : 0);
339 myLID = ktmp * this->lNumCoarseNodes10 + jtmp * this->lCoarseNodesPerDir[0] + itmp;
void getCoarseNodesData(const RCP< const Map > fineCoordinatesMap, Array< GO > &coarseNodeCoarseGIDs, Array< GO > &coarseNodeFineGIDs) const
void getGhostedNodesData(const RCP< const Map > fineMap, Array< LO > &ghostedNodeCoarseLIDs, Array< int > &ghostedNodeCoarsePIDs, Array< GO > &ghostedNodeCoarseGIDs) const
void getCoarseNodeLID(const LO i, const LO j, const LO k, LO &myLID) const
Array< GO > startIndices
lowest global tuple (i,j,k) of a node on the local process
void computeGlobalCoarseParameters()
void getCoarseNodeGID(const GO i, const GO j, const GO k, GO &myGID) const
const Array< GO > gFineNodesPerDir
global number of nodes per direction.
const Array< LO > lFineNodesPerDir
local number of nodes per direction.
void getGhostedNodeFineLID(const LO i, const LO j, const LO k, LO &myLID) const
void getFineNodeGID(const GO i, const GO j, const GO k, GO &myGID) const
Array< int > coarseRate
coarsening rate in each direction
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int >> &comm, LocalGlobal lg=Xpetra::GloballyDistributed)
void getFineNodeGlobalTuple(const GO myGID, GO &i, GO &j, GO &k) const
const int numDimensions
Number of spacial dimensions in the problem.
void getCoarseNodeFineLID(const LO i, const LO j, const LO k, LO &myLID) const
std::vector< std::vector< GO > > getCoarseMeshData() const
void getCoarseNodeLocalTuple(const LO myLID, LO &i, LO &j, LO &k) const
void getCoarseNodeGhostedLID(const LO i, const LO j, const LO k, LO &myLID) const
void resize(size_type new_size, const value_type &x=value_type())
void getCoarseNodeGlobalTuple(const GO myGID, GO &i, GO &j, GO &k) const
void getFineNodeLocalTuple(const LO myLID, LO &i, LO &j, LO &k) const
void computeMeshParameters()
void getGhostedNodeCoarseLID(const LO i, const LO j, const LO k, LO &myLID) const
GlobalLexicographicIndexManager()
void getFineNodeGhostedTuple(const LO myLID, LO &i, LO &j, LO &k) const
void getFineNodeLID(const LO i, const LO j, const LO k, LO &myLID) const
Container class for mesh layout and indices calculation.