46 #ifndef MUELU_INDEXMANAGER_DEF_HPP
47 #define MUELU_INDEXMANAGER_DEF_HPP
60 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
64 const bool singleCoarsePoint,
65 const int NumDimensions,
66 const int interpolationOrder,
71 , singleCoarsePoint_(singleCoarsePoint)
72 , numDimensions(NumDimensions)
73 , interpolationOrder_(interpolationOrder)
74 , gFineNodesPerDir(GFineNodesPerDir)
75 , lFineNodesPerDir(LFineNodesPerDir) {
89 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
93 if (
const char* dbg = std::getenv(
"MUELU_INDEXMANAGER_DEBUG")) {
94 out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
101 gNumFineNodes10 = gFineNodesPerDir[1] * gFineNodesPerDir[0];
102 gNumFineNodes = gFineNodesPerDir[2] * gNumFineNodes10;
107 lNumFineNodes10 = lFineNodesPerDir[1] * lFineNodesPerDir[0];
108 lNumFineNodes = lFineNodesPerDir[2] * lNumFineNodes10;
109 for (
int dim = 0; dim < 3; ++dim) {
110 if (dim < numDimensions) {
112 if (startIndices[dim] == 0) {
113 meshEdge[2 * dim] =
true;
115 if (startIndices[dim + 3] + 1 == gFineNodesPerDir[dim]) {
116 meshEdge[2 * dim + 1] =
true;
117 endRate[dim] = startIndices[dim + 3] % coarseRate[dim];
120 meshEdge[2 * dim] =
true;
121 meshEdge[2 * dim + 1] =
true;
122 endRate[dim] = (lFineNodesPerDir[dim] - 1) % coarseRate[dim];
124 if (endRate[dim] == 0) {
125 endRate[dim] = coarseRate[dim];
130 offsets[dim] = Teuchos::as<LO>(startIndices[dim]) % coarseRate[dim];
131 if (offsets[dim] == 0) {
132 coarseNodeOffsets[dim] = 0;
133 }
else if (startIndices[dim] + endRate[dim] == lFineNodesPerDir[dim]) {
134 coarseNodeOffsets[dim] = endRate[dim] - offsets[dim];
136 coarseNodeOffsets[dim] = coarseRate[dim] - offsets[dim];
139 if (interpolationOrder_ == 0) {
140 int rem = startIndices[dim] % coarseRate[dim];
141 if ((rem != 0) && (rem <= Teuchos::as<double>(coarseRate[dim]) / 2.0)) {
142 ghostInterface[2 * dim] =
true;
144 rem = startIndices[dim + 3] % coarseRate[dim];
146 if (coupled_ && (startIndices[dim + 3] != gFineNodesPerDir[dim] - 1) &&
147 (rem > Teuchos::as<double>(coarseRate[dim]) / 2.0)) {
148 ghostInterface[2 * dim + 1] =
true;
151 }
else if (interpolationOrder_ == 1) {
152 if (coupled_ && (startIndices[dim] % coarseRate[dim] != 0 ||
153 startIndices[dim] == gFineNodesPerDir[dim] - 1)) {
154 ghostInterface[2 * dim] =
true;
156 if (coupled_ && (startIndices[dim + 3] != gFineNodesPerDir[dim] - 1) &&
157 ((lFineNodesPerDir[dim] == 1) || (startIndices[dim + 3] % coarseRate[dim] != 0))) {
158 ghostInterface[2 * dim + 1] =
true;
167 *out <<
"singleCoarsePoint? " << singleCoarsePoint_ << std::endl;
168 *out <<
"gFineNodesPerDir: " << gFineNodesPerDir << std::endl;
169 *out <<
"lFineNodesPerDir: " << lFineNodesPerDir << std::endl;
170 *out <<
"endRate: " << endRate << std::endl;
171 *out <<
"ghostInterface: {" << ghostInterface[0] <<
", " << ghostInterface[1] <<
", "
172 << ghostInterface[2] <<
", " << ghostInterface[3] <<
", " << ghostInterface[4] <<
", "
173 << ghostInterface[5] <<
"}" << std::endl;
174 *out <<
"meshEdge: {" << meshEdge[0] <<
", " << meshEdge[1] <<
", "
175 << meshEdge[2] <<
", " << meshEdge[3] <<
", " << meshEdge[4] <<
", "
176 << meshEdge[5] <<
"}" << std::endl;
177 *out <<
"startIndices: " << startIndices << std::endl;
178 *out <<
"offsets: " << offsets << std::endl;
179 *out <<
"coarseNodeOffsets: " << coarseNodeOffsets << std::endl;
194 for (
int dim = 0; dim < 3; ++dim) {
195 if (dim < numDimensions) {
199 if (meshEdge[2 * dim + 1]) {
200 lCoarseNodesPerDir[dim] = (lFineNodesPerDir[dim] - endRate[dim] + offsets[dim] - 1) / coarseRate[dim] + 1;
201 if (offsets[dim] == 0) {
202 ++lCoarseNodesPerDir[dim];
207 if (singleCoarsePoint_ && lFineNodesPerDir[dim] - 1 < coarseRate[dim]) {
208 lCoarseNodesPerDir[dim] = 1;
211 lCoarseNodesPerDir[dim] = (lFineNodesPerDir[dim] + offsets[dim] - 1) / coarseRate[dim];
212 if (offsets[dim] == 0) {
213 ++lCoarseNodesPerDir[dim];
220 if (interpolationOrder_ == 0) {
221 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim];
222 int rem = startIndices[dim] % coarseRate[dim];
223 if (rem > (Teuchos::as<double>(coarseRate[dim]) / 2.0)) {
224 ++startGhostedCoarseNode[dim];
227 if ((startIndices[dim] == gFineNodesPerDir[dim] - 1) &&
228 (startIndices[dim] % coarseRate[dim] == 0)) {
229 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim] - 1;
231 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim];
237 gCoarseNodesPerDir[dim] = (gFineNodesPerDir[dim] - 1) / coarseRate[dim];
238 if ((gFineNodesPerDir[dim] - 1) % coarseRate[dim] == 0) {
239 ++gCoarseNodesPerDir[dim];
241 gCoarseNodesPerDir[dim] += 2;
245 gCoarseNodesPerDir[dim] = 1;
246 lCoarseNodesPerDir[dim] = 1;
251 if (lFineNodesPerDir[dim] < 1) {
252 lCoarseNodesPerDir[dim] = 0;
254 ghostedNodesPerDir[dim] = lCoarseNodesPerDir[dim];
256 if (ghostInterface[2 * dim]) {
257 ghostedNodesPerDir[dim] += 1;
260 if (ghostInterface[2 * dim + 1]) {
261 ghostedNodesPerDir[dim] += 1;
267 for (
int dim = 0; dim < 3; ++dim) {
268 gCoarseNodesPerDir[dim] = -1;
273 lNumCoarseNodes10 = lCoarseNodesPerDir[0] * lCoarseNodesPerDir[1];
274 lNumCoarseNodes = lNumCoarseNodes10 * lCoarseNodesPerDir[2];
275 numGhostedNodes10 = ghostedNodesPerDir[1] * ghostedNodesPerDir[0];
276 numGhostedNodes = numGhostedNodes10 * ghostedNodesPerDir[2];
277 numGhostNodes = numGhostedNodes - lNumCoarseNodes;
279 *out <<
"lCoarseNodesPerDir: " << lCoarseNodesPerDir << std::endl;
280 *out <<
"gCoarseNodesPerDir: " << gCoarseNodesPerDir << std::endl;
281 *out <<
"ghostedNodesPerDir: " << ghostedNodesPerDir << std::endl;
282 *out <<
"lNumCoarseNodes=" << lNumCoarseNodes << std::endl;
283 *out <<
"numGhostedNodes=" << numGhostedNodes << std::endl;
288 #define MUELU_INDEXMANAGER_SHORT
289 #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...