ENH: List/DynamicList appendUniq() method

- affords some code reduction.

STYLE: use HashSet insert() without found() check in more places
This commit is contained in:
Mark Olesen
2021-04-06 12:29:26 +02:00
committed by Andrew Heather
parent 6dc6d7ca9a
commit cdbc3e2de6
36 changed files with 166 additions and 341 deletions

View File

@ -100,10 +100,7 @@ int main(int argc, char *argv[])
const wordList& regions = iter();
forAll(regions, i)
{
if (!regionNames.found(regions[i]))
{
regionNames.append(regions[i]);
}
regionNames.appendUniq(regions[i]);
}
}
regionDirs = regionNames;

View File

@ -894,16 +894,9 @@ void Foam::conformalVoronoiMesh::checkCellSizing()
const label faceOwner = pMesh.faceOwner()[facei];
const label faceNeighbour = pMesh.faceNeighbour()[facei];
if (!cellsToResizeMap.found(faceOwner))
{
cellsToResizeMap.insert(faceOwner);
}
if (!cellsToResizeMap.found(faceNeighbour))
{
cellsToResizeMap.insert(faceNeighbour);
}
}
cellsToResizeMap += protrudingCells;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -727,14 +727,10 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseSurfaceTrees
if (nearest.hit() || nearestEdge.hit())
{
nStoppedInsertion++;
if (!hits[proci].found(peI))
{
hits[proci].insert(peI);
}
}
}
}
Pstream::listCombineGather(hits, plusEqOp<labelHashSet>());
Pstream::listCombineScatter(hits);
@ -822,14 +818,10 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseEdgeTrees
// << endl;
nStoppedInsertion++;
if (!hits[proci].found(peI))
{
hits[proci].insert(peI);
}
}
}
}
Pstream::listCombineGather(hits, plusEqOp<labelHashSet>());
Pstream::listCombineScatter(hits);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -467,15 +468,8 @@ inline Foam::List<Foam::label> Foam::conformalVoronoiMesh::processorsAttached
forAll(c1Procs, aPI)
{
if (!procsAttached.found(c1Procs[aPI]))
{
procsAttached.append(c1Procs[aPI]);
}
if (!procsAttached.found(c2Procs[aPI]))
{
procsAttached.append(c2Procs[aPI]);
}
procsAttached.appendUniq(c1Procs[aPI]);
procsAttached.appendUniq(c2Procs[aPI]);
}
return List<label>(procsAttached);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,23 +36,6 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::shortEdgeFilter2D::addRegion
(
const label regionI,
DynamicList<label>& bPointRegions
) const
{
if (bPointRegions.empty())
{
bPointRegions.append(regionI);
}
else if (!bPointRegions.found(regionI))
{
bPointRegions.append(regionI);
}
}
void Foam::shortEdgeFilter2D::assignBoundaryPointRegions
(
List<DynamicList<label>>& boundaryPointRegions
@ -61,13 +44,10 @@ void Foam::shortEdgeFilter2D::assignBoundaryPointRegions
forAllConstIters(mapEdgesRegion_, iter)
{
const edge& e = iter.key();
const label& regionI = iter();
const label regi = iter.val();
const label startI = e.start();
const label endI = e.end();
addRegion(regionI, boundaryPointRegions[startI]);
addRegion(regionI, boundaryPointRegions[endI]);
boundaryPointRegions[e.start()].appendUniq(regi);
boundaryPointRegions[e.end()].appendUniq(regi);
}
}

View File

