diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index f95e42516e..a73bbbb204 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.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 @@ -287,23 +287,24 @@ int main(int argc, char *argv[]) // Set time from database #include "createTime.H" - fileName dictPath; - // Check if the dictionary is specified on the command-line + fileName dictPath = fileName::null; if (args.optionFound("dict")) { dictPath = args["dict"]; - dictPath = - ( - isDir(dictPath) - ? dictPath/dictName - : dictPath - ); - } - else - { - dictPath = runTime.path()/"system"/dictName; + if (!isFile(dictPath)) + { + dictPath = dictPath/dictName; + } + + if (!isFile(dictPath)) + { + FatalErrorInFunction + << "Specified -dict " << args["dict"] << " but neither " + << args["dict"] << " nor " << args["dict"]/dictName + << " could be found" << nl << exit(FatalError); + } } // Allow override of time @@ -352,28 +353,37 @@ int main(int argc, char *argv[]) Info<< "\n\nDecomposing mesh " << regionName << nl << endl; - // Determine the existing processor count directly label nProcs = fileHandler().nProcs(runTime.path(), regionDir); + // Get the dictionary IO + const IOobject dictIO + ( + dictPath == fileName::null + ? IOobject + ( + dictName, + runTime.time().system(), + regionDir, // use region if non-standard + runTime, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false + ) + : IOobject + ( + dictPath, + runTime, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false + ) + ); + // Get requested numberOfSubdomains. Note: have no mesh yet so // cannot use decompositionModel::New - const label nDomains = readLabel - ( - IOdictionary - ( - IOobject - ( - dictName, - runTime.time().system(), - regionDir, // use region if non-standard - runTime, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE, - false - ) - ).lookup("numberOfSubdomains") - ); + const label nDomains = + readLabel(IOdictionary(dictIO).lookup("numberOfSubdomains")); if (decomposeFieldsOnly) { @@ -465,7 +475,7 @@ int main(int argc, char *argv[]) IOobject::NO_WRITE, false ), - dictPath + dictIO.objectPath() ); // Decompose the mesh @@ -477,7 +487,7 @@ int main(int argc, char *argv[]) fileOperations::collatedFileOperation::maxThreadFileBufferSize; fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0; - mesh.decomposeMesh(dictPath); + mesh.decomposeMesh(dictIO.objectPath()); mesh.writeDecomposition(decomposeSets);