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, NumDimensions, interpolationOrder, GFineNodesPerDir, LFineNodesPerDir) {
64 for(
int dim = 0; dim < 3; ++dim) {
66 if(CoarseRate.
size() == 1) {
83 for(
int dim = 0; dim < 3; ++dim) {
93 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
96 this->gNumCoarseNodes10 = this->gCoarseNodesPerDir[0]*this->gCoarseNodesPerDir[1];
97 this->gNumCoarseNodes = this->gNumCoarseNodes10*this->gCoarseNodesPerDir[2];
100 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
105 ghostedNodeCoarseLIDs.
resize(this->getNumLocalGhostedNodes());
106 ghostedNodeCoarsePIDs.
resize(this->getNumLocalGhostedNodes());
107 ghostedNodeCoarseGIDs.
resize(this->numGhostedNodes);
111 Array<GO> lCoarseNodeCoarseGIDs(this->lNumCoarseNodes),
112 lCoarseNodeFineGIDs(this->lNumCoarseNodes);
113 Array<GO> ghostedCoarseNodeFineGIDs(this->numGhostedNodes);
114 Array<LO> ghostedCoarseNodeCoarseIndices(3), ghostedCoarseNodeFineIndices(3), ijk(3);
115 LO currentIndex = -1, currentCoarseIndex = -1;
116 for(ijk[2] = 0; ijk[2] < this->ghostedNodesPerDir[2]; ++ijk[2]) {
117 for(ijk[1] = 0; ijk[1] < this->ghostedNodesPerDir[1]; ++ijk[1]) {
118 for(ijk[0] = 0; ijk[0] < this->ghostedNodesPerDir[0]; ++ijk[0]) {
119 currentIndex = ijk[2]*this->numGhostedNodes10 + ijk[1]*this->ghostedNodesPerDir[0] + ijk[0];
120 ghostedCoarseNodeCoarseIndices[0] = this->startGhostedCoarseNode[0] + ijk[0];
121 ghostedCoarseNodeCoarseIndices[1] = this->startGhostedCoarseNode[1] + ijk[1];
122 ghostedCoarseNodeCoarseIndices[2] = this->startGhostedCoarseNode[2] + ijk[2];
123 GO myCoarseGID = ghostedCoarseNodeCoarseIndices[0]
124 + ghostedCoarseNodeCoarseIndices[1]*this->gCoarseNodesPerDir[0]
125 + ghostedCoarseNodeCoarseIndices[2]*this->gNumCoarseNodes10;
126 ghostedNodeCoarseGIDs[currentIndex] = myCoarseGID;
127 GO myGID = 0, factor[3] = {};
128 factor[2] = this->gNumFineNodes10;
129 factor[1] = this->gFineNodesPerDir[0];
131 for(
int dim = 0; dim < 3; ++dim) {
132 if(dim < this->numDimensions) {
133 if(this->startIndices[dim] - this->offsets[dim] + ijk[dim]*this->coarseRate[dim]
134 < this->gFineNodesPerDir[dim] - 1) {
135 myGID += (this->startIndices[dim] - this->offsets[dim]
136 + ijk[dim]*this->coarseRate[dim])*factor[dim];
138 myGID += (this->startIndices[dim] - this->offsets[dim] + (ijk[dim] - 1)
139 *this->coarseRate[dim] + this->endRate[dim])*factor[dim];
147 if((!this->ghostInterface[0] || ijk[0] != 0) &&
148 (!this->ghostInterface[2] || ijk[1] != 0) &&
149 (!this->ghostInterface[4] || ijk[2] != 0) &&
150 (!this->ghostInterface[1] || ijk[0] != this->ghostedNodesPerDir[0] - 1) &&
151 (!this->ghostInterface[3] || ijk[1] != this->ghostedNodesPerDir[1] - 1) &&
152 (!this->ghostInterface[5] || ijk[2] != this->ghostedNodesPerDir[2] - 1)) {
155 if(this->interpolationOrder_ == 0) {
156 currentCoarseIndex = 0;
157 if(this->ghostInterface[4]) {
158 currentCoarseIndex += (ijk[2] - 1)*this->lNumCoarseNodes10;
160 currentCoarseIndex += ijk[2]*this->lNumCoarseNodes10;
162 if(this->ghostInterface[2]) {
163 currentCoarseIndex += (ijk[1] - 1)*this->getLocalCoarseNodesInDir(0);
165 currentCoarseIndex += ijk[1]*this->getLocalCoarseNodesInDir(0);
167 if(this->ghostInterface[0]) {
168 currentCoarseIndex += ijk[0] - 1;
170 currentCoarseIndex += ijk[0];
173 this->getGhostedNodeCoarseLID(ijk[0], ijk[1], ijk[2], currentCoarseIndex);
176 lCoarseNodeCoarseGIDs[currentCoarseIndex] = myCoarseGID;
177 lCoarseNodeFineGIDs[currentCoarseIndex] = myGID;
179 ghostedCoarseNodeFineGIDs[currentIndex] = myGID;
184 RCP<const Map> coarseMap = Xpetra::MapFactory<LO,GO,NO>::Build (fineMap->lib(),
185 this->gNumCoarseNodes,
186 lCoarseNodeCoarseGIDs(),
187 fineMap->getIndexBase(),
190 coarseMap->getRemoteIndexList(ghostedNodeCoarseGIDs(),
191 ghostedNodeCoarsePIDs(),
192 ghostedNodeCoarseLIDs());
196 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
203 coarseNodeCoarseGIDs.
resize(this->getNumLocalCoarseNodes());
204 coarseNodeFineGIDs.
resize(this->getNumLocalCoarseNodes());
211 for(
int dim = 0; dim < 3; ++dim) {
212 coarseStartIndices[dim] = this->startIndices[dim] / this->coarseRate[dim];
213 tmp = this->startIndices[dim] % this->coarseRate[dim];
214 if(tmp > 0) {++coarseStartIndices[dim];}
221 for(LO coarseLID = 0; coarseLID < this->getNumLocalCoarseNodes(); ++coarseLID) {
222 this->getCoarseNodeLocalTuple(coarseLID,
226 getCoarseNodeFineLID(lCoarseIndices[0], lCoarseIndices[1], lCoarseIndices[2], fineLID);
227 coarseNodeFineGIDs[coarseLID] = fineNodeGIDs[fineLID];
230 for(
int dim=0; dim<3; dim++) {
231 gCoarseIndices[dim] = coarseStartIndices[dim] + lCoarseIndices[dim];
233 getCoarseNodeGID(gCoarseIndices[0],
236 coarseNodeCoarseGIDs[coarseLID] );
242 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
245 std::vector<std::vector<GO> > coarseMeshData;
246 return coarseMeshData;
249 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
253 k = myGID / this->gNumFineNodes10;
254 tmp = myGID % this->gNumFineNodes10;
255 j = tmp / this->gFineNodesPerDir[0];
256 i = tmp % this->gFineNodesPerDir[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];
269 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
273 k = myLID / this->lNumFineNodes10;
274 tmp = myLID % this->lNumFineNodes10;
275 j = tmp / this->lFineNodesPerDir[0];
276 i = tmp % this->lFineNodesPerDir[0];
278 k += this->offsets[2];
279 j += this->offsets[1];
280 i += this->offsets[0];
283 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
286 myGID = k*this->gNumFineNodes10 + j*this->gFineNodesPerDir[0] + i;
289 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
292 myLID = k*this->lNumFineNodes10 + j*this->lFineNodesPerDir[0] + i;
295 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
299 k = myGID / this->gNumCoarseNodes10;
300 tmp = myGID % this->gNumCoarseNodes10;
301 j = tmp / this->gCoarseNodesPerDir[0];
302 i = tmp % this->gCoarseNodesPerDir[0];
305 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
309 k = myLID / this->lNumCoarseNodes10;
310 tmp = myLID % this->lNumCoarseNodes10;
311 j = tmp / this->lCoarseNodesPerDir[0];
312 i = tmp % this->lCoarseNodesPerDir[0];
315 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
318 myGID = k*this->gNumCoarseNodes10 + j*this->gCoarseNodesPerDir[0] + i;
321 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
324 myLID = k*this->lNumCoarseNodes10 + j*this->lCoarseNodesPerDir[0] + i;
327 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
330 myLID = k*this->numGhostedNodes10 + j*this->ghostedNodesPerDir[0] + i;
333 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
338 const LO multiplier[3] = {1, this->lFineNodesPerDir[0], this->lNumFineNodes10};
339 const LO indices[3] = {i, j, k};
342 for(
int dim = 0; dim < 3; ++dim) {
343 if((indices[dim] == this->getLocalCoarseNodesInDir(dim) - 1) && this->meshEdge[2*dim + 1]) {
346 myLID += (this->getLocalFineNodesInDir(dim) - 1)*multiplier[dim];
348 myLID += (indices[dim]*this->getCoarseningRate(dim) + this->getCoarseNodeOffset(dim))
354 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
357 LO itmp = i - (this->offsets[0] > 0 ? 1 : 0);
358 LO jtmp = j - (this->offsets[1] > 0 ? 1 : 0);
359 LO ktmp = k - (this->offsets[2] > 0 ? 1 : 0);
361 if(ktmp*this->coarseRate[2] < this->lFineNodesPerDir[2]) {
362 myLID += ktmp*this->coarseRate[2]*this->lNumCoarseNodes10;
364 myLID += (this->lFineNodesPerDir[2] - 1)*this->lNumCoarseNodes10;
367 if(jtmp*this->coarseRate[1] < this->lFineNodesPerDir[1]) {
368 myLID += jtmp*this->coarseRate[1]*this->lFineNodesPerDir[0];
370 myLID += (this->lFineNodesPerDir[1] - 1)*this->lFineNodesPerDir[1];
373 if(itmp*this->coarseRate[0] < this->lFineNodesPerDir[0]) {
374 myLID += itmp*this->coarseRate[0];
376 myLID += this->lFineNodesPerDir[0] - 1;
380 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
383 LO itmp = i - (this->offsets[0] > 0 ? 1 : 0);
384 LO jtmp = j - (this->offsets[1] > 0 ? 1 : 0);
385 LO ktmp = k - (this->offsets[2] > 0 ? 1 : 0);
386 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
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.