diff --git a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C index f941743c47a8c100e8fcbfe491f274cd49e5ee6c..d57eeefd48519fada0c3563989f3475c0a084d4f 100644 --- a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C +++ b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C @@ -322,7 +322,7 @@ void Foam::radiation::laserDTRM::initialise() Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T) : radiationModel(typeName, T), - mode_(powerDistNames_.lookup("mode", *this)), + mode_(powerDistNames_.get("mode", *this)), DTRMCloud_(mesh_, "DTRMCloud", IDLList<DTRMParticle>()), nParticles_(0), ndTheta_(get<label>("nTheta")), @@ -432,7 +432,7 @@ Foam::radiation::laserDTRM::laserDTRM ) : radiationModel(typeName, dict, T), - mode_(powerDistNames_.lookup("mode", *this)), + mode_(powerDistNames_.get("mode", *this)), DTRMCloud_(mesh_, "DTRMCloud", IDLList<DTRMParticle>()), nParticles_(0), ndTheta_(get<label>("nTheta")), diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C index e10422c800f5618a73118578813ea19b115068fc..cea0280392d26b32d31e9741f1ad6b4e6deb71fb 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C @@ -50,10 +50,10 @@ const Foam::Enum > Foam::compressible:: alphatWallBoilingWallFunctionFvPatchScalarField::phaseTypeNames_ -{ +({ { phaseType::vaporPhase, "vapor" }, { phaseType::liquidPhase, "liquid" }, -}; +}); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -102,7 +102,7 @@ alphatWallBoilingWallFunctionFvPatchScalarField ) : alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField(p, iF, dict), - phaseType_(phaseTypeNames_.lookup("phaseType", dict)), + phaseType_(phaseTypeNames_.get("phaseType", dict)), relax_(dict.lookupOrDefault<scalar>("relax", 0.5)), AbyV_(p.size(), 0), alphatConv_(p.size(), 0), diff --git a/applications/test/Enum/Make/files b/applications/test/Enum/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..efc235ca4424d86eed3b64b7d240dabe5f02b559 --- /dev/null +++ b/applications/test/Enum/Make/files @@ -0,0 +1,3 @@ +Test-Enum.C + +EXE = $(FOAM_USER_APPBIN)/Test-Enum diff --git a/applications/test/NamedEnum/Make/options b/applications/test/Enum/Make/options similarity index 100% rename from applications/test/NamedEnum/Make/options rename to applications/test/Enum/Make/options diff --git a/applications/test/Enum/Test-Enum.C b/applications/test/Enum/Test-Enum.C new file mode 100644 index 0000000000000000000000000000000000000000..c3ee516fd6f4c950da9f48c88873748e02ba8d1d --- /dev/null +++ b/applications/test/Enum/Test-Enum.C @@ -0,0 +1,166 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ 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 <http://www.gnu.org/licenses/>. + +Description + Testing of Enum lookups. + +\*---------------------------------------------------------------------------*/ + +#include "Enum.H" +#include "dictionary.H" +#include "FlatOutput.H" +#include "IOstreams.H" // For 'Sin' + +#include <array> + +using namespace Foam; + +struct testing +{ + enum class option { A, B, C, D }; + + static const Foam::Enum<option> option1Names; + static const Foam::Enum<option> option2Names; +}; + +// All names +const Foam::Enum<testing::option> testing::option1Names +({ + { testing::option::A, "a" }, + { testing::option::B, "b" }, + { testing::option::C, "c" }, + { testing::option::D, "d" }, +}); + +// Subset of names +const Foam::Enum<testing::option> testing::option2Names +({ + { testing::option::C, "c" }, + { testing::option::D, "d" }, +}); + + +// Can use for integers as well, but not scalar etc. +const Foam::Enum<int> otherNames1 +({ + { 0, "a" }, + { 2, "b" }, + { 3, "c" }, + { 3, "d" }, +}); + + +// Can use for integers as well, but not scalar etc. +const Foam::Enum<int> otherNames2 +({ + { 0, "a" }, + { 2, "b" }, + { 3, "c" }, + { 3, "asdasd" }, +}); + + +std::array<const char*, 2> myarray{ "false", "true" }; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + Info<<"Enum 1" << nl + << " names: " << testing::option1Names << nl + << " values: " << flatOutput(testing::option1Names.values()) + << nl << nl; + + Info<<"Enum 2" << nl + << " names: " << testing::option2Names << nl + << " values: " << flatOutput(testing::option2Names.values()) + << nl << nl; + + Info<<"Other Enum" << nl + << " names: " << otherNames2 << nl + << " values: " << flatOutput(otherNames2.values()) + << nl << nl; + + + dictionary testDict; + testDict.add("lookup1", "c"); + testDict.add("lookup2", "rubbish"); + + Info<< nl + << int(testing::option1Names["a"]) << nl + << testing::option1Names[testing::option::A] << nl; + + Info<< "--- test dictionary lookup ---" << endl; + { + Info<< "dict: " << testDict << endl; + + Info<< "lookupOrDefault(notFound) = " + << int + ( + testing::option1Names.lookupOrDefault + ( + "notFound", + testDict, + testing::option::A + ) + ) + << nl; + + Info<< "lookupOrDefault(lookup1) = " + << int + ( + testing::option1Names.lookupOrDefault + ( + "lookup1", + testDict, + testing::option::A + ) + ) + << nl; + + Info<< "lookupOrDefault(lookup1) = " + << int + ( + testing::option2Names.lookupOrDefault + ( + "lookup1", + testDict, + testing::option::A + ) + ) + << nl; + } + + Info<< "--- test read ---" << endl; + + testing::option dummy(testing::option1Names.read(Sin)); + Info<< testing::option1Names[dummy] << endl; + + Info<< "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/NamedEnum/Make/files b/applications/test/NamedEnum/Make/files deleted file mode 100644 index a1a70860418d9a1c8d10f2b78e1bf79ccb1fc721..0000000000000000000000000000000000000000 --- a/applications/test/NamedEnum/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -Test-NamedEnum.C - -EXE = $(FOAM_USER_APPBIN)/Test-NamedEnum diff --git a/applications/test/NamedEnum/Test-NamedEnum.C b/applications/test/NamedEnum/Test-NamedEnum.C deleted file mode 100644 index d0b7f58d79d9c5c4a3b15f760e0ac84774ee256c..0000000000000000000000000000000000000000 --- a/applications/test/NamedEnum/Test-NamedEnum.C +++ /dev/null @@ -1,161 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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 <http://www.gnu.org/licenses/>. - -Description - -\*---------------------------------------------------------------------------*/ - -#include "NamedEnum.H" -#include "Enum.H" -#include "IOstreams.H" - -using namespace Foam; - -class namedEnumTest -{ -public: - - enum class option - { - A, - B, - C, - D - }; - - enum class otherOption - { - A, - B, - C, - D - }; - - static const Foam::NamedEnum<option, 4> optionNamed; - - static const Foam::Enum<otherOption> optionEnum; - - static const Foam::Enum<option> optionEnum2; -}; - - -template<> -const char* Foam::NamedEnum<namedEnumTest::option, 4>::names[] = -{ - "a", - "b", - "c", - "d", -}; - -const Foam::NamedEnum<namedEnumTest::option, 4> namedEnumTest::optionNamed; - -const Foam::Enum<namedEnumTest::otherOption> namedEnumTest::optionEnum -{ - { namedEnumTest::otherOption::A, "a" }, - { namedEnumTest::otherOption::B, "b" }, - { namedEnumTest::otherOption::C, "c" }, - { namedEnumTest::otherOption::D, "d" }, -}; - - -const Foam::Enum<namedEnumTest::option> namedEnumTest::optionEnum2 -( - namedEnumTest::option::C, - { "c", "d" } -); - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Main program: - -int main(int argc, char *argv[]) -{ - Info<<"NamedEnum: " << namedEnumTest::optionNamed << nl; - Info<<"Enum: " << namedEnumTest::optionEnum << nl; - Info<<"Enum: " << namedEnumTest::optionEnum2 << nl; - - dictionary testDict; - testDict.add("lookup1", "c"); - - Info<< nl - << int(namedEnumTest::optionNamed["a"]) << nl - << namedEnumTest::optionNamed[namedEnumTest::option::A] << nl; - - Info<< nl - << int(namedEnumTest::optionEnum["a"]) << nl - << namedEnumTest::optionEnum[namedEnumTest::otherOption::A] << nl; - - Info<< "--- test dictionary lookup ---" << endl; - { - Info<< "dict: " << testDict << endl; - - Info<< "got: " - << int - ( - namedEnumTest::optionNamed.lookupOrDefault - ( - "notFound", - testDict, - namedEnumTest::option::A - ) - ) - << nl; - - Info<< "got: " - << int - ( - namedEnumTest::optionNamed.lookupOrDefault - ( - "lookup1", - testDict, - namedEnumTest::option::A - ) - ) - << nl; - - Info<< "got: " - << int - ( - namedEnumTest::optionEnum2.lookupOrDefault - ( - "lookup1", - testDict, - namedEnumTest::option::A - ) - ) - << nl; - } - - Info<< "--- test read ---" << endl; - - namedEnumTest::option dummy(namedEnumTest::optionNamed.read(Sin)); - Info<< namedEnumTest::optionNamed[dummy] << endl; - - Info<< "End\n" << endl; - - return 0; -} - - -// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 1529ce78226be5784c6b4ab652873953fe32da5c..fefdd463cd74197cd7854ec72f05e353faf50a55 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -300,11 +300,7 @@ int main(int argc, char *argv[]) const bool flipNormals(dict.get<bool>("flipNormals")); // What to extrude - const ExtrudeMode mode = ExtrudeModeNames.lookup - ( - "constructFrom", - dict - ); + const ExtrudeMode mode = ExtrudeModeNames.get("constructFrom", dict); // Any merging of small edges const scalar mergeTol(dict.lookupOrDefault<scalar>("mergeTol", 1e-4)); diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C index e5dc81bbdf7d44d95bca273ecbaa6d6fe330d505..0e84353209f248b1660cd0e7a9bf3c00deeb4180 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C @@ -1534,7 +1534,7 @@ int main(int argc, char *argv[]) mappedPatchBase::sampleMode sampleMode = - mappedPatchBase::sampleModeNames_.lookup("sampleMode", dict); + mappedPatchBase::sampleModeNames_.get("sampleMode", dict); const bool oneD(dict.get<bool>("oneD")); bool oneDNonManifoldEdges(false); diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index edb36f528c7b2c44589bd1104f7edd333ec683c1..e2a11768e284b71ab3547056f9f6767880cdcd3f 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -49,13 +49,13 @@ const Foam::Enum Foam::conformalVoronoiMesh::dualMeshPointType > Foam::conformalVoronoiMesh::dualMeshPointTypeNames_ -{ +({ { dualMeshPointType::internal, "internal" }, { dualMeshPointType::surface, "surface" }, { dualMeshPointType::featureEdge, "featureEdge" }, { dualMeshPointType::featurePoint, "featurePoint" }, { dualMeshPointType::constrained, "constrained" }, -}; +}); // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellEnum.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellEnum.C index b9542b22ab01fd19c5726358089acf49acf6e7d5..63eb46469f6f69b12167f857d0df4c3d7bbd2ff4 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellEnum.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellEnum.C @@ -32,14 +32,14 @@ const Foam::Enum Foam::indexedCellEnum::cellTypes > Foam::indexedCellEnum::cellTypesNames_ -{ +({ { cellTypes::ctUnassigned, "Unassigned" }, { cellTypes::ctFar, "Far" }, { cellTypes::ctInternal, "Internal" }, { cellTypes::ctSurface, "Surface" }, { cellTypes::ctFeatureEdge, "FeatureEdge" }, { cellTypes::ctFeaturePoint,"FeaturePoint" }, -}; +}); // ************************************************************************* // diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertexEnum.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertexEnum.C index 729eea93d20c1795916608738608f0998836df23..b5da11a5a1cbfc3a3b9cb2257bf8ec6908bda8b2 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertexEnum.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedVertex/indexedVertexEnum.C @@ -33,7 +33,7 @@ const Foam::Enum Foam::indexedVertexEnum::vertexType > Foam::indexedVertexEnum::vertexTypeNames_ -{ +({ { vertexType::vtUnassigned, "Unassigned" }, { vertexType::vtInternal, "Internal" }, { vertexType::vtInternalNearBoundary, "InternalNearBoundary" }, @@ -49,7 +49,7 @@ Foam::indexedVertexEnum::vertexTypeNames_ { vertexType::vtExternalFeaturePoint, "ExternalFeaturePoint" }, { vertexType::vtFar, "Far" }, { vertexType::vtConstrained, "Constrained" }, -}; +}); const Foam::Enum diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSet.C b/applications/utilities/mesh/manipulation/topoSet/topoSet.C index 9878b75b3c56394048cabd9d8fba4da17b6880d7..f08ea7516908b193a27045bae629c8170b8abac3 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSet.C +++ b/applications/utilities/mesh/manipulation/topoSet/topoSet.C @@ -242,7 +242,7 @@ int main(int argc, char *argv[]) const word setType(dict.get<word>("type")); const topoSetSource::setAction action = - topoSetSource::actionNames.lookup("action", dict); + topoSetSource::actionNames.get("action", dict); autoPtr<topoSet> currentSet; if diff --git a/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C b/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C index ddefd7f7ee4945a6357bb977bb300f039db6cbd4..59199c7bda83ff9bc3f342ecd5c4863da182a3a0 100644 --- a/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C +++ b/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C @@ -38,9 +38,11 @@ const Foam::Enum Foam::vector::components > Foam::channelIndex::vectorComponentsNames_ -( - Foam::vector::components::X, { "x", "y", "z" } -); +({ + { vector::components::X, "x" }, + { vector::components::Y, "y" }, + { vector::components::Z, "z" }, +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -224,7 +226,7 @@ Foam::channelIndex::channelIndex ) : symmetric_(dict.get<bool>("symmetric")), - dir_(vectorComponentsNames_.lookup("component", dict)) + dir_(vectorComponentsNames_.get("component", dict)) { const polyBoundaryMesh& patches = mesh.boundaryMesh(); diff --git a/applications/utilities/preProcessing/createZeroDirectory/solverTemplate.C b/applications/utilities/preProcessing/createZeroDirectory/solverTemplate.C index 0c85961e7e65a43b8629c0c31c2751a42b7698a9..1e07af5e0c5337b4097bda4e53069590e675ecda 100644 --- a/applications/utilities/preProcessing/createZeroDirectory/solverTemplate.C +++ b/applications/utilities/preProcessing/createZeroDirectory/solverTemplate.C @@ -36,12 +36,12 @@ const Foam::Enum Foam::solverTemplate::solverType > Foam::solverTemplate::solverTypeNames_ -{ +({ { solverType::stCompressible, "compressible" }, { solverType::stIncompressible, "incompressible" }, { solverType::stBuoyant, "buoyant" }, { solverType::stUnknown, "unknown" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -255,10 +255,10 @@ Foam::solverTemplate::solverTemplate Info<< "Selecting " << solverName << ": "; - solverType_ = solverTypeNames_.lookup("solverType", solverDict); - Info<< solverTypeNames_[solverType_]; - + solverType_ = solverTypeNames_.get("solverType", solverDict); multiRegion_ = solverDict.get<bool>("multiRegion"); + + Info<< solverTypeNames_[solverType_]; if (multiRegion_) { Info<< ", multi-region"; diff --git a/applications/utilities/preProcessing/setAlphaField/setAlphaField.C b/applications/utilities/preProcessing/setAlphaField/setAlphaField.C index 25a226d14271a5303d387a41b5ad46b622642ec7..37bc94df278e2faa01a9a1723af6dac6a6055af5 100644 --- a/applications/utilities/preProcessing/setAlphaField/setAlphaField.C +++ b/applications/utilities/preProcessing/setAlphaField/setAlphaField.C @@ -65,12 +65,12 @@ const Foam::Enum shapeSelector::shapeType > shapeSelector::shapeTypeNames -{ +({ { shapeSelector::shapeType::PLANE, "plane" }, { shapeSelector::shapeType::SPHERE, "sphere" }, { shapeSelector::shapeType::CYLINDER, "cylinder" }, { shapeSelector::shapeType::SIN, "sin" }, -}; +}); int main(int argc, char *argv[]) @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) const shapeSelector::shapeType surfType ( - shapeSelector::shapeTypeNames.lookup("type", dict) + shapeSelector::shapeTypeNames.get("type", dict) ); const vector centre(dict.get<vector>("centre")); const word fieldName(dict.get<word>("field")); diff --git a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/general/general.C b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/general/general.C index eb38f408b28655ec741f5da66435b6a1ae796f44..87df0faa8505f5f63a4a9673cba0ef4503437bb8 100644 --- a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/general/general.C +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/general/general.C @@ -48,9 +48,9 @@ const Foam::Enum Foam::tabulatedWallFunctions::general::interpolationType > Foam::tabulatedWallFunctions::general::interpolationTypeNames_ -{ +({ { interpolationType::itLinear, "linear" }, -}; +}); // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // @@ -132,7 +132,7 @@ Foam::tabulatedWallFunctions::general::general ) : tabulatedWallFunction(dict, mesh, typeName), - interpType_(interpolationTypeNames_.lookup("interpType", coeffDict_)), + interpType_(interpolationTypeNames_.get("interpType", coeffDict_)), yPlus_(), uPlus_(), log10YPlus_(coeffDict_.lookup("log10YPlus")), diff --git a/src/OSspecific/POSIX/fileMonitor.C b/src/OSspecific/POSIX/fileMonitor.C index 7d642541e064d49f119b26d193282b4b00ad1ef4..b3a82edc4748cb1e79f185f8187180654c210067 100644 --- a/src/OSspecific/POSIX/fileMonitor.C +++ b/src/OSspecific/POSIX/fileMonitor.C @@ -48,11 +48,11 @@ const Foam::Enum Foam::fileMonitor::fileState > Foam::fileMonitor::fileStateNames_ -{ +({ { fileState::UNMODIFIED, "unmodified" }, { fileState::MODIFIED, "modified" }, { fileState::DELETED, "deleted" }, -}; +}); namespace Foam diff --git a/src/OpenFOAM/algorithms/indexedOctree/volumeType.C b/src/OpenFOAM/algorithms/indexedOctree/volumeType.C index bc6040423c2fbb9f1ef9b63833c074503ce5d761..e1a8c919a473823a9a66bd7c387b92352ec7c2b8 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/volumeType.C +++ b/src/OpenFOAM/algorithms/indexedOctree/volumeType.C @@ -30,15 +30,15 @@ License const Foam::Enum < - Foam::volumeType + Foam::volumeType::type > Foam::volumeType::names -{ - { type::UNKNOWN, "unknown" }, - { type::INSIDE, "inside" }, - { type::OUTSIDE, "outside" }, - { type::MIXED, "mixed" }, -}; +({ + { volumeType::type::UNKNOWN, "unknown" }, + { volumeType::type::INSIDE, "inside" }, + { volumeType::type::OUTSIDE, "outside" }, + { volumeType::type::MIXED, "mixed" }, +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/algorithms/indexedOctree/volumeType.H b/src/OpenFOAM/algorithms/indexedOctree/volumeType.H index 4e66188fdd38ccf82d6c93884d0315b9ebd69136..2559dc4b49e72a0aa448d2b59d880f5ac51bebf7 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/volumeType.H +++ b/src/OpenFOAM/algorithms/indexedOctree/volumeType.H @@ -70,7 +70,7 @@ public: // Static data //- Names for the classification enumeration - static const Enum<volumeType> names; + static const Enum<volumeType::type> names; private: diff --git a/src/OpenFOAM/db/IOobject/IOobject.C b/src/OpenFOAM/db/IOobject/IOobject.C index ffb6d42ee24b5eaa78093baea7d2041cbcad02a9..6b67e982c067f70bb358eafafe671df05367bf69 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.C +++ b/src/OpenFOAM/db/IOobject/IOobject.C @@ -39,18 +39,18 @@ const Foam::Enum Foam::IOobject::fileCheckTypes > Foam::IOobject::fileCheckTypesNames -{ +({ { fileCheckTypes::timeStamp, "timeStamp" }, { fileCheckTypes::timeStampMaster, "timeStampMaster" }, { fileCheckTypes::inotify, "inotify" }, { fileCheckTypes::inotifyMaster, "inotifyMaster" }, -}; +}); // Default fileCheck type Foam::IOobject::fileCheckTypes Foam::IOobject::fileModificationChecking ( - fileCheckTypesNames.lookup + fileCheckTypesNames.get ( "fileModificationChecking", debug::optimisationSwitches() diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.C b/src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.C index 0e7b7dd844a6303ec700b9de06f519856d7ab251..2463ac9ac1c5cbe03f85398ec12195568a9582ef 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.C +++ b/src/OpenFOAM/db/IOstreams/IOstreams/IOstreamOption.C @@ -42,10 +42,10 @@ const Foam::Enum Foam::IOstreamOption::streamFormat > Foam::IOstreamOption::formatNames -{ +({ { streamFormat::ASCII, "ascii" }, - { streamFormat::BINARY, "binary" } -}; + { streamFormat::BINARY, "binary" }, +}); // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C index 9b3bf890fae2bd1ae8d89bcbb374562afd27c916..e1842eb038b56f3f8c88dba6324cee0989b4d57a 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C @@ -41,11 +41,11 @@ const Foam::Enum Foam::UPstream::commsTypes > Foam::UPstream::commsTypeNames -{ +({ { commsTypes::blocking, "blocking" }, { commsTypes::scheduled, "scheduled" }, { commsTypes::nonBlocking, "nonBlocking" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -411,7 +411,7 @@ registerOptSwitch Foam::UPstream::commsTypes Foam::UPstream::defaultCommsType ( - commsTypeNames.lookup + commsTypeNames.get ( "commsType", Foam::debug::optimisationSwitches() @@ -436,10 +436,8 @@ namespace Foam virtual void readData(Foam::Istream& is) { - UPstream::defaultCommsType = UPstream::commsTypeNames.read - ( - is - ); + UPstream::defaultCommsType = + UPstream::commsTypeNames.read(is); } virtual void writeData(Foam::Ostream& os) const diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 51b3819f88b8e76e614d311dfefd8305c93d5ac3..6a12ebf000cc1967266b720d6f5e8b020c29acd8 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -46,14 +46,14 @@ const Foam::Enum Foam::Time::stopAtControls > Foam::Time::stopAtControlNames -{ +({ { stopAtControls::saEndTime, "endTime" }, { stopAtControls::saNoWriteNow, "noWriteNow" }, { stopAtControls::saWriteNow, "writeNow" }, { stopAtControls::saNextWrite, "nextWrite" }, // NOTE: stopAtControls::saUnknown is left untabulated here so that it can // be used as fallback value to flag unknown settings -}; +}); const Foam::Enum @@ -61,13 +61,13 @@ const Foam::Enum Foam::Time::writeControls > Foam::Time::writeControlNames -{ +({ { writeControls::wcTimeStep, "timeStep" }, { writeControls::wcRunTime, "runTime" }, { writeControls::wcAdjustableRunTime, "adjustableRunTime" }, { writeControls::wcClockTime, "clockTime" }, { writeControls::wcCpuTime, "cpuTime" }, -}; +}); Foam::Time::fmtflags Foam::Time::format_(Foam::Time::general); diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index ea45f1b2f38e7777bbcc91a40b55d5700c28b3ce..ed6252d7eb065b9248db846f9d9182ce0f22c4e6 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -347,14 +347,12 @@ void Foam::Time::readDict() controlDict_.readEntry("deltaT", deltaT_); } - if (controlDict_.found("writeControl")) - { - writeControl_ = writeControlNames.lookup - ( - "writeControl", - controlDict_ - ); - } + writeControlNames.readIfPresent + ( + "writeControl", + controlDict_, + writeControl_ + ); scalar oldWriteInterval = writeInterval_; @@ -435,10 +433,8 @@ void Foam::Time::readDict() // stopAt at 'endTime' or a specified value // if nothing is specified, the endTime is zero - if (controlDict_.found("stopAt")) + if (stopAtControlNames.readIfPresent("stopAt", controlDict_, stopAt_)) { - stopAt_ = stopAtControlNames.lookup("stopAt", controlDict_); - if (stopAt_ == saEndTime) { controlDict_.readEntry("endTime", endTime_); diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C b/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C index 960e10e86dccecd4a5ecbf495f72e7856c8806a4..266714e7d7952b1daab865063559f6cdf9724d78 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C @@ -95,7 +95,7 @@ const Foam::Enum Foam::entry::inputMode > Foam::functionEntries::inputMode::selectableNames -{ +({ { entry::inputMode::MERGE, "merge" }, { entry::inputMode::OVERWRITE, "overwrite" }, { entry::inputMode::PROTECT, "protect" }, @@ -103,7 +103,7 @@ Foam::functionEntries::inputMode::selectableNames { entry::inputMode::ERROR, "error" }, // Aliases { entry::inputMode::MERGE, "default" }, -}; +}); // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -116,7 +116,7 @@ bool Foam::functionEntries::inputMode::execute { const word modeName(is); - // Behaviour like Enum lookupOrFailsafe() + // Like Enum::lookupOrDefault() with failsafe behaviour if (selectableNames.found(modeName)) { entry::globalInputMode = selectableNames[modeName]; diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C index 1e68e691dcac00d7932dabfa4677680ddd455298..18742f521ce622c4db6ae68f2332d5ae35599718 100644 --- a/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C @@ -33,7 +33,7 @@ const Foam::Enum Foam::timeControl::timeControls > Foam::timeControl::timeControlNames_ -{ +({ { timeControl::ocTimeStep, "timeStep" }, { timeControl::ocWriteTime, "writeTime" }, { timeControl::ocOutputTime, "outputTime" }, @@ -43,7 +43,7 @@ Foam::timeControl::timeControlNames_ { timeControl::ocCpuTime, "cpuTime" }, { timeControl::ocOnEnd, "onEnd" }, { timeControl::ocNone, "none" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -110,14 +110,8 @@ void Foam::timeControl::read(const dictionary& dict) intervalName = "outputInterval"; } - if (dict.found(controlName)) - { - timeControl_ = timeControlNames_.lookup(controlName, dict); - } - else - { - timeControl_ = ocTimeStep; - } + timeControl_ = + timeControlNames_.lookupOrDefault(controlName, dict, ocTimeStep); switch (timeControl_) { diff --git a/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C b/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C index b624145aeb56ee75b9dfe2b50a30f0cbb67699c9..0ac4876dbae81ecddaddc08e933a7de8bc226fb5 100644 --- a/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C +++ b/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C @@ -93,11 +93,12 @@ Foam::interpolation2DTable<Type>::interpolation2DTable(const dictionary& dict) List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>(), bounding_ ( - bounds::normalBoundingNames.lookupOrFailsafe + bounds::normalBoundingNames.lookupOrDefault ( "outOfBounds", dict, - bounds::normalBounding::WARN + bounds::normalBounding::WARN, + true // Failsafe behaviour ) ), fileName_(dict.lookup("file")), diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C index 8b162427e7945e9be6f01438f72bdaf8f50ff898..a4c3eceb7c7e8f50fde4beb2352f30e6e9d080b6 100644 --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C +++ b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C @@ -97,11 +97,12 @@ Foam::interpolationTable<Type>::interpolationTable(const dictionary& dict) List<Tuple2<scalar, Type>>(), bounding_ ( - bounds::repeatableBoundingNames.lookupOrFailsafe + bounds::repeatableBoundingNames.lookupOrDefault ( "outOfBounds", dict, - bounds::repeatableBounding::WARN + bounds::repeatableBounding::WARN, + true // Failsafe behaviour ) ), fileName_(dict.lookup("file")), diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C index 4090f6eafa9afacb73ddd8c41aa612ced5dfbabe..beb7188e0d1db6d49afe1c4cdab4376245e7f7da 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C @@ -43,13 +43,13 @@ const Foam::Enum Foam::coupledPolyPatch::transformType > Foam::coupledPolyPatch::transformTypeNames -{ +({ { transformType::UNKNOWN, "unknown" }, { transformType::ROTATIONAL, "rotational" }, { transformType::TRANSLATIONAL, "translational" }, { transformType::COINCIDENTFULLMATCH, "coincidentFullMatch" }, { transformType::NOORDERING, "noOrdering" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/primitiveShapes/triangle/intersection.C b/src/OpenFOAM/meshes/primitiveShapes/triangle/intersection.C index 11392de2dd4ae6de98bde0847a7eee62057a8ec6..23179f878d0fa664b9c743f901ca6aa4115d799e 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/triangle/intersection.C +++ b/src/OpenFOAM/meshes/primitiveShapes/triangle/intersection.C @@ -34,10 +34,10 @@ const Foam::Enum Foam::intersection::direction > Foam::intersection::directionNames_ -{ +({ { intersection::direction::VECTOR, "vector" }, { intersection::direction::CONTACT_SPHERE, "contactSphere" }, -}; +}); const Foam::Enum @@ -45,11 +45,11 @@ const Foam::Enum Foam::intersection::algorithm > Foam::intersection::algorithmNames_ -{ +({ { intersection::algorithm::FULL_RAY, "fullRay" }, { intersection::algorithm::HALF_RAY, "halfRay" }, { intersection::algorithm::VISIBLE, "visible" }, -}; +}); // ************************************************************************* // diff --git a/src/OpenFOAM/orientedType/orientedType.C b/src/OpenFOAM/orientedType/orientedType.C index 71f68726d77b91e24ac45b10ef9e9ae0c8b4964c..deeddd94124412c232b8bef82bf7751a2aa92057 100644 --- a/src/OpenFOAM/orientedType/orientedType.C +++ b/src/OpenFOAM/orientedType/orientedType.C @@ -32,11 +32,11 @@ const Foam::Enum Foam::orientedType::orientedOption > Foam::orientedType::orientedOptionNames -{ +({ { orientedOption::ORIENTED, "oriented" }, { orientedOption::UNORIENTED, "unoriented" }, { orientedOption::UNKNOWN, "unknown" }, -}; +}); bool Foam::orientedType::checkType @@ -45,19 +45,12 @@ bool Foam::orientedType::checkType const orientedType& ot2 ) { - if + return ( (ot1.oriented() == UNKNOWN) || (ot2.oriented() == UNKNOWN) || (ot1.oriented() == ot2.oriented()) - ) - { - return true; - } - else - { - return false; - } + ); } @@ -115,7 +108,8 @@ void Foam::orientedType::read(const dictionary& dict) ( "oriented", dict, - orientedOption::UNKNOWN + orientedOption::UNKNOWN, + true // Failsafe behaviour ); } diff --git a/src/OpenFOAM/primitives/bools/Switch/Switch.C b/src/OpenFOAM/primitives/bools/Switch/Switch.C index 098b7f79a54b4cf40b2348db509f07a413857b7e..71e9c1c818e66a35a0ce9f8459d0f486aeb7872a 100644 --- a/src/OpenFOAM/primitives/bools/Switch/Switch.C +++ b/src/OpenFOAM/primitives/bools/Switch/Switch.C @@ -112,7 +112,7 @@ Foam::Switch Foam::Switch::lookupOrAddToDict ( const word& name, dictionary& dict, - const Switch& defaultValue + const Switch defaultValue ) { return dict.lookupOrAddDefault<Switch>(name, defaultValue); diff --git a/src/OpenFOAM/primitives/bools/Switch/Switch.H b/src/OpenFOAM/primitives/bools/Switch/Switch.H index ab4da782aca176d65152398b33a22db9cc4402f7..d755b2dc268caec2fbdb665b2f44b5c09e7ddb4f 100644 --- a/src/OpenFOAM/primitives/bools/Switch/Switch.H +++ b/src/OpenFOAM/primitives/bools/Switch/Switch.H @@ -75,7 +75,7 @@ public: // The lower bit is tested for the true/false condition. // The values correspond to an index into the predefined output names // for the c_str() method. - enum switchType + enum switchType : unsigned char { FALSE = 0 /*!< "false" */, TRUE = 1 /*!< "true" */, NO = 2 /*!< "no" */, YES = 3 /*!< "yes" */, @@ -164,7 +164,7 @@ public: ( const word& name, dictionary& dict, - const Switch& defaultValue = switchType::FALSE + const Switch defaultValue = switchType::FALSE ); diff --git a/src/OpenFOAM/primitives/enums/Enum.C b/src/OpenFOAM/primitives/enums/Enum.C index 9bfc6ad5a544e21b24774da58e01450b8bfd8467..f74a393a562c7cab7cd5adfff0f56effcbb3c235 100644 --- a/src/OpenFOAM/primitives/enums/Enum.C +++ b/src/OpenFOAM/primitives/enums/Enum.C @@ -26,127 +26,54 @@ License #include "Enum.H" #include "dictionary.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template<class EnumType> -Foam::label Foam::Enum<EnumType>::getIndex(const word& enumName) const -{ - const label n = size(); - for (label idx=0; idx < n; ++idx) - { - if (names_[idx] == enumName) - { - return idx; - } - } - - return -1; -} - - -template<class EnumType> -Foam::label Foam::Enum<EnumType>::getIndex(const EnumType e) const -{ - const int val = int(e); - - const label n = size(); - for (label idx=0; idx < n; ++idx) - { - if (values_[idx] == val) - { - return idx; - } - } - - return -1; -} - - -template<class EnumType> -EnumType Foam::Enum<EnumType>::getEnum(const word& enumName) const -{ - const label idx = getIndex(enumName); - - if (idx < 0) - { - FatalErrorInFunction - << enumName << " is not in enumeration: " - << names_ << exit(FatalError); - } - - return EnumType(values_[idx]); -} - - -template<class EnumType> -const Foam::word& Foam::Enum<EnumType>::getName(const EnumType e) const -{ - const label idx = getIndex(e); - - if (idx < 0) - { - return word::null; - } - - return names_[idx]; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class EnumType> Foam::Enum<EnumType>::Enum ( - std::initializer_list<std::pair<EnumType, word>> lst + std::initializer_list<std::pair<EnumType, const char*>> list ) : - names_(lst.size()), - values_(lst.size()) + keys_(list.size()), + vals_(list.size()) { - int idx = 0; - for (const auto& pair : lst) + label i = 0; + for (const auto& pair : list) { - names_[idx] = pair.second; - values_[idx] = int(pair.first); + keys_[i] = pair.second; + vals_[i] = int(pair.first); - ++idx; + ++i; } } +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + template<class EnumType> -Foam::Enum<EnumType>::Enum -( - const EnumType start, - std::initializer_list<word> lst -) -: - names_(lst.size()), - values_(lst.size()) +Foam::List<Foam::word> Foam::Enum<EnumType>::sortedToc() const { - int val = int(start); + List<word> list(keys_); - int idx = 0; - for (const auto& key : lst) - { - names_[idx] = key; - values_[idx] = val; + Foam::sort(list); - ++val; - ++idx; - } + return list; } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - template<class EnumType> -Foam::List<Foam::word> Foam::Enum<EnumType>::sortedToc() const +EnumType Foam::Enum<EnumType>::get(const word& enumName) const { - wordList lst(names_); - Foam::sort(lst); + const label idx = find(enumName); - return lst; + if (idx < 0) + { + FatalErrorInFunction + << enumName << " is not in enumeration: " << *this << nl + << exit(FatalError); + } + + return EnumType(vals_[idx]); } @@ -154,28 +81,17 @@ template<class EnumType> EnumType Foam::Enum<EnumType>::read(Istream& is) const { const word enumName(is); - const label idx = getIndex(enumName); + + const label idx = find(enumName); if (idx < 0) { FatalIOErrorInFunction(is) - << enumName << " is not in enumeration: " - << names_ << nl + << enumName << " is not in enumeration: " << *this << nl << exit(FatalIOError); } - return EnumType(values_[idx]); -} - - -template<class EnumType> -void Foam::Enum<EnumType>::write(const EnumType e, Ostream& os) const -{ - const label idx = getIndex(e); - if (idx >= 0) - { - os << names_[idx]; - } + return EnumType(vals_[idx]); } @@ -186,29 +102,18 @@ EnumType Foam::Enum<EnumType>::get const dictionary& dict ) const { - const word enumName(dict.get<word>(key)); - const label idx = getIndex(enumName); + const word enumName(dict.get<word>(key, keyType::LITERAL)); + + const label idx = find(enumName); if (idx < 0) { FatalIOErrorInFunction(dict) - << enumName << " is not in enumeration: " - << names_ << nl + << enumName << " is not in enumeration: " << *this << nl << exit(FatalIOError); } - return EnumType(values_[idx]); -} - - -template<class EnumType> -EnumType Foam::Enum<EnumType>::lookup -( - const word& key, - const dictionary& dict -) const -{ - return this->get(key, dict); + return EnumType(vals_[idx]); } @@ -217,55 +122,96 @@ EnumType Foam::Enum<EnumType>::lookupOrDefault ( const word& key, const dictionary& dict, - const EnumType deflt + const EnumType defaultValue, + const bool failsafe ) const { - if (dict.found(key)) + const entry* eptr = dict.findEntry(key, keyType::LITERAL); + + if (eptr) { - return get(key, dict); + const word enumName(eptr->get<word>()); + + const label idx = find(enumName); + + if (idx >= 0) + { + return EnumType(vals_[idx]); + } + + // Found the entry, but failed the name lookup + + if (failsafe) + { + IOWarningInFunction(dict) + << enumName << " is not in enumeration: " << *this << nl + << "using failsafe " << get(defaultValue) + << " (value " << int(defaultValue) << ")" << endl; + } + else + { + FatalIOErrorInFunction(dict) + << enumName << " is not in enumeration: " << *this << nl + << exit(FatalIOError); + } } - return deflt; + return defaultValue; } template<class EnumType> -EnumType Foam::Enum<EnumType>::lookupOrFailsafe +bool Foam::Enum<EnumType>::readEntry ( const word& key, const dictionary& dict, - const EnumType deflt + EnumType& val, + bool mandatory ) const { - if (dict.found(key)) + const entry* eptr = dict.findEntry(key, keyType::LITERAL); + + if (eptr) { - const word enumName(dict.get<word>(key)); - const label idx = getIndex(enumName); + const word enumName(eptr->get<word>()); + + const label idx = find(enumName); if (idx >= 0) { - return EnumType(values_[idx]); + val = EnumType(vals_[idx]); + + return true; } - IOWarningInFunction(dict) - << "bad " << key <<" specifier " << enumName - << " using " << getName(deflt) << endl; + if (mandatory) + { + FatalIOErrorInFunction(dict) + << enumName << " is not in enumeration: " << *this << nl + << exit(FatalIOError); + } + } + else if (mandatory) + { + FatalIOErrorInFunction(dict) + << "'" << key << "' not found in dictionary " << dict.name() << nl + << exit(FatalIOError); } - return deflt; + return false; } -// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // - template<class EnumType> -Foam::Ostream& Foam::operator<< +bool Foam::Enum<EnumType>::readIfPresent ( - Ostream& os, - const Enum<EnumType>& wrapped -) + const word& key, + const dictionary& dict, + EnumType& val +) const { - return wrapped.names().writeList(os, 10); + // Reading is non-mandatory + return readEntry(key, dict, val, false); } diff --git a/src/OpenFOAM/primitives/enums/Enum.H b/src/OpenFOAM/primitives/enums/Enum.H index 480ed06908de5f3352d9dd4b438ba85795af6a0c..f85b8985d8902d0cf1ddd65ede48398c6d50e8f8 100644 --- a/src/OpenFOAM/primitives/enums/Enum.H +++ b/src/OpenFOAM/primitives/enums/Enum.H @@ -29,8 +29,8 @@ Description enumeration values. SourceFiles - EnumI.H Enum.C + EnumI.H \*---------------------------------------------------------------------------*/ @@ -45,13 +45,11 @@ SourceFiles namespace Foam { + // Forward declarations class dictionary; template<class EnumType> class Enum; -template<class EnumType> -Ostream& operator<<(Ostream& os, const Enum<EnumType>& wrapped); - /*---------------------------------------------------------------------------*\ Class Enum Declaration \*---------------------------------------------------------------------------*/ @@ -62,89 +60,79 @@ class Enum // Private Member Data //- The names for the enum - List<word> names_; + List<word> keys_; //- The values for the enum - List<int> values_; - - - // Private Member Functions - - //- The index for the given name. -1 if not found. - label getIndex(const word& enumName) const; - - //- The index for the given enumeration. -1 if not found. - label getIndex(const EnumType e) const; - - //- Get enumeration corresponding to the given name. - // FatalError if not found. - EnumType getEnum(const word& enumName) const; - - //- Get name corresponding to the given enumeration. - // Return empty word if not found. - const word& getName(const EnumType e) const; - - - //- No copy construct - Enum(const Enum&) = delete; - - //- No copy assignment - void operator=(const Enum&) = delete; + List<int> vals_; public: - //- The type of enumeration wrapped by Enum + //- The type of enumeration represented by the Enum typedef EnumType value_type; + // Normally only enum, but be generous and allow integrals as well + static_assert + ( + std::is_enum<EnumType>::value || std::is_integral<EnumType>::value, + "Enum must be enum or an integral type" + ); + // Constructors //- Construct from a values/names list. // Duplicate values are permitted (eg, for aliases). // Duplicate names are permitted, but won't make much sense. - explicit Enum(std::initializer_list<std::pair<EnumType, word>> lst); - - //- Construct from a list of names with values incremented from the - //- specified start value. - Enum(const EnumType start, std::initializer_list<word> lst); + explicit Enum + ( + std::initializer_list<std::pair<EnumType, const char*>> list + ); // Member Functions // Access - //- The number of enum names for the enumeration + //- The number of name/value pairs for the enumeration. inline label size() const; - //- The list of enum names, in construction order + //- The list of enum names, in construction order. Same as toc() inline const List<word>& names() const; - //- The list of enum names, in construction order + //- The list of enum names, in construction order. Same as names() inline const List<word>& toc() const; - //- The sorted list of enum names + //- The sorted list of enum names. List<word> sortedToc() const; - //- The list of enum values, in construction order + //- The list of enum values, in construction order. inline const List<int>& values() const; // Query + //- Find the index of the given name. + // \return position in list or -1 if not found. + inline label find(const word& enumName) const; + + //- Find the first index of given enumeration. + // \return position in list or -1 if not found. + inline label find(const EnumType e) const; + //- Test if there is an enumeration corresponding to the given name. inline bool found(const word& enumName) const; //- Test if there is a name corresponding to the given enumeration. inline bool found(const EnumType e) const; - //- Test if there is an enumeration corresponding to the given name. - // \deprecated Use found() - for compatibility with NamedEnum - inline bool hasEnum(const word& enumName) const; + //- The enumeration corresponding to the given name. + // FatalError if not found. + EnumType get(const word& enumName) const; - //- Test if there is a name corresponding to the given enumeration. - // \deprecated Use found() - for compatibility with NamedEnum - inline bool hasName(const EnumType e) const; + //- The name corresponding to the given enumeration. + // Return an empty word if not found. + inline const word& get(const EnumType e) const; // Read @@ -152,32 +140,48 @@ public: //- Get the key in the dictionary and return the corresponding //- enumeration element based on its name. // FatalError if anything is incorrect. - EnumType get(const word& key, const dictionary& dict) const; - - //- Same as get() - EnumType lookup(const word& key, const dictionary& dict) const; + EnumType get + ( + const word& key, //!< Lookup key. Uses LITERAL (not REGEX) + const dictionary& dict //!< dictionary + ) const; //- Find the key in the dictionary and return the corresponding //- enumeration element based on its name. - // Return the default value if the key was not found in the dictionary. - // FatalError if the enumerated name was incorrect. + // + // \return The value found or default if not found in dictionary. + // FatalError (or Warning) if the enumerated name was incorrect. EnumType lookupOrDefault ( - const word& key, - const dictionary& dict, - const EnumType deflt + const word& key, //!< Lookup key. Uses LITERAL (not REGEX) + const dictionary& dict, //!< dictionary + const EnumType defaultValue, //!< fallback if not found + const bool failsafe = false //!< Warn only on bad enumeration ) const; + //- Find entry and assign to T val. + //- FatalIOError if it is found and the number of tokens is incorrect, + //- or it is mandatory and not found. + // + // \return true if the entry was found. + bool readEntry + ( + const word& key, //!< Lookup key. Uses LITERAL (not REGEX) + const dictionary& dict, //!< dictionary + EnumType& val, //!< the value to read into + bool mandatory = true //!< the keyword is mandatory + ) const; - //- Find the key in the dictionary and return the corresponding - //- enumeration element based on its name. - // Return the default value if the key was not found in the dictionary - // or if the enumerated name was incorrect (emit warning) - EnumType lookupOrFailsafe + //- Find an entry if present, and assign to T val. + //- FatalIOError if it is found and the number of tokens is incorrect. + // Default search: non-recursive with patterns. + // + // \return true if the entry was found. + bool readIfPresent ( - const word& key, - const dictionary& dict, - const EnumType deflt + const word& key, //!< Lookup key. Uses LITERAL (not REGEX) + const dictionary& dict, //!< dictionary + EnumType& val //!< the value to read into ) const; @@ -188,49 +192,64 @@ public: //- Write the name representation of the enumeration to an Ostream // A noop if the enumeration wasn't found. - void write(const EnumType e, Ostream& os) const; + inline void write(const EnumType e, Ostream& os) const; - //- Write the names as a list to an Ostream - inline Ostream& writeList - ( - Ostream& os, - const label shortListLen=0 - ) const; + //- Write the names as a list to an Ostream. + // Default is without line-breaks. + inline Ostream& writeList(Ostream& os, const label shortLen=0) const; // Member Operators //- Return the enumeration corresponding to the given name // FatalError if the name is not found. - // Identical to getEnum() + // Identical to single parameter get() inline EnumType operator[](const word& enumName) const; //- Return the first name corresponding to the given enumeration. // Returns an empty word on failure. - // Identical to getName() + // Identical to single parameter get() inline const word& operator[](const EnumType e) const; - //- Return the enumeration corresponding to the given name or deflt - //- if the name is not found. + //- Return the enumeration corresponding to the given name or + //- defaultValue if the name is not found. inline EnumType operator() ( const word& enumName, - const EnumType deflt + const EnumType defaultValue ) const; - // IOstream operators + // Housekeeping - //- Write names to Ostream, as per writeList() with shortListLen=10 - friend Ostream& operator<< <EnumType> - ( - Ostream& os, - const Enum<EnumType>& wrapped - ); + //- Same as two-parameter get() + // \deprecated Use two-parameter get() instead (OCT-2018) + inline EnumType lookup(const word& key, const dictionary& dict) const + { + return get(key, dict); + } + //- Perform lookupOrDefault with warnings instead of error. + // \deprecated use lookupOrDefault with failsafe option (OCT-2018) + EnumType lookupOrFailsafe + ( + const word& key, + const dictionary& dict, + const EnumType defaultValue + ) const + { + return lookupOrDefault(key, dict, defaultValue, true); + } }; +// Ostream Operator + +//- Write enumeration names, without line-breaks (ie, FlatOutput) +template<class EnumType> +inline Ostream& operator<<(Ostream& os, const Enum<EnumType>& list); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/primitives/enums/EnumI.H b/src/OpenFOAM/primitives/enums/EnumI.H index d6e547c4bf1dc60ded8eb26fd47ceb2dbf56b0ca..35937fa61385c150010519dfc7a05b84b3ff4365 100644 --- a/src/OpenFOAM/primitives/enums/EnumI.H +++ b/src/OpenFOAM/primitives/enums/EnumI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,56 +28,70 @@ License template<class EnumType> inline Foam::label Foam::Enum<EnumType>::size() const { - return names_.size(); + return keys_.size(); } template<class EnumType> inline const Foam::wordList& Foam::Enum<EnumType>::names() const { - return names_; + return keys_; } template<class EnumType> inline const Foam::wordList& Foam::Enum<EnumType>::toc() const { - return names_; + return keys_; } template<class EnumType> inline const Foam::List<int>& Foam::Enum<EnumType>::values() const { - return values_; + return vals_; } template<class EnumType> -inline bool Foam::Enum<EnumType>::found(const word& enumName) const +inline Foam::label Foam::Enum<EnumType>::find(const word& enumName) const { - return getIndex(enumName) >= 0; + return keys_.find(enumName); } template<class EnumType> -inline bool Foam::Enum<EnumType>::found(const EnumType e) const +inline Foam::label Foam::Enum<EnumType>::find(const EnumType e) const +{ + return vals_.find(int(e)); +} + + +template<class EnumType> +inline bool Foam::Enum<EnumType>::found(const word& enumName) const { - return getIndex(e) >= 0; + return keys_.found(enumName); } template<class EnumType> -inline bool Foam::Enum<EnumType>::hasEnum(const word& enumName) const +inline bool Foam::Enum<EnumType>::found(const EnumType e) const { - return getIndex(enumName) >= 0; + return vals_.found(int(e)); } template<class EnumType> -inline bool Foam::Enum<EnumType>::hasName(const EnumType e) const +inline const Foam::word& Foam::Enum<EnumType>::get(const EnumType e) const { - return getIndex(e) >= 0; + const label idx = find(e); + + if (idx < 0) + { + return word::null; + } + + return keys_[idx]; } @@ -85,10 +99,22 @@ template<class EnumType> inline Foam::Ostream& Foam::Enum<EnumType>::writeList ( Ostream& os, - const label shortListLen + const label shortLen ) const { - return names_.writeList(os, shortListLen); + return keys_.writeList(os, shortLen); +} + + +template<class EnumType> +inline void Foam::Enum<EnumType>::write(const EnumType e, Ostream& os) const +{ + const label idx = find(e); + + if (idx >= 0) + { + os << keys_[idx]; + } } @@ -100,7 +126,7 @@ inline EnumType Foam::Enum<EnumType>::operator[] const word& enumName ) const { - return getEnum(enumName); + return get(enumName); } @@ -110,7 +136,7 @@ inline const Foam::word& Foam::Enum<EnumType>::operator[] const EnumType e ) const { - return getName(e); + return get(e); } @@ -118,17 +144,26 @@ template<class EnumType> inline EnumType Foam::Enum<EnumType>::operator() ( const word& enumName, - const EnumType deflt + const EnumType defaultValue ) const { - const label idx = getIndex(enumName); + const label idx = find(enumName); if (idx >= 0) { - return EnumType(values_[idx]); + return EnumType(vals_[idx]); } - return deflt; + return defaultValue; +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template<class EnumType> +inline Foam::Ostream& Foam::operator<<(Ostream& os, const Enum<EnumType>& list) +{ + return list.names().writeList(os, 0); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C index c068e240c275d97df2c6d436c59da8701bdcd8be..cf21e6ecc0836618e9aceadf6be07cb307def8bb 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C +++ b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C @@ -66,11 +66,12 @@ Foam::Function1Types::TableBase<Type>::TableBase name_(name), bounding_ ( - bounds::repeatableBoundingNames.lookupOrFailsafe + bounds::repeatableBoundingNames.lookupOrDefault ( "outOfBounds", dict, - bounds::repeatableBounding::CLAMP + bounds::repeatableBounding::CLAMP, + true // Failsafe behaviour ) ), interpolationScheme_ diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C index e0834f3b58a52c2927a0dd007b41b2b70daf2636..cdc526810f6bd3ed875e9bde5b47831fccdc4491 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C @@ -38,11 +38,11 @@ const Foam::Enum Foam::externalWallHeatFluxTemperatureFvPatchScalarField::operationMode > Foam::externalWallHeatFluxTemperatureFvPatchScalarField::operationModeNames -{ +({ { operationMode::fixedPower, "power" }, { operationMode::fixedHeatFlux, "flux" }, { operationMode::fixedHeatTransferCoeff, "coefficient" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -84,7 +84,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField : mixedFvPatchScalarField(p, iF), temperatureCoupledBase(patch(), dict), - mode_(operationModeNames.lookup("mode", dict)), + mode_(operationModeNames.get("mode", dict)), Q_(0), q_(), h_(), diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C index eade488e867861f50af1137ba2e4dea85bdff669..9f38a60eb4009bf4c0442a8dc2f0d518b98b71dd 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C @@ -36,12 +36,12 @@ const Foam::Enum Foam::temperatureCoupledBase::KMethodType > Foam::temperatureCoupledBase::KMethodTypeNames_ -{ +({ { KMethodType::mtFluidThermo, "fluidThermo" }, { KMethodType::mtSolidThermo, "solidThermo" }, { KMethodType::mtDirectionalSolidThermo, "directionalSolidThermo" }, { KMethodType::mtLookup, "lookup" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -68,7 +68,7 @@ Foam::temperatureCoupledBase::temperatureCoupledBase ) : patch_(patch), - method_(KMethodTypeNames_.lookup("kappaMethod", dict)), + method_(KMethodTypeNames_.get("kappaMethod", dict)), kappaName_(dict.lookupOrDefault<word>("kappa", "none")), alphaAniName_(dict.lookupOrDefault<word>("alphaAni","none")) { diff --git a/src/combustionModels/EDC/EDCs.C b/src/combustionModels/EDC/EDCs.C index 62ad797cb55fd3e95ecfe488a552a5f01837a2c3..3e1cd5d510f77bd2d1676c1ab8de4d640f4af573 100644 --- a/src/combustionModels/EDC/EDCs.C +++ b/src/combustionModels/EDC/EDCs.C @@ -36,12 +36,12 @@ const Foam::Enum Foam::combustionModels::EDCversions > Foam::combustionModels::EDCversionNames -{ +({ { EDCversions::v1981, "v1981" }, { EDCversions::v1996, "v1996" }, { EDCversions::v2005, "v2005" }, { EDCversions::v2016, "v2016" }, -}; +}); const Foam::combustionModels::EDCversions Foam::combustionModels::EDCdefaultVersion(EDCversions::v2005); diff --git a/src/dynamicMesh/meshCut/directions/directions.C b/src/dynamicMesh/meshCut/directions/directions.C index b6a4db66e53ca4f3cf9dfe55510baea520ec86a0..6846e30c4ea70877e602c99ecd86266e7d18508f 100644 --- a/src/dynamicMesh/meshCut/directions/directions.C +++ b/src/dynamicMesh/meshCut/directions/directions.C @@ -40,11 +40,11 @@ const Foam::Enum Foam::directions::directionType > Foam::directions::directionTypeNames_ -{ +({ { directionType::TAN1, "tan1" }, { directionType::TAN2, "tan2" }, { directionType::NORMAL, "normal" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C index dde8008349d9d988b133232cee4c2be7408c089f..17f0c3d1e60f7d1c9a1b06f6fe19af34053b8a5a 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C @@ -45,11 +45,11 @@ const Foam::Enum Foam::tetDecomposer::decompositionType > Foam::tetDecomposer::decompositionTypeNames -{ +({ { decompositionType::FACE_CENTRE_TRIS, "faceCentre" }, { decompositionType::FACE_DIAG_TRIS, "faceDiagonal" }, { decompositionType::PYRAMID, "pyramid" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/dynamicMesh/slidingInterface/slidingInterface.C b/src/dynamicMesh/slidingInterface/slidingInterface.C index 400ce29ec00e74054a1dae23bbea50771a5b622e..0a6b9635510363fe8fb48f62a1952c5a1a4f7c0a 100644 --- a/src/dynamicMesh/slidingInterface/slidingInterface.C +++ b/src/dynamicMesh/slidingInterface/slidingInterface.C @@ -53,10 +53,10 @@ const Foam::Enum Foam::slidingInterface::typeOfMatch > Foam::slidingInterface::typeOfMatchNames -{ +({ { typeOfMatch::INTEGRAL, "integral" }, { typeOfMatch::PARTIAL, "partial" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -241,12 +241,12 @@ Foam::slidingInterface::slidingInterface dict.lookup("slavePatchName"), mme.mesh().boundaryMesh() ), - matchType_(typeOfMatchNames.lookup("typeOfMatch", dict)), + matchType_(typeOfMatchNames.get("typeOfMatch", dict)), coupleDecouple_(dict.lookup("coupleDecouple")), attached_(dict.lookup("attached")), projectionAlgo_ ( - intersection::algorithmNames_.read(dict.lookup("projection")) + intersection::algorithmNames_.get("projection", dict) ), trigger_(false), cutFaceMasterPtr_(nullptr), diff --git a/src/fileFormats/coordSet/coordSet.C b/src/fileFormats/coordSet/coordSet.C index e1ed73bc6add59a695dbf24b3b536dc5bf4c16ad..1ec1173aebf478baccaff8f89d5959619cc2ead8 100644 --- a/src/fileFormats/coordSet/coordSet.C +++ b/src/fileFormats/coordSet/coordSet.C @@ -32,13 +32,13 @@ const Foam::Enum Foam::coordSet::coordFormat > Foam::coordSet::coordFormatNames -{ +({ { coordFormat::XYZ, "xyz" }, { coordFormat::X, "x" }, { coordFormat::Y, "y" }, { coordFormat::Z, "z" }, - { coordFormat::DISTANCE, "distance" } -}; + { coordFormat::DISTANCE, "distance" }, +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/fileFormats/fire/FIRECore.C b/src/fileFormats/fire/FIRECore.C index 02ebc4c3ff03a893da11e190b73f7de2e5267745..a8713e8be7edde96f72a1da5ca7fa456513ea866 100644 --- a/src/fileFormats/fire/FIRECore.C +++ b/src/fileFormats/fire/FIRECore.C @@ -32,12 +32,12 @@ const Foam::Enum Foam::fileFormats::FIRECore::fileExt3d > Foam::fileFormats::FIRECore::file3dExtensions -{ +({ { fileExt3d::POLY_ASCII, "fpma" }, { fileExt3d::POLY_BINARY, "fpmb" }, { fileExt3d::POLY_ASCII_Z, "fpmaz" }, - { fileExt3d::POLY_BINARY_Z, "fpmbz" } -}; + { fileExt3d::POLY_BINARY_Z, "fpmbz" }, +}); // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // diff --git a/src/fileFormats/nas/NASCore.C b/src/fileFormats/nas/NASCore.C index 59fc99cb51eb3fa4d2b2ff7c95b3663ab1be0a6f..610306c17b38c046dec2743f4bba7bdfa8272e05 100644 --- a/src/fileFormats/nas/NASCore.C +++ b/src/fileFormats/nas/NASCore.C @@ -35,11 +35,11 @@ const Foam::Enum Foam::fileFormats::NASCore::fieldFormat > Foam::fileFormats::NASCore::fieldFormatNames -{ +({ { fieldFormat::SHORT, "short" }, { fieldFormat::LONG, "long" }, { fieldFormat::FREE, "free" }, -}; +}); // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // diff --git a/src/fileFormats/starcd/STARCDCore.C b/src/fileFormats/starcd/STARCDCore.C index c98849dd75d980700d1ba1dfaaeae147dea11a8b..769b58676061d35dc3e4a06eb3d29edd45af3b1e 100644 --- a/src/fileFormats/starcd/STARCDCore.C +++ b/src/fileFormats/starcd/STARCDCore.C @@ -39,11 +39,11 @@ const Foam::Enum Foam::fileFormats::STARCDCore::fileHeader > Foam::fileFormats::STARCDCore::fileHeaders_ -{ +({ { fileHeader::HEADER_CEL, "PROSTAR_CELL" }, { fileHeader::HEADER_VRT, "PROSTAR_VERTEX" }, - { fileHeader::HEADER_BND, "PROSTAR_BOUNDARY" } -}; + { fileHeader::HEADER_BND, "PROSTAR_BOUNDARY" }, +}); const Foam::Enum @@ -51,12 +51,12 @@ const Foam::Enum Foam::fileFormats::STARCDCore::fileExt > Foam::fileFormats::STARCDCore::fileExtensions_ -{ +({ { fileExt::CEL_FILE, "cel" }, { fileExt::VRT_FILE, "vrt" }, { fileExt::BND_FILE, "bnd" }, - { fileExt::INP_FILE, "inp" } -}; + { fileExt::INP_FILE, "inp" }, +}); const char* const Foam::fileFormats::STARCDCore::defaultBoundaryName = diff --git a/src/fileFormats/vtk/core/foamVtkCore.C b/src/fileFormats/vtk/core/foamVtkCore.C index 6b8ab91b9306fc00b6e40967692fa9ebc0cb872b..7a61ccb0345d2744588811d211e5ac534935a49b 100644 --- a/src/fileFormats/vtk/core/foamVtkCore.C +++ b/src/fileFormats/vtk/core/foamVtkCore.C @@ -32,7 +32,7 @@ const Foam::Enum Foam::vtk::fileTag > Foam::vtk::fileTagNames -{ +({ { fileTag::VTK_FILE, "VTKFile" }, { fileTag::DATA_ARRAY, "DataArray" }, { fileTag::PIECE, "Piece" }, @@ -47,7 +47,7 @@ Foam::vtk::fileTagNames { fileTag::POLY_DATA, "PolyData" }, { fileTag::UNSTRUCTURED_GRID, "UnstructuredGrid" }, { fileTag::MULTI_BLOCK, "vtkMultiBlockDataSet" }, -}; +}); const Foam::Enum @@ -55,7 +55,7 @@ const Foam::Enum Foam::vtk::fileAttr > Foam::vtk::fileAttrNames -{ +({ { fileAttr::OFFSET, "offset" }, { fileAttr::NUMBER_OF_COMPONENTS, "NumberOfComponents" }, { fileAttr::NUMBER_OF_POINTS, "NumberOfPoints" }, @@ -63,7 +63,7 @@ Foam::vtk::fileAttrNames { fileAttr::NUMBER_OF_POLYS, "NumberOfPolys" }, { fileAttr::NUMBER_OF_VERTS, "NumberOfVerts" }, { fileAttr::NUMBER_OF_LINES, "NumberOfLines" }, -}; +}); const Foam::Enum @@ -71,14 +71,14 @@ const Foam::Enum Foam::vtk::dataArrayAttr > Foam::vtk::dataArrayAttrNames -{ +({ { dataArrayAttr::POINTS, "Points" }, { dataArrayAttr::OFFSETS, "offsets" }, { dataArrayAttr::CONNECTIVITY, "connectivity" }, { dataArrayAttr::TYPES, "types" }, { dataArrayAttr::FACES, "faces" }, { dataArrayAttr::FACEOFFSETS, "faceoffsets" }, -}; +}); // ************************************************************************* // diff --git a/src/fileFormats/vtk/output/foamVtkOutput.C b/src/fileFormats/vtk/output/foamVtkOutput.C index 2ee7dbd7a57d95061cd1b267e7227d0caa6e4a39..589537fd286b0cca87398a032492cf4c2494eb5c 100644 --- a/src/fileFormats/vtk/output/foamVtkOutput.C +++ b/src/fileFormats/vtk/output/foamVtkOutput.C @@ -42,10 +42,10 @@ const Foam::Enum Foam::vtk::fileTag > Foam::vtk::legacy::contentNames -{ +({ { vtk::fileTag::POLY_DATA, "POLYDATA" }, { vtk::fileTag::UNSTRUCTURED_GRID, "UNSTRUCTURED_GRID" }, -}; +}); const Foam::Enum @@ -53,10 +53,10 @@ const Foam::Enum Foam::vtk::fileTag > Foam::vtk::legacy::dataTypeNames -{ +({ { vtk::fileTag::CELL_DATA, "CELL_DATA" }, { vtk::fileTag::POINT_DATA, "POINT_DATA" } -}; +}); // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // diff --git a/src/fileFormats/vtk/read/vtkUnstructuredReader.C b/src/fileFormats/vtk/read/vtkUnstructuredReader.C index a79283fb8e38711785333134473f0bec387e1a9e..4bf27446327ef875387777328050aab05c5d4df4 100644 --- a/src/fileFormats/vtk/read/vtkUnstructuredReader.C +++ b/src/fileFormats/vtk/read/vtkUnstructuredReader.C @@ -43,7 +43,7 @@ const Foam::Enum Foam::vtkUnstructuredReader::vtkDataType > Foam::vtkUnstructuredReader::vtkDataTypeNames -{ +({ { vtkDataType::VTK_INT, "int" }, { vtkDataType::VTK_UINT, "unsigned_int" }, { vtkDataType::VTK_LONG, "long" }, @@ -51,8 +51,8 @@ Foam::vtkUnstructuredReader::vtkDataTypeNames { vtkDataType::VTK_FLOAT, "float" }, { vtkDataType::VTK_DOUBLE, "double" }, { vtkDataType::VTK_STRING, "string" }, - { vtkDataType::VTK_ID, "vtkIdType" } -}; + { vtkDataType::VTK_ID, "vtkIdType" }, +}); const Foam::Enum @@ -60,11 +60,11 @@ const Foam::Enum Foam::vtkUnstructuredReader::vtkDataSetType > Foam::vtkUnstructuredReader::vtkDataSetTypeNames -{ +({ { vtkDataSetType::VTK_FIELD, "FIELD" }, { vtkDataSetType::VTK_SCALARS, "SCALARS" }, - { vtkDataSetType::VTK_VECTORS, "VECTORS" } -}; + { vtkDataSetType::VTK_VECTORS, "VECTORS" }, +}); const Foam::Enum @@ -72,13 +72,13 @@ const Foam::Enum Foam::vtkUnstructuredReader::parseMode > Foam::vtkUnstructuredReader::parseModeNames -{ +({ { parseMode::NOMODE, "NOMODE" }, { parseMode::UNSTRUCTURED_GRID, "UNSTRUCTURED_GRID" }, { parseMode::POLYDATA, "POLYDATA" }, { parseMode::CELL_DATA, "CELL_DATA" }, - { parseMode::POINT_DATA, "POINT_DATA" } -}; + { parseMode::POINT_DATA, "POINT_DATA" }, +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C index 15fc6dcaec75e8f3a2627db98a3e466eecb6d131..227533bf23e8f3b9fa326b0cf0681b7852f11360 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C @@ -35,10 +35,10 @@ const Foam::Enum Foam::fanPressureFvPatchScalarField::fanFlowDirection > Foam::fanPressureFvPatchScalarField::fanFlowDirectionNames_ -{ +({ { fanFlowDirection::ffdIn, "in" }, { fanFlowDirection::ffdOut, "out" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -84,7 +84,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField : totalPressureFvPatchScalarField(p, iF, dict), fanCurve_(dict), - direction_(fanFlowDirectionNames_.lookup("direction", dict)), + direction_(fanFlowDirectionNames_.get("direction", dict)), nonDimensional_(dict.lookupOrDefault<Switch>("nonDimensional", false)), rpm_(dict.lookupOrDefault<scalar>("rpm", 0.0)), dm_(dict.lookupOrDefault<scalar>("dm", 0.0)) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C index 65985dab41cba7d5905ddb9badef507e8419fcfb..d032b31af80637ee4a1378f1c3f78889040a2f8e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C @@ -40,7 +40,7 @@ const Foam::Enum Foam::waveSurfacePressureFvPatchScalarField::ddtSchemeType > Foam::waveSurfacePressureFvPatchScalarField::ddtSchemeTypeNames_ -{ +({ { ddtSchemeType::tsEuler, fv::EulerDdtScheme<scalar>::typeName_() @@ -53,7 +53,7 @@ Foam::waveSurfacePressureFvPatchScalarField::ddtSchemeTypeNames_ ddtSchemeType::tsBackward, fv::backwardDdtScheme<scalar>::typeName_() }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/functionObjects/volRegion/volRegion.C b/src/finiteVolume/functionObjects/volRegion/volRegion.C index 5071085ec80edc1a872c48539f3b96b1537f6872..1f4779afebd605ed4f2bac46f1d72722fb36814c 100644 --- a/src/finiteVolume/functionObjects/volRegion/volRegion.C +++ b/src/finiteVolume/functionObjects/volRegion/volRegion.C @@ -43,10 +43,10 @@ const Foam::Enum Foam::functionObjects::volRegion::regionTypes > Foam::functionObjects::volRegion::regionTypeNames_ -{ +({ { regionTypes::vrtCellZone, "cellZone" }, { regionTypes::vrtAll, "all" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C index 134a49ef364eae9a2c80da6d604e582f221d6913..aecb0973d5e7f0bbc5da30b0d86206c171683d72 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C @@ -44,10 +44,10 @@ const Foam::Enum Foam::functionObjects::fieldAverageItem::baseType > Foam::functionObjects::fieldAverageItem::baseTypeNames_ -{ +({ { baseType::ITER, "iteration" }, { baseType::TIME, "time" }, -}; +}); const Foam::Enum @@ -55,11 +55,11 @@ const Foam::Enum Foam::functionObjects::fieldAverageItem::windowType > Foam::functionObjects::fieldAverageItem::windowTypeNames_ -{ +({ { windowType::NONE, "none" }, { windowType::APPROXIMATE, "approximate" }, { windowType::EXACT, "exact" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C index 80d11c3fdbd733e0eb92f1e2345692069f24a8db..03677d232d58a9a311808f890598f5786a5d84c0 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C @@ -69,13 +69,12 @@ Foam::Istream& Foam::functionObjects::operator>> faItem.fieldName_ = dictEntry.keyword(); faItem.mean_ = dict.get<bool>("mean"); faItem.prime2Mean_ = dict.get<bool>("prime2Mean"); - faItem.base_ = faItem.baseTypeNames_.lookup("base", dict); + faItem.base_ = faItem.baseTypeNames_.get("base", dict); faItem.window_ = dict.lookupOrDefault<scalar>("window", -1.0); if (faItem.window_ > 0) { - faItem.windowType_ = - faItem.windowTypeNames_.lookup("windowType", dict); + faItem.windowType_ = faItem.windowTypeNames_.get("windowType", dict); if (faItem.windowType_ != fieldAverageItem::windowType::NONE) { diff --git a/src/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/functionObjects/field/fieldMinMax/fieldMinMax.C index ff81147a1d6ebb44d7482b5ad10b9c4bdc31d444..e217e58b7f8e8cf442f12ddbc05ddfa08c449a6f 100644 --- a/src/functionObjects/field/fieldMinMax/fieldMinMax.C +++ b/src/functionObjects/field/fieldMinMax/fieldMinMax.C @@ -43,10 +43,10 @@ const Foam::Enum Foam::functionObjects::fieldMinMax::modeType > Foam::functionObjects::fieldMinMax::modeTypeNames_ -{ +({ { modeType::mdMag, "magnitude" }, { modeType::mdCmpt, "component" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // diff --git a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C index 21c2cc459c9a24832e9f3551a56a4ae30274c1f6..6768d069bb13859e8967651355164b81aa6f4403 100644 --- a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C +++ b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C @@ -46,13 +46,13 @@ const Foam::Enum Foam::functionObjects::fieldValues::fieldValueDelta::operationType > Foam::functionObjects::fieldValues::fieldValueDelta::operationTypeNames_ -{ +({ { operationType::opAdd, "add" }, { operationType::opSubtract, "subtract" }, { operationType::opMin, "min" }, { operationType::opMax, "max" }, { operationType::opAverage, "average" }, -}; +}); // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // @@ -146,7 +146,7 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::read ).ptr() ); - operation_ = operationTypeNames_.lookup("operation", dict); + operation_ = operationTypeNames_.get("operation", dict); return true; } diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index 4da57d8516b2b7e61f83b92aa077bdedc554055b..a398e7204caeb2232ed44f6fd4f0b635804430a3 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -55,12 +55,12 @@ const Foam::Enum Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes > Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypeNames_ -{ +({ { regionTypes::stFaceZone, "faceZone" }, { regionTypes::stPatch, "patch" }, { regionTypes::stSurface, "surface" }, { regionTypes::stSampledSurface, "sampledSurface" }, -}; +}); const Foam::Enum @@ -68,7 +68,7 @@ const Foam::Enum Foam::functionObjects::fieldValues::surfaceFieldValue::operationType > Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_ -{ +({ // Normal operations { operationType::opNone, "none" }, { operationType::opMin, "min" }, @@ -98,17 +98,17 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_ { operationType::opAbsWeightedAreaAverage, "absWeightedAreaAverage" }, { operationType::opAbsWeightedAreaIntegrate, "absWeightedAreaIntegrate" }, { operationType::opAbsWeightedUniformity, "absWeightedUniformity" }, -}; +}); const Foam::Enum < Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationType > Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationTypeNames_ -{ +({ { postOperationType::postOpNone, "none" }, { postOperationType::postOpSqrt, "sqrt" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -901,15 +901,16 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue ) : fieldValue(name, runTime, dict, typeName), - regionType_(regionTypeNames_.lookup("regionType", dict)), - operation_(operationTypeNames_.lookup("operation", dict)), + regionType_(regionTypeNames_.get("regionType", dict)), + operation_(operationTypeNames_.get("operation", dict)), postOperation_ ( postOperationTypeNames_.lookupOrDefault ( "postOperation", dict, - postOperationType::postOpNone + postOperationType::postOpNone, + true // Failsafe behaviour ) ), weightFieldName_("none"), @@ -932,15 +933,16 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue ) : fieldValue(name, obr, dict, typeName), - regionType_(regionTypeNames_.lookup("regionType", dict)), - operation_(operationTypeNames_.lookup("operation", dict)), + regionType_(regionTypeNames_.get("regionType", dict)), + operation_(operationTypeNames_.get("operation", dict)), postOperation_ ( postOperationTypeNames_.lookupOrDefault ( "postOperation", dict, - postOperationType::postOpNone + postOperationType::postOpNone, + true // Failsafe behaviour ) ), weightFieldName_("none"), diff --git a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C index fb72fcadee1eaddda207d7db780ce97e7b21c017..9a356559dba54f8a2051dc9629613c0745ffaa59 100644 --- a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C +++ b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C @@ -48,7 +48,7 @@ const Foam::Enum Foam::functionObjects::fieldValues::volFieldValue::operationType > Foam::functionObjects::fieldValues::volFieldValue::operationTypeNames_ -{ +({ // Normal operations { operationType::opNone, "none" }, { operationType::opMin, "min" }, @@ -65,7 +65,7 @@ Foam::functionObjects::fieldValues::volFieldValue::operationTypeNames_ { operationType::opWeightedAverage, "weightedAverage" }, { operationType::opWeightedVolAverage, "weightedVolAverage" }, { operationType::opWeightedVolIntegrate, "weightedVolIntegrate" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -205,7 +205,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue : fieldValue(name, runTime, dict, typeName), volRegion(fieldValue::mesh_, dict), - operation_(operationTypeNames_.lookup("operation", dict)), + operation_(operationTypeNames_.get("operation", dict)), weightFieldName_("none") { read(dict); @@ -222,7 +222,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue : fieldValue(name, obr, dict, typeName), volRegion(fieldValue::mesh_, dict), - operation_(operationTypeNames_.lookup("operation", dict)), + operation_(operationTypeNames_.get("operation", dict)), weightFieldName_("none") { read(dict); diff --git a/src/functionObjects/field/fluxSummary/fluxSummary.C b/src/functionObjects/field/fluxSummary/fluxSummary.C index a001f9b2b7f920ff06e6af9ce05f34462579d905..9de8b634dddf3ce504363aa17df0657df8fbffd6 100644 --- a/src/functionObjects/field/fluxSummary/fluxSummary.C +++ b/src/functionObjects/field/fluxSummary/fluxSummary.C @@ -59,13 +59,13 @@ const Foam::Enum Foam::functionObjects::fluxSummary::modeType > Foam::functionObjects::fluxSummary::modeTypeNames_ -{ +({ { modeType::mdFaceZone , "faceZone" }, { modeType::mdFaceZoneAndDirection, "faceZoneAndDirection" }, { modeType::mdCellZoneAndDirection, "cellZoneAndDirection" }, { modeType::mdSurface, "surface" }, { modeType::mdSurfaceAndDirection, "surfaceAndDirection" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -817,7 +817,7 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict) fvMeshFunctionObject::read(dict); writeFile::read(dict); - mode_ = modeTypeNames_.lookup("mode", dict); + mode_ = modeTypeNames_.get("mode", dict); phiName_ = dict.lookupOrDefault<word>("phi", "phi"); scaleFactor_ = dict.lookupOrDefault<scalar>("scaleFactor", 1.0); tolerance_ = dict.lookupOrDefault<scalar>("tolerance", 0.8); diff --git a/src/functionObjects/field/setFlow/setFlow.C b/src/functionObjects/field/setFlow/setFlow.C index 2f89e687f602caa98ebbcd5ac1f8f4c44d040d16..c294d216fb9e86e606d8044c9e3bf9b6a329c119 100644 --- a/src/functionObjects/field/setFlow/setFlow.C +++ b/src/functionObjects/field/setFlow/setFlow.C @@ -53,12 +53,12 @@ const Foam::Enum Foam::functionObjects::setFlow::modeType > Foam::functionObjects::setFlow::modeTypeNames -{ +({ { functionObjects::setFlow::modeType::FUNCTION, "function" }, { functionObjects::setFlow::modeType::ROTATION, "rotation" }, { functionObjects::setFlow::modeType::VORTEX2D, "vortex2D" }, - { functionObjects::setFlow::modeType::VORTEX3D, "vortex3D" } -}; + { functionObjects::setFlow::modeType::VORTEX3D, "vortex3D" }, +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -137,7 +137,8 @@ bool Foam::functionObjects::setFlow::read(const dictionary& dict) if (fvMeshFunctionObject::read(dict)) { Info<< name() << ":" << endl; - mode_ = modeTypeNames.lookup("mode", dict); + + modeTypeNames.readEntry("mode", dict, mode_); Info<< " operating mode: " << modeTypeNames[mode_] << endl; diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFields.C b/src/functionObjects/field/turbulenceFields/turbulenceFields.C index 3a257d5da6c8cecf0711f1859105b09c3f2fb706..b06c98315ec250a68ad299f9377b110bddde4b43 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFields.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFields.C @@ -50,7 +50,7 @@ const Foam::Enum Foam::functionObjects::turbulenceFields::compressibleField > Foam::functionObjects::turbulenceFields::compressibleFieldNames_ -{ +({ { compressibleField::cfK, "k" }, { compressibleField::cfEpsilon, "epsilon" }, { compressibleField::cfOmega, "omega" }, @@ -62,8 +62,8 @@ Foam::functionObjects::turbulenceFields::compressibleFieldNames_ { compressibleField::cfR, "R" }, { compressibleField::cfDevRhoReff, "devRhoReff" }, { compressibleField::cfL, "L" }, - { compressibleField::cfI, "I" } -}; + { compressibleField::cfI, "I" }, +}); const Foam::Enum @@ -71,7 +71,7 @@ const Foam::Enum Foam::functionObjects::turbulenceFields::incompressibleField > Foam::functionObjects::turbulenceFields::incompressibleFieldNames_ -{ +({ { incompressibleField::ifK, "k" }, { incompressibleField::ifEpsilon, "epsilon" }, { incompressibleField::ifOmega, "omega" }, @@ -81,8 +81,8 @@ Foam::functionObjects::turbulenceFields::incompressibleFieldNames_ { incompressibleField::ifR, "R" }, { incompressibleField::ifDevReff, "devReff" }, { incompressibleField::ifL, "L" }, - { incompressibleField::ifI, "I" } -}; + { incompressibleField::ifI, "I" }, +}); const Foam::word Foam::functionObjects::turbulenceFields::modelName diff --git a/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C b/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C index a7e6ba9db302c296a4972cf8c51c73a9b33617ed..1a804abc4e5ae8904f73d95809e72582604e5008 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C +++ b/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C @@ -52,22 +52,22 @@ const Foam::Enum Foam::functionObjects::fieldVisualisationBase::colourByType > Foam::functionObjects::fieldVisualisationBase::colourByTypeNames -{ +({ { colourByType::cbColour, "colour" }, { colourByType::cbField, "field" }, -}; +}); const Foam::Enum < Foam::functionObjects::fieldVisualisationBase::colourMapType > Foam::functionObjects::fieldVisualisationBase::colourMapTypeNames -{ +({ { colourMapType::cmRainbow, "rainbow" }, { colourMapType::cmBlueWhiteRed, "blueWhiteRed" }, { colourMapType::cmFire, "fire" }, { colourMapType::cmGreyscale, "greyscale" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -489,7 +489,7 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase colourMap_(cmRainbow), range_() { - colourBy_ = colourByTypeNames.lookup("colourBy", dict); + colourByTypeNames.readEntry("colourBy", dict, colourBy_); switch (colourBy_) { @@ -502,10 +502,7 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase { dict.readEntry("range", range_); - if (dict.found("colourMap")) - { - colourMap_ = colourMapTypeNames.lookup("colourMap", dict); - } + colourMapTypeNames.readIfPresent("colourMap", dict, colourMap_); const dictionary& sbarDict = dict.subDict("scalarBar"); sbarDict.readEntry("visible", scalarBar_.visible_); diff --git a/src/functionObjects/graphics/runTimePostProcessing/geometryBase.C b/src/functionObjects/graphics/runTimePostProcessing/geometryBase.C index 2be283ba58a09800705a66649b13cd3e60fc0366..7edb7f1748dec9db3978ac84ad6b597a81713566 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/geometryBase.C +++ b/src/functionObjects/graphics/runTimePostProcessing/geometryBase.C @@ -37,11 +37,11 @@ const Foam::Enum Foam::functionObjects::runTimePostPro::geometryBase::renderModeType > Foam::functionObjects::runTimePostPro::geometryBase::renderModeTypeNames -{ +({ { renderModeType::rmFlat, "flat" }, { renderModeType::rmGouraud, "gouraud" }, { renderModeType::rmPhong, "phong" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -87,15 +87,13 @@ Foam::functionObjects::runTimePostPro::geometryBase::geometryBase parent_(parent), name_(dict.dictName()), visible_(dict.get<bool>("visible")), - renderMode_(rmGouraud), + renderMode_ + ( + renderModeTypeNames.lookupOrDefault("renderMode", dict, rmGouraud) + ), opacity_(nullptr), colours_(colours) { - if (dict.found("renderMode")) - { - renderMode_ = renderModeTypeNames.lookup("renderMode", dict); - } - if (dict.found("opacity")) { opacity_.reset(Function1<scalar>::New("opacity", dict).ptr()); diff --git a/src/functionObjects/graphics/runTimePostProcessing/pathline.C b/src/functionObjects/graphics/runTimePostProcessing/pathline.C index 8f59b9d8879b99542af24549af47aca4390f0523..f85cbd8a2aa52d7ebd1b6fddd000468d2c1433bd 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/pathline.C +++ b/src/functionObjects/graphics/runTimePostProcessing/pathline.C @@ -55,12 +55,12 @@ const Foam::Enum Foam::functionObjects::runTimePostPro::pathline::representationType > Foam::functionObjects::runTimePostPro::pathline::representationTypeNames -{ +({ { representationType::rtNone, "none" }, { representationType::rtLine, "line" }, { representationType::rtTube, "tube" }, { representationType::rtVector, "vector" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -129,7 +129,7 @@ Foam::functionObjects::runTimePostPro::pathline::pathline geometryBase(parent, dict, colours), representation_ ( - representationTypeNames.lookup("representation", dict) + representationTypeNames.get("representation", dict) ), tubeRadius_(0.0), lineColour_(nullptr) diff --git a/src/functionObjects/graphics/runTimePostProcessing/pointData.C b/src/functionObjects/graphics/runTimePostProcessing/pointData.C index 58bafbdd026e58735dbb82f46f890e956aa48f3c..ce4e9bd69245cf260f8807c1666ec147bff262b7 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/pointData.C +++ b/src/functionObjects/graphics/runTimePostProcessing/pointData.C @@ -55,10 +55,10 @@ const Foam::Enum Foam::functionObjects::runTimePostPro::pointData::representationType > Foam::functionObjects::runTimePostPro::pointData::representationTypeNames -{ +({ { representationType::rtSphere, "sphere" }, { representationType::rtVector, "vector" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -99,7 +99,7 @@ Foam::functionObjects::runTimePostPro::pointData::pointData geometryBase(parent, dict, colours), representation_ ( - representationTypeNames.lookup("representation", dict) + representationTypeNames.get("representation", dict) ), maxGlyphLength_(dict.get<scalar>("maxGlyphLength")), pointColour_(nullptr) diff --git a/src/functionObjects/graphics/runTimePostProcessing/surface.C b/src/functionObjects/graphics/runTimePostProcessing/surface.C index f2d075df92c7c08cdbf00a3d98bd1261a9b2594e..8449b5f327a9c1c570807b132eef7b775d0de9f4 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/surface.C +++ b/src/functionObjects/graphics/runTimePostProcessing/surface.C @@ -56,13 +56,13 @@ const Foam::Enum Foam::functionObjects::runTimePostPro::surface::representationType > Foam::functionObjects::runTimePostPro::surface::representationTypeNames -{ +({ { representationType::rtNone, "none" }, { representationType::rtWireframe, "wireframe" }, { representationType::rtSurface, "surface" }, { representationType::rtSurfaceWithEdges, "surfaceWithEdges" }, { representationType::rtGlyph, "glyph" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -149,7 +149,7 @@ Foam::functionObjects::runTimePostPro::surface::surface geometryBase(parent, dict, colours), representation_ ( - representationTypeNames.lookup("representation", dict) + representationTypeNames.get("representation", dict) ), featureEdges_(false), surfaceColour_(nullptr), diff --git a/src/functionObjects/utilities/ensightWrite/ensightWrite.C b/src/functionObjects/utilities/ensightWrite/ensightWrite.C index 710bee74fe98f550f3eeb2d7dc51956e00aec1d2..06bbd0307d6a57a5d5095a0b696fe38a178273e4 100644 --- a/src/functionObjects/utilities/ensightWrite/ensightWrite.C +++ b/src/functionObjects/utilities/ensightWrite/ensightWrite.C @@ -106,11 +106,12 @@ Foam::functionObjects::ensightWrite::ensightWrite fvMeshFunctionObject(name, runTime, dict), writeOpts_ ( - IOstreamOption::formatNames.lookupOrFailsafe + IOstreamOption::formatNames.lookupOrDefault ( "format", dict, - runTime.writeFormat() + runTime.writeFormat(), + true // Failsafe behaviour ) ), caseOpts_(writeOpts_.format()), diff --git a/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationInitialResidualCondition/equationInitialResidualCondition.C b/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationInitialResidualCondition/equationInitialResidualCondition.C index 1f77eb09d81d938ea02120f63d1c79b777f86dbc..ac86c8313ed87e4b4f5dbc7f143e51f4c79b045c 100644 --- a/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationInitialResidualCondition/equationInitialResidualCondition.C +++ b/src/functionObjects/utilities/runTimeControl/runTimeCondition/equationInitialResidualCondition/equationInitialResidualCondition.C @@ -58,10 +58,10 @@ const Foam::Enum > Foam::functionObjects::runTimeControls::equationInitialResidualCondition:: operatingModeNames -{ +({ { operatingMode::omMin, "minimum" }, { operatingMode::omMax, "maximum" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -79,7 +79,7 @@ equationInitialResidualCondition fieldNames_(dict.get<wordList>("fields")), value_(dict.get<scalar>("value")), timeStart_(dict.lookupOrDefault("timeStart", -GREAT)), - mode_(operatingModeNames.lookup("mode", dict)) + mode_(operatingModeNames.get("mode", dict)) { if (fieldNames_.size()) { diff --git a/src/functionObjects/utilities/runTimeControl/runTimeCondition/minMaxCondition/minMaxCondition.C b/src/functionObjects/utilities/runTimeControl/runTimeCondition/minMaxCondition/minMaxCondition.C index d87644e931e85835311a5d32ae93cfb82825c543..9042fcc4d76b5b9066ec651eb5d3898da1bb2eb9 100644 --- a/src/functionObjects/utilities/runTimeControl/runTimeCondition/minMaxCondition/minMaxCondition.C +++ b/src/functionObjects/utilities/runTimeControl/runTimeCondition/minMaxCondition/minMaxCondition.C @@ -66,10 +66,10 @@ const Foam::Enum ::modeType > Foam::functionObjects::runTimeControls::minMaxCondition::modeTypeNames_ -{ +({ { modeType::mdMin, "minimum" }, { modeType::mdMax, "maximum" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -84,7 +84,7 @@ Foam::functionObjects::runTimeControls::minMaxCondition::minMaxCondition : runTimeCondition(name, obr, dict, state), functionObjectName_(dict.get<word>("functionObject")), - mode_(modeTypeNames_.lookup("mode", dict)), + mode_(modeTypeNames_.get("mode", dict)), fieldNames_(dict.get<wordList>("fields")), value_(dict.get<scalar>("value")) {} diff --git a/src/functionObjects/utilities/writeObjects/writeObjects.C b/src/functionObjects/utilities/writeObjects/writeObjects.C index 96579eb3d47f207e8c06ea98f7165d62ee3f8a18..236fa10f988cc7fb717cd91a3f51e696f84e4644 100644 --- a/src/functionObjects/utilities/writeObjects/writeObjects.C +++ b/src/functionObjects/utilities/writeObjects/writeObjects.C @@ -50,11 +50,11 @@ const Foam::Enum Foam::functionObjects::writeObjects::writeOption > Foam::functionObjects::writeObjects::writeOptionNames_ -{ +({ { writeOption::AUTO_WRITE, "autoWrite" }, { writeOption::NO_WRITE, "noWrite" }, { writeOption::ANY_WRITE, "anyWrite" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -89,8 +89,8 @@ bool Foam::functionObjects::writeObjects::read(const dictionary& dict) if (dict.found("field")) { - objectNames_.setSize(1); - dict.readEntry("field", objectNames_[0]); + objectNames_.resize(1); + dict.readEntry("field", objectNames_.first()); } else if (dict.found("fields")) { diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C index 3d0f31a4462de7647c56572718414025ca793adb..1eb531470eefd101103334be8c7a50266fa6665e 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C @@ -37,11 +37,11 @@ const Foam::Enum Foam::surfaceDisplacementPointPatchVectorField::projectMode > Foam::surfaceDisplacementPointPatchVectorField::projectModeNames_ -{ +({ { projectMode::NEAREST, "nearest" }, { projectMode::POINTNORMAL, "pointNormal" }, { projectMode::FIXEDNORMAL, "fixedNormal" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -318,7 +318,7 @@ surfaceDisplacementPointPatchVectorField fixedValuePointPatchVectorField(p, iF, dict), velocity_(dict.lookup("velocity")), surfacesDict_(dict.subDict("geometry")), - projectMode_(projectModeNames_.lookup("projectMode", dict)), + projectMode_(projectModeNames_.get("projectMode", dict)), projectDir_(dict.lookup("projectDirection")), wedgePlane_(dict.lookupOrDefault("wedgePlane", -1)), frozenPointsZone_(dict.lookupOrDefault("frozenPointsZone", word::null)) diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C index 2f3de5ce6a8cf5732e7ec75109bef52cbc11bcff..0be591f508c14b575aa44e21c30359c2dc6bc43b 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C @@ -37,11 +37,11 @@ const Foam::Enum Foam::surfaceSlipDisplacementPointPatchVectorField::projectMode > Foam::surfaceSlipDisplacementPointPatchVectorField::projectModeNames_ -{ +({ { projectMode::NEAREST, "nearest" }, { projectMode::POINTNORMAL, "pointNormal" }, { projectMode::FIXEDNORMAL, "fixedNormal" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -316,7 +316,7 @@ surfaceSlipDisplacementPointPatchVectorField : pointPatchVectorField(p, iF, dict), surfacesDict_(dict.subDict("geometry")), - projectMode_(projectModeNames_.lookup("projectMode", dict)), + projectMode_(projectModeNames_.get("projectMode", dict)), projectDir_(dict.lookup("projectDirection")), wedgePlane_(dict.lookupOrDefault("wedgePlane", -1)), frozenPointsZone_(dict.lookupOrDefault("frozenPointsZone", word::null)) diff --git a/src/fvOptions/cellSetOption/cellSetOption.C b/src/fvOptions/cellSetOption/cellSetOption.C index 6cc034a5969171b5422dc63e98e77cacb83a88e7..90b7224284bea7f96066c47ea71b88da9037cc77 100644 --- a/src/fvOptions/cellSetOption/cellSetOption.C +++ b/src/fvOptions/cellSetOption/cellSetOption.C @@ -42,12 +42,12 @@ const Foam::Enum Foam::fv::cellSetOption::selectionModeType > Foam::fv::cellSetOption::selectionModeTypeNames_ -{ +({ { selectionModeType::smPoints, "points" }, { selectionModeType::smCellSet, "cellSet" }, { selectionModeType::smCellZone, "cellZone" }, { selectionModeType::smAll, "all" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -204,10 +204,7 @@ Foam::fv::cellSetOption::cellSetOption option(name, modelType, dict, mesh), timeStart_(-1.0), duration_(0.0), - selectionMode_ - ( - selectionModeTypeNames_.lookup("selectionMode", coeffs_) - ), + selectionMode_(selectionModeTypeNames_.get("selectionMode", coeffs_)), cellSetName_("none"), V_(0.0) { diff --git a/src/fvOptions/constraints/derived/fixedTemperatureConstraint/fixedTemperatureConstraint.C b/src/fvOptions/constraints/derived/fixedTemperatureConstraint/fixedTemperatureConstraint.C index cdec55ac523e8a1eca73d7ea90660656d2688a9f..46ee6bc10ea3c328b49a5d9ffee0e7d629576023 100644 --- a/src/fvOptions/constraints/derived/fixedTemperatureConstraint/fixedTemperatureConstraint.C +++ b/src/fvOptions/constraints/derived/fixedTemperatureConstraint/fixedTemperatureConstraint.C @@ -50,10 +50,10 @@ const Foam::Enum Foam::fv::fixedTemperatureConstraint::temperatureMode > Foam::fv::fixedTemperatureConstraint::temperatureModeNames_ -{ +({ { temperatureMode::tmUniform, "uniform" }, { temperatureMode::tmLookup, "lookup" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -67,7 +67,7 @@ Foam::fv::fixedTemperatureConstraint::fixedTemperatureConstraint ) : cellSetOption(name, modelType, dict, mesh), - mode_(temperatureModeNames_.lookup("mode", coeffs_)), + mode_(temperatureModeNames_.get("mode", coeffs_)), Tuniform_(nullptr), TName_("T") { diff --git a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C index 697ff1e72a52b63768226d0eb28117fa078969e4..9d6adf3027a4fbcd300f80b32c3ebcda3aaa1e53 100644 --- a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C +++ b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C @@ -62,11 +62,11 @@ const Foam::Enum Foam::fv::directionalPressureGradientExplicitSource::pressureDropModel > Foam::fv::directionalPressureGradientExplicitSource::pressureDropModelNames_ -{ +({ { pressureDropModel::pVolumetricFlowRateTable, "volumetricFlowRateTable" }, { pressureDropModel::pConstant, "constant" }, { pressureDropModel::pDarcyForchheimer, "DarcyForchheimer" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -166,7 +166,7 @@ directionalPressureGradientExplicitSource ) : cellSetOption(sourceName, modelType, dict, mesh), - model_(pressureDropModelNames_.lookup("model", coeffs_)), + model_(pressureDropModelNames_.get("model", coeffs_)), gradP0_(cells_.size(), Zero), dGradP_(cells_.size(), Zero), gradPporous_(cells_.size(), Zero), diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C index 77c13c70d9bf7ce29eccfe03d9b8c4645d4ac399..8f41463545c10cf28a80442e1f9fda9e11c43c61 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C @@ -50,10 +50,10 @@ const Foam::Enum Foam::fv::rotorDiskSource::geometryModeType > Foam::fv::rotorDiskSource::geometryModeTypeNames_ -{ +({ { geometryModeType::gmAuto, "auto" }, { geometryModeType::gmSpecified, "specified" }, -}; +}); const Foam::Enum @@ -61,11 +61,11 @@ const Foam::Enum Foam::fv::rotorDiskSource::inletFlowType > Foam::fv::rotorDiskSource::inletFlowTypeNames_ -{ +({ { inletFlowType::ifFixed, "fixed" }, { inletFlowType::ifSurfaceNormal, "surfaceNormal" }, { inletFlowType::ifLocal, "local" }, -}; +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -267,7 +267,7 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem() vector refDir(Zero); geometryModeType gm = - geometryModeTypeNames_.lookup("geometryMode", coeffs_); + geometryModeTypeNames_.get("geometryMode", coeffs_); switch (gm) { @@ -558,7 +558,7 @@ bool Foam::fv::rotorDiskSource::read(const dictionary& dict) coeffs_.readEntry("nBlades", nBlades_); - inletFlow_ = inletFlowTypeNames_.lookup("inletFlowType", coeffs_); + inletFlowTypeNames_.readEntry("inletFlowType", coeffs_, inletFlow_); coeffs_.readEntry("tipEffect", tipEffect_); diff --git a/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C b/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C index 5fc0c9695ef1fb8eb27ed1b440b61d8366b88e38..f332f4d2b9f637f668f777b799331cc57f23a7a1 100644 --- a/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C +++ b/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C @@ -54,10 +54,10 @@ const Foam::Enum Foam::fv::solidificationMeltingSource::thermoMode > Foam::fv::solidificationMeltingSource::thermoModeTypeNames_ -{ +({ { thermoMode::mdThermo, "thermo" }, { thermoMode::mdLookup, "lookup" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -182,7 +182,7 @@ Foam::fv::solidificationMeltingSource::solidificationMeltingSource Tmelt_(coeffs_.get<scalar>("Tmelt")), L_(coeffs_.get<scalar>("L")), relax_(coeffs_.lookupOrDefault("relax", 0.9)), - mode_(thermoModeTypeNames_.lookup("thermoMode", coeffs_)), + mode_(thermoModeTypeNames_.get("thermoMode", coeffs_)), rhoRef_(coeffs_.get<scalar>("rhoRef")), TName_(coeffs_.lookupOrDefault<word>("T", "T")), CpName_(coeffs_.lookupOrDefault<word>("Cp", "Cp")), @@ -319,7 +319,7 @@ bool Foam::fv::solidificationMeltingSource::read(const dictionary& dict) coeffs_.readIfPresent("relax", relax_); - mode_ = thermoModeTypeNames_.lookup("thermoMode", coeffs_); + thermoModeTypeNames_.readEntry("thermoMode", coeffs_, mode_); coeffs_.readEntry("rhoRef", rhoRef_); coeffs_.readIfPresent("T", TName_); diff --git a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedNTUHeatTransfer/tabulatedNTUHeatTransfer.C b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedNTUHeatTransfer/tabulatedNTUHeatTransfer.C index 90d34365e7b31329e278738612e2d80b5d6287c3..2823572efe65c1c50fcce5a762a4eaff0a85c183 100644 --- a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedNTUHeatTransfer/tabulatedNTUHeatTransfer.C +++ b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/tabulatedNTUHeatTransfer/tabulatedNTUHeatTransfer.C @@ -48,10 +48,10 @@ const Foam::Enum Foam::fv::tabulatedNTUHeatTransfer::geometryModeType > Foam::fv::tabulatedNTUHeatTransfer::geometryModelNames_ -{ +({ { geometryModeType::gmCalculated, "calculated" }, { geometryModeType::gmUser, "user" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -89,7 +89,7 @@ void Foam::fv::tabulatedNTUHeatTransfer::initialiseGeometry() { if (Ain_ < 0) { - geometryMode_ = geometryModelNames_.lookup("geometryMode", coeffs_); + geometryMode_ = geometryModelNames_.get("geometryMode", coeffs_); Info<< "Region " << mesh_.name() << " " << type() << " " << name_ << " " << geometryModelNames_[geometryMode_] << " geometry:" << nl; diff --git a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C index 6ed39e470ca5e01b07319ad391099d271e4e511f..146c912221c764d45ef310f71ccdf072a33c8f54 100644 --- a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C +++ b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C @@ -32,12 +32,12 @@ const Foam::Enum Foam::phaseProperties::phaseType > Foam::phaseProperties::phaseTypeNames -{ +({ { phaseType::GAS, "gas" }, { phaseType::LIQUID, "liquid" }, { phaseType::SOLID, "solid" }, { phaseType::UNKNOWN, "unknown" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C index e8613476c336d8cb6dd3e9d8b55cc89614c442a8..c3e53ca67ce726d0ace1817ed7975d026ed860b9 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C @@ -37,11 +37,11 @@ const Foam::Enum typename Foam::ConeNozzleInjection<CloudType>::injectionMethod > Foam::ConeNozzleInjection<CloudType>::injectionMethodNames -{ +({ { injectionMethod::imPoint, "point" }, { injectionMethod::imDisc, "disc" }, - { injectionMethod::imMovingPoint, "movingPoint" } -}; + { injectionMethod::imMovingPoint, "movingPoint" }, +}); template<class CloudType> const Foam::Enum @@ -49,11 +49,11 @@ const Foam::Enum typename Foam::ConeNozzleInjection<CloudType>::flowType > Foam::ConeNozzleInjection<CloudType>::flowTypeNames -{ +({ { flowType::ftConstantVelocity, "constantVelocity" }, { flowType::ftPressureDrivenVelocity, "pressureDrivenVelocity" }, - { flowType::ftFlowRateAndDischarge, "flowRateAndDischarge" } -}; + { flowType::ftFlowRateAndDischarge, "flowRateAndDischarge" }, +}); // * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * // @@ -129,9 +129,9 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection InjectionModel<CloudType>(dict, owner, modelName, typeName), injectionMethod_ ( - injectionMethodNames.lookup("injectionMethod", this->coeffDict()) + injectionMethodNames.get("injectionMethod", this->coeffDict()) ), - flowType_(flowTypeNames.lookup("flowType", this->coeffDict())), + flowType_(flowTypeNames.get("flowType", this->coeffDict())), outerDiameter_(this->coeffDict().getScalar("outerDiameter")), innerDiameter_(this->coeffDict().getScalar("innerDiameter")), duration_(this->coeffDict().getScalar("duration")), diff --git a/src/lumpedPointMotion/lumpedPointMovement.C b/src/lumpedPointMotion/lumpedPointMovement.C index 8ecbe7e3c8308f9897c636e17f17ccef79ee174a..99fc9bc980477c4105835ad3f357e330902a076f 100644 --- a/src/lumpedPointMotion/lumpedPointMovement.C +++ b/src/lumpedPointMotion/lumpedPointMovement.C @@ -42,10 +42,10 @@ const Foam::Enum Foam::lumpedPointMovement::outputFormatType > Foam::lumpedPointMovement::formatNames -{ +({ { outputFormatType::PLAIN, "plain" }, - { outputFormatType::DICTIONARY, "dictionary" } -}; + { outputFormatType::DICTIONARY, "dictionary" }, +}); const Foam::Enum @@ -53,11 +53,11 @@ const Foam::Enum Foam::lumpedPointMovement::scalingType > Foam::lumpedPointMovement::scalingNames -{ +({ { scalingType::LENGTH, "length" }, { scalingType::FORCE, "force" }, - { scalingType::MOMENT, "moment" } -}; + { scalingType::MOMENT, "moment" }, +}); const Foam::word @@ -283,17 +283,11 @@ void Foam::lumpedPointMovement::readDict(const dictionary& dict) commDict.readEntry("outputName", outputName_); commDict.readIfPresent("logName", logName_); - inputFormat_ = lumpedPointState::formatNames.lookup - ( - "inputFormat", - commDict - ); + inputFormat_ = + lumpedPointState::formatNames.get("inputFormat", commDict); - outputFormat_ = lumpedPointMovement::formatNames.lookup - ( - "outputFormat", - commDict - ); + outputFormat_ = + lumpedPointMovement::formatNames.get("outputFormat", commDict); scaleInput_ = -1; scaleOutput_ = -1; diff --git a/src/lumpedPointMotion/lumpedPointState.C b/src/lumpedPointMotion/lumpedPointState.C index ac9c4351aacb1557486f3b96f8f9a52daf6c924b..1d38c4ad22a8434faa18ba50c3d9b129244dc0a6 100644 --- a/src/lumpedPointMotion/lumpedPointState.C +++ b/src/lumpedPointMotion/lumpedPointState.C @@ -38,10 +38,10 @@ const Foam::Enum Foam::lumpedPointState::inputFormatType > Foam::lumpedPointState::formatNames -{ +({ { inputFormatType::PLAIN, "plain" }, - { inputFormatType::DICTIONARY, "dictionary" } -}; + { inputFormatType::DICTIONARY, "dictionary" }, +}); // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C index a54f1e4fa20ba1e167f3c545a56e4bdfa9333926..2f7fb70d989b203a34750e4206d5e5702b2f2d81 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C @@ -71,13 +71,13 @@ const Foam::Enum Foam::meshRefinement::debugType > Foam::meshRefinement::debugTypeNames -{ +({ { debugType::MESH, "mesh" }, { debugType::OBJINTERSECTIONS, "intersections" }, { debugType::FEATURESEEDS, "featureSeeds" }, { debugType::ATTRACTION, "attraction" }, { debugType::LAYERINFO, "layerInfo" }, -}; +}); //const Foam::Enum @@ -85,9 +85,9 @@ Foam::meshRefinement::debugTypeNames // Foam::meshRefinement::outputType //> //Foam::meshRefinement::outputTypeNames -//{ +//({ // { outputType::OUTPUTLAYERINFO, "layerInfo" } -//}; +//}); const Foam::Enum @@ -95,13 +95,13 @@ const Foam::Enum Foam::meshRefinement::writeType > Foam::meshRefinement::writeTypeNames -{ +({ { writeType::WRITEMESH, "mesh" }, { writeType::NOWRITEREFINEMENT, "noRefinement" }, { writeType::WRITELEVELS, "scalarLevels" }, { writeType::WRITELAYERSETS, "layerSets" }, { writeType::WRITELAYERFIELDS, "layerFields" }, -}; +}); Foam::meshRefinement::writeType Foam::meshRefinement::writeLevel_; diff --git a/src/mesh/snappyHexMesh/refinementSurfaces/surfaceZonesInfo.C b/src/mesh/snappyHexMesh/refinementSurfaces/surfaceZonesInfo.C index 647c8dd6148d612ec5f81ed410f29bfcf5b8ee28..ccf8cf9155d9989ecd4e8d7d4312bdde823628ef 100644 --- a/src/mesh/snappyHexMesh/refinementSurfaces/surfaceZonesInfo.C +++ b/src/mesh/snappyHexMesh/refinementSurfaces/surfaceZonesInfo.C @@ -36,12 +36,12 @@ const Foam::Enum Foam::surfaceZonesInfo::areaSelectionAlgo > Foam::surfaceZonesInfo::areaSelectionAlgoNames -{ +({ { areaSelectionAlgo::INSIDE, "inside" }, { areaSelectionAlgo::OUTSIDE, "outside" }, { areaSelectionAlgo::INSIDEPOINT, "insidePoint" }, { areaSelectionAlgo::NONE, "none" }, -}; +}); const Foam::Enum @@ -49,11 +49,11 @@ const Foam::Enum Foam::surfaceZonesInfo::faceZoneType > Foam::surfaceZonesInfo::faceZoneTypeNames -{ +({ { faceZoneType::INTERNAL, "internal" }, { faceZoneType::BAFFLE, "baffle" }, { faceZoneType::BOUNDARY, "boundary" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C b/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C index 8de4a57b4d9f98b9a5a91d647de392360c11feb9..56d263c3fa1b42d6797be8d8760bccb09e12d15c 100644 --- a/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C +++ b/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C @@ -40,11 +40,11 @@ const Foam::Enum Foam::shellSurfaces::refineMode > Foam::shellSurfaces::refineModeNames_ -{ +({ { refineMode::INSIDE, "inside" }, { refineMode::OUTSIDE, "outside" }, { refineMode::DISTANCE, "distance" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -621,7 +621,7 @@ Foam::shellSurfaces::shellSurfaces unmatchedKeys.erase(eptr->keyword()); shells_[shellI] = geomI; - modes_[shellI] = refineModeNames_.lookup("mode", dict); + modes_[shellI] = refineModeNames_.get("mode", dict); // Read pairs of distance+level setAndCheckLevels(shellI, dict.lookup("levels")); diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index 6d93d803db02acab03739f80c8fc24f62a72a092..2a76bc90dce768bf4032b8b56961393a25d4c5bb 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -39,12 +39,12 @@ const Foam::Enum interpolationMethod > Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolationMethodNames_ -{ +({ { interpolationMethod::imDirect, "directAMI" }, { interpolationMethod::imMapNearest, "mapNearestAMI" }, { interpolationMethod::imFaceAreaWeight, "faceAreaWeightAMI" }, { interpolationMethod::imPartialFaceAreaWeight, "partialFaceAreaWeightAMI" } -}; +}); template<class SourcePatch, class TargetPatch> bool Foam::AMIInterpolation<SourcePatch, TargetPatch>::cacheIntersections_ = diff --git a/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersect.C b/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersect.C index 97e8b1a00e640b3b1b29ebe71bd4c8d117f27b1f..e70c6a3e144451613947053bba975e0011707756 100644 --- a/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersect.C +++ b/src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersect.C @@ -32,10 +32,10 @@ const Foam::Enum Foam::faceAreaIntersect::triangulationMode > Foam::faceAreaIntersect::triangulationModeNames_ -{ +({ { triangulationMode::tmFan, "fan" }, - { triangulationMode::tmMesh, "mesh" } -}; + { triangulationMode::tmMesh, "mesh" }, +}); Foam::scalar Foam::faceAreaIntersect::tol = 1e-6; diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C index 0baeaef92a09d3cb368578aa13da1b6c380230f3..cbde8cb0533a15c683df820945ab4fc100417c72 100644 --- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C +++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C @@ -48,12 +48,12 @@ const Foam::Enum Foam::extendedEdgeMesh::pointStatus > Foam::extendedEdgeMesh::pointStatusNames_ -{ +({ { pointStatus::CONVEX, "convex" }, { pointStatus::CONCAVE, "concave" }, { pointStatus::MIXED, "mixed" }, { pointStatus::NONFEATURE, "nonFeature" }, -}; +}); const Foam::Enum @@ -61,15 +61,14 @@ const Foam::Enum Foam::extendedEdgeMesh::edgeStatus > Foam::extendedEdgeMesh::edgeStatusNames_ -{ +({ { edgeStatus::EXTERNAL, "external" }, { edgeStatus::INTERNAL, "internal" }, { edgeStatus::FLAT, "flat" }, { edgeStatus::OPEN, "open" }, { edgeStatus::MULTIPLE, "multiple" }, { edgeStatus::NONE, "none" }, - -}; +}); const Foam::Enum @@ -77,12 +76,12 @@ const Foam::Enum Foam::extendedEdgeMesh::sideVolumeType > Foam::extendedEdgeMesh::sideVolumeTypeNames_ -{ +({ { sideVolumeType::INSIDE, "inside" }, { sideVolumeType::OUTSIDE, "outside" }, { sideVolumeType::BOTH, "both" }, { sideVolumeType::NEITHER, "neither" }, -}; +}); Foam::scalar Foam::extendedEdgeMesh::cosNormalAngleTol_ = diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index cfa8e9fbdccc693cf757ef84f7235defe93f542a..894a730f60f08a01e252a6b46a3c23cfeea029db 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -56,14 +56,14 @@ const Foam::Enum Foam::mappedPatchBase::sampleMode > Foam::mappedPatchBase::sampleModeNames_ -{ +({ { sampleMode::NEARESTCELL, "nearestCell" }, { sampleMode::NEARESTPATCHFACE, "nearestPatchFace" }, { sampleMode::NEARESTPATCHFACEAMI, "nearestPatchFaceAMI" }, { sampleMode::NEARESTPATCHPOINT, "nearestPatchPoint" }, { sampleMode::NEARESTFACE, "nearestFace" }, { sampleMode::NEARESTONLYCELL, "nearestOnlyCell" }, -}; +}); const Foam::Enum @@ -71,11 +71,11 @@ const Foam::Enum Foam::mappedPatchBase::offsetMode > Foam::mappedPatchBase::offsetModeNames_ -{ +({ { offsetMode::UNIFORM, "uniform" }, { offsetMode::NONUNIFORM, "nonuniform" }, { offsetMode::NORMAL, "normal" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -1018,7 +1018,7 @@ Foam::mappedPatchBase::mappedPatchBase : patch_(pp), sampleRegion_(dict.lookupOrDefault<word>("sampleRegion", "")), - mode_(sampleModeNames_.lookup("sampleMode", dict)), + mode_(sampleModeNames_.get("sampleMode", dict)), samplePatch_(dict.lookupOrDefault<word>("samplePatch", "")), coupleGroup_(dict), offsetMode_(UNIFORM), @@ -1042,10 +1042,8 @@ Foam::mappedPatchBase::mappedPatchBase } } - if (dict.found("offsetMode")) + if (offsetModeNames_.readIfPresent("offsetMode", dict, offsetMode_)) { - offsetMode_ = offsetModeNames_.lookup("offsetMode", dict); - switch (offsetMode_) { case UNIFORM: diff --git a/src/meshTools/sets/cellSources/faceToCell/faceToCell.C b/src/meshTools/sets/cellSources/faceToCell/faceToCell.C index 9142f32ae0acebdd1f051ea9168a24ca85b3de76..5499aaa9636a960773cd5d42373972e1cc130f9c 100644 --- a/src/meshTools/sets/cellSources/faceToCell/faceToCell.C +++ b/src/meshTools/sets/cellSources/faceToCell/faceToCell.C @@ -51,12 +51,12 @@ const Foam::Enum Foam::faceToCell::faceAction > Foam::faceToCell::faceActionNames_ -{ +({ { faceAction::ANY, "any" }, { faceAction::ALL, "all" }, { faceAction::OWNER, "owner" }, { faceAction::NEIGHBOUR, "neighbour" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -147,7 +147,7 @@ Foam::faceToCell::faceToCell : topoSetSource(mesh), setName_(dict.get<word>("set")), - option_(faceActionNames_.lookup("option", dict)) + option_(faceActionNames_.get("option", dict)) {} diff --git a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C index 8453e1a38767ee065009d93668bbf1aa60f603e8..8b10efb06a815e0d13a808d3ba637d2d058cbf86 100644 --- a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C +++ b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C @@ -51,10 +51,10 @@ const Foam::Enum Foam::faceZoneToCell::faceAction > Foam::faceZoneToCell::faceActionNames_ -{ +({ { faceAction::MASTER, "master" }, { faceAction::SLAVE, "slave" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -124,7 +124,7 @@ Foam::faceZoneToCell::faceZoneToCell : topoSetSource(mesh), zoneName_(dict.get<wordRe>("name")), - option_(faceActionNames_.lookup("option", dict)) + option_(faceActionNames_.get("option", dict)) {} diff --git a/src/meshTools/sets/cellSources/pointToCell/pointToCell.C b/src/meshTools/sets/cellSources/pointToCell/pointToCell.C index a11c7d739a3ebcb546b5d906374cc68525e3bdaa..90e99bc1120befcfa6dd41aba087c8cddaa38152 100644 --- a/src/meshTools/sets/cellSources/pointToCell/pointToCell.C +++ b/src/meshTools/sets/cellSources/pointToCell/pointToCell.C @@ -51,10 +51,10 @@ const Foam::Enum Foam::pointToCell::pointAction > Foam::pointToCell::pointActionNames_ -{ +({ { pointAction::ANY, "any" }, { pointAction::EDGE, "edge" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -130,7 +130,7 @@ Foam::pointToCell::pointToCell : topoSetSource(mesh), setName_(dict.get<word>("set")), - option_(pointActionNames_.lookup("option", dict)) + option_(pointActionNames_.get("option", dict)) {} diff --git a/src/meshTools/sets/faceSources/cellToFace/cellToFace.C b/src/meshTools/sets/faceSources/cellToFace/cellToFace.C index e36dd88c1d4cdd9c1211cbcada278cc5b5ea8bbc..5b271c8e0dab9a80597615e389a2da7df155d430 100644 --- a/src/meshTools/sets/faceSources/cellToFace/cellToFace.C +++ b/src/meshTools/sets/faceSources/cellToFace/cellToFace.C @@ -53,10 +53,10 @@ const Foam::Enum Foam::cellToFace::cellAction > Foam::cellToFace::cellActionNames_ -{ +({ { cellAction::ALL, "all" }, { cellAction::BOTH, "both" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -167,7 +167,7 @@ Foam::cellToFace::cellToFace : topoSetSource(mesh), setName_(dict.get<word>("set")), - option_(cellActionNames_.lookup("option", dict)) + option_(cellActionNames_.get("option", dict)) {} diff --git a/src/meshTools/sets/faceSources/pointToFace/pointToFace.C b/src/meshTools/sets/faceSources/pointToFace/pointToFace.C index 6da05cd63606ff55d60bba7933a0527a778a239e..21a1953cf8cfab776a094f4acc5a65424b9e6af3 100644 --- a/src/meshTools/sets/faceSources/pointToFace/pointToFace.C +++ b/src/meshTools/sets/faceSources/pointToFace/pointToFace.C @@ -53,11 +53,11 @@ const Foam::Enum Foam::pointToFace::pointAction > Foam::pointToFace::pointActionNames_ -{ +({ { pointAction::ANY, "any" }, { pointAction::ALL, "all" }, { pointAction::EDGE, "edge" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -161,7 +161,7 @@ Foam::pointToFace::pointToFace : topoSetSource(mesh), setName_(dict.get<word>("set")), - option_(pointActionNames_.lookup("option", dict)) + option_(pointActionNames_.get("option", dict)) {} diff --git a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C index 9db7bedc5ccf0d966b0eb35318bd1197fb219399..8ef233ec156e9971f7354cfc9576ebf179a1d932 100644 --- a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C +++ b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C @@ -50,9 +50,9 @@ const Foam::Enum Foam::cellToPoint::cellAction > Foam::cellToPoint::cellActionNames_ -{ +({ { cellAction::ALL, "all" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -104,7 +104,7 @@ Foam::cellToPoint::cellToPoint : topoSetSource(mesh), setName_(dict.get<word>("set")), - option_(cellActionNames_.lookup("option", dict)) + option_(cellActionNames_.get("option", dict)) {} diff --git a/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C b/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C index 72e93bdb78ecc7237b4d79d62bde8cf354fd7770..9f6583eb16402cddc4d999cf597ed3419feda42e 100644 --- a/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C +++ b/src/meshTools/sets/pointSources/faceToPoint/faceToPoint.C @@ -49,9 +49,9 @@ const Foam::Enum Foam::faceToPoint::faceAction > Foam::faceToPoint::faceActionNames_ -{ +({ { faceAction::ALL, "all" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -98,7 +98,7 @@ Foam::faceToPoint::faceToPoint : topoSetSource(mesh), setName_(dict.get<word>("set")), - option_(faceActionNames_.lookup("option", dict)) + option_(faceActionNames_.get("option", dict)) {} diff --git a/src/meshTools/sets/topoSetSource/topoSetSource.C b/src/meshTools/sets/topoSetSource/topoSetSource.C index 801190f5217c958a7680735c618e8b0e22df5ee1..2bd6225e198ee7c1d39f120f669ebeaebdc50066 100644 --- a/src/meshTools/sets/topoSetSource/topoSetSource.C +++ b/src/meshTools/sets/topoSetSource/topoSetSource.C @@ -45,7 +45,7 @@ const Foam::Enum Foam::topoSetSource::setAction > Foam::topoSetSource::actionNames -{ +({ { setAction::CLEAR, "clear" }, { setAction::NEW, "new" }, { setAction::INVERT, "invert" }, @@ -54,7 +54,7 @@ Foam::topoSetSource::actionNames { setAction::SUBSET, "subset" }, { setAction::LIST, "list" }, { setAction::REMOVE, "remove" }, -}; +}); const Foam::string Foam::topoSetSource::illegalSource_ diff --git a/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.C b/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.C index b8cc1834247668bba5744ab81856df00986d0d39..53981a2596be2a2bd214f808c9ee8cf03425a7d5 100644 --- a/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.C +++ b/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.C @@ -43,12 +43,12 @@ const Foam::Enum Foam::booleanSurface::booleanOpType > Foam::booleanSurface::booleanOpTypeNames -{ +({ { booleanOpType::UNION, "union" }, { booleanOpType::INTERSECTION, "intersection" }, { booleanOpType::DIFFERENCE, "difference" }, { booleanOpType::ALL, "all" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersection.C b/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersection.C index 1a067714c2bd2a6b0217fca4210d8ad318bc9320..8eb4827f684ace5b2f39a6bcaa363a54e63fe33e 100644 --- a/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersection.C +++ b/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersection.C @@ -46,11 +46,11 @@ const Foam::Enum Foam::surfaceIntersection::intersectionType > Foam::surfaceIntersection::selfIntersectionNames -{ +({ { intersectionType::SELF, "self" }, { intersectionType::SELF_REGION, "region" }, { intersectionType::NONE, "none" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/meshTools/triSurface/triSurfaceLoader/triSurfaceLoader.C b/src/meshTools/triSurface/triSurfaceLoader/triSurfaceLoader.C index a5f2a817acfed545f1a7d24c3fb2713f84424700..acc8ee270ce4531fe741e114913f546db3b25802 100644 --- a/src/meshTools/triSurface/triSurfaceLoader/triSurfaceLoader.C +++ b/src/meshTools/triSurface/triSurfaceLoader/triSurfaceLoader.C @@ -35,12 +35,12 @@ const Foam::Enum Foam::triSurfaceLoader::loadingOption > Foam::triSurfaceLoader::loadingOptionNames -{ +({ { loadingOption::SINGLE_REGION, "single" }, { loadingOption::FILE_REGION, "file" }, { loadingOption::OFFSET_REGION, "offset" }, - { loadingOption::MERGE_REGION, "merge" } -}; + { loadingOption::MERGE_REGION, "merge" }, +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C index d8fc062017265dfc10e3c900cb6f4c7b8c9455f7..afb63ccaac2e9f91fe183a9f4c4172fc02308fd5 100644 --- a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C +++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C @@ -42,11 +42,11 @@ const Foam::Enum Foam::cellCellStencil::cellType > Foam::cellCellStencil::cellTypeNames_ -{ +({ { cellType::CALCULATED, "calculated" }, { cellType::INTERPOLATED, "interpolated" }, { cellType::HOLE, "hole" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/parallel/decompose/kahipDecomp/kahipDecomp.C b/src/parallel/decompose/kahipDecomp/kahipDecomp.C index 6177e90a7f8a1b38ccef1e269f7a7819953c0e44..f9839f391c1ba471ed70f0d97788e3755adaca9a 100644 --- a/src/parallel/decompose/kahipDecomp/kahipDecomp.C +++ b/src/parallel/decompose/kahipDecomp/kahipDecomp.C @@ -60,14 +60,14 @@ const Foam::Enum Foam::kahipDecomp::configs > Foam::kahipDecomp::configNames -{ +({ { kahipDecomp::configs::FAST, "fast" }, { kahipDecomp::configs::ECO, "eco" }, { kahipDecomp::configs::STRONG, "strong" }, { kahipDecomp::configs::FASTSOCIAL, "fast-social" }, { kahipDecomp::configs::ECOSOCIAL, "eco-social" }, { kahipDecomp::configs::STRONGSOCIAL, "strong-social" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -130,9 +130,7 @@ Foam::label Foam::kahipDecomp::decomposeSerial } } - kahipConfig = - configNames.lookupOrDefault("config", coeffsDict_, kahipConfig); - + configNames.readIfPresent("config", coeffsDict_, kahipConfig); coeffsDict_.readIfPresent("imbalance", imbalance); coeffsDict_.readIfPresent("verbose", verbose); diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 7da8ce27f46b8db6ce4c72c7c88f70b56306f0e4..665cf0ce85b8bdbe781a8a806787ef1e9cf046fc 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -59,11 +59,11 @@ const Foam::Enum Foam::distributedTriSurfaceMesh::distributionType > Foam::distributedTriSurfaceMesh::distributionTypeNames_ -{ +({ { distributionType::FOLLOW, "follow" }, { distributionType::INDEPENDENT, "independent" }, { distributionType::FROZEN, "frozen" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -79,7 +79,7 @@ bool Foam::distributedTriSurfaceMesh::read() Pstream::scatterList(procBb_); // Distribution type - distType_ = distributionTypeNames_.lookup("distributionType", dict_); + distType_ = distributionTypeNames_.get("distributionType", dict_); // Merge distance dict_.readEntry("mergeDistance", mergeDist_); diff --git a/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C b/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C index 0c751ec61ebf5a942946bb9b83dd998ce11daf6f..a750f40d8edfeb4811b73a6c9eb3a7a9b8c2ccad 100644 --- a/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C +++ b/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C @@ -35,11 +35,11 @@ const Foam::Enum Foam::energyRegionCoupledFvPatchScalarField::kappaMethodType > Foam::energyRegionCoupledFvPatchScalarField::methodTypeNames_ -{ +({ { kappaMethodType::SOLID, "solid" }, { kappaMethodType::FLUID, "fluid" }, { kappaMethodType::UNDEFINED, "undefined" }, -}; +}); // * * * * * * * * * * * * * * * * Private members * * * * * * * * * * * * *// diff --git a/src/sampling/meshToMesh/meshToMesh.C b/src/sampling/meshToMesh/meshToMesh.C index f904480f00e5dd948cd4dea4b052d0eb3ed334b6..b141f3ada8b854a77c130660f8346bdec2ea3db2 100644 --- a/src/sampling/meshToMesh/meshToMesh.C +++ b/src/sampling/meshToMesh/meshToMesh.C @@ -41,7 +41,7 @@ const Foam::Enum Foam::meshToMesh::interpolationMethod > Foam::meshToMesh::interpolationMethodNames_ -{ +({ { interpolationMethod::imDirect, "direct" }, { interpolationMethod::imMapNearest, "mapNearest" }, { interpolationMethod::imCellVolumeWeight, "cellVolumeWeight" }, @@ -49,7 +49,7 @@ Foam::meshToMesh::interpolationMethodNames_ interpolationMethod::imCorrectedCellVolumeWeight, "correctedCellVolumeWeight" }, -}; +}); const Foam::Enum diff --git a/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C b/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C index 7ebff4e1b28c6b0ac856613edb1aeb08197478ab..2b6147f74f35b678251ca04ddff1f2a8d030daac 100644 --- a/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C +++ b/src/sampling/sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C @@ -58,11 +58,11 @@ Foam::sampledPatchInternalField::sampledPatchInternalField sampledPatch(name, mesh, dict), mappers_(patchIDs().size()) { - mappedPatchBase::offsetMode mode = mappedPatchBase::NORMAL; - if (dict.found("offsetMode")) - { - mode = mappedPatchBase::offsetModeNames_.lookup("offsetMode", dict); - } + mappedPatchBase::offsetMode mode = + mappedPatchBase::offsetModeNames_.lookupOrDefault + ( + "offsetMode", dict, mappedPatchBase::NORMAL + ); switch (mode) { diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C index 83db3ec3252daedea3cecedb4592d30e9bcc6823..505d75a0b8f00ca6a7eff1b2881cf9a9d6364104 100644 --- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C +++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C @@ -40,11 +40,11 @@ const Foam::Enum Foam::sampledTriSurfaceMesh::samplingSource > Foam::sampledTriSurfaceMesh::samplingSourceNames_ -{ +({ { samplingSource::cells, "cells" }, { samplingSource::insideCells, "insideCells" }, { samplingSource::boundaryFaces, "boundaryFaces" }, -}; +}); namespace Foam @@ -678,7 +678,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh ), dict ), - sampleSource_(samplingSourceNames_.lookup("source", dict)), + sampleSource_(samplingSourceNames_.get("source", dict)), needsUpdate_(true), keepIds_(dict.lookupOrDefault("keepIds", false)), originalIds_(), diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C index 8709c0a841205806a5979bbba55c7971aca2ff1c..c988f6a10d0cf8c1bcb2757c017ddb97cfdacf34 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C @@ -106,11 +106,12 @@ Foam::ensightSurfaceWriter::ensightSurfaceWriter(const dictionary& options) surfaceWriter(), writeFormat_ ( - IOstreamOption::formatNames.lookupOrFailsafe + IOstreamOption::formatNames.lookupOrDefault ( "format", options, - IOstreamOption::ASCII + IOstreamOption::ASCII, + true // Failsafe behaviour ) ), collateTimes_(options.lookupOrDefault("collateTimes", true)) diff --git a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C index 138ab05cd31e421852756cbc049b055a0d11ae52..e441a10ba971cfbeb40d29956baef36a25b77777 100644 --- a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C @@ -45,10 +45,10 @@ const Foam::Enum Foam::nastranSurfaceWriter::loadFormat > Foam::nastranSurfaceWriter::loadFormatNames_ -{ +({ { loadFormat::PLOAD2, "PLOAD2" }, { loadFormat::PLOAD4, "PLOAD4" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/sampling/surface/triSurfaceMesh/discreteSurface.C b/src/sampling/surface/triSurfaceMesh/discreteSurface.C index 5df8594ae74a95a8c93a58da09897b59c9d0f65a..1e0dccc66fc27cf4a62632b44486405d3e7c5b81 100644 --- a/src/sampling/surface/triSurfaceMesh/discreteSurface.C +++ b/src/sampling/surface/triSurfaceMesh/discreteSurface.C @@ -40,11 +40,11 @@ const Foam::Enum Foam::discreteSurface::samplingSource > Foam::discreteSurface::samplingSourceNames_ -{ +({ { samplingSource::cells, "cells" }, { samplingSource::insideCells, "insideCells" }, { samplingSource::boundaryFaces, "boundaryFaces" }, -}; +}); namespace Foam @@ -684,7 +684,7 @@ Foam::discreteSurface::discreteSurface false ) ), - sampleSource_(samplingSourceNames_.lookup("source", dict)), + sampleSource_(samplingSourceNames_.get("source", dict)), needsUpdate_(true), keepIds_(dict.lookupOrDefault("keepIds", false)), originalIds_(), diff --git a/src/sixDoFRigidBodyState/sixDoFRigidBodyState.C b/src/sixDoFRigidBodyState/sixDoFRigidBodyState.C index 7a88136a8e196af096727aa4e4b4d56a13eed19c..0a621590a1f0a1b0fb64d2c6c8e45244d6d2f481 100644 --- a/src/sixDoFRigidBodyState/sixDoFRigidBodyState.C +++ b/src/sixDoFRigidBodyState/sixDoFRigidBodyState.C @@ -51,10 +51,10 @@ const Foam::Enum Foam::functionObjects::sixDoFRigidBodyState::angleTypes > Foam::functionObjects::sixDoFRigidBodyState::angleTypeNames_ -{ +({ { angleTypes::RADIANS, "radians" }, - { angleTypes::DEGREES, "degrees" } -}; + { angleTypes::DEGREES, "degrees" }, +}); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // diff --git a/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationPropertiesPatch.C b/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationPropertiesPatch.C index 5d68a5c9c9d9c4dd043bc638a5becf93d2b2126a..f0df9e2658c47a3ae2261e9b9f0ce948119f7b26 100644 --- a/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationPropertiesPatch.C +++ b/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationPropertiesPatch.C @@ -35,11 +35,11 @@ const Foam::Enum Foam::radiation::boundaryRadiationPropertiesPatch::methodType > Foam::radiation::boundaryRadiationPropertiesPatch::methodTypeNames_ -{ +({ { methodType::SOLIDRADIATION, "solidRadiation" }, { methodType::LOOKUP, "lookup" }, - { methodType::MODEL, "model" } -}; + { methodType::MODEL, "model" }, +}); // * * * * * * * * * * * * * * * * Private functions * * * * * * * * * * * * // @@ -74,7 +74,7 @@ boundaryRadiationPropertiesPatch const dictionary& dict ) : - method_(methodTypeNames_.lookup("mode", dict)), + method_(methodTypeNames_.get("mode", dict)), dict_(dict), absorptionEmission_(nullptr), transmissivity_(nullptr), diff --git a/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C b/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C index 70a8df2ad8de1864a455be91857c8f8e11369b74..fca3d56aa25675e360634ef4b5b9a43db1cc656b 100644 --- a/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C +++ b/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C @@ -43,10 +43,10 @@ const Foam::Enum Foam::solarCalculator::sunDirModel > Foam::solarCalculator::sunDirectionModelTypeNames_ -{ +({ { sunDirModel::mSunDirConstant, "sunDirConstant" }, { sunDirModel::mSunDirTracking, "sunDirTracking" }, -}; +}); const Foam::Enum @@ -54,14 +54,14 @@ const Foam::Enum Foam::solarCalculator::sunLModel > Foam::solarCalculator::sunLoadModelTypeNames_ -{ +({ { sunLModel::mSunLoadConstant, "sunLoadConstant" }, { sunLModel::mSunLoadFairWeatherConditions, "sunLoadFairWeatherConditions" }, { sunLModel::mSunLoadTheoreticalMaximum, "sunLoadTheoreticalMaximum" }, -}; +}); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -261,19 +261,15 @@ Foam::solarCalculator::solarCalculator C_(dict.get<scalar>("C")), sunDirectionModel_ ( - sunDirectionModelTypeNames_.lookup("sunDirectionModel", dict) - ), - sunLoadModel_ - ( - sunLoadModelTypeNames_.lookup("sunLoadModel", dict) + sunDirectionModelTypeNames_.get("sunDirectionModel", dict) ), + sunLoadModel_(sunLoadModelTypeNames_.get("sunLoadModel", dict)), coord_() { init(); } - // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::solarCalculator::~solarCalculator() diff --git a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C index 316e1367e07ab1f43b56212fece071e2ca876e94..0175bbc9415c41a6012bfcf4672b61f1628490e8 100644 --- a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C @@ -38,7 +38,7 @@ const Foam::Enum Foam::humidityTemperatureCoupledMixedFvPatchScalarField::massTransferMode > Foam::humidityTemperatureCoupledMixedFvPatchScalarField::massModeTypeNames_ -{ +({ { massTransferMode::mtConstantMass, "constantMass" }, { massTransferMode::mtCondensation, "condensation" }, { massTransferMode::mtEvaporation, "evaporation" }, @@ -46,7 +46,7 @@ Foam::humidityTemperatureCoupledMixedFvPatchScalarField::massModeTypeNames_ massTransferMode::mtCondensationAndEvaporation, "condensationAndEvaporation" }, -}; +}); // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // @@ -240,9 +240,8 @@ humidityTemperatureCoupledMixedFvPatchScalarField fvPatchScalarField::operator=(scalarField("value", dict, p.size())); - if (dict.found("mode")) + if (massModeTypeNames_.readIfPresent("mode", dict, mode_)) { - mode_ = massModeTypeNames_.lookup("mode", dict); fluid_ = true; } diff --git a/src/transportModels/twoPhaseProperties/alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C b/src/transportModels/twoPhaseProperties/alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C index 75763c8301cbe3e4856a47b5b2ba0faeda0b90c4..32f2da49629d8685fe3609b2296143eeb9fb85d4 100644 --- a/src/transportModels/twoPhaseProperties/alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C +++ b/src/transportModels/twoPhaseProperties/alphaContactAngle/alphaContactAngle/alphaContactAngleFvPatchScalarField.C @@ -40,12 +40,12 @@ const Foam::Enum Foam::alphaContactAngleFvPatchScalarField::limitControls > Foam::alphaContactAngleFvPatchScalarField::limitControlNames_ -{ +({ { limitControls::lcNone, "none" }, { limitControls::lcGradient, "gradient" }, { limitControls::lcZeroGradient, "zeroGradient" }, { limitControls::lcAlpha, "alpha" }, -}; +}); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -69,7 +69,7 @@ Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField ) : fixedGradientFvPatchScalarField(p, iF), - limit_(limitControlNames_.lookup("limit", dict)) + limit_(limitControlNames_.get("limit", dict)) { if (dict.found("gradient")) {