ENH: add single-parameter sortedOrder() function

This commit is contained in:
Mark Olesen
2019-07-17 11:08:40 +02:00
committed by Andrew Heather
parent 5788fe056c
commit 1d86fc4f6b
33 changed files with 134 additions and 117 deletions

View File

@ -58,10 +58,12 @@ int main(int argc, char *argv[])
SortableList<label> list1r(list1.size()); SortableList<label> list1r(list1.size());
list1r = list1; list1r = list1;
Info<< "unsorted: " << orig << endl; Info<< "unsorted: " << orig << nl
<< "order: " << sortedOrder(list1) << endl;
sort(list1); sort(list1);
Info<< "sorted: " << list1 << nl Info<< "sorted: " << list1 << nl
<< "indices: " << order << endl; << "indices: " << order << nl
<< "order: " << sortedOrder(list1) << endl;
list1r.reverseSort(); list1r.reverseSort();
Info<< "reverse ..." << nl; Info<< "reverse ..." << nl;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2012-2017 OpenFOAM Foundation | Copyright (C) 2012-2017 OpenFOAM Foundation
@ -67,9 +67,7 @@ void Foam::DelaunayMesh<Triangulation>::sortFaces
<< "Sorting faces, owner and neighbour into upper triangular order" << "Sorting faces, owner and neighbour into upper triangular order"
<< endl; << endl;
labelList oldToNew; labelList oldToNew(sortedOrder(ownerNeighbourPair));
sortedOrder(ownerNeighbourPair, oldToNew);
oldToNew = invert(oldToNew.size(), oldToNew); oldToNew = invert(oldToNew.size(), oldToNew);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2012-2016 OpenFOAM Foundation | Copyright (C) 2012-2016 OpenFOAM Foundation
@ -1322,8 +1322,7 @@ void Foam::conformalVoronoiMesh::indexDualVertices
// Sort the vertices so that they will be in the same order on // Sort the vertices so that they will be in the same order on
// each processor // each processor
labelList oldToNew; labelList oldToNew(sortedOrder(cellVerticesPair));
sortedOrder(cellVerticesPair, oldToNew);
oldToNew = invert(oldToNew.size(), oldToNew); oldToNew = invert(oldToNew.size(), oldToNew);
inplaceReorder(oldToNew, cellVertices); inplaceReorder(oldToNew, cellVertices);
@ -2406,10 +2405,7 @@ void Foam::conformalVoronoiMesh::sortFaces
<< "Sorting faces, owner and neighbour into upper triangular order" << "Sorting faces, owner and neighbour into upper triangular order"
<< endl; << endl;
labelList oldToNew; labelList oldToNew(sortedOrder(ownerNeighbourPair));
sortedOrder(ownerNeighbourPair, oldToNew);
oldToNew = invert(oldToNew.size(), oldToNew); oldToNew = invert(oldToNew.size(), oldToNew);
inplaceReorder(oldToNew, faces); inplaceReorder(oldToNew, faces);
@ -2459,10 +2455,7 @@ void Foam::conformalVoronoiMesh::sortProcPatches
<< exit(FatalError) << endl; << exit(FatalError) << endl;
} }
labelList oldToNew; labelList oldToNew(sortedOrder(sortingIndices));
sortedOrder(sortingIndices, oldToNew);
oldToNew = invert(oldToNew.size(), oldToNew); oldToNew = invert(oldToNew.size(), oldToNew);
inplaceReorder(oldToNew, sortingIndices); inplaceReorder(oldToNew, sortingIndices);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -226,12 +226,10 @@ labelList getFaceOrder
} }
} }
order.setSize(nbr.size());
sortedOrder(nbr, order); sortedOrder(nbr, order);
forAll(order, i) for (const label index : order)
{ {
label index = order[i];
if (nbr[index] != -1) if (nbr[index] != -1)
{ {
oldToNewFace[cFaces[index]] = newFacei++; oldToNewFace[cFaces[index]] = newFacei++;
@ -495,8 +493,7 @@ autoPtr<mapPolyMesh> reorderMesh
newFlipMap[i] = fZone.flipMap()[i]; newFlipMap[i] = fZone.flipMap()[i];
} }
} }
labelList newToOld; labelList newToOld(sortedOrder(newAddressing));
sortedOrder(newAddressing, newToOld);
fZone.resetAddressing fZone.resetAddressing
( (
labelUIndList(newAddressing, newToOld)(), labelUIndList(newAddressing, newToOld)(),
@ -1010,8 +1007,7 @@ int main(int argc, char *argv[])
bndCellMap.setSize(nBndCells); bndCellMap.setSize(nBndCells);
// Sort // Sort
labelList order; labelList order(sortedOrder(bndCellMap));
sortedOrder(bndCellMap, order);
// Redo newReverseCellOrder // Redo newReverseCellOrder
labelList newReverseCellOrder(mesh.nCells(), -1); labelList newReverseCellOrder(mesh.nCells(), -1);

View File

@ -177,6 +177,10 @@ template<class Container>
label inplaceMapValue(const Map<label>& mapper, Container& input); label inplaceMapValue(const Map<label>& mapper, Container& input);
//- Return the (stable) sort order for the list
template<class T>
labelList sortedOrder(const UList<T>& input);
//- Generate the (stable) sort order for the list //- Generate the (stable) sort order for the list
template<class T> template<class T>
void sortedOrder(const UList<T>& input, labelList& order); void sortedOrder(const UList<T>& input, labelList& order);
@ -191,6 +195,10 @@ void sortedOrder
); );
//- Return (sorted) indices corresponding to duplicate list values
template<class T>
labelList duplicateOrder(const UList<T>& input);
//- Generate (sorted) indices corresponding to duplicate list values //- Generate (sorted) indices corresponding to duplicate list values
template<class T> template<class T>
void duplicateOrder(const UList<T>& input, labelList& order); void duplicateOrder(const UList<T>& input, labelList& order);
@ -206,6 +214,10 @@ void duplicateOrder
); );
//- Return (sorted) indices corresponding to unique list values
template<class T>
labelList uniqueOrder(const UList<T>& input);
//- Generate (sorted) indices corresponding to unique list values //- Generate (sorted) indices corresponding to unique list values
template<class T> template<class T>
void uniqueOrder(const UList<T>& input, labelList& order); void uniqueOrder(const UList<T>& input, labelList& order);

