10 #ifndef MUELU_INDEXMANAGER_DEF_HPP
11 #define MUELU_INDEXMANAGER_DEF_HPP
24 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
28 const bool singleCoarsePoint,
29 const int NumDimensions,
30 const int interpolationOrder,
35 , singleCoarsePoint_(singleCoarsePoint)
36 , numDimensions(NumDimensions)
37 , interpolationOrder_(interpolationOrder)
38 , gFineNodesPerDir(GFineNodesPerDir)
39 , lFineNodesPerDir(LFineNodesPerDir) {
53 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
57 if (
const char* dbg = std::getenv(
"MUELU_INDEXMANAGER_DEBUG")) {
58 out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
65 gNumFineNodes10 = gFineNodesPerDir[1] * gFineNodesPerDir[0];
66 gNumFineNodes = gFineNodesPerDir[2] * gNumFineNodes10;
71 lNumFineNodes10 = lFineNodesPerDir[1] * lFineNodesPerDir[0];
72 lNumFineNodes = lFineNodesPerDir[2] * lNumFineNodes10;
73 for (
int dim = 0; dim < 3; ++dim) {
74 if (dim < numDimensions) {
76 if (startIndices[dim] == 0) {
77 meshEdge[2 * dim] =
true;
79 if (startIndices[dim + 3] + 1 == gFineNodesPerDir[dim]) {
80 meshEdge[2 * dim + 1] =
true;
81 endRate[dim] = startIndices[dim + 3] % coarseRate[dim];
84 meshEdge[2 * dim] =
true;
85 meshEdge[2 * dim + 1] =
true;
86 endRate[dim] = (lFineNodesPerDir[dim] - 1) % coarseRate[dim];
88 if (endRate[dim] == 0) {
89 endRate[dim] = coarseRate[dim];
94 offsets[dim] = Teuchos::as<LO>(startIndices[dim]) % coarseRate[dim];
95 if (offsets[dim] == 0) {
96 coarseNodeOffsets[dim] = 0;
97 }
else if (startIndices[dim] + endRate[dim] == lFineNodesPerDir[dim]) {
98 coarseNodeOffsets[dim] = endRate[dim] - offsets[dim];
100 coarseNodeOffsets[dim] = coarseRate[dim] - offsets[dim];
103 if (interpolationOrder_ == 0) {
104 int rem = startIndices[dim] % coarseRate[dim];
105 if ((rem != 0) && (rem <= Teuchos::as<double>(coarseRate[dim]) / 2.0)) {
106 ghostInterface[2 * dim] =
true;
108 rem = startIndices[dim + 3] % coarseRate[dim];
110 if (coupled_ && (startIndices[dim + 3] != gFineNodesPerDir[dim] - 1) &&
111 (rem > Teuchos::as<double>(coarseRate[dim]) / 2.0)) {
112 ghostInterface[2 * dim + 1] =
true;
115 }
else if (interpolationOrder_ == 1) {
116 if (coupled_ && (startIndices[dim] % coarseRate[dim] != 0 ||
117 startIndices[dim] == gFineNodesPerDir[dim] - 1)) {
118 ghostInterface[2 * dim] =
true;
120 if (coupled_ && (startIndices[dim + 3] != gFineNodesPerDir[dim] - 1) &&
121 ((lFineNodesPerDir[dim] == 1) || (startIndices[dim + 3] % coarseRate[dim] != 0))) {
122 ghostInterface[2 * dim + 1] =
true;
131 *out <<
"singleCoarsePoint? " << singleCoarsePoint_ << std::endl;
132 *out <<
"gFineNodesPerDir: " << gFineNodesPerDir << std::endl;
133 *out <<
"lFineNodesPerDir: " << lFineNodesPerDir << std::endl;
134 *out <<
"endRate: " << endRate << std::endl;
135 *out <<
"ghostInterface: {" << ghostInterface[0] <<
", " << ghostInterface[1] <<
", "
136 << ghostInterface[2] <<
", " << ghostInterface[3] <<
", " << ghostInterface[4] <<
", "
137 << ghostInterface[5] <<
"}" << std::endl;
138 *out <<
"meshEdge: {" << meshEdge[0] <<
", " << meshEdge[1] <<
", "
139 << meshEdge[2] <<
", " << meshEdge[3] <<
", " << meshEdge[4] <<
", "
140 << meshEdge[5] <<
"}" << std::endl;
141 *out <<
"startIndices: " << startIndices << std::endl;
142 *out <<
"offsets: " << offsets << std::endl;
143 *out <<
"coarseNodeOffsets: " << coarseNodeOffsets << std::endl;
158 for (
int dim = 0; dim < 3; ++dim) {
159 if (dim < numDimensions) {
163 if (meshEdge[2 * dim + 1]) {
164 lCoarseNodesPerDir[dim] = (lFineNodesPerDir[dim] - endRate[dim] + offsets[dim] - 1) / coarseRate[dim] + 1;
165 if (offsets[dim] == 0) {
166 ++lCoarseNodesPerDir[dim];
171 if (singleCoarsePoint_ && lFineNodesPerDir[dim] - 1 < coarseRate[dim]) {
172 lCoarseNodesPerDir[dim] = 1;
175 lCoarseNodesPerDir[dim] = (lFineNodesPerDir[dim] + offsets[dim] - 1) / coarseRate[dim];
176 if (offsets[dim] == 0) {
177 ++lCoarseNodesPerDir[dim];
184 if (interpolationOrder_ == 0) {
185 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim];
186 int rem = startIndices[dim] % coarseRate[dim];
187 if (rem > (Teuchos::as<double>(coarseRate[dim]) / 2.0)) {
188 ++startGhostedCoarseNode[dim];
191 if ((startIndices[dim] == gFineNodesPerDir[dim] - 1) &&
192 (startIndices[dim] % coarseRate[dim] == 0)) {
193 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim] - 1;
195 startGhostedCoarseNode[dim] = startIndices[dim] / coarseRate[dim];
201 gCoarseNodesPerDir[dim] = (gFineNodesPerDir[dim] - 1) / coarseRate[dim];
202 if ((gFineNodesPerDir[dim] - 1) % coarseRate[dim] == 0) {
203 ++gCoarseNodesPerDir[dim];
205 gCoarseNodesPerDir[dim] += 2;
209 gCoarseNodesPerDir[dim] = 1;
210 lCoarseNodesPerDir[dim] = 1;
215 if (lFineNodesPerDir[dim] < 1) {
216 lCoarseNodesPerDir[dim] = 0;
218 ghostedNodesPerDir[dim] = lCoarseNodesPerDir[dim];
220 if (ghostInterface[2 * dim]) {
221 ghostedNodesPerDir[dim] += 1;
224 if (ghostInterface[2 * dim + 1]) {
225 ghostedNodesPerDir[dim] += 1;
231 for (
int dim = 0; dim < 3; ++dim) {
232 gCoarseNodesPerDir[dim] = -1;
237 lNumCoarseNodes10 = lCoarseNodesPerDir[0] * lCoarseNodesPerDir[1];
238 lNumCoarseNodes = lNumCoarseNodes10 * lCoarseNodesPerDir[2];
239 numGhostedNodes10 = ghostedNodesPerDir[1] * ghostedNodesPerDir[0];
240 numGhostedNodes = numGhostedNodes10 * ghostedNodesPerDir[2];
241 numGhostNodes = numGhostedNodes - lNumCoarseNodes;
243 *out <<
"lCoarseNodesPerDir: " << lCoarseNodesPerDir << std::endl;
244 *out <<
"gCoarseNodesPerDir: " << gCoarseNodesPerDir << std::endl;
245 *out <<
"ghostedNodesPerDir: " << ghostedNodesPerDir << std::endl;
246 *out <<
"lNumCoarseNodes=" << lNumCoarseNodes << std::endl;
247 *out <<
"numGhostedNodes=" << numGhostedNodes << std::endl;
252 #define MUELU_INDEXMANAGER_SHORT
253 #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...