@ -51,7 +51,7 @@ namespace Foam
class shortEdgeFilter2D
{
// Private data
// Private Data
const CV2D& cv2Dmesh_;
@ -72,12 +72,6 @@ class shortEdgeFilter2D
// Private Member Functions
void addRegion
(
const label regionI,
DynamicList<label>& bPointRegions
) const;
void assignBoundaryPointRegions
(
List<DynamicList<label>>& boundaryPointRegions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -516,9 +516,9 @@ void Foam::meshDualiser::createFacesAroundEdge
{
label startDual = faceToDualPoint_[startFaceLabel];
if (startDual != -1 && !verts.found(startDual))
if (startDual != -1)
{
verts.append(startDual);
verts.appendUniq(startDual);
}
}
break;

View File

@ -498,10 +498,8 @@ bool Foam::fileMonitor::removeWatch(const label watchFd)
<< watchFile_[watchFd] << endl;
}
if (!freeWatchFds_.found(watchFd))
{
freeWatchFds_.append(watchFd);
}
freeWatchFds_.appendUniq(watchFd);
return watcher_->removeWatch(watchFd);
}

View File

@ -494,10 +494,8 @@ bool Foam::fileMonitor::removeWatch(const label watchFd)
<< watchFile_[watchFd] << endl;
}
if (!freeWatchFds_.found(watchFd))
{
freeWatchFds_.append(watchFd);
}
freeWatchFds_.appendUniq(watchFd);
return watcher_->removeWatch(watchFd);
}

View File

@ -258,6 +258,10 @@ public:
inline DynamicList<T, SizeMin>&
append(SortableList<T>&& lst);
//- Append an element if not already in the list.
// \return the change in list length
inline label appendUniq(const T& val);
//- Remove and return the last element. Fatal on an empty list.
inline T remove();

View File

