diff --git a/applications/utilities/mesh/generation/blockMesh/blockMesh.C b/applications/utilities/mesh/generation/blockMesh/blockMesh.C index fe55d0d53c..9c5f286ac0 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockMesh.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -51,6 +51,7 @@ Usage #include "Time.H" #include "IOdictionary.H" #include "IOPtrList.H" +#include "systemDict.H" #include "blockMesh.H" #include "attachPolyTopoChanger.H" @@ -72,6 +73,7 @@ using namespace Foam; int main(int argc, char *argv[]) { argList::noParallel(); + #include "addDictOption.H" argList::addBoolOption ( "blockTopology", @@ -82,12 +84,6 @@ int main(int argc, char *argv[]) "noClean", "keep the existing files in the polyMesh" ); - argList::addOption - ( - "dict", - "file", - "specify alternative dictionary for the blockMesh description" - ); argList::addNote ( @@ -129,42 +125,6 @@ int main(int argc, char *argv[]) regionPath = regionName; } - // Search for the appropriate blockMesh dictionary.... - - 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 - ); - } - // Check if dictionary is present in the constant directory - else if - ( - exists - ( - runTime.path()/runTime.constant() - /regionPath/polyMesh::meshSubDir/dictName - ) - ) - { - dictPath = - runTime.constant() - /regionPath/polyMesh::meshSubDir/dictName; - } - // Otherwise assume the dictionary is present in the system directory - else - { - dictPath = runTime.system()/regionPath/dictName; - } - if (!args.optionFound("noClean")) { fileName polyMeshPath @@ -189,14 +149,7 @@ int main(int argc, char *argv[]) } } - IOobject meshDictIO - ( - dictPath, - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ); + IOobject meshDictIO(systemDictIO(dictName, args, runTime, regionName)); if (!meshDictIO.typeHeaderOk(true)) { diff --git a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C index b9efc7dcce..8a544cd62d 100644 --- a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C +++ b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,20 +29,10 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io, const word& dictName) +Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io, const IOobject& dictIO) : fvMesh(io), - mirrorMeshDict_ - ( - IOobject - ( - dictName, - time().system(), - *this, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ) + mirrorMeshDict_(dictIO) { plane mirrorPlane(mirrorMeshDict_); diff --git a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H index dcd0c9479e..93a452a2e5 100644 --- a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H +++ b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -70,7 +70,7 @@ public: // Constructors //- Construct from IOobject - mirrorFvMesh(const IOobject& io, const word& dictName); + mirrorFvMesh(const IOobject& io, const IOobject& dictIO); //- Disallow default bitwise copy construction mirrorFvMesh(const mirrorFvMesh&) = delete; diff --git a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C index fad2c00642..e2e51d1efe 100644 --- a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C +++ b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,6 +34,7 @@ Description #include "mirrorFvMesh.H" #include "mapPolyMesh.H" #include "hexRef8Data.H" +#include "systemDict.H" using namespace Foam; @@ -48,10 +49,6 @@ int main(int argc, char *argv[]) #include "createTime.H" const bool overwrite = args.optionFound("overwrite"); - const word dictName - ( - args.optionLookupOrDefault("dict", "mirrorMeshDict") - ); mirrorFvMesh mesh ( @@ -61,7 +58,7 @@ int main(int argc, char *argv[]) runTime.constant(), runTime ), - dictName + systemDictIO("mirrorMeshDict", args, runTime) ); hexRef8Data refData diff --git a/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C b/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C index 5dffba7991..833aec8294 100644 --- a/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C +++ b/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C @@ -45,6 +45,7 @@ Description #include "labelIOList.H" #include "IOdictionary.H" #include "syncTools.H" +#include "systemDict.H" using namespace Foam; @@ -187,55 +188,34 @@ int main(int argc, char *argv[]) labelList refCells; // Dictionary to control refinement - dictionary refineDict; const word dictName("refineMeshDict"); - + IOobject dictIO(systemDictIO(dictName, args, runTime)); + dictionary refineDict; if (readDict) { - fileName dictPath = args["dict"]; - if (isDir(dictPath)) - { - dictPath = dictPath/dictName; - } - - IOobject dictIO - ( - dictPath, - mesh, - IOobject::MUST_READ - ); - - if (!dictIO.typeHeaderOk(true)) - { - FatalErrorInFunction - << "Cannot open specified refinement dictionary " - << dictPath - << exit(FatalError); - } - - Info<< "Refining according to " << dictPath << nl << endl; - - refineDict = IOdictionary(dictIO); - } - else if (!refineAllCells) - { - IOobject dictIO - ( - dictName, - runTime.system(), - mesh, - IOobject::MUST_READ - ); - if (dictIO.typeHeaderOk(true)) { - Info<< "Refining according to " << dictName << nl << endl; - + Info<< "Refining according to " << dictIO.path() << nl << endl; refineDict = IOdictionary(dictIO); } else { - Info<< "Refinement dictionary " << dictName << " not found" << endl; + FatalErrorInFunction + << "Cannot open specified refinement dictionary " + << dictIO.path() << exit(FatalError); + } + } + else if (!refineAllCells) + { + if (dictIO.typeHeaderOk(true)) + { + Info<< "Refining according to " << dictIO.path() << nl << endl; + refineDict = IOdictionary(dictIO); + } + else + { + Info<< "Refinement dictionary " << dictIO.path() << " not found" + << nl << endl; } } diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 1a681a5ce5..4c41e08515 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 | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -97,6 +97,7 @@ Usage #include "tensorFieldIOField.H" #include "pointFields.H" #include "regionProperties.H" +#include "systemDict.H" #include "readFields.H" #include "dimFieldDecomposer.H" @@ -216,6 +217,7 @@ int main(int argc, char *argv[]) ); argList::noParallel(); + #include "addDictOption.H" #include "addRegionOption.H" #include "addAllRegionsOption.H" argList::addBoolOption @@ -260,13 +262,6 @@ 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); @@ -303,26 +298,6 @@ int main(int argc, char *argv[]) // Set time from database #include "createTime.H" - // Check if the dictionary is specified on the command-line - fileName dictPath = fileName::null; - if (args.optionFound("dict")) - { - dictPath = args["dict"]; - - 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 instantList times = timeSelector::selectIfPresent(runTime, args); @@ -409,26 +384,9 @@ int main(int argc, char *argv[]) // 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 - ) + systemDictIO(dictName, args, runTime, regionName) ); + // Get requested numberOfSubdomains. Note: have no mesh yet so // cannot use decompositionModel::New const label nDomains = diff --git a/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C b/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C index 6c57d87690..d4a53e1093 100644 --- a/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C +++ b/applications/utilities/postProcessing/lagrangian/particleTracks/particleTracks.C @@ -39,6 +39,7 @@ Description #include "OFstream.H" #include "passiveParticleCloud.H" #include "setWriter.H" +#include "systemDict.H" using namespace Foam; diff --git a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/createFields.H b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/createFields.H index 309d7718f6..fd2b9e9ac6 100644 --- a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/createFields.H +++ b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/createFields.H @@ -1,8 +1,9 @@ const word dictName("particleTrackDict"); -#include "setConstantMeshDictionaryIO.H" - -IOdictionary propsDict(dictIO); +IOdictionary propsDict +( + systemDict(dictName, args, runTime, word::null, runTime.constant()) +); word cloudName(propsDict.lookup("cloudName")); diff --git a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C index d383bb61a3..6e1e6cd77a 100644 --- a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C +++ b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -39,6 +39,7 @@ Description #include "timeSelector.H" #include "OFstream.H" #include "passiveParticleCloud.H" +#include "systemDict.H" #include "SortableList.H" #include "IOobjectList.H" diff --git a/applications/utilities/postProcessing/noise/createFields.H b/applications/utilities/postProcessing/noise/createFields.H index 53598de047..ae47a91baf 100644 --- a/applications/utilities/postProcessing/noise/createFields.H +++ b/applications/utilities/postProcessing/noise/createFields.H @@ -1,19 +1,6 @@ - word dictName("noiseDict"); - if (args.optionFound("dict")) - { - dictName = args["dict"]; - } + const word dictName("noiseDict"); - IOdictionary dict - ( - IOobject - ( - dictName, - runTime.system(), - runTime, - IOobject::MUST_READ - ) - ); + IOdictionary dict(systemDict(dictName, args, runTime)); // reference pressure scalar pRef = dict.lookupOrDefault("pRef", 0.0); diff --git a/applications/utilities/postProcessing/noise/noise.C b/applications/utilities/postProcessing/noise/noise.C index 802cfa37d4..61d29d707a 100644 --- a/applications/utilities/postProcessing/noise/noise.C +++ b/applications/utilities/postProcessing/noise/noise.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -83,6 +83,7 @@ See also #include "Time.H" #include "Table.H" #include "IOdictionary.H" +#include "systemDict.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C b/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C index adf2e92dff..9bd7ffc250 100644 --- a/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C +++ b/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,6 +41,7 @@ Description #include "labelListIOList.H" #include "syncTools.H" #include "globalIndex.H" +#include "systemDict.H" using namespace Foam; @@ -56,10 +57,11 @@ int main(int argc, char *argv[]) const word dictName("viewFactorsDict"); - #include "setConstantMeshDictionaryIO.H" - // Read control dictionary - const IOdictionary agglomDict(dictIO); + const IOdictionary agglomDict + ( + systemDict(dictName, args, runTime, word::null, runTime.constant()) + ); bool writeAgglom = readBool(agglomDict.lookup("writeFacesAgglomeration")); diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.C b/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.C index cdb433ec1d..e3972c47d9 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.C @@ -29,20 +29,32 @@ License // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // -Foam::IOdictionary Foam::systemDict +Foam::IOobject Foam::systemDictIO ( const word& dictName, const argList& args, - const objectRegistry& mesh + const objectRegistry& ob, + const word& regionName, + const word& systemName ) { - fileName dictPath = ""; + fileName dictPath = fileName::null; + if (args.optionFound("dict")) { dictPath = args["dict"]; - if (isDir(dictPath)) + + if + ( + isDir + ( + dictPath.isAbsolute() + ? dictPath + : ob.time().globalPath()/dictPath + ) + ) { - dictPath = dictPath / dictName; + dictPath = dictPath/dictName; } } @@ -50,34 +62,48 @@ Foam::IOdictionary Foam::systemDict { Info<< "Reading " << dictPath << nl << endl; - return IOdictionary - ( + return IOobject ( dictPath, - mesh, + ob.time(), IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE - ) - ); + ); } else { Info<< "Reading " << dictName << nl << endl; - return IOdictionary - ( + return IOobject ( dictName, - mesh.time().system(), - mesh, + systemName == word::null ? ob.time().system() : systemName, + regionName == polyMesh::defaultRegion ? word::null : regionName, + ob, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE - ) - ); + ); } } +Foam::IOdictionary Foam::systemDict +( + const word& dictName, + const argList& args, + const objectRegistry& ob, + const word& regionName, + const word& systemName +) +{ + return + IOdictionary + ( + systemDictIO(dictName, args, ob, regionName, systemName) + ); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.H b/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.H index 2cccdf5924..75e212d8b4 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.H +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.H @@ -38,6 +38,7 @@ SourceFiles #include "argList.H" #include "IOdictionary.H" +#include "polyMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -46,11 +47,22 @@ namespace Foam // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // +IOobject systemDictIO +( + const word& dictName, + const argList& args, + const objectRegistry& ob, + const word& regionName = polyMesh::defaultRegion, + const word& systemName = word::null // defaults to ob.time().system() +); + IOdictionary systemDict ( const word& dictName, const argList& args, - const objectRegistry& mesh + const objectRegistry& ob, + const word& regionName = polyMesh::defaultRegion, + const word& systemName = word::null // defaults to ob.time().system() ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/include/setConstantMeshDictionaryIO.H b/src/OpenFOAM/include/setConstantMeshDictionaryIO.H deleted file mode 100644 index aa5a68004c..0000000000 --- a/src/OpenFOAM/include/setConstantMeshDictionaryIO.H +++ /dev/null @@ -1,29 +0,0 @@ -fileName dictPath = ""; -if (args.optionFound("dict")) -{ - dictPath = args["dict"]; - if (isDir(dictPath)) - { - dictPath = dictPath / dictName; - } -} - -IOobject dictIO -( - dictName, - runTime.constant(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE -); - -if (dictPath.size()) -{ - dictIO = IOobject - ( - dictPath, - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ); -} diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/Allmesh b/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/Allmesh index eb64439004..6e7ad6c937 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/Allmesh +++ b/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/Allmesh @@ -11,13 +11,13 @@ runApplication -s porous blockMesh -region porous # Create rotor blades in air region runApplication -s air.1 \ - topoSet -region air -dict system/topoSetDict.1 + topoSet -region air -dict system/air/topoSetDict.1 runApplication createBaffles -region air -overwrite # Create rotor zone in air region for MRF runApplication -s air.2 \ - topoSet -region air -dict system/topoSetDict.2 + topoSet -region air -dict system/air/topoSetDict.2 rm -rf constant/air/polyMesh/sets diff --git a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun index 7d701e7ef2..7720d3c015 100755 --- a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun +++ b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun @@ -10,9 +10,9 @@ application=$(getApplication) runApplication blockMesh runApplication transformPoints "scale=(1.6666 1 1)" -runApplication mirrorMesh -dict mirrorMeshDict.x -overwrite +runApplication mirrorMesh -dict system/mirrorMeshDict.x -overwrite rm log.mirrorMesh -runApplication mirrorMesh -dict mirrorMeshDict.y -overwrite +runApplication mirrorMesh -dict system/mirrorMeshDict.y -overwrite runApplication topoSet runApplication createPatch -overwrite