From 0c84e50583c97337f497809b8482da7f63a1e591 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sun, 10 Mar 2024 14:32:57 +0100 Subject: [PATCH] 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 --- .../test/HashTable4/Test-HashTable4.cxx | 4 +- applications/test/nullObject/Make/files | 2 +- ...{Test-nullObject.C => Test-nullObject.cxx} | 13 ++ .../manipulation/renumberMesh/renumberMesh.C | 159 ++++++++++++++---- etc/caseDicts/annotated/renumberMeshDict | 5 + src/OSspecific/POSIX/cpuTime/cpuTimePosix.C | 6 + src/OSspecific/POSIX/cpuTime/cpuTimePosix.H | 13 +- src/OpenFOAM/fields/Fields/fieldTypes.C | 7 +- src/OpenFOAM/fields/Fields/fieldTypes.H | 8 +- src/OpenFOAM/global/clockTime/clockTime.H | 18 +- src/OpenFOAM/global/clockTime/clockTimeI.H | 8 +- src/OpenFOAM/global/clockValue/clockValue.H | 9 +- src/OpenFOAM/global/cpuTime/cpuTimeCxx.C | 6 + src/OpenFOAM/global/cpuTime/cpuTimeCxx.H | 17 +- .../global/profiling/profilingPstream.H | 2 +- .../meshes/bandCompression/bandCompression.C | 15 +- .../meshes/bandCompression/bandCompression.H | 6 +- .../parallel/globalIndex/globalIndex.H | 12 +- src/renumber/SloanRenumber/SloanRenumber.C | 12 +- src/renumber/SloanRenumber/SloanRenumber.H | 42 ++--- .../CuthillMcKeeRenumber.C | 44 +++-- .../CuthillMcKeeRenumber.H | 53 ++---- .../manualRenumber/manualRenumber.C | 30 ++-- .../manualRenumber/manualRenumber.H | 38 ++--- .../renumberMethods/noRenumber/noRenumber.C | 18 +- .../renumberMethods/noRenumber/noRenumber.H | 50 +++--- .../randomRenumber/randomRenumber.C | 18 +- .../randomRenumber/randomRenumber.H | 50 +++--- .../renumberMethod/renumberMethod.C | 50 ++---- .../renumberMethod/renumberMethod.H | 115 ++++++++----- .../springRenumber/springRenumber.C | 9 +- .../springRenumber/springRenumber.H | 39 ++--- .../structuredRenumber/structuredRenumber.C | 28 +-- .../structuredRenumber/structuredRenumber.H | 36 ++-- src/renumber/zoltanRenumber/zoltanRenumber.C | 11 +- src/renumber/zoltanRenumber/zoltanRenumber.H | 36 ++-- 36 files changed, 541 insertions(+), 448 deletions(-) rename applications/test/nullObject/{Test-nullObject.C => Test-nullObject.cxx} (92%) diff --git a/applications/test/HashTable4/Test-HashTable4.cxx b/applications/test/HashTable4/Test-HashTable4.cxx index e474436870..12b63ae291 100644 --- a/applications/test/HashTable4/Test-HashTable4.cxx +++ b/applications/test/HashTable4/Test-HashTable4.cxx @@ -206,7 +206,7 @@ int main(int argc, char *argv[]) #endif loopInsert(map, nElem); - (void)timer.cpuTimeIncrement(); + timer.resetCpuTimeIncrement(); unsigned long sum = 0; for (label loopi = 0; loopi < nFind*nLoops; ++loopi) @@ -268,7 +268,7 @@ int main(int argc, char *argv[]) HashSet> map(32); loopInsert(map, nElem); - (void)timer.cpuTimeIncrement(); + timer.resetCpuTimeIncrement(); unsigned long sum = 0; for (label loopi = 0; loopi < nFind*nLoops; ++loopi) diff --git a/applications/test/nullObject/Make/files b/applications/test/nullObject/Make/files index dffa06d747..fdd71c155e 100644 --- a/applications/test/nullObject/Make/files +++ b/applications/test/nullObject/Make/files @@ -1,3 +1,3 @@ -Test-nullObject.C +Test-nullObject.cxx EXE = $(FOAM_USER_APPBIN)/Test-nullObject diff --git a/applications/test/nullObject/Test-nullObject.C b/applications/test/nullObject/Test-nullObject.cxx similarity index 92% rename from applications/test/nullObject/Test-nullObject.C rename to applications/test/nullObject/Test-nullObject.cxx index 0f7cd10dad..475a4e55b0 100644 --- a/applications/test/nullObject/Test-nullObject.C +++ b/applications/test/nullObject/Test-nullObject.cxx @@ -37,6 +37,7 @@ Description #include "HashSet.H" #include "faceList.H" #include "pointField.H" +#include "globalIndex.H" #include "IOstreams.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -150,6 +151,18 @@ int main() NullObject::nullObject = "hello world"; 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; return 0; diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 7c08c679a5..64011258c6 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -123,6 +123,7 @@ Usage \*---------------------------------------------------------------------------*/ #include "argList.H" +#include "clockTime.H" #include "timeSelector.H" #include "IOobjectList.H" #include "fvMesh.H" @@ -147,6 +148,24 @@ Usage 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 timings; + // Create named field from labelList for post-processing tmp createScalarField @@ -205,8 +224,8 @@ void getBand scalar& sumSqrIntersect // scalar to avoid overflow ) { - labelList cellBandwidth(nCells, Zero); - scalarField nIntersect(nCells, Zero); + labelList cellBandwidth(nCells, Foam::zero{}); + scalarField nIntersect(nCells, Foam::zero{}); forAll(neighbour, facei) { @@ -627,8 +646,33 @@ CompactListList