45 label nPairLevels = 0;
46 label nCreatedLevels = 0;
50 label nCoarseCells = -1;
61 nCells_[nCreatedLevels] = nCoarseCells;
91 delete faceWeightsPtr;
94 faceWeightsPtr = aggFaceWeightsPtr;
97 if (nPairLevels % mergeLevels_)
115 delete faceWeightsPtr;
125 const lduAddressing& fineMatrixAddressing,
129 const label nFineCells = fineMatrixAddressing.size();
131 const labelUList& upperAddr = fineMatrixAddressing.upperAddr();
132 const labelUList& lowerAddr = fineMatrixAddressing.lowerAddr();
135 labelList cellFaces(upperAddr.size() + lowerAddr.size());
136 labelList cellFaceOffsets(nFineCells + 1);
144 nNbrs[upperAddr[facei]]++;
149 nNbrs[lowerAddr[facei]]++;
152 cellFaceOffsets[0] = 0;
155 cellFaceOffsets[celli+1] = cellFaceOffsets[celli] + nNbrs[celli];
165 cellFaceOffsets[upperAddr[facei]] + nNbrs[upperAddr[facei]]
168 nNbrs[upperAddr[facei]]++;
175 cellFaceOffsets[lowerAddr[facei]] + nNbrs[lowerAddr[facei]]
178 nNbrs[lowerAddr[facei]]++;
185 tmp<labelField> tcoarseCellMap(
new labelField(nFineCells, -1));
186 labelField& coarseCellMap = tcoarseCellMap.ref();
191 for (label cellfi=0; cellfi<nFineCells; cellfi++)
194 celli = forward_ ? cellfi : nFineCells - cellfi - 1;
196 if (coarseCellMap[celli] < 0)
198 label matchFaceNo = -1;
199 scalar maxFaceWeight = -GREAT;
204 label faceOs=cellFaceOffsets[celli];
205 faceOs<cellFaceOffsets[celli+1];
209 label facei = cellFaces[faceOs];
215 coarseCellMap[upperAddr[facei]] < 0
216 && coarseCellMap[lowerAddr[facei]] < 0
217 && faceWeights[facei] > maxFaceWeight
222 maxFaceWeight = faceWeights[facei];
226 if (matchFaceNo >= 0)
229 coarseCellMap[upperAddr[matchFaceNo]] = nCoarseCells;
230 coarseCellMap[lowerAddr[matchFaceNo]] = nCoarseCells;
237 label clusterMatchFaceNo = -1;
238 scalar clusterMaxFaceCoeff = -GREAT;
242 label faceOs=cellFaceOffsets[celli];
243 faceOs<cellFaceOffsets[celli+1];
247 label facei = cellFaces[faceOs];
249 if (faceWeights[facei] > clusterMaxFaceCoeff)
251 clusterMatchFaceNo = facei;
252 clusterMaxFaceCoeff = faceWeights[facei];
256 if (clusterMatchFaceNo >= 0)
259 coarseCellMap[celli] =
max
261 coarseCellMap[upperAddr[clusterMatchFaceNo]],
262 coarseCellMap[lowerAddr[clusterMatchFaceNo]]
271 for (label cellfi=0; cellfi<nFineCells; cellfi++)
274 celli = forward_ ? cellfi : nFineCells - cellfi - 1;
276 if (coarseCellMap[celli] < 0)
278 coarseCellMap[celli] = nCoarseCells;
287 forAll(coarseCellMap, celli)
289 coarseCellMap[celli] = nCoarseCells - coarseCellMap[celli];
297 forward_ = !forward_;
299 return tcoarseCellMap;