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;
129 const label nFineCells = fineMatrixAddressing.
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]]++;
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;
void agglomerateLduAddressing(const label fineLevelIndex)
Assemble coarse mesh addressing.
const label maxLevels_
Max number of levels.
void compactLevels(const label nCreatedLevels)
Shrink the number of levels to that specified.
PtrList< lduPrimitiveMesh > meshLevels_
Hierarchy of mesh addressing.
bool continueAgglomerating(const label nCells, const label nCoarseCells) const
Check the need for further agglomeration.
labelList nCells_
The number of cells in each level.
void restrictFaceField(Field< Type > &cf, const Field< Type > &ff, const label fineLevelIndex) const
Restrict (integrate by summation) face field.
void combineLevels(const label curLevel)
Combine a level with the previous one.
PtrList< labelField > restrictAddressing_
Cell restriction addressing array.
const lduMesh & meshLevel(const label leveli) const
Return LDU mesh of given level.
void size(const label n)
Older name for setAddressableSize.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
label size() const
Return number of equations.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
void agglomerate(const lduMesh &mesh, const scalarField &faceWeights)
Agglomerate all levels starting from the given face weights.
A class for managing temporary objects.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Field< label > labelField
Specialisation of Field<T> for label.
static constexpr const zero Zero
Global zero (0)
#define forAll(list, i)
Loop across all elements in list.