ENH: sort cellCentre output according to global cell index (issue #869)

- replace SortableList with sortedOrder, to reduce some overhead
This commit is contained in:
Mark Olesen 2018-06-13 11:08:58 +02:00
parent 22a7c8bb7f
commit 67310ed4ef
3 changed files with 13 additions and 7 deletions

View File

@ -27,6 +27,7 @@ License
#include "meshSearch.H"
#include "polyMesh.H"
#include "volFields.H"
#include "globalIndex.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -44,6 +45,8 @@ void Foam::cellCentreSet::genSamples()
{
const label len = mesh().nCells();
const globalIndex globalSampleNumbers(len);
const auto& cellCentres =
refCast<const fvMesh>(mesh()).C().primitiveField();
@ -70,8 +73,13 @@ void Foam::cellCentreSet::genSamples()
}
labelList samplingFaces(selectedCells.size(), -1);
labelList samplingSegments(selectedCells.size(), -1);
scalarList samplingCurveDist(selectedCells.size(), 0.0);
labelList samplingSegments(selectedCells.size(), 0);
scalarList samplingCurveDist(selectedCells.size());
forAll(selectedCells, i)
{
samplingCurveDist[i] = globalSampleNumbers.toGlobal(selectedCells[i]);
}
// Move into *this
setSamples

View File

@ -29,7 +29,6 @@ License
#include "meshSearch.H"
#include "writer.H"
#include "particle.H"
#include "SortableList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -467,7 +466,7 @@ Foam::autoPtr<Foam::coordSet> Foam::sampledSet::gather
);
if (Pstream::master() && allCurveDist.size() == 0)
if (Pstream::master() && allCurveDist.empty())
{
WarningInFunction
<< "Sample set " << name()
@ -475,8 +474,8 @@ Foam::autoPtr<Foam::coordSet> Foam::sampledSet::gather
}
// Sort curveDist and use to fill masterSamplePts
SortableList<scalar> sortedDist(allCurveDist);
indexSet = sortedDist.indices();
Foam::sortedOrder(allCurveDist, indexSet); // uses stable sort
scalarList sortedDist(allCurveDist, indexSet); // with indices for mapping
return autoPtr<coordSet>::New
(

View File

@ -28,7 +28,6 @@ License
#include "Time.H"
#include "volFields.H"
#include "ListListOps.H"
#include "SortableList.H"
#include "volPointInterpolation.H"
#include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H"