Commit 3ee2f329 authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: avoid global findIndex() in favour of UList::find()

parent c126464d
......@@ -1253,12 +1253,11 @@ bool Foam::faMeshDecomposition::writeDecomposition()
{
const labelList& curEdgeLabels = curPatchEdgeLabels[nPatches];
label ngbPolyPatchIndex =
findIndex
const label ngbPolyPatchIndex =
fvBoundaryProcAddressing.find
(
fvBoundaryProcAddressing,
meshPatches[curBoundaryAddressing[patchi]]
.ngbPolyPatchIndex()
.ngbPolyPatchIndex()
);
procPatches[nPatches] =
......
......@@ -250,17 +250,21 @@ labelList identity(const label len);
template<class ListType>
label findIndex
(
const ListType&,
typename ListType::const_reference,
const ListType& input,
typename ListType::const_reference val,
const label start=0
);
)
{
return input.find(val, start);
}
//- Find all occurences of given element. Linear search.
template<class ListType>
labelList findIndices
(
const ListType& l,
typename ListType::const_reference t,
const ListType& input,
typename ListType::const_reference val,
const label start=0
);
......
......@@ -565,29 +565,6 @@ void Foam::invertManyToMany
}
template<class ListType>
Foam::label Foam::findIndex
(
const ListType& l,
typename ListType::const_reference t,
const label start
)
{
label index = -1;
for (label i = start; i < l.size(); i++)
{
if (l[i] == t)
{
index = i;
break;
}
}
return index;
}
template<class ListType>
Foam::labelList Foam::findIndices
(
......
......@@ -90,8 +90,8 @@ void Foam::faGlobalMeshData::updateMesh()
label polyMeshPoint =
mesh_.patch().meshPoints()[localPointLabels[pointI]];
label sharedPolyMeshPoint =
findIndex(polyMeshSharedPointLabels, polyMeshPoint);
const label sharedPolyMeshPoint =
polyMeshSharedPointLabels.find(polyMeshPoint);
if
(
......@@ -124,11 +124,11 @@ void Foam::faGlobalMeshData::updateMesh()
sharedPointAddr_.setSize(sharedPointLabels_.size());
forAll(sharedPointAddr_, pointI)
{
label polyMeshSharedPointIndex = findIndex
(
polyMeshSharedPointLabels,
mesh_.patch().meshPoints()[sharedPointLabels_[pointI]]
);
const label polyMeshSharedPointIndex =
polyMeshSharedPointLabels.find
(
mesh_.patch().meshPoints()[sharedPointLabels_[pointI]]
);
sharedPointAddr_[pointI] =
globalList[polyMeshSharedPointAddr[polyMeshSharedPointIndex]]
......
......@@ -560,7 +560,7 @@ Foam::faMesh::faMesh
{
label curFace = edgeFaces[curPMeshEdge][faceI];
if (findIndex(faceLabels_, curFace) == -1)
if (faceLabels_.found(curFace))
{
label polyPatchID = pbm.whichPatch(curFace);
......
......@@ -1647,7 +1647,7 @@ void Foam::faMesh::calcPointAreaNormalsByQuadricsFit() const
{
List<List<vector>> procLsPoints(Pstream::nProcs());
label curSharedPointIndex = findIndex(addr, k);
const label curSharedPointIndex = addr.find(k);
scalar tol = 0.0;
......
......@@ -269,8 +269,7 @@ void Foam::processorFaPatch::initUpdateMesh()
const edge& e = patchEdges[edgeI];
indexInEdge[patchPointI] =
findIndex(e, pointLabels()[patchPointI]);
indexInEdge[patchPointI] = e.find(pointLabels()[patchPointI]);
}
OPstream toNeighbProc
......@@ -326,9 +325,9 @@ void Foam::processorFaPatch::updateMesh()
// Find edge and index in edge on this side.
const edge& e = patchEdges[nbrPatchEdge[nbrPointI]];
label index = 1 - nbrIndexInEdge[nbrPointI];
const label index = 1 - nbrIndexInEdge[nbrPointI];
label patchPointI = findIndex(pointLabels(), e[index]);
const label patchPointI = pointLabels().find(e[index]);
neighbPoints[patchPointI] = nbrPointI;
}
......
......@@ -197,7 +197,7 @@ void Foam::faPatch::calcPointEdges() const
forAll(curPoints, pointI)
{
label localPointIndex = findIndex(points, curPoints[pointI]);
const label localPointIndex = points.find(curPoints[pointI]);
pointEdgs[localPointIndex].append(edgeI);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment