ENH: refine renumberMesh and renumberMethod (addenda to !669)

- provide no_topology() characteristic to avoid triggering potentially
  expensive mesh connectivity calculations when they are not required.

- remove/deprecate unused pointField references from the renumber
  methods. These appear to have crept in from outer similarities
  with decompositionMethod, but have no meaning for renumbering.

- remove/deprecate various unused aggregation renumberings since these
  have been previously replaced by pre-calling calcCellCells, or
  using bandCompression directly.

- make regionFaceOrder for block-wise renumbering optional and
  treat as experimental (ie, default is now disabled).

  The original idea was to sort the intra-region and inter-region faces
  separately. However, this will mostly lead to non-upper triangular
  ordering between regions, which checkMesh and others don't really like.

ENH: add timing information for various renumberMesh stages

ENH: add reset of clockTime and cpuTime increment

- simplifies section-wise timings

ENH: add globalIndex::null() and fieldTypes::processorType conveniences

- provides more central management of these characteristics
This commit is contained in:
Mark Olesen
2024-03-10 14:32:57 +01:00
parent 618faa0ab6
commit 0c84e50583
36 changed files with 541 additions and 448 deletions

View File

@ -206,7 +206,7 @@ int main(int argc, char *argv[])
#endif #endif
loopInsert(map, nElem); loopInsert(map, nElem);
(void)timer.cpuTimeIncrement(); timer.resetCpuTimeIncrement();
unsigned long sum = 0; unsigned long sum = 0;
for (label loopi = 0; loopi < nFind*nLoops; ++loopi) for (label loopi = 0; loopi < nFind*nLoops; ++loopi)
@ -268,7 +268,7 @@ int main(int argc, char *argv[])
HashSet<label, Hash<label>> map(32); HashSet<label, Hash<label>> map(32);
loopInsert(map, nElem); loopInsert(map, nElem);
(void)timer.cpuTimeIncrement(); timer.resetCpuTimeIncrement();
unsigned long sum = 0; unsigned long sum = 0;
for (label loopi = 0; loopi < nFind*nLoops; ++loopi) for (label loopi = 0; loopi < nFind*nLoops; ++loopi)

View File

@ -1,3 +1,3 @@
Test-nullObject.C Test-nullObject.cxx
EXE = $(FOAM_USER_APPBIN)/Test-nullObject EXE = $(FOAM_USER_APPBIN)/Test-nullObject

View File

@ -37,6 +37,7 @@ Description
#include "HashSet.H" #include "HashSet.H"
#include "faceList.H" #include "faceList.H"
#include "pointField.H" #include "pointField.H"
#include "globalIndex.H"
#include "IOstreams.H" #include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -150,6 +151,18 @@ int main()
NullObject::nullObject = "hello world"; NullObject::nullObject = "hello world";
NullObject::nullObject = Foam::identity(5); NullObject::nullObject = Foam::identity(5);
{
const auto& gi = globalIndex::null();
Info<< "globalIndex::null() => "
<< " empty: " << gi.empty()
<< " nProcs: " << gi.nProcs()
<< " total-size: " << gi.totalSize() << nl;
// Even this works
Info<< " offsets: " << gi.offsets() << nl;
}
Info<< nl; Info<< nl;
return 0; return 0;

View File

