diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/options b/applications/utilities/parallelProcessing/decomposePar/Make/options index 7194eb1bce..5d5d67f989 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/options +++ b/applications/utilities/parallelProcessing/decomposePar/Make/options @@ -3,7 +3,8 @@ EXE_INC = \ -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude EXE_LIBS = \ -lfiniteVolume \ @@ -11,4 +12,5 @@ EXE_LIBS = \ -lgenericPatchFields \ -ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp \ -llagrangian \ - -lmeshTools + -lmeshTools \ + -lregionModels diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 26d3813004..257c31df53 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -39,6 +39,10 @@ Usage \param -region regionName \n Decompose named region. Does not check for existence of processor*. + \param -allRegions \n + Decompose all regions in regionProperties. Does not check for + existence of processor*. + \param -copyUniform \n Copy any \a uniform directories too. @@ -82,6 +86,7 @@ Usage #include "tensorIOField.H" #include "tensorFieldIOField.H" #include "pointFields.H" +#include "regionProperties.H" #include "readFields.H" #include "dimFieldDecomposer.H" @@ -101,6 +106,11 @@ int main(int argc, char *argv[]) argList::noParallel(); #include "addRegionOption.H" argList::addBoolOption + ( + "allRegions", + "operate on all regions in regionProperties" + ); + argList::addBoolOption ( "cellDist", "write cell distribution as a labelList - for use with 'manual' " @@ -132,15 +142,7 @@ int main(int argc, char *argv[]) #include "setRootCase.H" - word regionName = fvMesh::defaultRegion; - word regionDir = word::null; - - if (args.optionReadIfPresent("region", regionName)) - { - regionDir = regionName; - Info<< "Decomposing mesh " << regionName << nl << endl; - } - + bool allRegions = args.optionFound("allRegions"); bool writeCellDist = args.optionFound("cellDist"); bool copyUniform = args.optionFound("copyUniform"); bool decomposeFieldsOnly = args.optionFound("fields"); @@ -152,756 +154,659 @@ int main(int argc, char *argv[]) // Allow override of time instantList times = timeSelector::selectIfPresent(runTime, args); - // determine the existing processor count directly - label nProcs = 0; - while - ( - isDir - ( - runTime.path() - / (word("processor") + name(nProcs)) - / runTime.constant() - / regionDir - / polyMesh::meshSubDir - ) - ) + + wordList regionNames; + wordList regionDirs; + if (allRegions) { - ++nProcs; - } - - // get requested numberOfSubdomains - const label nDomains = readLabel - ( - IOdictionary - ( - IOobject - ( - "decomposeParDict", - runTime.time().system(), - regionDir, // use region if non-standard - runTime, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE, - false - ) - ).lookup("numberOfSubdomains") - ); - - if (decomposeFieldsOnly) - { - // Sanity check on previously decomposed case - if (nProcs != nDomains) + Info<< "Decomposing all regions in regionProperties" << nl << endl; + regionProperties rp(runTime); + forAllConstIter(HashTable, rp, iter) { - FatalErrorIn(args.executable()) - << "Specified -fields, but the case was decomposed with " - << nProcs << " domains" - << nl - << "instead of " << nDomains - << " domains as specified in decomposeParDict" - << nl - << exit(FatalError); - } - } - else if (nProcs) - { - bool procDirsProblem = true; - - if (ifRequiredDecomposition && nProcs == nDomains) - { - // we can reuse the decomposition - decomposeFieldsOnly = true; - procDirsProblem = false; - forceOverwrite = false; - - Info<< "Using existing processor directories" << nl; - } - - if (forceOverwrite) - { - Info<< "Removing " << nProcs - << " existing processor directories" << endl; - - // remove existing processor dirs - // reverse order to avoid gaps if someone interrupts the process - for (label procI = nProcs-1; procI >= 0; --procI) + const wordList& regions = iter(); + forAll(regions, i) { - fileName procDir - ( - runTime.path()/(word("processor") + name(procI)) - ); - - rmDir(procDir); - } - - 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); - } - } - - Info<< "Create mesh" << endl; - domainDecomposition mesh - ( - IOobject - ( - regionName, - runTime.timeName(), - runTime - ) - ); - - // Decompose the mesh - if (!decomposeFieldsOnly) - { - mesh.decomposeMesh(); - - mesh.writeDecomposition(); - - if (writeCellDist) - { - const labelList& procIds = mesh.cellToProc(); - - // Write the decomposition as labelList for use with 'manual' - // decomposition method. - labelIOList cellDecomposition - ( - IOobject - ( - "cellDecomposition", - mesh.facesInstance(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - procIds - ); - cellDecomposition.write(); - - Info<< nl << "Wrote decomposition to " - << cellDecomposition.objectPath() - << " for use in manual decomposition." << endl; - - // Write as volScalarField for postprocessing. - volScalarField cellDist - ( - IOobject - ( - "cellDist", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimensionedScalar("cellDist", dimless, 0), - zeroGradientFvPatchScalarField::typeName - ); - - forAll(procIds, celli) - { - cellDist[celli] = procIds[celli]; - } - - cellDist.write(); - - Info<< nl << "Wrote decomposition as volScalarField to " - << cellDist.name() << " for use in postprocessing." - << endl; - } - } - - - - // Caches - // ~~~~~~ - // Cached processor meshes and maps. These are only preserved if running - // with multiple times. - PtrList