46 #ifndef MUELU_INDEXMANAGER_DEF_HPP
47 #define MUELU_INDEXMANAGER_DEF_HPP
61 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
64 const int NumDimensions,
65 const int interpolationOrder,
68 comm_(comm), coupled_(coupled), numDimensions(NumDimensions),
69 interpolationOrder_(interpolationOrder), gFineNodesPerDir(GFineNodesPerDir),
70 lFineNodesPerDir(LFineNodesPerDir) {
85 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
89 if(
const char* dbg = std::getenv(
"MUELU_INDEXMANAGER_DEBUG")) {
90 out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
97 gNumFineNodes10 = gFineNodesPerDir[1]*gFineNodesPerDir[0];
98 gNumFineNodes = gFineNodesPerDir[2]*gNumFineNodes10;
103 lNumFineNodes10 = lFineNodesPerDir[1]*lFineNodesPerDir[0];
104 lNumFineNodes = lFineNodesPerDir[2]*lNumFineNodes10;
105 for(
int dim = 0; dim < 3; ++dim) {
106 if(dim < numDimensions) {
108 if(startIndices[dim] == 0) {
109 meshEdge[2*dim] =
true;
111 if(startIndices[dim + 3] + 1 == gFineNodesPerDir[dim]) {
112 meshEdge[2*dim + 1] =
true;
113 endRate[dim] = startIndices[dim + 3] % coarseRate[dim];
116 meshEdge[2*dim] =
true;
117 meshEdge[2*dim + 1] =
true;
118 endRate[dim] = (lFineNodesPerDir[dim] - 1) % coarseRate[dim];
120 if(endRate[dim] == 0) {endRate[dim] = coarseRate[dim];}
124 offsets[dim] = Teuchos::as<LO>(startIndices[dim]) % coarseRate[dim];
125 if(offsets[dim] == 0) {
126 coarseNodeOffsets[dim] = 0;
127 }
else if(startIndices[dim] + endRate[dim] == lFineNodesPerDir[dim]) {
128 coarseNodeOffsets[dim] = endRate[dim] - offsets[dim];
130 coarseNodeOffsets[dim] = coarseRate[dim] - offsets[dim];
133 if(interpolationOrder_ == 0) {
134 int rem = startIndices[dim] % coarseRate[dim];
135 if( (rem != 0) && (rem <= Teuchos::as<double>(coarseRate[dim]) / 2.0)) {
136 ghostInterface[2*dim] =
true;
138 rem = startIndices[dim + 3] % coarseRate[dim];
140 if(coupled_ && (startIndices[dim + 3] != gFineNodesPerDir[dim] - 1) &&
141 (rem > Teuchos::as<double>(coarseRate[dim]) / 2.0)) {
142 ghostInterface[2*dim + 1] =
true;
145 }
else if(interpolationOrder_ == 1) {
146 if(coupled_ && (startIndices[dim] % coarseRate[dim] != 0 ||
147 startIndices[dim] == gFineNodesPerDir[dim]-1)) {
148 ghostInterface[2*dim] =
true;
150 if(coupled_ && (startIndices[dim + 3] != gFineNodesPerDir[dim] - 1) &&
151 ((lFineNodesPerDir[dim] == 1) || (startIndices[dim + 3] % coarseRate[dim] != 0))) {
152 ghostInterface[2*dim+1] =
true;
161 *out <<
"gFineNodesPerDir: " << gFineNodesPerDir << std::endl;
162 *out <<
"lFineNodesPerDir: " << lFineNodesPerDir << std::endl;
163 *out <<
"endRate: " << endRate << std::endl;
164 *out <<
"ghostInterface: {" << ghostInterface[0] <<
", " << ghostInterface[1] <<
", "
165 << ghostInterface[2] <<
", " << ghostInterface[3] <<
", " << ghostInterface[4] <<
", "
166 << ghostInterface[5] <<
"}" << std::endl;
167 *out <<
"meshEdge: {" << meshEdge[0] <<
", " << meshEdge[1] <<
", "
168 << meshEdge[2] <<
", " << meshEdge[3] <<
", " << meshEdge[4] <<
", "
169 << meshEdge[5] <<
"}" << std::endl;
170 *out <<
"startIndices: " << startIndices << std::endl;
171 *out <<
"offsets: " << offsets << std::endl;
172 *out <<
"coarseNodeOffsets: " << coarseNodeOffsets << std::endl;
187 for(
int dim = 0; dim < 3; ++dim) {
188 if(dim < numDimensions) {
192 if( meshEdge[2*dim + 1] ) {
193 lCoarseNodesPerDir[dim] = (lFineNodesPerDir[dim] - endRate[dim] + offsets[dim] - 1)
194 / coarseRate[dim] + 1;
195 if(offsets[dim] == 0) {++lCoarseNodesPerDir[dim];}
197 lCoarseNodesPerDir[dim] = (lFineNodesPerDir[dim] + offsets[dim] - 1) / coarseRate[dim];
198 if(offsets[dim] == 0) {++lCoarseNodesPerDir[dim];}
204 if(interpolationOrder_ == 0) {
205 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim];
206 int rem = startIndices[dim] % coarseRate[dim];
207 if(rem > (Teuchos::as<double>(coarseRate[dim]) / 2.0) ) {
208 ++startGhostedCoarseNode[dim];
211 if((startIndices[dim] == gFineNodesPerDir[dim] - 1) &&
212 (startIndices[dim] % coarseRate[dim] == 0)) {
213 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim] - 1;
215 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim];
221 gCoarseNodesPerDir[dim] = (gFineNodesPerDir[dim] - 1) / coarseRate[dim];
222 if((gFineNodesPerDir[dim] - 1) % coarseRate[dim] == 0) {
223 ++gCoarseNodesPerDir[dim];
225 gCoarseNodesPerDir[dim] += 2;
229 gCoarseNodesPerDir[dim] = 1;
230 lCoarseNodesPerDir[dim] = 1;
235 if(lFineNodesPerDir[dim] < 1) {lCoarseNodesPerDir[dim] = 0;}
236 ghostedNodesPerDir[dim] = lCoarseNodesPerDir[dim];
238 if(ghostInterface[2*dim]) {ghostedNodesPerDir[dim] += 1;}
240 if(ghostInterface[2*dim + 1]) {ghostedNodesPerDir[dim] += 1;}
245 for(
int dim = 0; dim < 3; ++dim) {
246 gCoarseNodesPerDir[dim] = -1;
251 lNumCoarseNodes10 = lCoarseNodesPerDir[0]*lCoarseNodesPerDir[1];
252 lNumCoarseNodes = lNumCoarseNodes10*lCoarseNodesPerDir[2];
253 numGhostedNodes10 = ghostedNodesPerDir[1]*ghostedNodesPerDir[0];
254 numGhostedNodes = numGhostedNodes10*ghostedNodesPerDir[2];
255 numGhostNodes = numGhostedNodes - lNumCoarseNodes;
257 *out <<
"lCoarseNodesPerDir: " << lCoarseNodesPerDir << std::endl;
258 *out <<
"gCoarseNodesPerDir: " << gCoarseNodesPerDir << std::endl;
259 *out <<
"ghostedNodesPerDir: " << ghostedNodesPerDir << std::endl;
260 *out <<
"gNumCoarseNodes=" << gNumCoarseNodes << std::endl;
261 *out <<
"lNumCoarseNodes=" << lNumCoarseNodes << std::endl;
262 *out <<
"numGhostedNodes=" << numGhostedNodes << std::endl;
267 #define MUELU_INDEXMANAGER_SHORT
268 #endif // MUELU_INDEXMANAGER_DEF_HPP
Array< GO > gCoarseNodesPerDir
global number of nodes per direction remaining after coarsening.
basic_FancyOStream & setShowProcRank(const bool showProcRank)
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.
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
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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.
basic_FancyOStream & setShowAllFrontMatter(const bool showAllFrontMatter)
void resize(size_type new_size, const value_type &x=value_type())
void computeMeshParameters()
Array< LO > coarseNodeOffsets
distance between lowest (resp. highest) index to the lowest (resp. highest) coarseNodeIndex in that d...