@ -608,6 +608,21 @@ Foam::DynamicList<T, SizeMin>::append
}
template<class T, int SizeMin>
inline Foam::label Foam::DynamicList<T, SizeMin>::appendUniq(const T& val)
{
if (this->found(val))
{
return 0;
}
else
{
this->append(val);
return 1; // Increased list length by one
}
}
template<class T, int SizeMin>
inline T Foam::DynamicList<T, SizeMin>::remove()
{

View File

@ -242,6 +242,10 @@ public:
template<class Addr>
inline void append(const IndirectListBase<T, Addr>& list);
//- Append an element if not already in the list.
// \return the change in list length
inline label appendUniq(const T& val);
//- Transfer the contents of the argument List into this list
//- and annul the argument list
void transfer(List<T>& list);

View File

@ -218,6 +218,21 @@ inline void Foam::List<T>::append(const IndirectListBase<T, Addr>& list)
}
template<class T>
inline Foam::label Foam::List<T>::appendUniq(const T& val)
{
if (this->found(val))
{
return 0;
}
else
{
this->append(val);
return 1; // Increased list length by one
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T>

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,10 +54,7 @@ Foam::wallPolyPatch::wallPolyPatch
polyPatch(name, size, start, index, bm, patchType)
{
// wall is not constraint type so add wall group explicitly
if (!inGroups().found(typeName))
{
inGroups().append(typeName);
}
inGroups().appendUniq(typeName);
}
@ -72,10 +70,7 @@ Foam::wallPolyPatch::wallPolyPatch
polyPatch(name, dict, index, bm, patchType)
{
// wall is not constraint type so add wall group explicitly
if (!inGroups().found(typeName))
{
inGroups().append(typeName);
}
inGroups().appendUniq(typeName);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -100,14 +100,9 @@ Foam::polyPatch::polyPatch
faceCellsPtr_(nullptr),
mePtr_(nullptr)
{
if
(
patchType != word::null
&& constraintType(patchType)
&& !inGroups().found(patchType)
)
if (!patchType.empty() && constraintType(patchType))
{
inGroups().append(patchType);
inGroups().appendUniq(patchType);
}
}
@ -161,14 +156,9 @@ Foam::polyPatch::polyPatch
faceCellsPtr_(nullptr),
mePtr_(nullptr)
{
if
(
patchType != word::null
&& constraintType(patchType)
&& !inGroups().found(patchType)
)
if (!patchType.empty() && constraintType(patchType))
{
inGroups().append(patchType);
inGroups().appendUniq(patchType);
}
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -77,13 +78,10 @@ void Foam::primitiveMesh::calcCellEdges() const
const labelList& curEdges = fe[facei];
forAll(curEdges, edgeI)
{
if (!curCellEdges.found(curEdges[edgeI]))
for (const label edgei : curEdges)
{
// Add the edge
curCellEdges.append(curEdges[edgeI]);
}
curCellEdges.appendUniq(edgei);
}
}
@ -93,13 +91,10 @@ void Foam::primitiveMesh::calcCellEdges() const
const labelList& curEdges = fe[facei];
forAll(curEdges, edgeI)
for (const label edgei : curEdges)
{
if (!curCellEdges.found(curEdges[edgeI]))
{
// add the edge
curCellEdges.append(curEdges[edgeI]);
}
// Add the edge
curCellEdges.appendUniq(edgei);
}
}

View File

@ -305,12 +305,9 @@ bool Foam::UPstream::init(int& argc, char**& argv, const bool needsThread)
if (Pstream::master())
{
DynamicList<word> allWorlds(numprocs);
for (const auto& world : worlds)
for (const word& world : worlds)
{
if (!allWorlds.found(world))
{
allWorlds.append(world);
}
allWorlds.appendUniq(world);
}
allWorlds_ = std::move(allWorlds);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 Zeljko Tukovic, FSB Zagreb.
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1100,14 +1100,11 @@ void Foam::interfaceTrackingFvMesh::correctPointDisplacement
label index = pLabels.find(curPoint);
if (index == -1)
{
if (!pointSet.found(curPoint))
{
pointSet.insert(curPoint);
}
}
}
}
labelList corrPoints = pointSet.toc();
@ -1126,13 +1123,10 @@ void Foam::interfaceTrackingFvMesh::correctPointDisplacement
label index = eFaces.find(curFace);
if (index != -1)
{
if (!faceSet.found(curFace))
{
faceSet.insert(curFace);
}
}
}
corrPointFaces[pointI] = faceSet.toc();
}
@ -1196,13 +1190,10 @@ void Foam::interfaceTrackingFvMesh::correctPointDisplacement
label index = eFaces.find(curFace);
if (index != -1)
{
if (!faceSet.found(curFace))
{
faceSet.insert(curFace);
}
}
}
corrPointFaces[pointI] = faceSet.toc();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -290,14 +290,12 @@ bool Foam::geomCellLooper::cut
// Check distance of endpoints to cutPlane
//
if (!checkedPoints.found(e.start()))
if (checkedPoints.insert(e.start()))
{
checkedPoints.insert(e.start());
const scalar typLen = pointEqualTol_ * minEdgeLen(e.start());
scalar typStartLen = pointEqualTol_ * minEdgeLen(e.start());
// Check distance of startPt to plane.
if (cutPlane.distance(points[e.start()]) < typStartLen)
// Check distance to plane.
if (cutPlane.distance(points[e.start()]) < typLen)
{
// Use point.
localLoop.append(vertToEVert(e.start()));
@ -306,14 +304,13 @@ bool Foam::geomCellLooper::cut
useStart = true;
}
}
if (!checkedPoints.found(e.end()))
if (checkedPoints.insert(e.end()))
{
checkedPoints.insert(e.end());
const scalar typLen = pointEqualTol_ * minEdgeLen(e.end());
scalar typEndLen = pointEqualTol_ * minEdgeLen(e.end());
// Check distance of endPt to plane.
if (cutPlane.distance(points[e.end()]) < typEndLen)
// Check distance to plane.
if (cutPlane.distance(points[e.end()]) < typLen)
{
// Use point.
localLoop.append(vertToEVert(e.end()));

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019,2021 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -916,10 +916,7 @@ void Foam::polyMeshAdder::mergePointZones
else if (pointToZone[allPointi] != zoneI)
{
labelList& pZones = addPointToZones[allPointi];
if (!pZones.found(zoneI))
{
pZones.append(zoneI);
}
pZones.appendUniq(zoneI);
}
}
}
@ -942,10 +939,7 @@ void Foam::polyMeshAdder::mergePointZones
else if (pointToZone[allPointi] != allZoneI)
{
labelList& pZones = addPointToZones[allPointi];
if (!pZones.found(allZoneI))
{
pZones.append(allZoneI);
}
pZones.appendUniq(allZoneI);
}
}
}
@ -1074,9 +1068,8 @@ void Foam::polyMeshAdder::mergeFaceZones
labelList& fZones = addFaceToZones[allFacei];
boolList& flipZones = addFaceToFlips[allFacei];
if (!fZones.found(zoneI))
if (fZones.appendUniq(zoneI))
{
fZones.append(zoneI);
flipZones.append(flip0);
}
}
@ -1117,9 +1110,8 @@ void Foam::polyMeshAdder::mergeFaceZones
labelList& fZones = addFaceToZones[allFacei];
boolList& flipZones = addFaceToFlips[allFacei];
if (!fZones.found(allZoneI))
if (fZones.appendUniq(allZoneI))
{
fZones.append(allZoneI);
flipZones.append(flip1);
}
}
@ -1239,10 +1231,7 @@ void Foam::polyMeshAdder::mergeCellZones
else if (cellToZone[cell0] != zoneI)
{
labelList& cZones = addCellToZones[cell0];
if (!cZones.found(zoneI))
{
cZones.append(zoneI);
}
cZones.appendUniq(zoneI);
}
}
}
@ -1264,10 +1253,7 @@ void Foam::polyMeshAdder::mergeCellZones
else if (cellToZone[allCelli] != allZoneI)
{
labelList& cZones = addCellToZones[allCelli];
if (!cZones.found(allZoneI))
{
cZones.append(allZoneI);
}
cZones.appendUniq(allZoneI);
}
}
}

