diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index e9fe85e3da0da027abc5bc70ecbda9b89b6f2f46..3685be43c4d99bb808d8e0a4b55b1dcdb6ffcf57 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -48,15 +48,15 @@ Usage @param -force \n Remove any existing @a processor subdirectories before decomposing the - geometry. Has precedence over the @a -lazy option. + geometry. @param -lazy \n - Only decompose the geometry if the number of domains has changed - from a previous decomposition. Any existing @a processor subdirectories - are removed as necessary. This option can be used to avoid redundant - geometry decomposition (eg, in scripts), but should be used with caution - when the underlying (serial) geometry or the decomposition method etc - have been changed between decompositions. + Only decompose the geometry if the number of domains has changed from a + previous decomposition. No @a processor subdirectories will be removed + unless the @a -force option is also specified. This option can be used + to avoid redundant geometry decomposition (eg, in scripts), but should + be used with caution when the underlying (serial) geometry or the + decomposition method etc. have been changed between decompositions. \*---------------------------------------------------------------------------*/ @@ -110,83 +110,84 @@ int main(int argc, char *argv[]) ++nProcs; } - // Check for previously decomposed case first + // get requested numberOfSubdomains + label nDomains = 0; + { + IOdictionary decompDict + ( + IOobject + ( + "decomposeParDict", + runTime.time().system(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + + decompDict.lookup("numberOfSubdomains") >> nDomains; + } + if (decomposeFieldsOnly) { - if (!nProcs) + // Sanity check on previously decomposed case + if (nProcs != nDomains) { FatalErrorIn(args.executable()) - << "Specifying -fields requires a decomposed geometry!" + << "Specified -fields, but the case was decomposed with " + << nProcs << " domains" + << nl + << "instead of " << nDomains + << " domains as specified in decomposeParDict" << nl << exit(FatalError); } } - else + else if (nProcs) { - if (nProcs) - { - bool hasProcDirs = true; + bool procDirsProblem = true; - if (forceOverwrite) - { - Info<< "Removing " << nProcs - << " existing processor directories" << endl; + if (lazyDecomposition && nProcs == nDomains) + { + // we can reuse the decomposition + decomposeFieldsOnly = true; + procDirsProblem = false; + forceOverwrite = false; - // remove existing processor dirs - for (label procI = nProcs-1; procI >= 0; --procI) - { - fileName procDir - ( - runTime.path()/(word("processor") + name(procI)) - ); + Info<< "Using existing processor directories" << nl; + } - rmDir(procDir); - } + if (forceOverwrite) + { + Info<< "Removing " << nProcs + << " existing processor directories" << endl; - hasProcDirs = false; - } - else if (lazyDecomposition) + // remove existing processor dirs + // reverse order to avoid gaps if someone interrupts the process + for (label procI = nProcs-1; procI >= 0; --procI) { - // lazy decomposition - IOdictionary decompDict - ( - IOobject - ( - "decomposeParDict", - runTime.time().system(), - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - - label nDomains + fileName procDir ( - readInt(decompDict.lookup("numberOfSubdomains")) + runTime.path()/(word("processor") + name(procI)) ); - // avoid repeated decomposition - if (nDomains == nProcs) - { - decomposeFieldsOnly = true; - hasProcDirs = false; - - Info<< "Using existing processor directories" << nl; - } + rmDir(procDir); } - if (hasProcDirs) - { - FatalErrorIn(args.executable()) - << "Case is already decomposed with " << nProcs - << " domains, use the -force option or manually" << nl - << "remove processor directories before decomposing. e.g.," - << nl - << " rm -rf " << runTime.path().c_str() << "/processor*" - << nl - << exit(FatalError); - } + procDirsProblem = false; + } + + if (procDirsProblem) + { + FatalErrorIn(args.executable()) + << "Case is already decomposed with " << nProcs + << " domains, use the -force option or manually" << nl + << "remove processor directories before decomposing. e.g.," + << nl + << " rm -rf " << runTime.path().c_str() << "/processor*" + << nl + << exit(FatalError); } } diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposeParDict b/applications/utilities/parallelProcessing/decomposePar/decomposeParDict index b9ee4eaeb126871f082cf1e42a8e8357571f1529..c7317b464faeaa114f70cc6cb55f7fade8bbcd08 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposeParDict +++ b/applications/utilities/parallelProcessing/decomposePar/decomposeParDict @@ -1,61 +1,61 @@ -// Mesh decomposition control dictionary - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - +/*-------------------------------*- C++ -*---------------------------------*\ +| ========= | +| \\ / OpenFOAM | +| \\ / | +| \\ / The Open Source CFD Toolbox | +| \\/ http://www.OpenFOAM.org | +\*-------------------------------------------------------------------------*/ FoamFile { - version 0.5; - format ascii; - - root "ROOT"; - case "CASE"; - instance "system"; - local ""; - - class dictionary; - - object decompositionDict; + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + location "system"; + object decomposeParDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -numberOfSubdomains 4; +numberOfSubdomains 4; -//preservePatches (inlet); -//preserveFaceZones (heater solid1 solid3); +// preservePatches (inlet); +// preserveFaceZones (heater solid1 solid3); -method simple; -//method hierarchical; -//method metis; -//method manual; +method simple; +// method hierarchical; +// method metis; +// method manual; simpleCoeffs { - n (2 2 1); - delta 0.001; + n (2 2 1); + delta 0.001; } hierarchicalCoeffs { - n (2 2 1); - delta 0.001; - order xyz; + n (2 2 1); + delta 0.001; + order xyz; } metisCoeffs { - //processorWeights - //( - // 1 - // 1 - // 1 - // 1 - //); + /* + processorWeights + ( + 1 + 1 + 1 + 1 + ); + */ } manualCoeffs { - dataFile "decompositionData"; + dataFile "decompositionData"; } // ************************************************************************* //