java-topology/defects/openfoam-0002/patch/openfoam-0002-cfcfacetocelstencil-hashset.patch

105 lines
3.3 KiB
Diff

# UNDF: UNDF-2026-000001134
# UNDF:
--- a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C
+++ b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C
@@ -28,6 +28,7 @@ License
#include "CFCFaceToCellStencil.H"
#include "syncTools.H"
+#include "HashSet.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@@ -128,37 +129,42 @@ void Foam::CFCFaceToCellStencil::calcCellStencil
// Determine faces of cellCells in global numbering
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- DynamicList<label> allGlobalFaces(100);
+ DynamicList<label> allGlobalFaces(100);
+ labelHashSet seen(100);
globalCellFaces.setSize(mesh().nCells());
forAll(globalCellFaces, celli)
{
const cell& cFaces = mesh().cells()[celli];
allGlobalFaces.clear();
+ seen.clear();
// My faces first
forAll(cFaces, i)
{
label facei = cFaces[i];
if
(
mesh().isInternalFace(facei)
|| validBFace[facei-mesh().nInternalFaces()]
)
{
- allGlobalFaces.append(globalNumbering().toGlobal(facei));
+ label globalI = globalNumbering().toGlobal(facei);
+ if (seen.insert(globalI))
+ {
+ allGlobalFaces.append(globalI);
+ }
}
}
// faces of neighbouring cells second
forAll(cFaces, i)
{
label facei = cFaces[i];
if (mesh().isInternalFace(facei))
{
label nbrCelli = own[facei];
if (nbrCelli == celli)
{
nbrCelli = nei[facei];
}
const cell& nbrFaces = mesh().cells()[nbrCelli];
forAll(nbrFaces, j)
{
label nbrFacei = nbrFaces[j];
if
(
mesh().isInternalFace(nbrFacei)
|| validBFace[nbrFacei-mesh().nInternalFaces()]
)
{
label nbrGlobalI = globalNumbering().toGlobal(nbrFacei);
- // Check if already there. Note:should use hashset?
- if (findIndex(allGlobalFaces, nbrGlobalI) == -1)
+ if (seen.insert(nbrGlobalI))
{
allGlobalFaces.append(nbrGlobalI);
}
}
}
}
else
{
const labelList& nbrGlobalFaces =
neiGlobal[facei-mesh().nInternalFaces()];
forAll(nbrGlobalFaces, j)
{
label nbrGlobalI = nbrGlobalFaces[j];
- // Check if already there. Note:should use hashset?
- if (findIndex(allGlobalFaces, nbrGlobalI) == -1)
+ if (seen.insert(nbrGlobalI))
{
allGlobalFaces.append(nbrGlobalI);
}
}
}
}
globalCellFaces[celli] = allGlobalFaces;
}
}