From 81fd429524a837fd9229f799d54a1755e9042ce1 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Thu, 30 May 2024 22:04:06 +0100 Subject: [PATCH] reconstructPar: Added -rm option With the new -rm option the processor time directories are removed after the reconstruction of each one. For multi-region cases with the -region and -rm options only the processor time directory for the reconstructed region is removed whereas with the -allRegions option the entire processor time directory is removed after reconstruction of all the regions. --- .../reconstructPar/reconstructPar.C | 77 ++++++++++++++----- 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index b914c50901..98c4da690c 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -105,7 +105,6 @@ void writeDecomposition(const domainDecomposition& meshes) << endl; } - } @@ -189,6 +188,11 @@ int main(int argc, char *argv[]) "newTimes", "only reconstruct new times (i.e. that do not exist already)" ); + argList::addBoolOption + ( + "rm", + "remove processor time directories after reconstruction" + ); // Include explicit constant options, and explicit zero option (to prevent // the user accidentally trashing the initial fields) @@ -573,30 +577,67 @@ int main(int argc, char *argv[]) Info<< endl; } - if (regionNames == wordList(1, polyMesh::defaultRegion)) continue; - - // Collect the region uniform directories - forAll(regionNames, regioni) + if (regionNames != wordList(1, polyMesh::defaultRegion)) { - const word& regionName = regionNames[regioni]; - const word regionDir = - regionName == polyMesh::defaultRegion ? word::null : regionName; - - if (haveUniform(runTimes, regionDir)) + // Collect the region uniform directories + forAll(regionNames, regioni) { - // Prefixed scope + const word& regionName = regionNames[regioni]; + const word regionDir = + regionName == polyMesh::defaultRegion + ? word::null + : regionName; + + if (haveUniform(runTimes, regionDir)) { - const RegionRef meshes = - regionMeshes[regioni]; + // Prefixed scope + { + const RegionRef meshes = + regionMeshes[regioni]; - Info<< "Collecting uniform files" << endl; + Info<< "Collecting uniform files" << endl; - reconstructUniform(runTimes, regionDir); + reconstructUniform(runTimes, regionDir); + } + + Info<< endl; } - - Info<< endl; } } + + if (args.optionFound("rm") && times[timei].name() != Time::constantName) + { + const bool allRegions = args.optionFound("allRegions"); + + forAll(regionNames, regioni) + { + const word& regionName = regionNames[regioni]; + const word regionDir = + allRegions || regionName == polyMesh::defaultRegion + ? word::null + : regionName; + + const RegionRef meshes = + regionMeshes[regioni]; + + Info<< "Removing processors time directory" << endl; + + for (label proci=0; proci