diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index f9425cc50..c5ba4132e 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -74,6 +74,9 @@ Usage be used with caution when the underlying (serial) geometry or the decomposition method etc. have been changed between decompositions. + - \par -dict \ + Specify alternative dictionary for the decomposition. + \*---------------------------------------------------------------------------*/ #include "OSspecific.H" @@ -248,6 +251,13 @@ int main(int argc, char *argv[]) "only decompose geometry if the number of domains has changed" ); + argList::addOption + ( + "dict", + "dictionary file name", + "specify alternative decomposition dictionary" + ); + // Include explicit constant options, have zero from time range timeSelector::addOptions(true, false); @@ -262,12 +272,33 @@ int main(int argc, char *argv[]) bool forceOverwrite = args.optionFound("force"); bool ifRequiredDecomposition = args.optionFound("ifRequired"); + const word dictName("decomposeParDict"); + // Set time from database #include "createTime.H" + + fileName dictPath; + + // Check if the dictionary is specified on the command-line + if (args.optionFound("dict")) + { + dictPath = args["dict"]; + + dictPath = + ( + isDir(dictPath) + ? dictPath/dictName + : dictPath + ); + } + else + { + dictPath = runTime.path()/"system"/dictName; + } + // Allow override of time instantList times = timeSelector::selectIfPresent(runTime, args); - wordList regionNames; wordList regionDirs; if (allRegions) @@ -337,7 +368,7 @@ int main(int argc, char *argv[]) ( IOobject ( - "decomposeParDict", + dictName, runTime.time().system(), regionDir, // use region if non-standard runTime, @@ -358,7 +389,7 @@ int main(int argc, char *argv[]) << nProcs << " domains" << nl << "instead of " << nDomains - << " domains as specified in decomposeParDict" + << " domains as specified in " << dictName << nl << exit(FatalError); } @@ -421,13 +452,14 @@ int main(int argc, char *argv[]) IOobject::NO_READ, IOobject::NO_WRITE, false - ) + ), + dictPath ); // Decompose the mesh if (!decomposeFieldsOnly) { - mesh.decomposeMesh(); + mesh.decomposeMesh(dictPath); mesh.writeDecomposition(decomposeSets); diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C index 3cad0f554..9c1ad8c4d 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -69,7 +69,11 @@ void Foam::domainDecomposition::mark // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::domainDecomposition::domainDecomposition(const IOobject& io) +Foam::domainDecomposition::domainDecomposition +( + const IOobject& io, + const fileName& dictFile +) : fvMesh(io), facesInstancePointsPtr_ @@ -96,7 +100,8 @@ Foam::domainDecomposition::domainDecomposition(const IOobject& io) ( decompositionModel::New ( - *this + *this, + dictFile ).lookup("numberOfSubdomains") ) ), @@ -115,7 +120,8 @@ Foam::domainDecomposition::domainDecomposition(const IOobject& io) { decompositionModel::New ( - *this + *this, + dictFile ).readIfPresent("distributed", distributed_); } diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.H b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.H index c183b2df6..53884444c 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.H +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -114,7 +114,7 @@ class domainDecomposition // Private Member Functions - void distributeCells(); + void distributeCells(const fileName& dictFile); //- Mark all elements with value or -2 if occur twice static void mark @@ -156,8 +156,12 @@ public: // Constructors - //- Construct from IOobject - domainDecomposition(const IOobject& io); + //- Construct from IOobject and decomposition dictionary name + domainDecomposition + ( + const IOobject& io, + const fileName& dictFile + ); //- Destructor @@ -179,7 +183,7 @@ public: } //- Decompose mesh. - void decomposeMesh(); + void decomposeMesh(const fileName& dict); //- Write decomposition bool writeDecomposition(const bool decomposeSets); diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDistribute.C b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDistribute.C index c6df1cfa7..f7bb937d5 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDistribute.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDistribute.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,13 +34,12 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -void Foam::domainDecomposition::distributeCells() +void Foam::domainDecomposition::distributeCells(const fileName& dict) { Info<< "\nCalculating distribution of cells" << endl; cpuTime decompositionTime; - - const decompositionModel& method = decompositionModel::New(*this); + const decompositionModel& method = decompositionModel::New(*this, dict); scalarField cellWeights; if (method.found("weightField")) diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionMesh.C b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionMesh.C index c4bf9d4f7..ab6b93663 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionMesh.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -94,10 +94,10 @@ void Foam::domainDecomposition::addInterProcFace } -void Foam::domainDecomposition::decomposeMesh() +void Foam::domainDecomposition::decomposeMesh(const fileName& dict) { // Decide which cell goes to which processor - distributeCells(); + distributeCells(dict); // Distribute the cells according to the given processor label