View File

@ -320,6 +320,18 @@ Foam::label Foam::inplaceMapValue
} }
template<class T>
Foam::labelList Foam::sortedOrder
(
const UList<T>& input
)
{
labelList order(input.size());
sortedOrder(input, order, typename UList<T>::less(input));
return order;
}
template<class T> template<class T>
void Foam::sortedOrder void Foam::sortedOrder
( (
@ -355,6 +367,18 @@ void Foam::sortedOrder
} }
template<class T>
Foam::labelList Foam::duplicateOrder
(
const UList<T>& input
)
{
labelList order(input.size());
duplicateOrder(input, order, typename UList<T>::less(input));
return order;
}
template<class T> template<class T>
void Foam::duplicateOrder void Foam::duplicateOrder
( (
@ -396,6 +420,18 @@ void Foam::duplicateOrder
} }
template<class T>
Foam::labelList Foam::uniqueOrder
(
const UList<T>& input
)
{
labelList order(input.size());
uniqueOrder(input, order, typename UList<T>::less(input));
return order;
}
template<class T> template<class T>
void Foam::uniqueOrder void Foam::uniqueOrder
( (

View File

@ -49,6 +49,10 @@ SourceFiles
namespace Foam namespace Foam
{ {
//- Return (stable) sort order for the list
template<class T>
labelList sortedOrder(const UPtrList<T>& input);
//- Generate (stable) sort order for the list //- Generate (stable) sort order for the list
template<class T> template<class T>
void sortedOrder(const UPtrList<T>& input, labelList& order); void sortedOrder(const UPtrList<T>& input, labelList& order);

View File

@ -27,6 +27,18 @@ License
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class T>
Foam::labelList Foam::sortedOrder
(
const UPtrList<T>& input
)
{
labelList order(input.size());
sortedOrder(input, order, typename PtrListOps::less<T>(input));
return order;
}
template<class T> template<class T>
void Foam::sortedOrder void Foam::sortedOrder
( (
@ -65,7 +77,7 @@ void Foam::sortedOrder
template<class T> template<class T>
void Foam::sort(UPtrList<T>& list) void Foam::sort(UPtrList<T>& list)
{ {
labelList order; labelList order(input.size());
sortedOrder(list, order); sortedOrder(list, order);
list.sortOrder(order, false); // false = allow nullptr list.sortOrder(order, false); // false = allow nullptr
} }
@ -74,7 +86,7 @@ void Foam::sort(UPtrList<T>& list)
template<class T, class Compare> template<class T, class Compare>
void Foam::sort(UPtrList<T>& list, const Compare& comp) void Foam::sort(UPtrList<T>& list, const Compare& comp)
{ {
labelList order; labelList order(input.size());
sortedOrder(list, order, comp); sortedOrder(list, order, comp);
list.sortOrder(order, false); // false = allow nullptr list.sortOrder(order, false); // false = allow nullptr
} }
@ -83,7 +95,7 @@ void Foam::sort(UPtrList<T>& list, const Compare& comp)
template<class T> template<class T>
void Foam::shuffle(UPtrList<T>& list) void Foam::shuffle(UPtrList<T>& list)
{ {
labelList order = identity(list.size()); labelList order(identity(list.size()));
Foam::shuffle(order); Foam::shuffle(order);
list.sortOrder(order, false); // false = allow nullptr list.sortOrder(order, false); // false = allow nullptr
} }

View File

@ -190,8 +190,7 @@ Foam::procFacesGAMGProcAgglomeration::processorAgglomeration
} }
// Sort according to master and redo restriction // Sort according to master and redo restriction
labelList newToOld; labelList newToOld(sortedOrder(coarseToMaster));
sortedOrder(coarseToMaster, newToOld);
labelList oldToNew(invert(newToOld.size(), newToOld)); labelList oldToNew(invert(newToOld.size(), newToOld));
fineToCoarse = labelUIndList(oldToNew, fineToCoarse)(); fineToCoarse = labelUIndList(oldToNew, fineToCoarse)();

View File

@ -182,16 +182,14 @@ Foam::labelList Foam::lduPrimitiveMesh::upperTriOrder
label nNbr = offsets[celli+1] - startOfCell; label nNbr = offsets[celli+1] - startOfCell;
nbr.setSize(nNbr); nbr.setSize(nNbr);
order.setSize(nNbr); forAll(nbr, i)
forAll(order, i)
{ {
nbr[i] = upper[cellToFaces[offsets[celli]+i]]; nbr[i] = upper[cellToFaces[offsets[celli]+i]];
} }
sortedOrder(nbr, order); sortedOrder(nbr, order);
forAll(order, i) for (const label index : order)
{ {
label index = order[i];
oldToNew[cellToFaces[startOfCell + index]] = newFacei++; oldToNew[cellToFaces[startOfCell + index]] = newFacei++;
} }
} }
@ -807,8 +805,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
); );
} }
labelList order; labelList order(sortedOrder(procPairs));
sortedOrder(procPairs, order);
// Count // Count
label n = 0; label n = 0;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -84,8 +84,7 @@ Foam::label Foam::mergePoints
{ {
magSqrDist[pointi] = magSqr(points[pointi] - compareOrigin); magSqrDist[pointi] = magSqr(points[pointi] - compareOrigin);
} }
labelList order; labelList order(Foam::sortedOrder(magSqrDist));
Foam::sortedOrder(magSqrDist, order);
Field<scalar> sortedTol(nPoints); Field<scalar> sortedTol(nPoints);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -771,8 +771,10 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary
// Sort according to ascending region numbers, but leave // Sort according to ascending region numbers, but leave
// "Default_Boundary_Region" as the final patch // "Default_Boundary_Region" as the final patch
{ {
labelList sortedIndices; labelList sortedIndices
sortedOrder(SubList<label>(origRegion, nPatches-1), sortedIndices); (
sortedOrder(SubList<label>(origRegion, nPatches-1))
);
labelList oldToNew = identity(nPatches); labelList oldToNew = identity(nPatches);
forAll(sortedIndices, i) forAll(sortedIndices, i)

View File

@ -1183,8 +1183,8 @@ void Foam::polyMeshAdder::mergeFaceZones
fzFaces[i].shrink(); fzFaces[i].shrink();
fzFlips[i].shrink(); fzFlips[i].shrink();
labelList order; labelList order(sortedOrder(fzFaces[i]));
sortedOrder(fzFaces[i], order);
fzFaces[i] = labelUIndList(fzFaces[i], order)(); fzFaces[i] = labelUIndList(fzFaces[i], order)();
fzFlips[i] = boolUIndList(fzFlips[i], order)(); fzFlips[i] = boolUIndList(fzFlips[i], order)();
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -583,9 +583,7 @@ Foam::edgeCollapser::collapseType Foam::edgeCollapser::collapseFace
// Sort the projected distances and the corresponding vertex // Sort the projected distances and the corresponding vertex
// indices along the collapse axis // indices along the collapse axis
labelList oldToNew; labelList oldToNew(sortedOrder(d));
sortedOrder(d, oldToNew);
oldToNew = invert(oldToNew.size(), oldToNew); oldToNew = invert(oldToNew.size(), oldToNew);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -725,7 +725,6 @@ void Foam::polyTopoChange::getFaceOrder
label nFaces = cellFaceOffsets[celli+1] - startOfCell; label nFaces = cellFaceOffsets[celli+1] - startOfCell;
// Neighbouring cells // Neighbouring cells
//SortableList<label> nbr(nFaces);
nbr.setSize(nFaces); nbr.setSize(nFaces);
for (label i = 0; i < nFaces; i++) for (label i = 0; i < nFaces; i++)
@ -765,21 +764,10 @@ void Foam::polyTopoChange::getFaceOrder
} }
} }
//nbr.sort();
order.setSize(nFaces);
sortedOrder(nbr, order); sortedOrder(nbr, order);
//forAll(nbr, i) for (const label index : order)
//{
// if (nbr[i] != -1)
// {
// oldToNew[cellFaces[startOfCell + nbr.indices()[i]]] =
// newFacei++;
// }
//}
forAll(order, i)
{ {
label index = order[i];
if (nbr[index] != -1) if (nbr[index] != -1)
{ {
oldToNew[cellFaces[startOfCell + index]] = newFacei++; oldToNew[cellFaces[startOfCell + index]] = newFacei++;
@ -1672,8 +1660,7 @@ void Foam::polyTopoChange::resetZones
// Sort the addressing // Sort the addressing
forAll(addressing, zonei) forAll(addressing, zonei)
{ {
labelList newToOld; labelList newToOld(sortedOrder(addressing[zonei]));
sortedOrder(addressing[zonei], newToOld);
{ {
labelList newAddressing(addressing[zonei].size()); labelList newAddressing(addressing[zonei].size());
forAll(newAddressing, i) forAll(newAddressing, i)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
isoAdvector | Copyright (C) 2016-2017 DHI isoAdvector | Copyright (C) 2016-2017 DHI
@ -299,8 +299,7 @@ void Foam::isoCutCell::calcIsoFacePointsFromEdges()
DebugPout<< "Calculated isoFace point angles" << endl; DebugPout<< "Calculated isoFace point angles" << endl;
// Sorting isoface points by angle and inserting into isoFacePoints_ // Sorting isoface points by angle and inserting into isoFacePoints_
labelList order(unsortedIsoFacePointAngles.size()); labelList order(sortedOrder(unsortedIsoFacePointAngles));
Foam::sortedOrder(unsortedIsoFacePointAngles, order);
isoFacePoints_.append(unsortedIsoFacePoints[order[0]]); isoFacePoints_.append(unsortedIsoFacePoints[order[0]]);
for (label pi = 1; pi < order.size(); pi++) for (label pi = 1; pi < order.size(); pi++)
{ {
@ -508,8 +507,7 @@ Foam::label Foam::isoCutCell::vofCutCell
{ {
fvert[pi] = f_[pLabels[pi]]; fvert[pi] = f_[pLabels[pi]];
} }
labelList order(fvert.size()); labelList order(sortedOrder(fvert));
sortedOrder(fvert, order);
scalar f1 = fvert[order.first()]; scalar f1 = fvert[order.first()];
scalar f2 = fvert[order.last()]; scalar f2 = fvert[order.last()];

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
isoAdvector | Copyright (C) 2016-2017 DHI isoAdvector | Copyright (C) 2016-2017 DHI
@ -496,8 +496,7 @@ Foam::scalar Foam::isoCutFace::timeIntegratedArea
scalar tIntArea = 0.0; scalar tIntArea = 0.0;
// Finding ordering of vertex points // Finding ordering of vertex points
labelList order(pTimes.size()); labelList order(sortedOrder(pTimes));
sortedOrder(pTimes, order);
const scalar firstTime = pTimes[order.first()]; const scalar firstTime = pTimes[order.first()];
const scalar lastTime = pTimes[order.last()]; const scalar lastTime = pTimes[order.last()];

View File

@ -388,8 +388,7 @@ void Foam::functionObjects::externalCoupled::checkOrder
const wordList& regionNames const wordList& regionNames
) )
{ {
labelList order; labelList order(sortedOrder(regionNames));
sortedOrder(regionNames, order);
if (order != identity(regionNames.size())) if (order != identity(regionNames.size()))
{ {
FatalErrorInFunction FatalErrorInFunction

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -97,8 +97,7 @@ void Foam::PatchPostProcessing<CloudType>::write()
accessOp<List<scalar>>() accessOp<List<scalar>>()
); );
labelList indices; labelList indices(sortedOrder(globalTimes));
sortedOrder(globalTimes, indices);
string header("# Time currentProc " + parcelType::propertyList_); string header("# Time currentProc " + parcelType::propertyList_);
patchOutFile<< header.c_str() << nl; patchOutFile<< header.c_str() << nl;

View File

@ -375,14 +375,13 @@ void Foam::PairCollision<CloudType>::wallInteraction()
// ascending distance to their nearest point so that // ascending distance to their nearest point so that
// grouping occurs around the closest in any group // grouping occurs around the closest in any group
labelList sortedOtherSiteIndices; labelList sortedOtherSiteIndices
(
sortedOrder(otherSiteDistances)
);
sortedOrder(otherSiteDistances, sortedOtherSiteIndices); for (const label orderedIndex : sortedOtherSiteIndices)
forAll(sortedOtherSiteIndices, siteI)
{ {
label orderedIndex = sortedOtherSiteIndices[siteI];
const point& otherPt = otherSitePoints[orderedIndex]; const point& otherPt = otherSitePoints[orderedIndex];
if if

View File

@ -110,8 +110,8 @@ void Foam::InjectedParticleInjection<CloudType>::initialise()
} }
// Sort and renumber to ensure lists in ascending time // Sort and renumber to ensure lists in ascending time
labelList sortedIndices; labelList sortedIndices(Foam::sortedOrder(time));
Foam::sortedOrder(time, sortedIndices);
time_ = UIndirectList<scalar>(time, sortedIndices); time_ = UIndirectList<scalar>(time, sortedIndices);
position_ = UIndirectList<point>(position, sortedIndices); position_ = UIndirectList<point>(position, sortedIndices);
diameter_ = UIndirectList<scalar>(diameter, sortedIndices); diameter_ = UIndirectList<scalar>(diameter, sortedIndices);

View File

@ -2639,8 +2639,7 @@ Foam::label Foam::meshRefinement::findRegions
); );
// Sort according to curveDist // Sort according to curveDist
labelList indexSet; labelList indexSet(Foam::sortedOrder(allDist));
Foam::sortedOrder(allDist, indexSet);
allLeakPaths.set allLeakPaths.set
( (

View File

@ -186,11 +186,9 @@ void Foam::meshRefinement::collectAndPrint
scalarField magAllPoints(mag(allPoints-point(-0.317, 0.117, 0.501))); scalarField magAllPoints(mag(allPoints-point(-0.317, 0.117, 0.501)));
labelList visitOrder; labelList visitOrder(sortedOrder(magAllPoints));
sortedOrder(magAllPoints, visitOrder); for (const label allPointi : visitOrder)
forAll(visitOrder, i)
{ {
label allPointi = visitOrder[i];
Info<< allPoints[allPointi] << " : " << allData[allPointi] Info<< allPoints[allPointi] << " : " << allData[allPointi]
<< endl; << endl;
} }

View File

@ -2138,8 +2138,7 @@ Foam::label Foam::snappyRefineDriver::directionalSmooth
} }
// Sort the normalized position // Sort the normalized position
labelList order; labelList order(sortedOrder(normalizedPosition));
sortedOrder(normalizedPosition, order);
DynamicList<scalar> seedPointDist; DynamicList<scalar> seedPointDist;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation | Copyright (C) 2011-2015 OpenFOAM Foundation
@ -724,8 +724,7 @@ void Foam::snappySnapDriver::correctAttraction
// Tangential component along edge // Tangential component along edge
scalar tang = ((pt-edgePt)&edgeNormal); scalar tang = ((pt-edgePt)&edgeNormal);
labelList order; labelList order(sortedOrder(surfaceCounts));
Foam::sortedOrder(surfaceCounts, order);
if (order[0] < order[1]) if (order[0] < order[1])
{ {

View File

@ -45,8 +45,7 @@ namespace Foam
void Foam::cellZoneSet::updateSet() void Foam::cellZoneSet::updateSet()
{ {
labelList order; labelList order(sortedOrder(addressing_));
sortedOrder(addressing_, order);
inplaceReorder(order, addressing_); inplaceReorder(order, addressing_);
cellSet::clearStorage(); cellSet::clearStorage();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -49,8 +49,7 @@ namespace Foam
void Foam::faceZoneSet::updateSet() void Foam::faceZoneSet::updateSet()
{ {
labelList order; labelList order(sortedOrder(addressing_));
sortedOrder(addressing_, order);
addressing_ = labelUIndList(addressing_, order)(); addressing_ = labelUIndList(addressing_, order)();
flipMap_ = boolUIndList(flipMap_, order)(); flipMap_ = boolUIndList(flipMap_, order)();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -46,8 +46,7 @@ namespace Foam
void Foam::pointZoneSet::updateSet() void Foam::pointZoneSet::updateSet()
{ {
labelList order; labelList order(sortedOrder(addressing_));
sortedOrder(addressing_, order);
inplaceReorder(order, addressing_); inplaceReorder(order, addressing_);
pointSet::clearStorage(); pointSet::clearStorage();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -161,8 +161,7 @@ Foam::labelList Foam::springRenumber::renumber
//writeOBJ("endPosition.obj", cellCells, position); //writeOBJ("endPosition.obj", cellCells, position);
// Move cells to new position // Move cells to new position
labelList shuffle; labelList shuffle(sortedOrder(position));
sortedOrder(position, shuffle);
// Reorder oldToNew // Reorder oldToNew
inplaceReorder(shuffle, oldToNew); inplaceReorder(shuffle, oldToNew);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -85,8 +85,7 @@ void Foam::MeshedSurface<Face>::sortFacesAndStore
// Determine the sorted order: // Determine the sorted order:
// use sortedOrder directly since we discard the intermediate list anyhow // use sortedOrder directly since we discard the intermediate list anyhow
List<label> faceMap; labelList faceMap(sortedOrder(zones));
sortedOrder(zones, faceMap);
zones.clear(); zones.clear();
// Sorted faces // Sorted faces

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -164,8 +164,7 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
{ {
// Determine the sorted order: // Determine the sorted order:
// use sortedOrder directly (the intermediate list is discarded anyhow) // use sortedOrder directly (the intermediate list is discarded anyhow)
labelList faceMap; labelList faceMap(sortedOrder(zoneIds));
sortedOrder(zoneIds, faceMap);
// Generate sorted faces // Generate sorted faces
forAll(faceMap, facei) forAll(faceMap, facei)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -124,8 +124,7 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
{ {
// Determine the sorted order: // Determine the sorted order:
// use sortedOrder directly (the intermediate list is discared anyhow) // use sortedOrder directly (the intermediate list is discared anyhow)
labelList faceMap; labelList faceMap(sortedOrder(zoneIds));
sortedOrder(zoneIds, faceMap);
// Generate sorted faces // Generate sorted faces
forAll(faceMap, facei) forAll(faceMap, facei)

View File

@ -304,7 +304,7 @@ Foam::triSurface::calcPatches(labelList& faceMap) const
// Determine the sorted order: // Determine the sorted order:
// use sortedOrder directly (the intermediate list is discarded anyhow) // use sortedOrder directly (the intermediate list is discarded anyhow)
List<label> regions(size()); labelList regions(size());
forAll(regions, facei) forAll(regions, facei)
{ {
regions[facei] = operator[](facei).region(); regions[facei] = operator[](facei).region();