From ae02a86562e788cf1ef593c4c16a645f867d14e4 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 11 Jun 2021 14:47:16 +0200 Subject: [PATCH] ENH: multi-region support for reconstructParMesh (#2072) --- .../Test-checkDecomposePar.C | 19 +- .../decomposePar/domainDecompositionWrite.C | 2 +- .../reconstructPar/reconstructPar.C | 41 +- .../reconstructParMesh/reconstructParMesh.C | 1103 +++++++++-------- 4 files changed, 651 insertions(+), 514 deletions(-) diff --git a/applications/test/checkDecomposePar/Test-checkDecomposePar.C b/applications/test/checkDecomposePar/Test-checkDecomposePar.C index 52ca8f9961..3445b3b309 100644 --- a/applications/test/checkDecomposePar/Test-checkDecomposePar.C +++ b/applications/test/checkDecomposePar/Test-checkDecomposePar.C @@ -71,7 +71,6 @@ int main(int argc, char *argv[]) #include "setRootCase.H" const auto decompFile = args.get(1); - const bool region = args.found("region"); const bool verbose = args.found("verbose"); // Set time from database @@ -87,23 +86,17 @@ int main(int argc, char *argv[]) // Get region names #include "getAllRegionOptions.H" - wordList regionDirs(regionNames); - if (regionDirs.size() == 1 && regionDirs[0] == polyMesh::defaultRegion) - { - regionDirs[0].clear(); - } - else - { - Info<< "Decomposing regions: " - << flatOutput(regionNames) << nl << endl; - } - labelList cellToProc; forAll(regionNames, regioni) { const word& regionName = regionNames[regioni]; - const word& regionDir = regionDirs[regioni]; + // const word& regionDir = + // ( + // regionName != polyMesh::defaultRegion + // ? regionName + // : word::null + // ); Info<< "\n\nDecomposing mesh " << regionName << nl << endl; Info<< "Create mesh..." << flush; diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionWrite.C b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionWrite.C index cc2ee88bcd..271be14e4f 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionWrite.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionWrite.C @@ -52,7 +52,7 @@ void Foam::domainDecomposition::writeVolField false ), this->mesh(), - dimensionedScalar("cellDist", dimless, -1), + dimensionedScalar(dimless, Zero), zeroGradientFvPatchScalarField::typeName ); diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index b854aa5d89..ee91690b2d 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -167,28 +167,34 @@ int main(int argc, char *argv[]) << nl << endl; } - const bool newTimes = args.found("newTimes"); + const bool newTimes = args.found("newTimes"); // Get region names #include "getAllRegionOptions.H" - wordList regionDirs(regionNames); + // Determine the processor count + label nProcs{0}; - if (regionNames.size() == 1) + if (regionNames.empty()) { - if (regionNames[0] == polyMesh::defaultRegion) - { - regionDirs[0].clear(); - } - else + FatalErrorInFunction + << "No regions specified or detected." + << exit(FatalError); + } + else if (regionNames[0] == polyMesh::defaultRegion) + { + nProcs = fileHandler().nProcs(args.path()); + } + else + { + nProcs = fileHandler().nProcs(args.path(), regionNames[0]); + + if (regionNames.size() == 1) { Info<< "Using region: " << regionNames[0] << nl << endl; } } - // Determine the processor count - label nProcs = fileHandler().nProcs(args.path(), regionDirs[0]); - if (!nProcs) { FatalErrorInFunction @@ -261,16 +267,21 @@ int main(int argc, char *argv[]) forAll(regionNames, regioni) { const word& regionName = regionNames[regioni]; - const word& regionDir = regionDirs[regioni]; + const word& regionDir = + ( + regionName != polyMesh::defaultRegion + ? regionName + : word::null + ); - Info<< "\n\nReconstructing fields for mesh " << regionName << nl - << endl; + Info<< "\n\nReconstructing fields" << nl + << "region=" << regionName << nl << endl; if ( newTimes && regionNames.size() == 1 - && regionDirs[0].empty() + && regionDir.empty() && haveAllTimes(masterTimeDirSet, timeDirs) ) { diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C index 11ac95b907..8ba2ff25ad 100644 --- a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C +++ b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C @@ -71,6 +71,7 @@ Usage #include "polyTopoChange.H" #include "extrapolatedCalculatedFvPatchFields.H" #include "topoSet.H" +#include "regionProperties.H" #include "fvMeshTools.H" using namespace Foam; @@ -304,31 +305,29 @@ autoPtr mergeSharedPoints boundBox procBounds ( - const argList& args, const PtrList