46 #ifndef MUELU_GLOBALLEXICOGRAPHICINDEXMANAGER_DEF_HPP_
47 #define MUELU_GLOBALLEXICOGRAPHICINDEXMANAGER_DEF_HPP_
50 #include <Xpetra_MapFactory.hpp>
54 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
57 const int NumDimensions,
const int interpolationOrder,
60 const GO MinGlobalIndex)
61 :
IndexManager(comm, coupled, false, NumDimensions, interpolationOrder, GFineNodesPerDir, LFineNodesPerDir) {
63 for (
int dim = 0; dim < 3; ++dim) {
65 if (CoarseRate.
size() == 1) {
82 for (
int dim = 0; dim < 3; ++dim) {
91 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
94 this->gNumCoarseNodes10 = this->gCoarseNodesPerDir[0] * this->gCoarseNodesPerDir[1];
95 this->gNumCoarseNodes = this->gNumCoarseNodes10 * this->gCoarseNodesPerDir[2];
98 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
102 ghostedNodeCoarseLIDs.
resize(this->getNumLocalGhostedNodes());
103 ghostedNodeCoarsePIDs.
resize(this->getNumLocalGhostedNodes());
104 ghostedNodeCoarseGIDs.
resize(this->numGhostedNodes);
108 Array<GO> lCoarseNodeCoarseGIDs(this->lNumCoarseNodes),
109 lCoarseNodeFineGIDs(this->lNumCoarseNodes);
110 Array<GO> ghostedCoarseNodeFineGIDs(this->numGhostedNodes);
111 Array<LO> ghostedCoarseNodeCoarseIndices(3), ghostedCoarseNodeFineIndices(3), ijk(3);
112 LO currentIndex = -1, currentCoarseIndex = -1;
113 for (ijk[2] = 0; ijk[2] < this->ghostedNodesPerDir[2]; ++ijk[2]) {
114 for (ijk[1] = 0; ijk[1] < this->ghostedNodesPerDir[1]; ++ijk[1]) {
115 for (ijk[0] = 0; ijk[0] < this->ghostedNodesPerDir[0]; ++ijk[0]) {
116 currentIndex = ijk[2] * this->numGhostedNodes10 + ijk[1] * this->ghostedNodesPerDir[0] + ijk[0];
117 ghostedCoarseNodeCoarseIndices[0] = this->startGhostedCoarseNode[0] + ijk[0];
118 ghostedCoarseNodeCoarseIndices[1] = this->startGhostedCoarseNode[1] + ijk[1];
119 ghostedCoarseNodeCoarseIndices[2] = this->startGhostedCoarseNode[2] + ijk[2];
120 GO myCoarseGID = ghostedCoarseNodeCoarseIndices[0] + ghostedCoarseNodeCoarseIndices[1] * this->gCoarseNodesPerDir[0] + ghostedCoarseNodeCoarseIndices[2] * this->gNumCoarseNodes10;
121 ghostedNodeCoarseGIDs[currentIndex] = myCoarseGID;
122 GO myGID = 0, factor[3] = {};
123 factor[2] = this->gNumFineNodes10;
124 factor[1] = this->gFineNodesPerDir[0];
126 for (
int dim = 0; dim < 3; ++dim) {
127 if (dim < this->numDimensions) {
128 if (this->startIndices[dim] - this->offsets[dim] + ijk[dim] * this->coarseRate[dim] < this->gFineNodesPerDir[dim] - 1) {
129 myGID += (this->startIndices[dim] - this->offsets[dim] + ijk[dim] * this->coarseRate[dim]) * factor[dim];
131 myGID += (this->startIndices[dim] - this->offsets[dim] + (ijk[dim] - 1) * this->coarseRate[dim] + this->endRate[dim]) * factor[dim];
139 if ((!this->ghostInterface[0] || ijk[0] != 0) &&
140 (!this->ghostInterface[2] || ijk[1] != 0) &&
141 (!this->ghostInterface[4] || ijk[2] != 0) &&
142 (!this->ghostInterface[1] || ijk[0] != this->ghostedNodesPerDir[0] - 1) &&
143 (!this->ghostInterface[3] || ijk[1] != this->ghostedNodesPerDir[1] - 1) &&
144 (!this->ghostInterface[5] || ijk[2] != this->ghostedNodesPerDir[2] - 1)) {
146 if (this->interpolationOrder_ == 0) {
147 currentCoarseIndex = 0;
148 if (this->ghostInterface[4]) {
149 currentCoarseIndex += (ijk[2] - 1) * this->lNumCoarseNodes10;
151 currentCoarseIndex += ijk[2] * this->lNumCoarseNodes10;
153 if (this->ghostInterface[2]) {
154 currentCoarseIndex += (ijk[1] - 1) * this->getLocalCoarseNodesInDir(0);
156 currentCoarseIndex += ijk[1] * this->getLocalCoarseNodesInDir(0);
158 if (this->ghostInterface[0]) {
159 currentCoarseIndex += ijk[0] - 1;
161 currentCoarseIndex += ijk[0];
164 this->getGhostedNodeCoarseLID(ijk[0], ijk[1], ijk[2], currentCoarseIndex);
167 lCoarseNodeCoarseGIDs[currentCoarseIndex] = myCoarseGID;
168 lCoarseNodeFineGIDs[currentCoarseIndex] = myGID;
170 ghostedCoarseNodeFineGIDs[currentIndex] = myGID;
176 this->gNumCoarseNodes,
177 lCoarseNodeCoarseGIDs(),
178 fineMap->getIndexBase(),
181 coarseMap->getRemoteIndexList(ghostedNodeCoarseGIDs(),
182 ghostedNodeCoarsePIDs(),
183 ghostedNodeCoarseLIDs());
187 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
193 coarseNodeCoarseGIDs.
resize(this->getNumLocalCoarseNodes());
194 coarseNodeFineGIDs.
resize(this->getNumLocalCoarseNodes());
201 for (
int dim = 0; dim < 3; ++dim) {
202 coarseStartIndices[dim] = this->startIndices[dim] / this->coarseRate[dim];
203 tmp = this->startIndices[dim] % this->coarseRate[dim];
205 ++coarseStartIndices[dim];
213 for (
LO coarseLID = 0; coarseLID < this->getNumLocalCoarseNodes(); ++coarseLID) {
214 this->getCoarseNodeLocalTuple(coarseLID,
218 getCoarseNodeFineLID(lCoarseIndices[0], lCoarseIndices[1], lCoarseIndices[2], fineLID);
219 coarseNodeFineGIDs[coarseLID] = fineNodeGIDs[fineLID];
222 for (
int dim = 0; dim < 3; dim++) {
223 gCoarseIndices[dim] = coarseStartIndices[dim] + lCoarseIndices[dim];
225 getCoarseNodeGID(gCoarseIndices[0],
228 coarseNodeCoarseGIDs[coarseLID]);
232 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
235 std::vector<std::vector<GO> > coarseMeshData;
236 return coarseMeshData;
239 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
243 k = myGID / this->gNumFineNodes10;
244 tmp = myGID % this->gNumFineNodes10;
245 j = tmp / this->gFineNodesPerDir[0];
246 i = tmp % this->gFineNodesPerDir[0];
249 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
253 k = myLID / this->lNumFineNodes10;
254 tmp = myLID % this->lNumFineNodes10;
255 j = tmp / this->lFineNodesPerDir[0];
256 i = tmp % this->lFineNodesPerDir[0];
259 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
263 k = myLID / this->lNumFineNodes10;
264 tmp = myLID % this->lNumFineNodes10;
265 j = tmp / this->lFineNodesPerDir[0];
266 i = tmp % this->lFineNodesPerDir[0];
268 k += this->offsets[2];
269 j += this->offsets[1];
270 i += this->offsets[0];
273 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
276 myGID = k * this->gNumFineNodes10 + j * this->gFineNodesPerDir[0] + i;
279 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
282 myLID = k * this->lNumFineNodes10 + j * this->lFineNodesPerDir[0] + i;
285 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
289 k = myGID / this->gNumCoarseNodes10;
290 tmp = myGID % this->gNumCoarseNodes10;
291 j = tmp / this->gCoarseNodesPerDir[0];
292 i = tmp % this->gCoarseNodesPerDir[0];
295 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
299 k = myLID / this->lNumCoarseNodes10;
300 tmp = myLID % this->lNumCoarseNodes10;
301 j = tmp / this->lCoarseNodesPerDir[0];
302 i = tmp % this->lCoarseNodesPerDir[0];
305 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
308 myGID = k * this->gNumCoarseNodes10 + j * this->gCoarseNodesPerDir[0] + i;
311 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
314 myLID = k * this->lNumCoarseNodes10 + j * this->lCoarseNodesPerDir[0] + i;
317 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
320 myLID = k * this->numGhostedNodes10 + j * this->ghostedNodesPerDir[0] + i;
323 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
328 const LO multiplier[3] = {1, this->lFineNodesPerDir[0], this->lNumFineNodes10};
329 const LO indices[3] = {i, j, k};
332 for (
int dim = 0; dim < 3; ++dim) {
333 if ((indices[dim] == this->getLocalCoarseNodesInDir(dim) - 1) && this->meshEdge[2 * dim + 1]) {
336 myLID += (this->getLocalFineNodesInDir(dim) - 1) * multiplier[dim];
338 myLID += (indices[dim] * this->getCoarseningRate(dim) + this->getCoarseNodeOffset(dim)) * multiplier[dim];
343 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
346 LO itmp = i - (this->offsets[0] > 0 ? 1 : 0);
347 LO jtmp = j - (this->offsets[1] > 0 ? 1 : 0);
348 LO ktmp = k - (this->offsets[2] > 0 ? 1 : 0);
350 if (ktmp * this->coarseRate[2] < this->lFineNodesPerDir[2]) {
351 myLID += ktmp * this->coarseRate[2] * this->lNumCoarseNodes10;
353 myLID += (this->lFineNodesPerDir[2] - 1) * this->lNumCoarseNodes10;
356 if (jtmp * this->coarseRate[1] < this->lFineNodesPerDir[1]) {
357 myLID += jtmp * this->coarseRate[1] * this->lFineNodesPerDir[0];
359 myLID += (this->lFineNodesPerDir[1] - 1) * this->lFineNodesPerDir[1];
362 if (itmp * this->coarseRate[0] < this->lFineNodesPerDir[0]) {
363 myLID += itmp * this->coarseRate[0];
365 myLID += this->lFineNodesPerDir[0] - 1;
369 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
372 LO itmp = i - (this->offsets[0] > 0 ? 1 : 0);
373 LO jtmp = j - (this->offsets[1] > 0 ? 1 : 0);
374 LO ktmp = k - (this->offsets[2] > 0 ? 1 : 0);
375 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.