@ -123,6 +123,7 @@ Usage
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H" #include "argList.H"
#include "clockTime.H"
#include "timeSelector.H" #include "timeSelector.H"
#include "IOobjectList.H" #include "IOobjectList.H"
#include "fvMesh.H" #include "fvMesh.H"
@ -147,6 +148,24 @@ Usage
using namespace Foam; using namespace Foam;
// Slightly messy way of handling timing, but since the timing points
// are scattered between 'main()' and other local functions...
clockTime timer;
// Timing categories
enum TimingType
{
READ_MESH, // Reading mesh
READ_FIELDS, // Reading fields
DECOMPOSE, // Domain decomposition (if any)
CELL_CELLS, // globalMeshData::calcCellCells
RENUMBER, // The renumberMethod
REORDER, // Mesh reordering (topoChange)
WRITING, // Writing mesh/fields
};
FixedList<double, 8> timings;
// Create named field from labelList for post-processing // Create named field from labelList for post-processing
tmp<volScalarField> createScalarField tmp<volScalarField> createScalarField
@ -205,8 +224,8 @@ void getBand
scalar& sumSqrIntersect // scalar to avoid overflow scalar& sumSqrIntersect // scalar to avoid overflow
) )
{ {
labelList cellBandwidth(nCells, Zero); labelList cellBandwidth(nCells, Foam::zero{});
scalarField nIntersect(nCells, Zero); scalarField nIntersect(nCells, Foam::zero{});
forAll(neighbour, facei) forAll(neighbour, facei)
{ {
@ -627,8 +646,33 @@ CompactListList<label> regionRenumber
invertOneToManyCompact(nRegions, cellToRegion) invertOneToManyCompact(nRegions, cellToRegion)
); );
if (method.needs_mesh()) if (method.no_topology())
{ {
// Special case when renumberMesh is only used for decomposition.
// - can skip generating the connectivity
// - nonetheless calculate the order in case it is non-identity
timer.resetTimeIncrement();
forAll(regionCellOrder, regioni)
{
// Note: cellMap is identical to regionToCells[regioni]
// since it is already sorted
labelList subCellOrder =
method.renumber(regionCellOrder[regioni].size());
// Per region reordering (inplace but with SubList)
regionCellOrder[regioni] =
labelUIndList(regionCellOrder[regioni], subCellOrder)();
}
timings[TimingType::RENUMBER] += timer.timeIncrement();
}
else if (method.needs_mesh())
{
timer.resetTimeIncrement();
forAll(regionCellOrder, regioni) forAll(regionCellOrder, regioni)
{ {
// Info<< " region " << regioni // Info<< " region " << regioni
@ -645,20 +689,20 @@ CompactListList<label> regionRenumber
// (assuming they are properly sorted!) // (assuming they are properly sorted!)
const labelList& cellMap = subsetter.cellMap(); const labelList& cellMap = subsetter.cellMap();
labelList subCellOrder = method.renumber labelList subCellOrder = method.renumber(subsetter.subMesh());
(
subsetter.subMesh(),
subsetter.subMesh().cellCentres()
);
UPstream::parRun(oldParRun); // Restore parallel state UPstream::parRun(oldParRun); // Restore parallel state
// Per region reordering // Per region reordering
regionCellOrder[regioni] = labelUIndList(cellMap, subCellOrder); regionCellOrder[regioni] = labelUIndList(cellMap, subCellOrder);
} }
timings[TimingType::RENUMBER] += timer.timeIncrement();
} }
else else
{ {
timer.resetTimeIncrement();
forAll(regionCellOrder, regioni) forAll(regionCellOrder, regioni)
{ {
// Info<< " region " << regioni // Info<< " region " << regioni
@ -677,17 +721,16 @@ CompactListList<label> regionRenumber
cellCells cellCells
); );
// Note: cellCentres not needed by every renumber method timings[TimingType::CELL_CELLS] += timer.timeIncrement();
labelList subCellOrder = method.renumber
( labelList subCellOrder = method.renumber(cellCells);
cellCells,
pointField(mesh.cellCentres(), cellMap)
);
UPstream::parRun(oldParRun); // Restore parallel state UPstream::parRun(oldParRun); // Restore parallel state
// Per region reordering // Per region reordering
regionCellOrder[regioni] = labelUIndList(cellMap, subCellOrder); regionCellOrder[regioni] = labelUIndList(cellMap, subCellOrder);
timings[TimingType::RENUMBER] += timer.timeIncrement();
} }
} }
// Info<< endl; // Info<< endl;
@ -832,8 +875,15 @@ int main(int argc, char *argv[])
runTime.setTime(Times[startTime], startTime); runTime.setTime(Times[startTime], startTime);
// Start/reset all timings
timer.resetTime();
timings = Foam::zero{};
#include "createNamedMeshes.H" #include "createNamedMeshes.H"
timings[TimingType::READ_MESH] += timer.timeIncrement();
for (fvMesh& mesh : meshes) for (fvMesh& mesh : meshes)
{ {
@ -881,6 +931,7 @@ int main(int argc, char *argv[])
bool sortCoupledFaceCells = false; bool sortCoupledFaceCells = false;
bool writeMaps = args.found("write-maps"); bool writeMaps = args.found("write-maps");
bool orderPoints = false; bool orderPoints = false;
bool useRegionFaceOrder = false;
label blockSize = 0; label blockSize = 0;
// Construct renumberMethod // Construct renumberMethod
@ -920,6 +971,12 @@ int main(int argc, char *argv[])
<< " and region-external." << " and region-external."
<< nl << endl; << nl << endl;
} }
if (blockSize > 0)
{
useRegionFaceOrder =
renumberDict.getOrDefault("regionFaceOrder", false);
}
} }
orderPoints = renumberDict.getOrDefault("orderPoints", false); orderPoints = renumberDict.getOrDefault("orderPoints", false);
@ -969,12 +1026,12 @@ int main(int argc, char *argv[])
{ {
renumberPtr.reset(new CuthillMcKeeRenumber(renumberDict)); renumberPtr.reset(new CuthillMcKeeRenumber(renumberDict));
Info<< "Using renumber-method: " << renumberPtr().type() Info<< "Using renumber-method: " << renumberPtr().type()
<< " [default]" << nl << endl; << " [default]" << endl;
} }
else else
{ {
Info<< "Using renumber-method: " << renumberPtr().type() Info<< "Using renumber-method: " << renumberPtr().type()
<< nl << endl; << endl;
} }
@ -1042,6 +1099,10 @@ int main(int argc, char *argv[])
if (!dryrun && doFields) if (!dryrun && doFields)
{ {
Info<< nl << "Reading fields" << nl;
timer.resetTimeIncrement();
objects = IOobjectList(mesh, runTime.timeName()); objects = IOobjectList(mesh, runTime.timeName());
storedObjects.reserve(objects.size()); storedObjects.reserve(objects.size());
@ -1089,6 +1150,8 @@ int main(int argc, char *argv[])
#undef ReadFields #undef ReadFields
#undef ReadPointFields #undef ReadPointFields
timings[TimingType::READ_FIELDS] += timer.timeIncrement();
} }
@ -1116,6 +1179,8 @@ int main(int argc, char *argv[])
if (blockSize > 0 && !doDecompose) if (blockSize > 0 && !doDecompose)
{ {
timer.resetTimeIncrement();
// Renumbering in two phases. Should be done in one so mapping of // Renumbering in two phases. Should be done in one so mapping of
// fields is done correctly! // fields is done correctly!
@ -1143,6 +1208,7 @@ int main(int argc, char *argv[])
UPstream::parRun(oldParRun); // Restore parallel state UPstream::parRun(oldParRun); // Restore parallel state
timings[TimingType::DECOMPOSE] += timer.timeIncrement();
// For debugging: write out region // For debugging: write out region
createScalarField createScalarField
@ -1163,12 +1229,14 @@ int main(int argc, char *argv[])
cellOrder = regionCellOrder.values(); cellOrder = regionCellOrder.values();
// Determine new to old face order with new cell numbering // Determine new to old face order with new cell numbering
faceOrder = getRegionFaceOrder if (useRegionFaceOrder)
( {
mesh, faceOrder = getRegionFaceOrder(mesh, cellOrder, cellToRegion);
cellOrder, }
cellToRegion else
); {
faceOrder = getFaceOrder(mesh, cellOrder);
}
} }
else else
{ {
@ -1178,6 +1246,8 @@ int main(int argc, char *argv[])
// 1. decompose into regions (like decomposePar) // 1. decompose into regions (like decomposePar)
// 2. renumber each sub-region // 2. renumber each sub-region
timer.resetTimeIncrement();
// Read decompositionMethod dictionary // Read decompositionMethod dictionary
IOdictionary decomposeDict IOdictionary decomposeDict
( (
@ -1212,6 +1282,8 @@ int main(int argc, char *argv[])
) )
); );
timings[TimingType::DECOMPOSE] += timer.timeIncrement();
UPstream::parRun(oldParRun); // Restore parallel state UPstream::parRun(oldParRun); // Restore parallel state
CompactListList<label> regionCellOrder = CompactListList<label> regionCellOrder =
@ -1236,11 +1308,21 @@ int main(int argc, char *argv[])
else else
{ {
// Determines sorted back to original cell ordering // Determines sorted back to original cell ordering
cellOrder = renumberPtr().renumber
( const auto& method = renumberPtr();
mesh,
mesh.cellCentres() timer.resetTimeIncrement();
);
if (method.no_topology())
{
cellOrder = method.renumber(mesh.nCells());
}
else
{
cellOrder = method.renumber(mesh);
}
timings[TimingType::RENUMBER] += timer.timeIncrement();
} }
@ -1321,11 +1403,7 @@ int main(int argc, char *argv[])
// Determine new to old face order with new cell numbering // Determine new to old face order with new cell numbering
faceOrder = getFaceOrder faceOrder = getFaceOrder(mesh, cellOrder);
(
mesh,
cellOrder // New to old cell
);
} }
@ -1681,6 +1759,8 @@ int main(int argc, char *argv[])
} }
else else
{ {
timer.resetTimeIncrement();
if (overwrite) if (overwrite)
{ {
mesh.setInstance(oldInstance); mesh.setInstance(oldInstance);
@ -1720,6 +1800,8 @@ int main(int argc, char *argv[])
mesh.write(); mesh.write();
timings[TimingType::WRITING] += timer.timeIncrement();
if (writeMaps) if (writeMaps)
{ {
// For debugging: write out region // For debugging: write out region
@ -1771,6 +1853,19 @@ int main(int argc, char *argv[])
} }
} }
Info<< nl
<< "Timings:" << nl
<< " read mesh : " << timings[TimingType::READ_MESH] << nl
<< " read fields : " << timings[TimingType::READ_FIELDS] << nl
<< " decompose : " << timings[TimingType::DECOMPOSE] << nl
<< " cell-cells : " << timings[TimingType::CELL_CELLS] << nl
<< " renumber : " << timings[TimingType::RENUMBER] << nl
<< " write : " << timings[TimingType::WRITING] << nl
<< "TotalTime = " << timer.elapsedTime() << " s" << nl
<< nl;
runTime.printExecutionTime(Info);
Info<< "End\n" << endl; Info<< "End\n" << endl;
return 0; return 0;

View File

@ -38,6 +38,11 @@ sortCoupledFaceCells false;
// Optional entry: sort points into internal and boundary points // Optional entry: sort points into internal and boundary points
//orderPoints false; //orderPoints false;
// Optional entry (experimental) - for block-by-block (blockSize > 0) option:
// - sort intra-region and iter-region faces separately.
// This will likely lead to non-upper triangular ordering between regions.
//regionFaceOrder false;
method CuthillMcKee; method CuthillMcKee;
//method RCM; // == reverseCuthillMcKee; //method RCM; // == reverseCuthillMcKee;

View File

@ -77,6 +77,12 @@ void Foam::cpuTimePosix::resetCpuTime()
} }
void Foam::cpuTimePosix::resetCpuTimeIncrement() const
{
last_.update();
}
double Foam::cpuTimePosix::elapsedCpuTime() const double Foam::cpuTimePosix::elapsedCpuTime() const
{ {
last_.update(); last_.update();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -72,7 +72,8 @@ class cpuTimePosix
//- Start time, at the time of construction //- Start time, at the time of construction
value_type start_; value_type start_;
//- Last time when elapsedTime or timeIncrement was called //- Last time when elapsedCpuTime or cpuTimeIncrement was called.
//- Also affected by resetCpuTime and resetCpuTimeIncrement.
mutable value_type last_; mutable value_type last_;
@ -95,10 +96,14 @@ public:
//- Reset to use the current time for the start time //- Reset to use the current time for the start time
void resetCpuTime(); void resetCpuTime();
//- Return CPU time (in seconds) from the start //- Reset to use the current time for the increment point
void resetCpuTimeIncrement() const;
//- Return CPU time [seconds] from the start
double elapsedCpuTime() const; double elapsedCpuTime() const;
//- Return CPU time (in seconds) since last call to cpuTimeIncrement() //- Return CPU time [seconds] since last call to cpuTimeIncrement(),
//- resetCpuTimeIncrement().
double cpuTimeIncrement() const; double cpuTimeIncrement() const;
}; };

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2023 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -59,6 +59,11 @@ const Foam::word Foam::fieldTypes::extrapolatedCalculatedType
Foam::fieldTypes::extrapolatedCalculatedTypeName_() Foam::fieldTypes::extrapolatedCalculatedTypeName_()
); );
const Foam::word Foam::fieldTypes::processorType
(
Foam::fieldTypes::processorTypeName_()
);
const Foam::word Foam::fieldTypes::zeroGradientType const Foam::word Foam::fieldTypes::zeroGradientType
( (
Foam::fieldTypes::zeroGradientTypeName_() Foam::fieldTypes::zeroGradientTypeName_()

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2023 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -105,6 +105,12 @@ inline const char* extrapolatedCalculatedTypeName_() noexcept
//- A combined \c zero-gradient and \c calculated patch field type //- A combined \c zero-gradient and \c calculated patch field type
extern const word extrapolatedCalculatedType; extern const word extrapolatedCalculatedType;
//- A \c processor patch field type
inline const char* processorTypeName_() noexcept { return "processor"; }
//- A \c processor patch field type
extern const word processorType;
//- A \c zeroGradient patch field type //- A \c zeroGradient patch field type
inline const char* zeroGradientTypeName_() noexcept { return "zeroGradient"; } inline const char* zeroGradientTypeName_() noexcept { return "zeroGradient"; }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -46,8 +46,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef clockTime_H #ifndef Foam_clockTime_H
#define clockTime_H #define Foam_clockTime_H
#include "clockValue.H" #include "clockValue.H"
@ -67,7 +67,8 @@ class clockTime
//- Time point at start, or after resetTime //- Time point at start, or after resetTime
clockValue start_; clockValue start_;
//- Time point when elapsedTime or timeIncrement was called //- Time point when elapsedTime or timeIncrement was called.
//- Also updated by resetTime and resetTimeIncrement.
mutable clockValue last_; mutable clockValue last_;
@ -84,13 +85,18 @@ public:
// Member Functions // Member Functions
//- Reset to use the current clock value for the start point //- Reset to use the current clock value for the start
//- and increment points
inline void resetTime(); inline void resetTime();
//- Reset to use the current clock value for the increment point
inline void resetTimeIncrement() const;
//- The time [seconds] since the start point //- The time [seconds] since the start point
inline double elapsedTime() const; inline double elapsedTime() const;
//- The time [seconds] since the last call to timeIncrement() //- The time [seconds] since the last call to elapsedTime(),
//- timeIncrement() or resetTime(), resetTimeIncrement()
inline double timeIncrement() const; inline double timeIncrement() const;
}; };

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -50,6 +50,12 @@ inline void Foam::clockTime::resetTime()
} }
inline void Foam::clockTime::resetTimeIncrement() const
{
last_.update();
}
inline double Foam::clockTime::elapsedTime() const inline double Foam::clockTime::elapsedTime() const
{ {
last_.update(); last_.update();

View File

@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef clockValue_H #ifndef Foam_clockValue_H
#define clockValue_H #define Foam_clockValue_H
#include <chrono> #include <chrono>
#include <string> #include <string>
@ -93,10 +93,7 @@ public:
// Member Functions // Member Functions
//- The time duration //- The time duration
inline const value_type& value() const const value_type& value() const noexcept { return value_; }
{
return value_;
}
//- Reset to zero //- Reset to zero
inline void clear(); inline void clear();

View File

@ -65,6 +65,12 @@ void Foam::cpuTimeCxx::resetCpuTime()
} }
void Foam::cpuTimeCxx::resetCpuTimeIncrement() const
{
last_.update();
}
double Foam::cpuTimeCxx::elapsedCpuTime() const double Foam::cpuTimeCxx::elapsedCpuTime() const
{ {
last_.update(); last_.update();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef cpuTimeCxx_H #ifndef Foam_cpuTimeCxx_H
#define cpuTimeCxx_H #define Foam_cpuTimeCxx_H
#include <ctime> #include <ctime>
@ -71,7 +71,8 @@ class cpuTimeCxx
//- Start time, at the time of construction //- Start time, at the time of construction
value_type start_; value_type start_;
//- Last time when elapsedTime or timeIncrement was called //- Last time when elapsedCpuTime or cpuTimeIncrement was called.
//- Also affected by resetCpuTime and resetCpuTimeIncrement.
mutable value_type last_; mutable value_type last_;
@ -91,13 +92,17 @@ public:
// Member Functions // Member Functions
//- Reset to use the current time for the start time //- Reset to use the current time for the start and increment points
void resetCpuTime(); void resetCpuTime();
//- Reset to use the current time for the increment point
void resetCpuTimeIncrement() const;
//- Return CPU time (in seconds) from the start //- Return CPU time (in seconds) from the start
double elapsedCpuTime() const; double elapsedCpuTime() const;
//- Return CPU time (in seconds) since last call to cpuTimeIncrement() //- Return CPU time [seconds] since last call to cpuTimeIncrement(),
//- resetCpuTimeIncrement().
double cpuTimeIncrement() const; double cpuTimeIncrement() const;
}; };

