mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: avoid global findIndex() in favour of UList::find()
This commit is contained in:
@ -1253,12 +1253,11 @@ bool Foam::faMeshDecomposition::writeDecomposition()
|
|||||||
{
|
{
|
||||||
const labelList& curEdgeLabels = curPatchEdgeLabels[nPatches];
|
const labelList& curEdgeLabels = curPatchEdgeLabels[nPatches];
|
||||||
|
|
||||||
label ngbPolyPatchIndex =
|
const label ngbPolyPatchIndex =
|
||||||
findIndex
|
fvBoundaryProcAddressing.find
|
||||||
(
|
(
|
||||||
fvBoundaryProcAddressing,
|
|
||||||
meshPatches[curBoundaryAddressing[patchi]]
|
meshPatches[curBoundaryAddressing[patchi]]
|
||||||
.ngbPolyPatchIndex()
|
.ngbPolyPatchIndex()
|
||||||
);
|
);
|
||||||
|
|
||||||
procPatches[nPatches] =
|
procPatches[nPatches] =
|
||||||
|
|||||||
@ -250,17 +250,21 @@ labelList identity(const label len);
|
|||||||
template<class ListType>
|
template<class ListType>
|
||||||
label findIndex
|
label findIndex
|
||||||
(
|
(
|
||||||
const ListType&,
|
const ListType& input,
|
||||||
typename ListType::const_reference,
|
typename ListType::const_reference val,
|
||||||
const label start=0
|
const label start=0
|
||||||
);
|
)
|
||||||
|
{
|
||||||
|
return input.find(val, start);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Find all occurences of given element. Linear search.
|
//- Find all occurences of given element. Linear search.
|
||||||
template<class ListType>
|
template<class ListType>
|
||||||
labelList findIndices
|
labelList findIndices
|
||||||
(
|
(
|
||||||
const ListType& l,
|
const ListType& input,
|
||||||
typename ListType::const_reference t,
|
typename ListType::const_reference val,
|
||||||
const label start=0
|
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>
|
template<class ListType>
|
||||||
Foam::labelList Foam::findIndices
|
Foam::labelList Foam::findIndices
|
||||||
(
|
(
|
||||||
|
|||||||
@ -90,8 +90,8 @@ void Foam::faGlobalMeshData::updateMesh()
|
|||||||
label polyMeshPoint =
|
label polyMeshPoint =
|
||||||
mesh_.patch().meshPoints()[localPointLabels[pointI]];
|
mesh_.patch().meshPoints()[localPointLabels[pointI]];
|
||||||
|
|
||||||
label sharedPolyMeshPoint =
|
const label sharedPolyMeshPoint =
|
||||||
findIndex(polyMeshSharedPointLabels, polyMeshPoint);
|
polyMeshSharedPointLabels.find(polyMeshPoint);
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -124,11 +124,11 @@ void Foam::faGlobalMeshData::updateMesh()
|
|||||||
sharedPointAddr_.setSize(sharedPointLabels_.size());
|
sharedPointAddr_.setSize(sharedPointLabels_.size());
|
||||||
forAll(sharedPointAddr_, pointI)
|
forAll(sharedPointAddr_, pointI)
|
||||||
{
|
{
|
||||||
label polyMeshSharedPointIndex = findIndex
|
const label polyMeshSharedPointIndex =
|
||||||
(
|
polyMeshSharedPointLabels.find
|
||||||
polyMeshSharedPointLabels,
|
(
|
||||||
mesh_.patch().meshPoints()[sharedPointLabels_[pointI]]
|
mesh_.patch().meshPoints()[sharedPointLabels_[pointI]]
|
||||||
);
|
);
|
||||||
|
|
||||||
sharedPointAddr_[pointI] =
|
sharedPointAddr_[pointI] =
|
||||||
globalList[polyMeshSharedPointAddr[polyMeshSharedPointIndex]]
|
globalList[polyMeshSharedPointAddr[polyMeshSharedPointIndex]]
|
||||||
|
|||||||
@ -560,7 +560,7 @@ Foam::faMesh::faMesh
|
|||||||
{
|
{
|
||||||
label curFace = edgeFaces[curPMeshEdge][faceI];
|
label curFace = edgeFaces[curPMeshEdge][faceI];
|
||||||
|
|
||||||
if (findIndex(faceLabels_, curFace) == -1)
|
if (faceLabels_.found(curFace))
|
||||||
{
|
{
|
||||||
label polyPatchID = pbm.whichPatch(curFace);
|
label polyPatchID = pbm.whichPatch(curFace);
|
||||||
|
|
||||||
|
|||||||
@ -1647,7 +1647,7 @@ void Foam::faMesh::calcPointAreaNormalsByQuadricsFit() const
|
|||||||
{
|
{
|
||||||
List<List<vector>> procLsPoints(Pstream::nProcs());
|
List<List<vector>> procLsPoints(Pstream::nProcs());
|
||||||
|
|
||||||
label curSharedPointIndex = findIndex(addr, k);
|
const label curSharedPointIndex = addr.find(k);
|
||||||
|
|
||||||
scalar tol = 0.0;
|
scalar tol = 0.0;
|
||||||
|
|
||||||
|
|||||||
@ -269,8 +269,7 @@ void Foam::processorFaPatch::initUpdateMesh()
|
|||||||
|
|
||||||
const edge& e = patchEdges[edgeI];
|
const edge& e = patchEdges[edgeI];
|
||||||
|
|
||||||
indexInEdge[patchPointI] =
|
indexInEdge[patchPointI] = e.find(pointLabels()[patchPointI]);
|
||||||
findIndex(e, pointLabels()[patchPointI]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OPstream toNeighbProc
|
OPstream toNeighbProc
|
||||||
@ -326,9 +325,9 @@ void Foam::processorFaPatch::updateMesh()
|
|||||||
// Find edge and index in edge on this side.
|
// Find edge and index in edge on this side.
|
||||||
const edge& e = patchEdges[nbrPatchEdge[nbrPointI]];
|
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;
|
neighbPoints[patchPointI] = nbrPointI;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -197,7 +197,7 @@ void Foam::faPatch::calcPointEdges() const
|
|||||||
|
|
||||||
forAll(curPoints, pointI)
|
forAll(curPoints, pointI)
|
||||||
{
|
{
|
||||||
label localPointIndex = findIndex(points, curPoints[pointI]);
|
const label localPointIndex = points.find(curPoints[pointI]);
|
||||||
|
|
||||||
pointEdgs[localPointIndex].append(edgeI);
|
pointEdgs[localPointIndex].append(edgeI);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user