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.
This commit is contained in:
Henry Weller
2024-05-30 22:04:06 +01:00
parent a4cba5b0d1
commit 81fd429524

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -105,7 +105,6 @@ void writeDecomposition(const domainDecomposition& meshes)
<< endl; << endl;
} }
} }
@ -189,6 +188,11 @@ int main(int argc, char *argv[])
"newTimes", "newTimes",
"only reconstruct new times (i.e. that do not exist already)" "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 // Include explicit constant options, and explicit zero option (to prevent
// the user accidentally trashing the initial fields) // the user accidentally trashing the initial fields)
@ -573,14 +577,16 @@ int main(int argc, char *argv[])
Info<< endl; Info<< endl;
} }
if (regionNames == wordList(1, polyMesh::defaultRegion)) continue; if (regionNames != wordList(1, polyMesh::defaultRegion))
{
// Collect the region uniform directories // Collect the region uniform directories
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word regionDir = const word regionDir =
regionName == polyMesh::defaultRegion ? word::null : regionName; regionName == polyMesh::defaultRegion
? word::null
: regionName;
if (haveUniform(runTimes, regionDir)) if (haveUniform(runTimes, regionDir))
{ {
@ -599,6 +605,41 @@ int main(int argc, char *argv[])
} }
} }
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<domainDecomposition> meshes =
regionMeshes[regioni];
Info<< "Removing processors time directory" << endl;
for (label proci=0; proci<nProcs; proci++)
{
const fileName procTimePath = fileHandler().filePath
(
runTimes.procTimes()[proci].timePath()/regionDir
);
if (isDir(procTimePath))
{
rmDir(procTimePath);
}
}
}
Info<< endl;
}
}
Info<< "End" << nl << endl; Info<< "End" << nl << endl;
return 0; return 0;