View File

@ -158,7 +158,7 @@ public:
{ {
if (!suspend_ && timer_) if (!suspend_ && timer_)
{ {
(void) timer_->cpuTimeIncrement(); timer_->resetCpuTimeIncrement();
} }
} }

View File

@ -159,6 +159,13 @@ Foam::labelList cuthill_mckee_algorithm
} }
} }
// Debug:
// - the peak capacity of queuedCells approximates the
// maximum intermediate bandwidth
#if 0
Pout<< "bandCompression: peak-capacity=" << queuedCells.capacity() << nl;
#endif
// Now we have new-to-old in newOrder. // Now we have new-to-old in newOrder.
return newOrder; return newOrder;
} }
@ -306,8 +313,14 @@ Foam::labelList Foam::meshTools::bandCompression
} }
} }
// Now we have new-to-old in newOrder. // Debug:
// - the peak capacity of queuedCells approximates the
// maximum intermediate bandwidth
#if 0
Pout<< "bandCompression: peak-capacity=" << queuedCells.capacity() << nl;
#endif
// Now we have new-to-old in newOrder.
return newOrder; return newOrder;
} }

View File

@ -103,15 +103,17 @@ labelList bandCompression
namespace Foam namespace Foam
{ {
//- Forward to meshTools::bandCompression //- Deprecated - prefer meshTools::bandCompression()
// \deprecated(2022-03) prefer meshTools::bandCompression() // \deprecated(2022-03) prefer meshTools::bandCompression()
FOAM_DEPRECATED_FOR(2022-03, "meshTools::bandCompression()")
inline labelList bandCompression(const labelListList& cellCellAddressing) inline labelList bandCompression(const labelListList& cellCellAddressing)
{ {
return meshTools::bandCompression(cellCellAddressing); return meshTools::bandCompression(cellCellAddressing);
} }
//- Forward to meshTools::bandCompression //- Deprecated - prefer meshTools::bandCompression()
// \deprecated(2022-03) prefer meshTools::bandCompression() // \deprecated(2022-03) prefer meshTools::bandCompression()
FOAM_DEPRECATED_FOR(2022-03, "meshTools::bandCompression()")
inline labelList bandCompression inline labelList bandCompression
( (
const labelUList& cellCells, const labelUList& cellCells,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2023 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -118,6 +118,16 @@ public:
struct gatherNonLocal{}; struct gatherNonLocal{};
// Static Member Functions
//- Return a null globalIndex (reference to a nullObject).
//- Behaves like an empty globalIndex
static const globalIndex& null() noexcept
{
return NullObjectRef<globalIndex>();
}
// Constructors // Constructors
//- Default construct (empty) //- Default construct (empty)

View File

@ -30,7 +30,6 @@ License
#include "SloanRenumber.H" #include "SloanRenumber.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "globalMeshData.H"
#include "processorPolyPatch.H" #include "processorPolyPatch.H"
#include "syncTools.H" #include "syncTools.H"
@ -165,8 +164,7 @@ Foam::labelList renumberImpl(Graph& G, const bool useReverse)
Foam::labelList Foam::SloanRenumber::renumber Foam::labelList Foam::SloanRenumber::renumber
( (
const polyMesh& mesh, const polyMesh& mesh
const pointField& points
) const ) const
{ {
// Construct graph : faceOwner + connections across cyclics. // Construct graph : faceOwner + connections across cyclics.
@ -186,7 +184,7 @@ Foam::labelList Foam::SloanRenumber::renumber
Graph G(mesh.nCells()); Graph G(mesh.nCells());
// Add internal faces // Add internal faces
forAll(mesh.faceNeighbour(), facei) for (label facei = 0; facei < mesh.nInternalFaces(); ++facei)
{ {
add_edge(mesh.faceOwner()[facei], mesh.faceNeighbour()[facei], G); add_edge(mesh.faceOwner()[facei], mesh.faceNeighbour()[facei], G);
} }
@ -226,8 +224,7 @@ Foam::labelList Foam::SloanRenumber::renumber
Foam::labelList Foam::SloanRenumber::renumber Foam::labelList Foam::SloanRenumber::renumber
( (
const CompactListList<label>& cellCells, const CompactListList<label>& cellCells
const pointField&
) const ) const
{ {
Graph G(cellCells.size()); Graph G(cellCells.size());
@ -251,8 +248,7 @@ Foam::labelList Foam::SloanRenumber::renumber
Foam::labelList Foam::SloanRenumber::renumber Foam::labelList Foam::SloanRenumber::renumber
( (
const labelListList& cellCells, const labelListList& cellCells
const pointField&
) const ) const
{ {
Graph G(cellCells.size()); Graph G(cellCells.size());

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd. Copyright (C) 2022-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -83,44 +83,26 @@ public:
//- Toggle reverse on/off //- Toggle reverse on/off
void reverse(bool on) noexcept { reverse_ = on; } void reverse(bool on) noexcept { reverse_ = on; }
//- The renumbering method does not require a polyMesh
virtual bool needs_mesh() const { return false; } // With mesh topology
//- Return the cell visit order (from ordered back to original cell id)
//- using the mesh to determine the connectivity.
virtual labelList renumber(const polyMesh& mesh) const;
//- Return the order in which cells need to be visited // With explicit topology
//- (ie. from ordered back to original cell label).
// This is only defined for geometric renumberMethods.
virtual labelList renumber(const pointField&) const
{
NotImplemented;
return labelList();
}
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label).
// Use the mesh connectivity (if needed)
virtual labelList renumber virtual labelList renumber
( (
const polyMesh& mesh, const CompactListList<label>& cellCells
const pointField& cc
) const; ) const;
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label).
virtual labelList renumber virtual labelList renumber
( (
const CompactListList<label>& cellCells, const labelListList& cellCells
const pointField& cellCentres
) const;
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label).
// The connectivity is equal to mesh.cellCells() except
// - the connections are across coupled patches
virtual labelList renumber
(
const labelListList& cellCells,
const pointField& cc
) const; ) const;
}; };

View File

@ -112,8 +112,7 @@ Foam::reverseCuthillMcKeeRenumber::reverseCuthillMcKeeRenumber
Foam::labelList Foam::CuthillMcKeeRenumber::renumber Foam::labelList Foam::CuthillMcKeeRenumber::renumber
( (
const polyMesh& mesh, const polyMesh& mesh
const pointField&
) const ) const
{ {
labelList orderedToOld = meshTools::bandCompression(mesh); labelList orderedToOld = meshTools::bandCompression(mesh);
@ -129,26 +128,7 @@ Foam::labelList Foam::CuthillMcKeeRenumber::renumber
Foam::labelList Foam::CuthillMcKeeRenumber::renumber Foam::labelList Foam::CuthillMcKeeRenumber::renumber
( (
const labelList& cellCells, const CompactListList<label>& cellCells
const labelList& offsets,
const pointField& cc
) const
{
labelList orderedToOld = meshTools::bandCompression(cellCells, offsets);
if (reverse_)
{
Foam::reverse(orderedToOld);
}
return orderedToOld;
}
Foam::labelList Foam::CuthillMcKeeRenumber::renumber
(
const CompactListList<label>& cellCells,
const pointField&
) const ) const
{ {
labelList orderedToOld = meshTools::bandCompression(cellCells); labelList orderedToOld = meshTools::bandCompression(cellCells);
@ -164,8 +144,7 @@ Foam::labelList Foam::CuthillMcKeeRenumber::renumber
Foam::labelList Foam::CuthillMcKeeRenumber::renumber Foam::labelList Foam::CuthillMcKeeRenumber::renumber
( (
const labelListList& cellCells, const labelListList& cellCells
const pointField&
) const ) const
{ {
labelList orderedToOld = meshTools::bandCompression(cellCells); labelList orderedToOld = meshTools::bandCompression(cellCells);
@ -179,4 +158,21 @@ Foam::labelList Foam::CuthillMcKeeRenumber::renumber
} }
// Foam::labelList Foam::CuthillMcKeeRenumber::renumber
// (
// const labelUList& cellCells,
// const labelUList& offsets
// ) const
// {
// labelList orderedToOld = meshTools::bandCompression(cellCells, offsets);
//
// if (reverse_)
// {
// Foam::reverse(orderedToOld);
// }
//
// return orderedToOld;
// }
// ************************************************************************* // // ************************************************************************* //

View File

@ -30,6 +30,9 @@ Class
Description Description
Cuthill-McKee renumbering (CM or RCM) Cuthill-McKee renumbering (CM or RCM)
SeeAlso
Foam::meshTools::bandCompression
SourceFiles SourceFiles
CuthillMcKeeRenumber.C CuthillMcKeeRenumber.C
@ -85,62 +88,32 @@ public:
//- Toggle reverse on/off //- Toggle reverse on/off
void reverse(bool on) noexcept { reverse_ = on; } void reverse(bool on) noexcept { reverse_ = on; }
//- The renumbering method does not require a polyMesh
virtual bool needs_mesh() const { return false; }
// With mesh topology
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label). //- using the mesh to determine the connectivity.
// This is only defined for geometric renumberMethods.
virtual labelList renumber(const pointField&) const
{
NotImplemented;
return labelList();
}
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label).
// Use the mesh connectivity (if needed)
virtual labelList renumber virtual labelList renumber
( (
//! Mesh connectivity (see globalMeshData::calcCellCells) //! Mesh connectivity (see globalMeshData::calcCellCells)
const polyMesh& mesh, const polyMesh& mesh
//! \em ignored
const pointField& cellCentres
) const; ) const;
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label).
// Connectivity in losort addressing (= neighbour + offsets into
// neighbour)
virtual labelList renumber
(
const labelList& cellCells,
const labelList& offsets,
//! \em ignored
const pointField& cellCentres
) const;
//- Return the order in which cells need to be visited // With explicit topology
//- (ie. from ordered back to original cell label).
//- Return the cell visit order (from ordered back to original cell id).
virtual labelList renumber virtual labelList renumber
( (
//! Mesh connectivity //! Mesh connectivity
const CompactListList<label>& cellCells, const CompactListList<label>& cellCells
//! \em ignored
const pointField& cellCentres
) const; ) const;
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id).
//- (ie. from ordered back to original cell label).
// The connectivity is equal to mesh.cellCells() except
// - the connections are across coupled patches
virtual labelList renumber virtual labelList renumber
( (
//! Mesh connectivity //! Mesh connectivity
const labelListList& cellCells, const labelListList& cellCells
//! \em ignored
const pointField& cellCentres
) const; ) const;
}; };

View File

@ -68,10 +68,11 @@ Foam::manualRenumber::manualRenumber(const dictionary& dict)
Foam::labelList Foam::manualRenumber::renumber Foam::labelList Foam::manualRenumber::renumber
( (
const polyMesh& mesh, const polyMesh& mesh
const pointField& points
) const ) const
{ {
const label nCells = mesh.nCells();
labelList newToOld labelList newToOld
( (
labelIOList::readContents labelIOList::readContents
@ -87,31 +88,27 @@ Foam::labelList Foam::manualRenumber::renumber
); );
// Check if the final renumbering is OK // Check if the final renumbering is OK
if (newToOld.size() != points.size()) if (newToOld.size() != nCells)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Size of renumber list does not correspond " << "Size of renumber list: "
<< "to the number of points. Size: " << newToOld.size() << " != number of cells: " << nCells << nl
<< newToOld.size() << " Number of points: " << "Renumbering data read from file " << dataFile_ << endl
<< points.size()
<< ".\n" << "Manual renumbering data read from file "
<< dataFile_ << "." << endl
<< exit(FatalError); << exit(FatalError);
} }
// Invert to see if one to one // Invert to see if one to one
labelList oldToNew(points.size(), -1); labelList oldToNew(nCells, -1);
forAll(newToOld, i) forAll(newToOld, i)
{ {
const label origCelli = newToOld[i]; const label origCelli = newToOld[i];
if (origCelli < 0 || origCelli >= points.size()) if (origCelli < 0 || origCelli >= nCells)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Renumbering is not one-to-one. Index " << "Renumbering range error. Index " << i
<< i << " maps onto original cell " << origCelli << " maps to cell " << origCelli << " from " << nCells << nl
<< ".\n" << "Manual renumbering data read from file " << "Renumbering data read from file " << dataFile_ << endl
<< dataFile_ << nl
<< exit(FatalError); << exit(FatalError);
} }
@ -124,8 +121,7 @@ Foam::labelList Foam::manualRenumber::renumber
FatalErrorInFunction FatalErrorInFunction
<< "Renumbering is not one-to-one. Index " << i << " and " << "Renumbering is not one-to-one. Index " << i << " and "
<< oldToNew[origCelli] << " map onto " << origCelli << nl << oldToNew[origCelli] << " map onto " << origCelli << nl
<< "Manual renumbering data read from file " << "Renumbering data read from file " << dataFile_ << endl
<< dataFile_ << nl
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -80,41 +80,31 @@ public:
virtual bool needs_mesh() const { return true; } virtual bool needs_mesh() const { return true; }
//- Return the order in which cells need to be visited // With mesh topology
//- (ie. from ordered back to original cell label).
virtual labelList renumber(const pointField&) const
{
NotImplemented;
return labelList();
}
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label). //- using the mesh for its IOobject and instance.
// Uses mesh for regIOobject virtual labelList renumber(const polyMesh& mesh) const;
// With explicit topology - Not implemented!
//- Return the cell visit order (from ordered back to original cell id)
//- Not implemented!
virtual labelList renumber virtual labelList renumber
( (
const polyMesh& mesh, const CompactListList<label>& cellCells
const pointField& cc
) const;
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label).
virtual labelList renumber
(
const CompactListList<label>& cellCells,
const pointField& cellCentres
) const ) const
{ {
NotImplemented; NotImplemented;
return labelList(); return labelList();
} }
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label). //- Not implemented!
virtual labelList renumber virtual labelList renumber
( (
const labelListList& cellCells, const labelListList& cellCells
const pointField& cellCentres
) const ) const
{ {
NotImplemented; NotImplemented;

View File

@ -60,6 +60,15 @@ Foam::noRenumber::noRenumber(const dictionary& dict)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::labelList Foam::noRenumber::renumber
(
const label nCells
) const
{
return Foam::identity(nCells);
}
Foam::labelList Foam::noRenumber::renumber Foam::labelList Foam::noRenumber::renumber
( (
const pointField& cellCentres const pointField& cellCentres
@ -71,8 +80,7 @@ Foam::labelList Foam::noRenumber::renumber
Foam::labelList Foam::noRenumber::renumber Foam::labelList Foam::noRenumber::renumber
( (
const polyMesh& mesh, const polyMesh& mesh
const pointField&
) const ) const
{ {
return Foam::identity(mesh.nCells()); return Foam::identity(mesh.nCells());
@ -81,8 +89,7 @@ Foam::labelList Foam::noRenumber::renumber
Foam::labelList Foam::noRenumber::renumber Foam::labelList Foam::noRenumber::renumber
( (
const CompactListList<label>& cellCells, const CompactListList<label>& cellCells
const pointField&
) const ) const
{ {
return Foam::identity(cellCells.size()); return Foam::identity(cellCells.size());
@ -91,8 +98,7 @@ Foam::labelList Foam::noRenumber::renumber
Foam::labelList Foam::noRenumber::renumber Foam::labelList Foam::noRenumber::renumber
( (
const labelListList& cellCells, const labelListList& cellCells
const pointField&
) const ) const
{ {
return Foam::identity(cellCells.size()); return Foam::identity(cellCells.size());

View File

@ -73,42 +73,48 @@ public:
// Member Functions // Member Functions
//- The renumbering method does not require a polyMesh //- Renumbering method without mesh or cell-cell topology!
virtual bool needs_mesh() const { return false; } virtual bool no_topology() const { return true; }
//- Return the order in which cells need to be visited // No topology
//- (ie. from ordered back to original cell label).
//- Return the cell visit order (from ordered back to original cell id)
//- based solely on the number of cells.
virtual labelList renumber(const label nCells) const;
//- Return the cell visit order (from ordered back to original cell id).
//- based solely on pointField size
virtual labelList renumber(const pointField&) const; virtual labelList renumber(const pointField&) const;
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label). // With mesh topology
//- Return the cell visit order (from ordered back to original cell id)
//- using the mesh only for the number of cells
virtual labelList renumber virtual labelList renumber
( (
//! Mesh number of cells //! Mesh provides the number of cells
const polyMesh& mesh, const polyMesh& mesh
//! \em ignored
const pointField& cellCentres
) const; ) const;
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label). // With explicit topology
//- Return the cell visit order (from ordered back to original cell id)
//- using the topology only for the number of cells
virtual labelList renumber virtual labelList renumber
( (
//! Mesh connectivity for number of cells //! Connectivity provides the number of cells
const CompactListList<label>& cellCells, const CompactListList<label>& cellCells
//! \em ignored
const pointField& cellCentres
) const; ) const;
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label). //- using the topology only for the number of cells
virtual labelList renumber virtual labelList renumber
( (
//! Mesh connectivity for number of cells //! Connectivity provides the number of cells
const labelListList& cellCells, const labelListList& cellCells
//! \em ignored
const pointField& cellCentres
) const; ) const;
}; };

View File

@ -86,6 +86,15 @@ Foam::randomRenumber::randomRenumber(const dictionary& dict)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::labelList Foam::randomRenumber::renumber
(
const label nCells
) const
{
return randomMap(nCells);
}
Foam::labelList Foam::randomRenumber::renumber Foam::labelList Foam::randomRenumber::renumber
( (
const pointField& cellCentres const pointField& cellCentres
@ -97,8 +106,7 @@ Foam::labelList Foam::randomRenumber::renumber
Foam::labelList Foam::randomRenumber::renumber Foam::labelList Foam::randomRenumber::renumber
( (
const polyMesh& mesh, const polyMesh& mesh
const pointField&
) const ) const
{ {
return randomMap(mesh.nCells()); return randomMap(mesh.nCells());
@ -107,8 +115,7 @@ Foam::labelList Foam::randomRenumber::renumber
Foam::labelList Foam::randomRenumber::renumber Foam::labelList Foam::randomRenumber::renumber
( (
const CompactListList<label>& cellCells, const CompactListList<label>& cellCells
const pointField&
) const ) const
{ {
return randomMap(cellCells.size()); return randomMap(cellCells.size());
@ -117,8 +124,7 @@ Foam::labelList Foam::randomRenumber::renumber
Foam::labelList Foam::randomRenumber::renumber Foam::labelList Foam::randomRenumber::renumber
( (
const labelListList& cellCells, const labelListList& cellCells
const pointField&
) const ) const
{ {
return randomMap(cellCells.size()); return randomMap(cellCells.size());

View File

@ -72,42 +72,48 @@ public:
// Member Functions // Member Functions
//- The renumbering method does not require a polyMesh //- Renumbering method without mesh or cell-cell topology!
virtual bool needs_mesh() const { return false; } virtual bool no_topology() const { return true; }
//- Return the order in which cells need to be visited // No topology
//- (ie. from ordered back to original cell label).
//- Return the cell visit order (from ordered back to original cell id)
//- based solely on the number of cells.
virtual labelList renumber(const label nCells) const;
//- Return the cell visit order (from ordered back to original cell id).
//- based solely on pointField size
virtual labelList renumber(const pointField&) const; virtual labelList renumber(const pointField&) const;
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label). // With mesh topology
//- Return the cell visit order (from ordered back to original cell id)
//- using the mesh only for the number of cells
virtual labelList renumber virtual labelList renumber
( (
//! Mesh number of cells //! Mesh provides the number of cells
const polyMesh& mesh, const polyMesh& mesh
//! \em ignored
const pointField& cellCentres
) const; ) const;
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label). // With explicit topology
//- Return the cell visit order (from ordered back to original cell id)
//- using the topology only for the number of cells
virtual labelList renumber virtual labelList renumber
( (
//! Mesh connectivity for number of cells //! Connectivity provides the number of cells
const CompactListList<label>& cellCells, const CompactListList<label>& cellCells
//! \em ignored
const pointField& cellCentres
) const; ) const;
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label). //- using the topology only for the number of cells
virtual labelList renumber virtual labelList renumber
( (
//! Mesh connectivity for number of cells //! Connectivity provides the number of cells
const labelListList& cellCells, const labelListList& cellCells
//! \em ignored
const pointField& cellCentres
) const; ) const;
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -82,10 +82,14 @@ Foam::autoPtr<Foam::renumberMethod> Foam::renumberMethod::New
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::labelList Foam::renumberMethod::renumber Foam::labelList Foam::renumberMethod::renumber(const label nCells) const
( {
const pointField& NotImplemented;
) const return labelList();
}
Foam::labelList Foam::renumberMethod::renumber(const pointField& cc) const
{ {
NotImplemented; NotImplemented;
return labelList(); return labelList();
@ -94,44 +98,21 @@ Foam::labelList Foam::renumberMethod::renumber
Foam::labelList Foam::renumberMethod::renumber Foam::labelList Foam::renumberMethod::renumber
( (
const polyMesh& mesh, const polyMesh& mesh
const pointField& points
) const ) const
{ {
// Local mesh connectivity // Local mesh connectivity
CompactListList<label> cellCells; CompactListList<label> cellCells;
globalMeshData::calcCellCells(mesh, cellCells); globalMeshData::calcCellCells(mesh, cellCells);
return renumber(cellCells, points); return renumber(cellCells);
}
Foam::labelList Foam::renumberMethod::renumber
(
const CompactListList<label>& cellCells,
const pointField& points
) const
{
return renumber(cellCells.unpack(), points);
}
Foam::labelList Foam::renumberMethod::renumber
(
const labelList& cellCells,
const labelList& offsets,
const pointField& cc
) const
{
NotImplemented;
return labelList();
} }
Foam::labelList Foam::renumberMethod::renumber Foam::labelList Foam::renumberMethod::renumber
( (
const polyMesh& mesh, const polyMesh& mesh,
const labelList& fineToCoarse, const labelUList& fineToCoarse,
const pointField& coarsePoints const pointField& coarsePoints
) const ) const
{ {
@ -140,16 +121,13 @@ Foam::labelList Foam::renumberMethod::renumber
( (
mesh, mesh,
fineToCoarse, fineToCoarse,
coarsePoints.size(), coarsePoints.size(), // nLocalCoarse
false, // local only (parallel = false) false, // local only (parallel = false)
coarseCellCells coarseCellCells
); );
// Renumber based on agglomerated points // Renumber based on agglomerated points
labelList coarseDistribution labelList coarseDistribution = renumber(coarseCellCells);
(
renumber(coarseCellCells, coarsePoints)
);
// From coarse back to fine for original mesh // From coarse back to fine for original mesh
return labelList(coarseDistribution, fineToCoarse); return labelList(coarseDistribution, fineToCoarse);

View File

@ -98,72 +98,99 @@ public:
// Member Functions // Member Functions
//- Does renumbering method require a polyMesh? //- Renumbering method without mesh or cell-cell topology
//- (very special case)
virtual bool no_topology() const { return false; }
//- Renumbering method requires a polyMesh for its topology
virtual bool needs_mesh() const { return false; } virtual bool needs_mesh() const { return false; }
// No topology // No topology
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label). //- based solely on the number of cells.
// This is only defined for geometric renumber methods. // Only applicable for no_topology() methods.
virtual labelList renumber(const label nCells) const;
//- Return the cell visit order (from ordered back to original cell id)
//- based solely on the cell centres (or number of cell centres).
// Only applicable for no_topology() methods.
virtual labelList renumber(const pointField&) const; virtual labelList renumber(const pointField&) const;
// Topology provided by mesh // With mesh topology
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label). //- using the mesh to determine the connectivity.
// Use the mesh connectivity (if needed) virtual labelList renumber(const polyMesh& mesh) const;
virtual labelList renumber(const polyMesh&, const pointField&) const;
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label). // With explicit topology
// Gets passed agglomeration map (from fine to coarse cells) and coarse
// cell //- Return the cell visit order (from ordered back to original cell id),
// location. Can be overridden by renumberMethods that provide this virtual labelList renumber
// functionality natively. Coarse cells are local to the processor (
// (if in parallel). If you want to have coarse cells spanning //! Mesh connectivity
// processors use the globalCellCells instead. const CompactListList<label>& cellCells
) const = 0;
//- Return the cell visit order (from ordered back to original cell id),
virtual labelList renumber
(
//! Mesh connectivity
const labelListList& cellCells
) const = 0;
// Housekeeping
//- Deprecated - the pointField is unused
// \deprecated(2024-03) the pointField is unused
FOAM_DEPRECATED_FOR(2024-03, "renumber(const polyMesh&)")
virtual labelList renumber virtual labelList renumber
( (
const polyMesh& mesh, const polyMesh& mesh,
const labelList& fineToCoarse,
const pointField& coarsePoints
) const;
// Topology provided explicitly
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label).
// Addressing in losort addressing (= neighbour + offsets into
// neighbour)
virtual labelList renumber
(
const labelList& cellCells,
const labelList& offsets,
const pointField& const pointField&
) const; ) const
{
return renumber(mesh);
}
//- Return the order in which cells need to be visited //- Deprecated - the pointField is unused
//- (ie. from ordered back to original cell label). // \deprecated(2024-03) the pointField is unused
// Uses 'unpack' internally, so should be overloaded when possible FOAM_DEPRECATED_FOR(2024-03, "renumber(const CompactListList<label>&)")
virtual labelList renumber virtual labelList renumber
( (
const CompactListList<label>& cellCells, const CompactListList<label>& cellCells,
const pointField& cellCentres const pointField&
) const; ) const
{
return renumber(cellCells);
}
//- Return the order in which cells need to be visited //- Deprecated - the pointField is unused
//- (ie. from ordered back to original cell label). // \deprecated(2024-03) the pointField is unused
// The connectivity is equal to mesh.cellCells() except FOAM_DEPRECATED_FOR(2024-03, "renumber(const labelListList&)")
// - the connections are across coupled patches
virtual labelList renumber virtual labelList renumber
( (
const labelListList& cellCells, const labelListList& cellCells,
const pointField& cellCentres const pointField&
) const = 0; ) const
{
return renumber(cellCells);
}
//- Deprecated - renumbering with agglomeration map.
//- Calculate globalCellCells directly
// \deprecated(2024-03) calculate globalCellCells directly
FOAM_DEPRECATED_FOR(2024-03, "calcCellCells and renumber separately")
virtual labelList renumber
(
const polyMesh& mesh,
const labelUList& fineToCoarse,
const pointField& coarsePoints
) const;
}; };

View File

@ -159,8 +159,7 @@ Foam::labelList Foam::springRenumber::renumberImpl
Foam::labelList Foam::springRenumber::renumber Foam::labelList Foam::springRenumber::renumber
( (
const polyMesh& mesh, const polyMesh& mesh
const pointField&
) const ) const
{ {
// Local mesh connectivity // Local mesh connectivity
@ -173,8 +172,7 @@ Foam::labelList Foam::springRenumber::renumber
Foam::labelList Foam::springRenumber::renumber Foam::labelList Foam::springRenumber::renumber
( (
const CompactListList<label>& cellCells, const CompactListList<label>& cellCells
const pointField&
) const ) const
{ {
return renumberImpl(cellCells); return renumberImpl(cellCells);
@ -183,8 +181,7 @@ Foam::labelList Foam::springRenumber::renumber
Foam::labelList Foam::springRenumber::renumber Foam::labelList Foam::springRenumber::renumber
( (
const labelListList& cellCells, const labelListList& cellCells
const pointField&
) const ) const
{ {
return renumberImpl(cellCells); return renumberImpl(cellCells);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd. Copyright (C) 2022-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -111,40 +111,31 @@ public:
// Member Functions // Member Functions
//- Return the order in which cells need to be visited // With mesh topology
//- (ie. from ordered back to original cell label).
// This is only defined for geometric renumberMethods.
virtual labelList renumber(const pointField&) const
{
NotImplemented;
return labelList();
}
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label). //- using the mesh to determine the connectivity.
// Use the mesh connectivity (if needed)
virtual labelList renumber virtual labelList renumber
( (
const polyMesh& mesh, //! Mesh connectivity (see globalMeshData::calcCellCells)
const pointField& const polyMesh& mesh
) const; ) const;
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label). // With explicit topology
//- Return the cell visit order (from ordered back to original cell id)
virtual labelList renumber virtual labelList renumber
( (
const CompactListList<label>& cellCells, //! Mesh connectivity
const pointField& cellCentres const CompactListList<label>& cellCells
) const; ) const;
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label).
// The connectivity is equal to mesh.cellCells() except
// - the connections are across coupled patches
virtual labelList renumber virtual labelList renumber
( (
const labelListList& cellCells, //! Mesh connectivity
const pointField& cellCentres const labelListList& cellCells
) const; ) const;
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -137,18 +137,9 @@ bool Foam::structuredRenumber::layerLess::operator()
Foam::labelList Foam::structuredRenumber::renumber Foam::labelList Foam::structuredRenumber::renumber
( (
const polyMesh& mesh, const polyMesh& mesh
const pointField& points
) const ) const
{ {
if (points.size() != mesh.nCells())
{
FatalErrorInFunction
<< "Number of points " << points.size()
<< " should equal the number of cells " << mesh.nCells()
<< exit(FatalError);
}
const polyBoundaryMesh& pbm = mesh.boundaryMesh(); const polyBoundaryMesh& pbm = mesh.boundaryMesh();
const labelHashSet patchIDs(pbm.patchSet(patches_)); const labelHashSet patchIDs(pbm.patchSet(patches_));
@ -187,21 +178,20 @@ Foam::labelList Foam::structuredRenumber::renumber
dynamic_cast<const fvMesh&>(mesh), dynamic_cast<const fvMesh&>(mesh),
patchCells patchCells
); );
const fvMesh& subMesh = subsetter.subMesh();
pointField subPoints(points, subsetter.cellMap()); const labelList& cellMap = subsetter.cellMap();
// Locally renumber the layer of cells // Locally renumber the layer of cells
labelList subOrder(method_().renumber(subMesh, subPoints)); labelList subOrder = method_().renumber(subsetter.subMesh());
labelList subOrigToOrdered(invert(subOrder.size(), subOrder)); labelList subOrigToOrdered(invert(subOrder.size(), subOrder));
globalIndex globalSubCells(subOrder.size()); const globalIndex globalSubCells(subOrder.size());
// Transfer to final decomposition and convert into global numbering // Transfer to final decomposition and convert into global numbering
forAll(subOrder, i) forAll(subOrder, i)
{ {
orderedToOld[subsetter.cellMap()[i]] = orderedToOld[cellMap[i]] =
globalSubCells.toGlobal(subOrigToOrdered[i]); globalSubCells.toGlobal(subOrigToOrdered[i]);
} }
} }
@ -253,11 +243,7 @@ Foam::labelList Foam::structuredRenumber::renumber
// by any visited cell so are used only if the number of nLayers is limited. // by any visited cell so are used only if the number of nLayers is limited.
labelList oldToOrdered labelList oldToOrdered
( (
invert invert(mesh.nCells(), method_().renumber(mesh))
(
mesh.nCells(),
method_().renumber(mesh, points)
)
); );
// Use specialised sorting to sorted either layers or columns first // Use specialised sorting to sorted either layers or columns first

View File

@ -132,46 +132,38 @@ public:
// Member Functions // Member Functions
//- Renumbering method requires a polyMesh //- Renumbering method requires a polyMesh!
virtual bool needs_mesh() const { return true; } virtual bool needs_mesh() const { return true; }
//- Return the order in which cells need to be visited // With mesh topology
//- (ie. from ordered back to original cell label).
// This is only defined for geometric renumberMethods.
virtual labelList renumber(const pointField&) const
{
NotImplemented;
return labelList();
}
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label). // using the mesh.
// Use the mesh connectivity (if needed)
virtual labelList renumber virtual labelList renumber
( (
const polyMesh& mesh, const polyMesh& mesh
const pointField& cc
) const; ) const;
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label). // With explicit topology - Not implemented!
//- Return the cell visit order (from ordered back to original cell id).
//- Not implemented!
virtual labelList renumber virtual labelList renumber
( (
const CompactListList<label>& cellCells, const CompactListList<label>& cellCells
const pointField& cellCentres
) const ) const
{ {
NotImplemented; NotImplemented;
return labelList(); return labelList();
} }
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id).
//- (ie. from ordered back to original cell label). //- Not implemented!
virtual labelList renumber virtual labelList renumber
( (
const labelListList& cellCells, const labelListList& cellCells
const pointField& cellCentres
) const ) const
{ {
NotImplemented; NotImplemented;

View File

@ -24,10 +24,7 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Notes
Foam::zoltanRenumber
Description
Renumber using Zoltan Renumber using Zoltan
Zoltan install: Zoltan install:
@ -46,9 +43,6 @@ Description
--prefix=$ZOLTAN_ARCH_DIR \ --prefix=$ZOLTAN_ARCH_DIR \
--with-ccflags=-fPIC --with-cxxflags=-fPIC --with-ldflags=-shared --with-ccflags=-fPIC --with-cxxflags=-fPIC --with-ldflags=-shared
SourceFiles
zoltanRenumber.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "zoltanRenumber.H" #include "zoltanRenumber.H"
@ -365,8 +359,7 @@ Foam::zoltanRenumber::zoltanRenumber(const dictionary& dict)
Foam::labelList Foam::zoltanRenumber::renumber Foam::labelList Foam::zoltanRenumber::renumber
( (
const polyMesh& pMesh, const polyMesh& pMesh
const pointField& points
) const ) const
{ {
// Zoltan_Initialize will trigger MPI_Init() if not already done. // Zoltan_Initialize will trigger MPI_Init() if not already done.

View File

@ -83,46 +83,38 @@ public:
// Member Functions // Member Functions
//- Renumbering method requires a polyMesh //- Renumbering method requires a polyMesh for its topology
virtual bool needs_mesh() const { return true; } virtual bool needs_mesh() const { return true; }
//- Return the order in which cells need to be visited // With mesh topology
//- (ie. from ordered back to original cell label).
// This is only defined for geometric renumberMethods.
virtual labelList renumber(const pointField&) const
{
NotImplemented;
return labelList();
}
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id)
//- (ie. from ordered back to original cell label). //- uses the mesh for connectivity and global exchanges
// Use the mesh connectivity (if needed)
virtual labelList renumber virtual labelList renumber
( (
const polyMesh& mesh, const polyMesh& mesh
const pointField& cc
) const; ) const;
//- Return the order in which cells need to be visited
//- (ie. from ordered back to original cell label). // With explicit topology - Not implemented!
//- Return the cell visit order (from ordered back to original cell id).
//- Not implemented!
virtual labelList renumber virtual labelList renumber
( (
const CompactListList<label>& cellCells, const CompactListList<label>& cellCells
const pointField& cellCentres
) const ) const
{ {
NotImplemented; NotImplemented;
return labelList(); return labelList();
} }
//- Return the order in which cells need to be visited //- Return the cell visit order (from ordered back to original cell id).
//- (ie. from ordered back to original cell label). //- Not implemented!
virtual labelList renumber virtual labelList renumber
( (
const labelListList& cellCells, const labelListList& cellCells
const pointField& cellCentres
) const ) const
{ {
NotImplemented; NotImplemented;