43 label nPairLevels = 0;
44 label nCreatedLevels = 0;
48 label nCoarseCells = -1;
59 nCells_[nCreatedLevels] = nCoarseCells;
89 delete faceWeightsPtr;
92 faceWeightsPtr = aggFaceWeightsPtr;
95 if (nPairLevels % mergeLevels_)
113 delete faceWeightsPtr;
127 const label nFineCells = fineMatrixAddressing.
size();
134 labelList cellFaceOffsets(nFineCells + 1);
142 nNbrs[upperAddr[facei]]++;
147 nNbrs[lowerAddr[facei]]++;
150 cellFaceOffsets[0] = 0;
153 cellFaceOffsets[celli+1] = cellFaceOffsets[celli] + nNbrs[celli];
163 cellFaceOffsets[upperAddr[facei]] + nNbrs[upperAddr[facei]]
166 nNbrs[upperAddr[facei]]++;
173 cellFaceOffsets[lowerAddr[facei]] + nNbrs[lowerAddr[facei]]
176 nNbrs[lowerAddr[facei]]++;
189 for (
label cellfi=0; cellfi<nFineCells; cellfi++)
192 celli = forward_ ? cellfi : nFineCells - cellfi - 1;
194 if (coarseCellMap[celli] < 0)
196 label matchFaceNo = -1;
197 scalar maxFaceWeight = -great;
202 label faceOs=cellFaceOffsets[celli];
203 faceOs<cellFaceOffsets[celli+1];
207 label facei = cellFaces[faceOs];
213 coarseCellMap[upperAddr[facei]] < 0
214 && coarseCellMap[lowerAddr[facei]] < 0
224 if (matchFaceNo >= 0)
227 coarseCellMap[upperAddr[matchFaceNo]] = nCoarseCells;
228 coarseCellMap[lowerAddr[matchFaceNo]] = nCoarseCells;
235 label clusterMatchFaceNo = -1;
236 scalar clusterMaxFaceCoeff = -great;
240 label faceOs=cellFaceOffsets[celli];
241 faceOs<cellFaceOffsets[celli+1];
245 label facei = cellFaces[faceOs];
249 clusterMatchFaceNo = facei;
254 if (clusterMatchFaceNo >= 0)
257 coarseCellMap[celli] =
max
259 coarseCellMap[upperAddr[clusterMatchFaceNo]],
260 coarseCellMap[lowerAddr[clusterMatchFaceNo]]
269 for (
label cellfi=0; cellfi<nFineCells; cellfi++)
272 celli = forward_ ? cellfi : nFineCells - cellfi - 1;
274 if (coarseCellMap[celli] < 0)
276 coarseCellMap[celli] = nCoarseCells;
285 forAll(coarseCellMap, celli)
287 coarseCellMap[celli] = nCoarseCells - coarseCellMap[celli];
295 forward_ = !forward_;
297 return tcoarseCellMap;
#define forAll(list, i)
Loop across all elements in list.
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.
label size() const
Return the number of elements in the UList.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
label size() const
Return number of equations.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
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.
T & ref() const
Return non-const reference or generate a fatal error.
tmp< scalarField > faceWeights(const polyMesh &mesh, const vectorField &fCtrs, const vectorField &fAreas, const vectorField &cellCtrs)
Generate interpolation factors field.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Field< label > labelField
Specialisation of Field<T> for label.