46 #ifndef MUELU_INDEXMANAGER_DEF_HPP 47 #define MUELU_INDEXMANAGER_DEF_HPP 49 #include "Teuchos_OrdinalTraits.hpp" 61 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
65 const bool singleCoarsePoint,
66 const int NumDimensions,
67 const int interpolationOrder,
68 const Array<GO> GFineNodesPerDir,
69 const Array<LO> LFineNodesPerDir) :
70 comm_(comm), coupled_(coupled), singleCoarsePoint_(singleCoarsePoint),
71 numDimensions(NumDimensions), interpolationOrder_(interpolationOrder),
72 gFineNodesPerDir(GFineNodesPerDir), lFineNodesPerDir(LFineNodesPerDir) {
87 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
91 RCP<Teuchos::FancyOStream> out;
92 if(
const char* dbg = std::getenv(
"MUELU_INDEXMANAGER_DEBUG")) {
93 out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
94 out->setShowAllFrontMatter(
false).setShowProcRank(
true);
96 out = Teuchos::getFancyOStream(rcp(
new Teuchos::oblackholestream()));
100 gNumFineNodes10 = gFineNodesPerDir[1]*gFineNodesPerDir[0];
101 gNumFineNodes = gFineNodesPerDir[2]*gNumFineNodes10;
103 gNumFineNodes10 = Teuchos::OrdinalTraits<GO>::invalid();
104 gNumFineNodes = Teuchos::OrdinalTraits<GO>::invalid();
106 lNumFineNodes10 = lFineNodesPerDir[1]*lFineNodesPerDir[0];
107 lNumFineNodes = lFineNodesPerDir[2]*lNumFineNodes10;
108 for(
int dim = 0; dim < 3; ++dim) {
109 if(dim < numDimensions) {
111 if(startIndices[dim] == 0) {
112 meshEdge[2*dim] =
true;
114 if(startIndices[dim + 3] + 1 == gFineNodesPerDir[dim]) {
115 meshEdge[2*dim + 1] =
true;
116 endRate[dim] = startIndices[dim + 3] % coarseRate[dim];
119 meshEdge[2*dim] =
true;
120 meshEdge[2*dim + 1] =
true;
121 endRate[dim] = (lFineNodesPerDir[dim] - 1) % coarseRate[dim];
123 if(endRate[dim] == 0) {endRate[dim] = coarseRate[dim];}
127 offsets[dim] = Teuchos::as<LO>(startIndices[dim]) % coarseRate[dim];
128 if(offsets[dim] == 0) {
129 coarseNodeOffsets[dim] = 0;
130 }
else if(startIndices[dim] + endRate[dim] == lFineNodesPerDir[dim]) {
131 coarseNodeOffsets[dim] = endRate[dim] - offsets[dim];
133 coarseNodeOffsets[dim] = coarseRate[dim] - offsets[dim];
136 if(interpolationOrder_ == 0) {
137 int rem = startIndices[dim] % coarseRate[dim];
138 if( (rem != 0) && (rem <= Teuchos::as<double>(coarseRate[dim]) / 2.0)) {
139 ghostInterface[2*dim] =
true;
141 rem = startIndices[dim + 3] % coarseRate[dim];
143 if(coupled_ && (startIndices[dim + 3] != gFineNodesPerDir[dim] - 1) &&
144 (rem > Teuchos::as<double>(coarseRate[dim]) / 2.0)) {
145 ghostInterface[2*dim + 1] =
true;
148 }
else if(interpolationOrder_ == 1) {
149 if(coupled_ && (startIndices[dim] % coarseRate[dim] != 0 ||
150 startIndices[dim] == gFineNodesPerDir[dim]-1)) {
151 ghostInterface[2*dim] =
true;
153 if(coupled_ && (startIndices[dim + 3] != gFineNodesPerDir[dim] - 1) &&
154 ((lFineNodesPerDir[dim] == 1) || (startIndices[dim + 3] % coarseRate[dim] != 0))) {
155 ghostInterface[2*dim+1] =
true;
164 *out <<
"singleCoarsePoint? " << singleCoarsePoint_ << std::endl;
165 *out <<
"gFineNodesPerDir: " << gFineNodesPerDir << std::endl;
166 *out <<
"lFineNodesPerDir: " << lFineNodesPerDir << std::endl;
167 *out <<
"endRate: " << endRate << std::endl;
168 *out <<
"ghostInterface: {" << ghostInterface[0] <<
", " << ghostInterface[1] <<
", " 169 << ghostInterface[2] <<
", " << ghostInterface[3] <<
", " << ghostInterface[4] <<
", " 170 << ghostInterface[5] <<
"}" << std::endl;
171 *out <<
"meshEdge: {" << meshEdge[0] <<
", " << meshEdge[1] <<
", " 172 << meshEdge[2] <<
", " << meshEdge[3] <<
", " << meshEdge[4] <<
", " 173 << meshEdge[5] <<
"}" << std::endl;
174 *out <<
"startIndices: " << startIndices << std::endl;
175 *out <<
"offsets: " << offsets << std::endl;
176 *out <<
"coarseNodeOffsets: " << coarseNodeOffsets << std::endl;
191 for(
int dim = 0; dim < 3; ++dim) {
192 if(dim < numDimensions) {
196 if( meshEdge[2*dim + 1] ) {
197 lCoarseNodesPerDir[dim] = (lFineNodesPerDir[dim] - endRate[dim] + offsets[dim] - 1)
198 / coarseRate[dim] + 1;
199 if(offsets[dim] == 0) {++lCoarseNodesPerDir[dim];}
203 if(singleCoarsePoint_ && lFineNodesPerDir[dim] - 1 < coarseRate[dim]) {
204 lCoarseNodesPerDir[dim] =1;
207 lCoarseNodesPerDir[dim] = (lFineNodesPerDir[dim] + offsets[dim] - 1) / coarseRate[dim];
208 if(offsets[dim] == 0) {++lCoarseNodesPerDir[dim];}
214 if(interpolationOrder_ == 0) {
215 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim];
216 int rem = startIndices[dim] % coarseRate[dim];
217 if(rem > (Teuchos::as<double>(coarseRate[dim]) / 2.0) ) {
218 ++startGhostedCoarseNode[dim];
221 if((startIndices[dim] == gFineNodesPerDir[dim] - 1) &&
222 (startIndices[dim] % coarseRate[dim] == 0)) {
223 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim] - 1;
225 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim];
231 gCoarseNodesPerDir[dim] = (gFineNodesPerDir[dim] - 1) / coarseRate[dim];
232 if((gFineNodesPerDir[dim] - 1) % coarseRate[dim] == 0) {
233 ++gCoarseNodesPerDir[dim];
235 gCoarseNodesPerDir[dim] += 2;
239 gCoarseNodesPerDir[dim] = 1;
240 lCoarseNodesPerDir[dim] = 1;
245 if(lFineNodesPerDir[dim] < 1) {lCoarseNodesPerDir[dim] = 0;}
246 ghostedNodesPerDir[dim] = lCoarseNodesPerDir[dim];
248 if(ghostInterface[2*dim]) {ghostedNodesPerDir[dim] += 1;}
250 if(ghostInterface[2*dim + 1]) {ghostedNodesPerDir[dim] += 1;}
255 for(
int dim = 0; dim < 3; ++dim) {
256 gCoarseNodesPerDir[dim] = -1;
261 lNumCoarseNodes10 = lCoarseNodesPerDir[0]*lCoarseNodesPerDir[1];
262 lNumCoarseNodes = lNumCoarseNodes10*lCoarseNodesPerDir[2];
263 numGhostedNodes10 = ghostedNodesPerDir[1]*ghostedNodesPerDir[0];
264 numGhostedNodes = numGhostedNodes10*ghostedNodesPerDir[2];
265 numGhostNodes = numGhostedNodes - lNumCoarseNodes;
267 *out <<
"lCoarseNodesPerDir: " << lCoarseNodesPerDir << std::endl;
268 *out <<
"gCoarseNodesPerDir: " << gCoarseNodesPerDir << std::endl;
269 *out <<
"ghostedNodesPerDir: " << ghostedNodesPerDir << std::endl;
270 *out <<
"gNumCoarseNodes=" << gNumCoarseNodes << std::endl;
271 *out <<
"lNumCoarseNodes=" << lNumCoarseNodes << std::endl;
272 *out <<
"numGhostedNodes=" << numGhostedNodes << std::endl;
277 #define MUELU_INDEXMANAGER_SHORT 278 #endif // MUELU_INDEXMANAGER_DEF_HPP
Array< GO > gCoarseNodesPerDir
global number of nodes per direction remaining after coarsening.
Array< GO > startIndices
lowest global tuple (i,j,k) of a node on the local process
Array< GO > startGhostedCoarseNode
lowest coarse global tuple (i,j,k) of a node remaing on the local process after coarsening.
Namespace for MueLu classes and methods.
Array< LO > offsets
distance between lowest (resp. highest) index to the lowest (resp. highest) ghostedNodeIndex in that ...
Array< LO > ghostedNodesPerDir
local number of ghosted nodes (i.e. ghost + coarse nodes) per direction
Array< int > coarseRate
coarsening rate in each direction
Array< LO > lCoarseNodesPerDir
local number of nodes per direction remaing after coarsening.
Array< int > endRate
adapted coarsening rate at the edge of the mesh in each direction.
void computeMeshParameters()
Array< LO > coarseNodeOffsets
distance between lowest (resp. highest) index to the lowest (resp. highest) coarseNodeIndex in that d...