diff --git a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C index 2a9623f516..2c6c1737a7 100644 --- a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C +++ b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.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 @@ -53,6 +53,7 @@ Usage #include "fvMesh.H" #include "polyMeshFilter.H" #include "faceSet.H" +#include "systemDict.H" using namespace Foam; @@ -92,12 +93,7 @@ int main(int argc, char *argv[]) const word oldInstance = mesh.pointsInstance(); - const word dictName("collapseDict"); - #include "setSystemMeshDictionaryIO.H" - - Info<< "Reading " << dictName << nl << endl; - - IOdictionary collapseDict(dictIO); + const dictionary collapseDict(systemDict("collapseDict", args, mesh)); const bool overwrite = args.optionFound("overwrite"); diff --git a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C index 388171897f..e7946a66c8 100644 --- a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C +++ b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.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 @@ -59,7 +59,7 @@ Description #include "meshTools.H" #include "Pair.H" #include "globalIndex.H" -#include "IOdictionary.H" +#include "systemDict.H" using namespace Foam; @@ -327,8 +327,6 @@ label findCell(const primitiveMesh& mesh, const point& nearPoint) } - - int main(int argc, char *argv[]) { #include "addOverwriteOption.H" @@ -341,19 +339,7 @@ int main(int argc, char *argv[]) const bool overwrite = args.optionFound("overwrite"); - Info<< "Reading modifyMeshDict\n" << endl; - - IOdictionary dict - ( - IOobject - ( - "modifyMeshDict", - runTime.system(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ) - ); + const dictionary dict(systemDict("modifyMeshDict", args, mesh)); // Read all from the dictionary. List> pointsToMove(dict.lookup("pointsToMove")); diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 3808629f54..538ec7dfd0 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.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 @@ -45,6 +45,7 @@ Description #include "MeshedSurfaces.H" #include "globalIndex.H" #include "cellSet.H" +#include "systemDict.H" #include "extrudedMesh.H" #include "extrudeModel.H" @@ -266,7 +267,7 @@ int main(int argc, char *argv[]) #include "addDictOption.H" #include "setRootCase.H" - #include "createTimeExtruded.H" + #include "createTime.H" // Get optional regionName word regionName; @@ -275,30 +276,16 @@ int main(int argc, char *argv[]) { regionDir = regionName; Info<< "Create mesh " << regionName << " for time = " - << runTimeExtruded.timeName() << nl << endl; + << runTime.timeName() << nl << endl; } else { regionName = fvMesh::defaultRegion; Info<< "Create mesh for time = " - << runTimeExtruded.timeName() << nl << endl; + << runTime.timeName() << nl << endl; } - const word dictName - ( - args.optionLookupOrDefault("dict", "extrudeMeshDict") - ); - - IOdictionary dict - ( - IOobject - ( - dictName, - runTimeExtruded.system(), - runTimeExtruded, - IOobject::MUST_READ_IF_MODIFIED - ) - ); + const dictionary dict(systemDict("extrudeMeshDict", args, runTime)); // Point generator autoPtr model(extrudeModel::New(dict)); @@ -376,13 +363,6 @@ int main(int argc, char *argv[]) << " on mesh " << sourceCasePath << nl << endl; - Time runTime - ( - Time::controlDictName, - sourceRootDir, - sourceCaseDir - ); - #include "createMesh.H" const polyBoundaryMesh& patches = mesh.boundaryMesh(); @@ -711,8 +691,8 @@ int main(int argc, char *argv[]) IOobject ( regionName, - runTimeExtruded.constant(), - runTimeExtruded, + runTime.constant(), + runTime, IOobject::NO_READ, IOobject::AUTO_WRITE, false @@ -795,8 +775,8 @@ int main(int argc, char *argv[]) IOobject ( extrudedMesh::defaultRegion, - runTimeExtruded.constant(), - runTimeExtruded + runTime.constant(), + runTime ), fMesh, model() @@ -1040,7 +1020,7 @@ int main(int argc, char *argv[]) } } - mesh.setInstance(runTimeExtruded.constant()); + mesh.setInstance(runTime.constant()); Info<< "Writing mesh to " << mesh.localObjectPath() << nl << endl; if (!mesh.write()) diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C index eca7ecb836..c184458357 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.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 @@ -126,6 +126,7 @@ Notes: #include "fvMeshTools.H" #include "OBJstream.H" #include "PatchTools.H" +#include "systemDict.H" using namespace Foam; @@ -1406,11 +1407,7 @@ int main(int argc, char *argv[]) bool overwrite = args.optionFound("overwrite"); - const word dictName("extrudeToRegionMeshDict"); - - #include "setSystemMeshDictionaryIO.H" - - IOdictionary dict(dictIO); + const dictionary dict(systemDict("extrudeToRegionMeshDict", args, mesh)); // Point generator diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index b560733c0f..644b48eb19 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -58,6 +58,7 @@ Description #include "globalIndex.H" #include "IOmanip.H" #include "fvMeshTools.H" +#include "systemDict.H" using namespace Foam; @@ -731,9 +732,7 @@ int main(int argc, char *argv[]) // Read meshing dictionary - const word dictName("snappyHexMeshDict"); - #include "setSystemMeshDictionaryIO.H" - const IOdictionary meshDict(dictIO); + const dictionary meshDict(systemDict("snappyHexMeshDict", args, mesh)); // all surface geometry diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C index 977a6ee238..b6e081d0ba 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C +++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C @@ -51,6 +51,7 @@ Description #include "faceSelection.H" #include "searchableSurface.H" #include "fvMeshTools.H" +#include "systemDict.H" using namespace Foam; @@ -450,17 +451,13 @@ int main(int argc, char *argv[]) const word oldInstance = mesh.pointsInstance(); - const word dictName("createBafflesDict"); - #include "setSystemMeshDictionaryIO.H" - Switch internalFacesOnly(false); Switch fields(false); PtrList selectors; { - Info<< "Reading baffle criteria from " << dictName << nl << endl; - IOdictionary dict(dictIO); + const dictionary dict(systemDict("createBafflesDict", args, mesh)); dict.lookup("internalFacesOnly") >> internalFacesOnly; fields = dict.lookupOrDefault("fields", false); diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatch.C b/applications/utilities/mesh/manipulation/createPatch/createPatch.C index d31f7c570b..93548be2e2 100644 --- a/applications/utilities/mesh/manipulation/createPatch/createPatch.C +++ b/applications/utilities/mesh/manipulation/createPatch/createPatch.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 @@ -49,7 +49,7 @@ Description #include "polyTopoChange.H" #include "polyModifyFace.H" #include "wordReList.H" -#include "IOdictionary.H" +#include "systemDict.H" using namespace Foam; @@ -488,12 +488,7 @@ int main(int argc, char *argv[]) const word oldInstance = mesh.pointsInstance(); - const word dictName("createPatchDict"); - #include "setSystemMeshDictionaryIO.H" - - Info<< "Reading " << dictName << nl << endl; - - IOdictionary dict(dictIO); + const dictionary dict(systemDict("createPatchDict", args, mesh)); // Whether to synchronise points const Switch pointSync(dict.lookup("pointSync")); diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 323a66b30e..e9a60cc30c 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.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 @@ -49,6 +49,7 @@ Description #include "cellSet.H" #include "faceSet.H" #include "pointSet.H" +#include "systemDict.H" #ifdef FOAM_USE_ZOLTAN #include "zoltanRenumber.H" @@ -691,18 +692,16 @@ int main(int argc, char *argv[]) bool renumberSets = true; // Construct renumberMethod - autoPtr renumberDictPtr; + autoPtr renumberDictPtr; autoPtr renumberPtr; if (readDict) { - const word dictName("renumberMeshDict"); - #include "setSystemMeshDictionaryIO.H" - - Info<< "Renumber according to " << dictName << nl << endl; - - renumberDictPtr.reset(new IOdictionary(dictIO)); - const IOdictionary& renumberDict = renumberDictPtr(); + renumberDictPtr.reset + ( + new dictionary(systemDict("renumberMeshDict", args, mesh)) + ); + const dictionary& renumberDict = renumberDictPtr(); renumberPtr = renumberMethod::New(renumberDict); diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSet.C b/applications/utilities/mesh/manipulation/topoSet/topoSet.C index 3cf81e9789..559ab1b8cb 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSet.C +++ b/applications/utilities/mesh/manipulation/topoSet/topoSet.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 @@ -39,7 +39,7 @@ Description #include "cellZoneSet.H" #include "faceZoneSet.H" #include "pointZoneSet.H" -#include "IOdictionary.H" +#include "systemDict.H" using namespace Foam; @@ -211,12 +211,7 @@ int main(int argc, char *argv[]) const bool noSync = args.optionFound("noSync"); - const word dictName("topoSetDict"); - #include "setSystemMeshDictionaryIO.H" - - Info<< "Reading " << dictName << "\n" << endl; - - IOdictionary topoSetDict(dictIO); + const dictionary topoSetDict(systemDict("topoSetDict", args, mesh)); // Read set construct info from dictionary PtrList actions(topoSetDict.lookup("actions")); diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C index 6233ddafd0..36bfef884b 100644 --- a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C +++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.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 @@ -80,6 +80,7 @@ Note #include "volFields.H" #include "stringListOps.H" #include "timeSelector.H" +#include "systemDict.H" using namespace Foam; @@ -508,10 +509,7 @@ int main(int argc, char *argv[]) // Get the replacement rules from a dictionary - - const word dictName("changeDictionaryDict"); - #include "setSystemMeshDictionaryIO.H" - IOdictionary dict(dictIO); + const dictionary dict(systemDict("changeDictionaryDict", args, mesh)); const dictionary* replaceDictsPtr = &dict; diff --git a/applications/utilities/preProcessing/setFields/setFields.C b/applications/utilities/preProcessing/setFields/setFields.C index ccd8393e2d..2f3f6992aa 100644 --- a/applications/utilities/preProcessing/setFields/setFields.C +++ b/applications/utilities/preProcessing/setFields/setFields.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 @@ -33,9 +33,12 @@ Description #include "cellSet.H" #include "faceSet.H" #include "volFields.H" +#include "systemDict.H" using namespace Foam; +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + template bool setCellFieldType ( @@ -373,7 +376,6 @@ public: }; - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) @@ -384,12 +386,7 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createNamedMesh.H" - const word dictName("setFieldsDict"); - #include "setSystemMeshDictionaryIO.H" - - Info<< "Reading " << dictName << "\n" << endl; - - IOdictionary setFieldsDict(dictIO); + const dictionary setFieldsDict(systemDict("setFieldsDict", args, mesh)); if (setFieldsDict.found("defaultFieldValues")) { @@ -402,7 +399,6 @@ int main(int argc, char *argv[]) Info<< endl; } - Info<< "Setting field region values" << endl; PtrList regions(setFieldsDict.lookup("regions")); diff --git a/applications/utilities/preProcessing/setWaves/setWaves.C b/applications/utilities/preProcessing/setWaves/setWaves.C index beb25bf549..62c424ef8c 100644 --- a/applications/utilities/preProcessing/setWaves/setWaves.C +++ b/applications/utilities/preProcessing/setWaves/setWaves.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -39,6 +39,7 @@ Description #include "wallPolyPatch.H" #include "waveAlphaFvPatchScalarField.H" #include "waveVelocityFvPatchVectorField.H" +#include "systemDict.H" using namespace Foam; @@ -78,10 +79,7 @@ int main(int argc, char *argv[]) #include "createNamedMesh.H" - const word dictName("setWavesDict"); - #include "setSystemMeshDictionaryIO.H" - Info<< "Reading " << dictName << "\n" << endl; - IOdictionary setWavesDict(dictIO); + const dictionary setWavesDict(systemDict("setWavesDict", args, mesh)); #include "readGravitationalAcceleration.H" diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 116e78eef6..32d22c51c9 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -240,6 +240,7 @@ IOdictionary = db/IOobjects/IOdictionary $(IOdictionary)/IOdictionary.C $(IOdictionary)/IOdictionaryIO.C $(IOdictionary)/localIOdictionary.C +$(IOdictionary)/systemDict.C db/IOobjects/IOMap/IOMapName.C db/IOobjects/decomposedBlockData/decomposedBlockData.C diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.C b/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.C new file mode 100644 index 0000000000..adc7067b0e --- /dev/null +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.C @@ -0,0 +1,83 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2021 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "systemDict.H" +#include "IOdictionary.H" +#include "Time.H" + +// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // + +Foam::dictionary Foam::systemDict +( + const word& dictName, + const argList& args, + const objectRegistry& mesh +) +{ + fileName dictPath = ""; + if (args.optionFound("dict")) + { + dictPath = args["dict"]; + if (isDir(dictPath)) + { + dictPath = dictPath / dictName; + } + } + + if (dictPath.size()) + { + Info<< "Reading " << dictPath << nl << endl; + + return IOdictionary + ( + IOobject + ( + dictPath, + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + } + else + { + Info<< "Reading " << dictName << nl << endl; + + return IOdictionary + ( + IOobject + ( + dictName, + mesh.time().system(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.H b/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.H new file mode 100644 index 0000000000..962db4b970 --- /dev/null +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/systemDict.H @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2021 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::systemDict + +Description + Read and return the specified dictionary from system or from path provided + with the -dict option. + +SourceFiles + systemDict.C + +\*---------------------------------------------------------------------------*/ + +#ifndef systemDict_H +#define systemDict_H + +#include "argList.H" +#include "objectRegistry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // + +dictionary systemDict +( + const word& dictName, + const argList& args, + const objectRegistry& mesh +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/include/setSystemMeshDictionaryIO.H b/src/OpenFOAM/include/setSystemMeshDictionaryIO.H deleted file mode 100644 index 4d5f2e68ec..0000000000 --- a/src/OpenFOAM/include/setSystemMeshDictionaryIO.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.system(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE -); - -if (dictPath.size()) -{ - dictIO = IOobject - ( - dictPath, - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ); -}