44template<
class AgglomerationType>
48 const AgglomerationType& agglom,
49 const label nLocalCoarse,
68 const label myAgglomOffset = globalAgglom.
localStart(myProci);
72 const label nBoundaryFaces = bndFaceOwner.
size();
74 globalNeighbour.
resize(nBoundaryFaces);
76 for (label bfacei = 0; bfacei < nBoundaryFaces; ++bfacei)
78 label val = agglom[bndFaceOwner[bfacei]];
82 val += myAgglomOffset;
84 globalNeighbour[bfacei] = val;
99 for (label facei = 0; facei <
mesh.nInternalFaces(); ++facei)
101 const label own = agglom[faceOwner[facei]];
102 const label nei = agglom[faceNeigh[facei]];
105 if (own < 0 || nei < 0)
continue;
107 ++nFacesPerCell[own];
108 ++nFacesPerCell[nei];
115 const label bndOffset =
mesh.nInternalFaces();
117 for (
const label facei :
pp.range())
119 const label own = agglom[faceOwner[facei]];
120 const label globalNei = globalNeighbour[facei-bndOffset];
123 if (own < 0 || globalNei < 0)
continue;
127 !globalAgglom.
isLocal(myProci, globalNei)
128 || globalAgglom.
toLocal(myProci, globalNei) != own
131 ++nFacesPerCell[own];
154 if (cellCellWeightsPtr)
156 cellCellWeightsPtr->clear();
162 for (label facei = 0; facei <
mesh.nInternalFaces(); ++facei)
164 const label own = agglom[faceOwner[facei]];
165 const label nei = agglom[faceNeigh[facei]];
168 if (own < 0 || nei < 0)
continue;
170 const label ownIndex = offsets[own] + nFacesPerCell[own]++;
171 const label neiIndex = offsets[nei] + nFacesPerCell[nei]++;
173 connect[ownIndex] = globalAgglom.
toGlobal(myProci, nei);
174 connect[neiIndex] = globalAgglom.
toGlobal(myProci, own);
176 if (!weights.
empty())
179 weights[neiIndex] = weights[ownIndex];
188 const label bndOffset =
mesh.nInternalFaces();
190 for (
const label facei :
pp.range())
192 const label own = agglom[faceOwner[facei]];
193 const label globalNei = globalNeighbour[facei-bndOffset];
196 if (own < 0 || globalNei < 0)
continue;
200 !globalAgglom.
isLocal(myProci, globalNei)
201 || globalAgglom.
toLocal(myProci, globalNei) != own
204 const label ownIndex = offsets[own] + nFacesPerCell[own]++;
206 connect[ownIndex] = globalNei;
208 if (!weights.
empty())
225 if (!cellCells.
empty())
230 label startIndex = offsets[0];
234 const label nCellCells = cellCells.
size();
236 for (label celli = 0; celli < nCellCells; ++celli)
242 const label self = globalAgglom.
toGlobal(myProci, celli);
247 const label endIndex = offsets[celli+1];
249 for (label i = startIndex; i < endIndex; ++i)
251 if (nbrCells.
insert(connect[i]))
253 connect[newIndex] = connect[i];
255 if (!weights.
empty())
257 weights[newIndex] = weights[i];
263 startIndex = endIndex;
264 offsets[celli+1] = newIndex;
268 if (!weights.
empty())
277 if (cellCellWeightsPtr)
279 cellCellWeightsPtr->offsets() = cellCells.
offsets();
280 cellCellWeightsPtr->values() = std::move(weights);
307 const polyMesh&
mesh,
308 const labelUList& agglom,
309 const label nLocalCoarse,
311 CompactListList<label>& cellCells
329 const label nLocalCoarse,
370 const bitSet& selectedCells,
375 const label nCells =
mesh.nCells();
382 for (
const label celli : selectedCells)
391 agglom[celli] = celli;
402 for (label& celli : agglom)
406 cellMap[nCompact] = celli;
410 if (nCompact == cellMap.
size())
439 const label nCells =
mesh.nCells();
446 for (
const label celli : selectedCells)
449 if (celli >= 0 && celli < nCells && agglom[celli] < 0)
451 agglom[celli] = celli;
462 for (label& celli : agglom)
466 cellMap[nCompact] = celli;
470 if (nCompact == cellMap.
size())
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
A packed storage of objects of type <T> using an offset table for access.
void resize_nocopy(const label mRows, const label nVals)
Redimension without preserving existing content.
label totalSize() const noexcept
The total addressed size, which corresponds to the end (back) offset and also the sum of all localSiz...
bool empty() const noexcept
True if the number of rows/sublists is zero.
const labelList & offsets() const noexcept
Return the offset table (= size()+1).
const List< T > & values() const noexcept
Return the packed values.
label size() const noexcept
The primary size (the number of rows/sublists).
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
void clear()
Remove all entries from table.
void resize(const label len)
Adjust allocated size of list.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
label toLocal(const label proci, const label i) const
From global to local on proci.
bool isLocal(const label proci, const label i) const
Is on processor proci.
label toGlobal(const label proci, const label i) const
From local to global on proci.
label localStart(const label proci) const
Start of proci data.
bool parallel() const noexcept
Does the mesh contain processor patches? (also valid when not running parallel).
static void calcCellCells(const polyMesh &mesh, const labelUList &agglom, const label nLocalCoarse, const bool parallel, CompactListList< label > &cellCells)
Determine (local or global) cellCells from mesh agglomeration.
const polyMesh & mesh() const noexcept
Return the mesh reference.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static void calcCellCellsImpl(const polyMesh &mesh, const AgglomerationType &agglom, const label nLocalCoarse, const bool parallel, CompactListList< label > &cellCells, CompactListList< scalar > *cellCellWeightsPtr=nullptr)
UList< label > labelUList
A UList of labels.
List< scalar > scalarList
List of scalar.
A functor that returns its argument unchanged (cf. C++20 std::identity) Should never be specialized.