46 #ifndef MUELU_LOCALLEXICOGRAPHICINDEXMANAGER_DEF_HPP_ 47 #define MUELU_LOCALLEXICOGRAPHICINDEXMANAGER_DEF_HPP_ 50 #include <Xpetra_MapFactory.hpp> 54 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
57 const int NumDimensions,
const int interpolationOrder,
58 const int MyRank,
const int NumRanks,
59 const Array<GO> GFineNodesPerDir,
const Array<LO> LFineNodesPerDir,
60 const Array<LO> CoarseRate,
const Array<GO> MeshData) :
61 IndexManager(comm, coupled, NumDimensions, interpolationOrder, GFineNodesPerDir, LFineNodesPerDir),
62 myRank(MyRank), numRanks(NumRanks) {
70 for(
int dim = 0; dim < 3; ++dim) {
72 if(CoarseRate.size() == 1) {
83 for(
int rank = 0; rank <
numRanks; ++rank) {
85 for(
int entry = 0; entry < 10; ++entry) {
86 meshData[rank][entry] = MeshData[10*rank + entry];
97 for(
int dim = 0; dim < 3; ++dim) {
107 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
114 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
117 Array<LO>& ghostedNodeCoarseLIDs, Array<int>& ghostedNodeCoarsePIDs, Array<GO>& ghostedNodeCoarseGIDs)
const {
129 Array<LO> ghostedCoarseNodeCoarseIndices(3), ghostedCoarseNodeFineIndices(3);
130 Array<LO> lCoarseNodeCoarseIndices(3);
132 LO currentIndex = -1, countCoarseNodes = 0;
134 for(
int j = 0; j < this->ghostedNodesPerDir[1]; ++j) {
135 for(
int i = 0; i < this->ghostedNodesPerDir[0]; ++i) {
138 ghostedCoarseNodeFineIndices[0] = ghostedCoarseNodeCoarseIndices[0]*this->
coarseRate[0];
143 ghostedCoarseNodeFineIndices[1] = ghostedCoarseNodeCoarseIndices[1]*this->coarseRate[1];
148 ghostedCoarseNodeFineIndices[2] = ghostedCoarseNodeCoarseIndices[2]*this->coarseRate[2];
153 GO myGID = -1, myCoarseGID = -1;
154 LO myLID = -1, myPID = -1, myCoarseLID = -1;
158 for(
int dim = 0; dim < 3; ++dim) {
160 lCoarseNodeCoarseIndices[dim] = ghostedCoarseNodeCoarseIndices[dim]
166 LO myRankIndexCoarseNodes10 = (coarseMeshData[rankIndex][6]
167 - coarseMeshData[rankIndex][5] + 1)
168 *myRankIndexCoarseNodesInDir0;
169 myCoarseLID = lCoarseNodeCoarseIndices[2]*myRankIndexCoarseNodes10
170 + lCoarseNodeCoarseIndices[1]*myRankIndexCoarseNodesInDir0
171 + lCoarseNodeCoarseIndices[0];
172 myCoarseGID = myCoarseLID + coarseMeshData[rankIndex][9];
174 ghostedNodeCoarseLIDs[currentIndex] = myCoarseLID;
175 ghostedNodeCoarsePIDs[currentIndex] = myPID;
176 ghostedNodeCoarseGIDs[currentIndex] = myCoarseGID;
179 lCoarseNodeCoarseGIDs[countCoarseNodes] = myCoarseGID;
187 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
190 Array<GO>& coarseNodeCoarseGIDs,
191 Array<GO>& coarseNodeFineGIDs)
const {
198 ArrayView<const GO> fineNodeGIDs = fineCoordinatesMap->getNodeElementList();
200 Array<GO> coarseStartIndices(3);
202 for(
int dim = 0; dim < 3; ++dim) {
209 Array<LO> coarseIndices(3), fineIndices(3), gCoarseIndices(3);
215 coarseNodeFineGIDs[coarseLID] = fineNodeGIDs[fineLID];
219 LO myRankIndexCoarseNodes10 = (coarseMeshData[
myRankIndex][6]
221 *myRankIndexCoarseNodesInDir0;
222 LO myCoarseLID = coarseIndices[2]*myRankIndexCoarseNodes10
223 + coarseIndices[1]*myRankIndexCoarseNodesInDir0
225 GO myCoarseGID = myCoarseLID + coarseMeshData[
myRankIndex][9];
226 coarseNodeCoarseGIDs[coarseLID] = myCoarseGID;
231 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
234 const Array<LO> coarseNodeFineIndices,
235 GO& myGID, LO& myPID, LO& myLID)
const {
237 LO ni = -1, nj = -1, li = -1, lj = -1, lk = -1;
251 myRankGuess -=
pj*
pi;
253 myRankGuess +=
pj*
pi;
255 if(coarseNodeFineIndices[0] >=
meshData[myRankGuess][3]
256 && coarseNodeFineIndices[0] <=
meshData[myRankGuess][4]
257 && coarseNodeFineIndices[1] >=
meshData[myRankGuess][5]
258 && coarseNodeFineIndices[1] <=
meshData[myRankGuess][6]
259 && coarseNodeFineIndices[2] >=
meshData[myRankGuess][7]
260 && coarseNodeFineIndices[2] <=
meshData[myRankGuess][8]
264 nj = meshData[myRankGuess][6] - meshData[myRankGuess][5] + 1;
265 li = coarseNodeFineIndices[0] - meshData[myRankGuess][3];
266 lj = coarseNodeFineIndices[1] - meshData[myRankGuess][5];
267 lk = coarseNodeFineIndices[2] - meshData[myRankGuess][7];
268 myLID = lk*nj*ni + lj*ni + li;
269 myGID = meshData[myRankGuess][9] + myLID;
274 [coarseNodeFineIndices](
const std::vector<GO>& vec){
275 if(coarseNodeFineIndices[0] >= vec[3]
276 && coarseNodeFineIndices[0] <= vec[4]
277 && coarseNodeFineIndices[1] >= vec[5]
278 && coarseNodeFineIndices[1] <= vec[6]
279 && coarseNodeFineIndices[2] >= vec[7]
280 && coarseNodeFineIndices[2] <= vec[8]) {
286 myPID = (*nodeRank)[0];
287 ni = (*nodeRank)[4] - (*nodeRank)[3] + 1;
288 nj = (*nodeRank)[6] - (*nodeRank)[5] + 1;
289 li = coarseNodeFineIndices[0] - (*nodeRank)[3];
290 lj = coarseNodeFineIndices[1] - (*nodeRank)[5];
291 lk = coarseNodeFineIndices[2] - (*nodeRank)[7];
292 myLID = lk*nj*ni + lj*ni + li;
293 myGID = (*nodeRank)[9] + myLID;
297 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
302 [](
const std::vector<GO>& a,
const std::vector<GO>& b)->
bool {
306 }
else if(a[2] == b[2]) {
309 }
else if(a[7] == b[7]) {
312 }
else if(a[5] == b[5]) {
313 if(a[3] < b[3]) {
return true;}
323 [] (
const std::vector<GO>& vec,
const GO val)->
bool {
324 return (vec[2] < val) ? true :
false;
327 [] (
const GO val,
const std::vector<GO>& vec)->
bool {
328 return (val < vec[2]) ? true :
false;
334 [] (
const GO val,
const std::vector<GO>& vec)->
bool {
335 return (val < vec[7]) ?
true :
false;
338 [] (
const GO val,
const std::vector<GO>& vec)->
bool {
339 return (val < vec[5]) ?
true :
false;
346 const int MyRank =
myRank;
349 [MyRank] (
const std::vector<GO>& vec)->
bool {
350 return (vec[0] == MyRank) ?
true :
false;
355 for(
int rankIndex = 0; rankIndex <
numRanks; ++rankIndex) {
360 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
363 Array<LO> rankOffset(3);
364 for(
int rank = 0; rank <
numRanks; ++rank) {
369 for(
int dim = 0; dim < 3; ++dim) {
390 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
394 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
399 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
409 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
423 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
428 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
433 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
438 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
448 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
453 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
458 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
464 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
470 const LO indices[3] = {i, j, k};
473 for(
int dim = 0; dim < 3; ++dim) {
485 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
490 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
const bool coupled_
Flag for coupled vs uncoupled aggregation mode, if true aggregation is coupled.
LO numGhostedNodes
local number of ghosted nodes (i.e. ghost + coarse nodes).
void getGhostedNodeFineLID(const LO i, const LO j, const LO k, LO &myLID) const
Array< GO > gCoarseNodesPerDir
global number of nodes per direction remaining after coarsening.
void sortLocalLexicographicData()
std::vector< std::vector< GO > > getCoarseMeshData() const
void getFineNodeLID(const LO i, const LO j, const LO k, LO &myLID) const
int myRankIndex
local process index for record in meshData after sorting.
Array< GO > startIndices
lowest global tuple (i,j,k) of a node on the local process
void getCoarseNodeGID(const GO i, const GO j, const GO k, GO &myGID) const
void getCoarseNodeGlobalTuple(const GO myGID, GO &i, GO &j, GO &k) const
std::vector< std::vector< GO > > meshData
layout of indices accross all processes.
Array< GO > startGhostedCoarseNode
lowest coarse global tuple (i,j,k) of a node remaing on the local process after coarsening.
void getCoarseNodesData(const RCP< const Map > fineCoordinatesMap, Array< GO > &coarseNodeCoarseGIDs, Array< GO > &coarseNodeFineGIDs) const
LO getNumLocalGhostedNodes() const
LO getNumLocalCoarseNodes() const
void getCoarseNodeLID(const LO i, const LO j, const LO k, LO &myLID) const
void getFineNodeGhostedTuple(const LO myLID, LO &i, LO &j, LO &k) const
Namespace for MueLu classes and methods.
void getFineNodeLocalTuple(const LO myLID, LO &i, LO &j, LO &k) const
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.
int numBlocks
Number of mesh block.
void getGhostedNodesData(const RCP< const Map > fineMap, Array< LO > &ghostedNodeCoarseLIDs, Array< int > &ghostedNodeCoarsePIDs, Array< GO > &ghostedNodeCoarseGIDs) const
void getCoarseNodeLocalTuple(const LO myLID, LO &i, LO &j, LO &k) const
const Array< LO > lFineNodesPerDir
local number of nodes per direction.
Array< LO > ghostedNodesPerDir
local number of ghosted nodes (i.e. ghost + coarse nodes) per direction
int myBlock
local mesh block ID.
int pk
Number of processors in each diretcion.
void getGhostedNodeCoarseLID(const LO i, const LO j, const LO k, LO &myLID) const
LO lNumCoarseNodes
local number of nodes remaining after coarsening.
LO numGhostedNodes10
local number of ghosted nodes (i.e. ghost + coarse nodes) per 0-1 slice.
Array< int > coarseRate
coarsening rate in each direction
void getFineNodeGlobalTuple(const GO myGID, GO &i, GO &j, GO &k) const
LO getCoarseNodeOffset(int const dim) const
std::vector< std::vector< GO > >::iterator myBlockStart
const int numDimensions
Number of spacial dimensions in the problem.
Array< LO > lCoarseNodesPerDir
local number of nodes per direction remaing after coarsening.
Array< int > rankIndices
mapping between rank ID and reordered rank ID.
bool ghostInterface[6]
flags indicating if ghost points are needed at ilo, ihi, jlo, jhi, klo and khi boundaries.
const int numRanks
Number of ranks used to decompose the problem.
void computeGlobalCoarseParameters()
void getCoarseNodeFineLID(const LO i, const LO j, const LO k, LO &myLID) const
LO getLocalFineNodesInDir(const int dim) const
std::vector< std::vector< GO > >::iterator myBlockEnd
bool meshEdge[6]
flags indicating if we run into the edge of the mesh in ilo, ihi, jlo, jhi, klo or khi...
LO lNumCoarseNodes10
local number of nodes per 0-1 slice remaining after coarsening.
void getFineNodeGID(const GO i, const GO j, const GO k, GO &myGID) const
LO getLocalCoarseNodesInDir(const int dim) const
void getCoarseNodeGhostedLID(const LO i, const LO j, const LO k, LO &myLID) const
LocalLexicographicIndexManager()=default
void computeCoarseLocalLexicographicData()
GO gNumCoarseNodes10
global number of nodes per 0-1 slice remaining after coarsening.
LO lNumFineNodes10
local number of nodes per 0-1 slice.
void computeMeshParameters()
void getGIDLocalLexicographic(const LO iGhosted, const LO jGhosted, const LO kGhosted, const Array< LO > coarseNodeFineIndices, GO &myGID, LO &myPID, LO &myLID) const
const int myRank
Local rank ID.
GO gNumCoarseNodes
global number of nodes remaining after coarsening.
Container class for mesh layout and indices calculation.
std::vector< std::vector< GO > > coarseMeshData
layout of indices accross all processes after coarsening.
int getCoarseningRate(const int dim) const