diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index f036e1b99..4dd6568a8 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -362,24 +362,40 @@ int main(int argc, char *argv[]) << " existing processor directories" << endl; // Remove existing processors directory - const fileName procDir(runTime.path()/word("processors")); - if (fileHandler().exists(procDir)) - { - fileHandler().rmDir(procDir); - } - - // Remove existing processor directories - // reverse order to avoid gaps if someone interrupts the process - for (label proci = nProcs-1; proci >= 0; --proci) - { - const fileName procDir + fileNameList dirs + ( + fileHandler().readDir ( - runTime.path()/(word("processor") + name(proci)) - ); + runTime.path(), + fileName::Type::DIRECTORY + ) + ); + forAllReverse(dirs, diri) + { + const fileName& d = dirs[diri]; - if (fileHandler().exists(procDir)) + // Starts with 'processors' + if (d.find("processors") == 0) { - fileHandler().rmDir(procDir); + if (fileHandler().exists(d)) + { + fileHandler().rmDir(d); + } + } + + // Starts with 'processor' + if (d.find("processor") == 0) + { + // Check that integer after processor + fileName num(d.substr(9)); + label proci = -1; + if (Foam::read(num.c_str(), proci)) + { + if (fileHandler().exists(d)) + { + fileHandler().rmDir(d); + } + } } } } @@ -430,12 +446,14 @@ int main(int argc, char *argv[]) false ) ); - // Get requested numberOfSubdomains. Note: have no mesh yet so // cannot use decompositionModel::New const label nDomains = readLabel(IOdictionary(dictIO).lookup("numberOfSubdomains")); + // Give file handler a chance to determine the output directory + const_cast(fileHandler()).setNProcs(nDomains); + if (decomposeFieldsOnly) { // Sanity check on previously decomposed case diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index bdcc5c2c2..490103447 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 | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -219,6 +219,9 @@ int main(int argc, char *argv[]) << exit(FatalError); } + // Warn fileHandler of number of processors + const_cast(fileHandler()).setNProcs(nProcs); + // Create the processor databases PtrList