Commit 67310ed4 authored by Mark Olesen's avatar Mark Olesen
Browse files

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

- replace SortableList with sortedOrder, to reduce some overhead
parent 22a7c8bb
...@@ -27,6 +27,7 @@ License ...@@ -27,6 +27,7 @@ License
#include "meshSearch.H" #include "meshSearch.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "volFields.H" #include "volFields.H"
#include "globalIndex.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...@@ -44,6 +45,8 @@ void Foam::cellCentreSet::genSamples() ...@@ -44,6 +45,8 @@ void Foam::cellCentreSet::genSamples()
{ {
const label len = mesh().nCells(); const label len = mesh().nCells();
const globalIndex globalSampleNumbers(len);
const auto& cellCentres = const auto& cellCentres =
refCast<const fvMesh>(mesh()).C().primitiveField(); refCast<const fvMesh>(mesh()).C().primitiveField();
...@@ -70,8 +73,13 @@ void Foam::cellCentreSet::genSamples() ...@@ -70,8 +73,13 @@ void Foam::cellCentreSet::genSamples()
} }
labelList samplingFaces(selectedCells.size(), -1); labelList samplingFaces(selectedCells.size(), -1);
labelList samplingSegments(selectedCells.size(), -1); labelList samplingSegments(selectedCells.size(), 0);
scalarList samplingCurveDist(selectedCells.size(), 0.0); scalarList samplingCurveDist(selectedCells.size());
forAll(selectedCells, i)
{
samplingCurveDist[i] = globalSampleNumbers.toGlobal(selectedCells[i]);
}
// Move into *this // Move into *this
setSamples setSamples
......
...@@ -29,7 +29,6 @@ License ...@@ -29,7 +29,6 @@ License
#include "meshSearch.H" #include "meshSearch.H"
#include "writer.H" #include "writer.H"
#include "particle.H" #include "particle.H"
#include "SortableList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...@@ -467,7 +466,7 @@ Foam::autoPtr<Foam::coordSet> Foam::sampledSet::gather ...@@ -467,7 +466,7 @@ Foam::autoPtr<Foam::coordSet> Foam::sampledSet::gather
); );
if (Pstream::master() && allCurveDist.size() == 0) if (Pstream::master() && allCurveDist.empty())
{ {
WarningInFunction WarningInFunction
<< "Sample set " << name() << "Sample set " << name()
...@@ -475,8 +474,8 @@ Foam::autoPtr<Foam::coordSet> Foam::sampledSet::gather ...@@ -475,8 +474,8 @@ Foam::autoPtr<Foam::coordSet> Foam::sampledSet::gather
} }
// Sort curveDist and use to fill masterSamplePts // Sort curveDist and use to fill masterSamplePts
SortableList<scalar> sortedDist(allCurveDist); Foam::sortedOrder(allCurveDist, indexSet); // uses stable sort
indexSet = sortedDist.indices(); scalarList sortedDist(allCurveDist, indexSet); // with indices for mapping
return autoPtr<coordSet>::New return autoPtr<coordSet>::New
( (
......
...@@ -28,7 +28,6 @@ License ...@@ -28,7 +28,6 @@ License
#include "Time.H" #include "Time.H"
#include "volFields.H" #include "volFields.H"
#include "ListListOps.H" #include "ListListOps.H"
#include "SortableList.H"
#include "volPointInterpolation.H" #include "volPointInterpolation.H"
#include "mapPolyMesh.H" #include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
......
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