View File

@ -267,10 +267,7 @@ bool Foam::combineFaces::faceNeighboursValid
}
else
{
if (!neighbourFaces.found(nbrI))
{
neighbourFaces.append(nbrI);
}
neighbourFaces.appendUniq(nbrI);
}
}

View File

@ -1849,17 +1849,14 @@ bool Foam::hexRef8::matchHexShape
if (iter.found())
{
labelList& pFaces = iter.val();
if (!pFaces.found(facei))
{
pFaces.append(facei);
}
pFaces.appendUniq(facei);
}
else
{
pointFaces.insert
(
pointi,
labelList(1, facei)
labelList(one{}, facei)
);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,19 +58,11 @@ void Foam::enrichedPatch::calcPointPoints() const
// Do next label
const label next = curFace.nextLabel(pointi);
if (!curPp.found(next))
{
curPp.append(next);
}
curPp.appendUniq(next);
// Do previous label
const label prev = curFace.prevLabel(pointi);
if (!curPp.found(prev))
{
curPp.append(prev);
}
curPp.appendUniq(prev);
}
}

View File

@ -945,7 +945,7 @@ void Foam::faMesh::calcPointAreaNormals() const
labelList curPointPoints = curPatch.edgeLoops()[0];
for (int i = 0; i < curPointPoints.size(); ++i)
for (label i = 0; i < curPointPoints.size(); ++i)
{
vector d1 =
points[curPatch.meshPoints()[curPointPoints[i]]]
@ -1212,60 +1212,35 @@ void Foam::faMesh::calcPointAreaNormalsByQuadricsFit() const
labelHashSet pointSet;
pointSet.insert(curPoint);
for (label i=0; i<curFaces.size(); ++i)
for (const label facei : curFaces)
{
const labelList& facePoints = faces[curFaces[i]];
for (label j=0; j<facePoints.size(); ++j)
{
if (!pointSet.found(facePoints[j]))
{
pointSet.insert(facePoints[j]);
}
}
const labelList& facePoints = faces[facei];
pointSet.insert(facePoints);
}
pointSet.erase(curPoint);
labelList curPoints(pointSet.toc());
if (curPoints.size() < 5)
if (pointSet.size() < 5)
{
DebugInfo
<< "WARNING: Extending point set for fitting." << endl;
labelHashSet faceSet(pointFaces[curPoint]);
labelList curFaces(faceSet.toc());
forAll(curFaces, faceI)
for (const label facei : curFaces)
{
const labelList& curFaceFaces =
patch().faceFaces()[curFaces[faceI]];
forAll(curFaceFaces, fI)
{
label curFaceFace = curFaceFaces[fI];
if (!faceSet.found(curFaceFace))
{
faceSet.insert(curFaceFace);
}
}
const labelList& curFaceFaces = patch().faceFaces()[facei];
faceSet.insert(curFaceFaces);
}
curFaces = faceSet.toc();
labelHashSet pointSet;
pointSet.clear();
pointSet.insert(curPoint);
for (label i=0; i<curFaces.size(); ++i)
for (const label facei : curFaces)
{
const labelList& facePoints = faces[curFaces[i]];
for (label j=0; j<facePoints.size(); ++j)
{
if (!pointSet.found(facePoints[j]))
{
pointSet.insert(facePoints[j]);
const labelList& facePoints = faces[facei];
pointSet.insert(facePoints);
}
}
}
pointSet.erase(curPoint);
curPoints = pointSet.toc();
}
@ -1372,17 +1347,10 @@ void Foam::faMesh::calcPointAreaNormalsByQuadricsFit() const
labelHashSet pointSet;
pointSet.insert(curPoint);
for (label i=0; i<curFaces.size(); ++i)
for (const label facei : curFaces)
{
const labelList& facePoints = faces[curFaces[i]];
for (label j=0; j<facePoints.size(); ++j)
{
if (!pointSet.found(facePoints[j]))
{
pointSet.insert(facePoints[j]);
}
}
const labelList& facePoints = faces[facei];
pointSet.insert(facePoints);
}
pointSet.erase(curPoint);
labelList curPoints = pointSet.toc();
@ -1456,17 +1424,10 @@ void Foam::faMesh::calcPointAreaNormalsByQuadricsFit() const
labelHashSet pointSet;
pointSet.insert(curPoint);
for (label i=0; i<curFaces.size(); ++i)
for (const label facei : curFaces)
{
const labelList& facePoints = faces[curFaces[i]];
for (label j=0; j<facePoints.size(); ++j)
{
if (!pointSet.found(facePoints[j]))
{
pointSet.insert(facePoints[j]);
}
}
const labelList& facePoints = faces[facei];
pointSet.insert(facePoints);
}
pointSet.erase(curPoint);
labelList curPoints = pointSet.toc();
@ -1653,17 +1614,10 @@ void Foam::faMesh::calcPointAreaNormalsByQuadricsFit() const
const labelList curFaces(faceSet.toc());
labelHashSet pointSet;
pointSet.insert(curPoint);
for (label i=0; i<curFaces.size(); ++i)
for (const label facei : curFaces)
{
const labelList& facePoints = faces[curFaces[i]];
for (label j=0; j<facePoints.size(); ++j)
{
if (!pointSet.found(facePoints[j]))
{
pointSet.insert(facePoints[j]);
}
}
const labelList& facePoints = faces[facei];
pointSet.insert(facePoints);
}
pointSet.erase(curPoint);
labelList curPoints = pointSet.toc();

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -140,10 +141,8 @@ void Foam::CFCFaceToCellStencil::calcCellStencil
allGlobalFaces.clear();
// My faces first
forAll(cFaces, i)
for (const label facei : cFaces)
{
label facei = cFaces[i];
if
(
mesh().isInternalFace(facei)
@ -155,10 +154,8 @@ void Foam::CFCFaceToCellStencil::calcCellStencil
}
// faces of neighbouring cells second
forAll(cFaces, i)
for (const label facei : cFaces)
{
label facei = cFaces[i];
if (mesh().isInternalFace(facei))
{
label nbrCelli = own[facei];
@ -168,23 +165,18 @@ void Foam::CFCFaceToCellStencil::calcCellStencil
}
const cell& nbrFaces = mesh().cells()[nbrCelli];
forAll(nbrFaces, j)
for (const label nbrFacei : nbrFaces)
{
label nbrFacei = nbrFaces[j];
if
(
mesh().isInternalFace(nbrFacei)
|| validBFace[nbrFacei-mesh().nInternalFaces()]
)
{
label nbrGlobalI = globalNumbering().toGlobal(nbrFacei);
label nbrGlobali = globalNumbering().toGlobal(nbrFacei);
// Check if already there. Note:should use hashset?
if (!allGlobalFaces.found(nbrGlobalI))
{
allGlobalFaces.append(nbrGlobalI);
}
// Note:should use hashset?
allGlobalFaces.appendUniq(nbrGlobali);
}
}
}
@ -193,15 +185,10 @@ void Foam::CFCFaceToCellStencil::calcCellStencil
const labelList& nbrGlobalFaces =
neiGlobal[facei-mesh().nInternalFaces()];
forAll(nbrGlobalFaces, j)
for (const label nbrGlobali : nbrGlobalFaces)
{
label nbrGlobalI = nbrGlobalFaces[j];
// Check if already there. Note:should use hashset?
if (!allGlobalFaces.found(nbrGlobalI))
{
allGlobalFaces.append(nbrGlobalI);
}
// Note:should use hashset?
allGlobalFaces.appendUniq(nbrGlobali);
}
}
}

