43 label nPairLevels = 0;
44 label nCreatedLevels = 0;
46 while (nCreatedLevels < maxLevels_ - 1)
48 label nCoarseCells = -1;
53 meshLevel(nCreatedLevels).lduAddr(),
57 if (continueAgglomerating(nCoarseCells))
59 nCells_[nCreatedLevels] = nCoarseCells;
60 restrictAddressing_.set(nCreatedLevels, finalAgglomPtr);
67 agglomerateLduAddressing(nCreatedLevels);
75 meshLevels_[nCreatedLevels].upperAddr().size(),
89 delete faceWeightsPtr;
92 faceWeightsPtr = aggFaceWeightsPtr;
95 if (nPairLevels % mergeLevels_)
97 combineLevels(nCreatedLevels);
108 compactLevels(nCreatedLevels);
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
215 && faceWeights[facei] > maxFaceWeight
220 maxFaceWeight = faceWeights[facei];
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];
247 if (faceWeights[facei] > clusterMaxFaceCoeff)
249 clusterMatchFaceNo = facei;
250 clusterMaxFaceCoeff = faceWeights[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;
Field< label > labelField
Specialisation of Field<T> for label.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
void agglomerate(const lduMesh &mesh, const scalarField &faceWeights)
Agglomerate all levels starting from the given face weights.
label size() const
Return number of equations.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label size() const
Return the number of elements in the UList.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.