View File

@ -1974,14 +1974,11 @@ void Foam::snappyLayerDriver::getPatchDisplacement
// if (faceFnd.found())
// {
// labelList& faces = faceFnd();
// if (!faces.found(patchFacei))
// {
// faces.append(patchFacei);
// }
// faces.appendUniq(patchFacei);
// }
// else
// {
// cellToFaces.insert(celli, labelList(1, patchFacei));
// cellToFaces.insert(celli, labelList(one{}, patchFacei));
// }
// }
//

View File

@ -107,10 +107,7 @@ void Foam::cellDistFuncs::getPointNeighbours
for (const label nbr : faceNeighbours)
{
if (!neighbours.found(nbr))
{
neighbours.append(nbr);
}
neighbours.appendUniq(nbr);
}
// Add all point-only neighbours by linear searching in edge neighbours.
@ -128,10 +125,7 @@ void Foam::cellDistFuncs::getPointNeighbours
for (const label facei : pointNbs)
{
// Check for facei in edge-neighbours part of neighbours
if (!neighbours.found(facei))
{
neighbours.append(facei);
}
neighbours.appendUniq(facei);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -180,16 +180,12 @@ void Foam::cellFeatures::walkSuperFace
Map<label>& toSuperFace
) const
{
if (!toSuperFace.found(facei))
if (toSuperFace.insert(facei, superFacei))
{
toSuperFace.insert(facei, superFacei);
const labelList& fEdges = mesh_.faceEdges()[facei];
forAll(fEdges, fEdgeI)
for (const label edgeI : fEdges)
{
label edgeI = fEdges[fEdgeI];
if (!featureEdge_.found(edgeI))
{
label face0;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,10 +56,7 @@ Foam::mappedPolyPatch::mappedPolyPatch
mappedPatchBase(static_cast<const polyPatch&>(*this))
{
// mapped is not constraint type so add mapped group explicitly
if (!inGroups().found(typeName))
{
inGroups().append(typeName);
}
inGroups().appendUniq(typeName);
}
@ -125,10 +123,7 @@ Foam::mappedPolyPatch::mappedPolyPatch
mappedPatchBase(*this, dict)
{
// mapped is not constraint type so add mapped group explicitly
if (!inGroups().found(typeName))
{
inGroups().append(typeName);
}
inGroups().appendUniq(typeName);
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,10 +62,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
mappedPatchBase(static_cast<const polyPatch&>(*this))
{
// mapped is not constraint type so add mapped group explicitly
if (!inGroups().found(mappedPolyPatch::typeName))
{
inGroups().append(mappedPolyPatch::typeName);
}
inGroups().appendUniq(mappedPolyPatch::typeName);
}
@ -131,10 +129,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
mappedPatchBase(*this, dict)
{
// mapped is not constraint type so add mapped group explicitly
if (!inGroups().found(mappedPolyPatch::typeName))
{
inGroups().append(mappedPolyPatch::typeName);
}
inGroups().appendUniq(mappedPolyPatch::typeName);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -172,7 +172,7 @@ void Foam::localPointRegion::countPointRegions
}
else
{
label localPointi = meshPointMap_.size();
const label localPointi = meshPointMap_.size();
meshPointMap_.insert(pointi, localPointi);
labelList regions(2);
regions[0] = minPointRegion[pointi];
@ -180,7 +180,7 @@ void Foam::localPointRegion::countPointRegions
pointRegions.append(regions);
}
label meshFaceMapI = meshFaceMap_.size();
const label meshFaceMapI = meshFaceMap_.size();
meshFaceMap_.insert(facei, meshFaceMapI);
}
}
@ -372,7 +372,7 @@ void Foam::localPointRegion::calcPointRegions
const label pointi = f[fp];
auto iter = minPointValue.find(pointi);
if (iter == minPointValue.end())
if (!iter.found())
{
minPointValue.insert(pointi, minRegion[facei][fp]);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -56,10 +56,7 @@ Foam::oversetPolyPatch::oversetPolyPatch
masterPatchID_(-1)
{
// 'overset' is not constraint type so add to group explicitly
if (!inGroups().found(typeName))
{
inGroups().append(typeName);
}
inGroups().appendUniq(typeName);
}
@ -76,10 +73,7 @@ Foam::oversetPolyPatch::oversetPolyPatch
masterPatchID_(-1)
{
// 'overset' is not constraint type so add to group explicitly
if (!inGroups().found(typeName))
{
inGroups().append(typeName);
}
inGroups().appendUniq(typeName);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2015 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -290,8 +290,8 @@ Foam::label Foam::mapNearestMethod::findMappedSrcCell
const List<DynamicList<label>>& tgtToSrc
) const
{
DynamicList<label> testCells(10);
DynamicList<label> visitedCells(10);
DynamicList<label> testCells(16);
DynamicList<label> visitedCells(16);
testCells.append(tgtCelli);
@ -312,11 +312,11 @@ Foam::label Foam::mapNearestMethod::findMappedSrcCell
{
const labelList& nbrCells = tgt_.cellCells()[tgtI];
forAll(nbrCells, i)
for (const label nbrCelli : nbrCells)
{
if (!visitedCells.found(nbrCells[i]))
if (!visitedCells.found(nbrCelli))
{
testCells.append(nbrCells[i]);
testCells.append(nbrCelli);
}
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2014 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -194,13 +194,9 @@ void Foam::meshToMeshMethod::appendNbrCells
// filter out cells already visited from cell neighbours
for (const label nbrCelli : nbrCells)
{
if
(
!visitedCells.found(nbrCelli)
&& !nbrCellIDs.found(nbrCelli)
)
if (!visitedCells.found(nbrCelli))
{
nbrCellIDs.append(nbrCelli);
nbrCellIDs.appendUniq(nbrCelli);
}
}
}

View File

@ -270,8 +270,6 @@ scalar RRreaction = RRcal;
scalar allCommonT = 1000.0;
word currentElementName;
label currentElementIndex = 0;
word currentSpecieName;
label currentSpecieIndex = 0;
label nSpecieElements = 0;
@ -332,9 +330,8 @@ bool finishReaction = false;
currentElementName = word::validate(YYText());
correctElementName(currentElementName);
if (!elementIndices_.found(currentElementName))
if (elementIndices_.insert(currentElementName, elementNames_.size()))
{
elementIndices_.insert(currentElementName, currentElementIndex++);
elementNames_.append(currentElementName);
}
else

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,9 +61,8 @@ void Foam::foamChemistryReader<ThermoType>::readSpeciesComposition()
for (const word& elemName : elems)
{
if (!elementIndices_.found(elemName))
if (elementIndices_.insert(elemName, elementNames_.size()))
{
elementIndices_.insert(elemName, elementNames_.size());
elementNames_.append(elemName);
}
else