From fb4971644ffb7387069ab9d19cf9634a6cb0d202 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 29 May 2017 10:30:55 +0200 Subject: [PATCH] ENH: cleanup of NamedEnum - Remove the unused enums() method since it delivers wholly unreliable results. It is not guaranteed to cover the full enumeration range, but only the listed names. - Remove the unused strings() method. Duplicated functionality of the words(), but was never used. - Change access of words() method from static to object. Better code isolation. Permits the constructor to take over as the single point of failure for bad input. - Add values() method - do not expose internal (HashTable) lookup since it makes it more difficult to enforce constness and the implementation detail should not be exposed. However leave toc() and sortedToc() for the interface. STYLE: relocated NamedEnum under primitives (was containers) - internal typedef as 'value_type' for some consistency with STL conventions --- applications/test/NamedEnum/Test-NamedEnum.C | 83 ++++----- .../DelaunayMeshToolsTemplates.C | 21 +-- .../preProcessing/mapFieldsPar/mapFieldsPar.C | 2 +- .../enums}/NamedEnum.C | 168 ++++++++++-------- .../enums}/NamedEnum.H | 111 +++++++----- src/OpenFOAM/primitives/enums/NamedEnumI.H | 81 +++++++++ .../temperatureCoupledBase.C | 10 +- src/conversion/fire/FIREMeshReader.C | 2 +- src/conversion/fire/FIREMeshWriter.C | 2 +- .../functionObjects/volRegion/volRegion.C | 2 +- .../surfaceFieldValue/surfaceFieldValue.C | 5 +- .../field/mapFields/mapFields.C | 6 +- .../utilities/writeObjects/writeObjects.C | 3 +- src/fvOptions/cellSetOption/cellSetOption.C | 6 +- ...irectionalPressureGradientExplicitSource.C | 2 +- .../derived/rotorDiskSource/rotorDiskSource.C | 3 +- .../mappedPolyPatch/mappedPatchBase.C | 4 +- .../energyRegionCoupledFvPatchScalarField.C | 2 +- .../boundaryRadiationPropertiesPatch.C | 7 +- 19 files changed, 315 insertions(+), 205 deletions(-) rename src/OpenFOAM/{containers/NamedEnum => primitives/enums}/NamedEnum.C (58%) rename src/OpenFOAM/{containers/NamedEnum => primitives/enums}/NamedEnum.H (66%) create mode 100644 src/OpenFOAM/primitives/enums/NamedEnumI.H diff --git a/applications/test/NamedEnum/Test-NamedEnum.C b/applications/test/NamedEnum/Test-NamedEnum.C index 079938b6b7..4fc20d182c 100644 --- a/applications/test/NamedEnum/Test-NamedEnum.C +++ b/applications/test/NamedEnum/Test-NamedEnum.C @@ -34,15 +34,15 @@ class namedEnumTest { public: - enum option + enum class option { - a, - b, - c, - d + A, + B, + C, + D }; - static const Foam::NamedEnum namedEnum; + static const Foam::NamedEnum optionNamed; }; @@ -52,10 +52,10 @@ const char* Foam::NamedEnum::names[] = "a", "b", "c", - "d" + "d", }; -const Foam::NamedEnum namedEnumTest::namedEnum; +const Foam::NamedEnum namedEnumTest::optionNamed; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -69,56 +69,43 @@ int main(int argc, char *argv[]) dictionary testDict; testDict.add("lookup1", "c"); - Info<< "enums: " << options << nl; - - Info<< "loop over enums (as list):" << nl; - forAll(options, i) - { - const namedEnumTest::option& opt = options[i]; - - Info<< "option[" << opt - << "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl; - } - - Info<< "loop over enums (C++11 for range):" << nl; - for (const auto& opt : options) - { - Info<< "option[" << opt - << "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl; - } - Info<< nl - << namedEnumTest::namedEnum["a"] << nl - << namedEnumTest::namedEnum[namedEnumTest::a] << nl; + << int(namedEnumTest::optionNamed["a"]) << nl + << namedEnumTest::optionNamed[namedEnumTest::option::A] << nl; Info<< "--- test dictionary lookup ---" << endl; { Info<< "dict: " << testDict << endl; - namedEnumTest::option gotOpt = - namedEnumTest::namedEnum.lookupOrDefault - ( - "test", - testDict, - namedEnumTest::option::a - ); + Info<< "got: " + << int + ( + namedEnumTest::optionNamed.lookupOrDefault + ( + "notFound", + testDict, + namedEnumTest::option::A + ) + ) + << nl; - Info<< "got: " << gotOpt << endl; - - gotOpt = namedEnumTest::namedEnum.lookupOrDefault - ( - "lookup1", - testDict, - namedEnumTest::option::a - ); - - Info<< "got: " << gotOpt << endl; + Info<< "got: " + << int + ( + namedEnumTest::optionNamed.lookupOrDefault + ( + "lookup1", + testDict, + namedEnumTest::option::A + ) + ) + << nl; } - Info<< "--- test read construction ---" << endl; + Info<< "--- test read ---" << endl; - namedEnumTest::option dummy(namedEnumTest::namedEnum.read(Sin)); - Info<< namedEnumTest::namedEnum[dummy] << endl; + namedEnumTest::option dummy(namedEnumTest::optionNamed.read(Sin)); + Info<< namedEnumTest::optionNamed[dummy] << endl; Info<< "End\n" << endl; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C index ed6818dd39..da9f4ce3ed 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C @@ -44,22 +44,9 @@ void Foam::DelaunayMeshTools::writeOBJ OFstream str(fName); Pout<< nl - << "Writing points of types:" << nl; - - forAllConstIter - ( - HashTable, - indexedVertexEnum::vertexTypeNames_, - iter - ) - { - if (iter() >= startPointType && iter() <= endPointType) - { - Pout<< " " << iter.key() << nl; - } - } - - Pout<< "to " << str.name() << endl; + << "Writing points of types (" + << int(startPointType) << "-" << int(endPointType) + << ") to " << str.name() << endl; for ( @@ -265,7 +252,7 @@ void Foam::DelaunayMeshTools::drawDelaunayCell << "f " << 1 + offset << " " << 4 + offset << " " << 3 + offset << nl << "f " << 1 + offset << " " << 2 + offset << " " << 4 + offset << endl; -// os << "# cicumcentre " << endl; +// os << "# circumcentre " << endl; // meshTools::writeOBJ(os, c->dual()); diff --git a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C index 43caab7dcc..d6df8f1a16 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C +++ b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C @@ -229,7 +229,7 @@ int main(int argc, char *argv[]) word patchMapMethod; - if (meshToMesh::interpolationMethodNames_.found(mapMethod)) + if (meshToMesh::interpolationMethodNames_.hasEnum(mapMethod)) { // Lookup corresponding AMI method meshToMesh::interpolationMethod method = diff --git a/src/OpenFOAM/containers/NamedEnum/NamedEnum.C b/src/OpenFOAM/primitives/enums/NamedEnum.C similarity index 58% rename from src/OpenFOAM/containers/NamedEnum/NamedEnum.C rename to src/OpenFOAM/primitives/enums/NamedEnum.C index 0f5e05630f..7b5cc701de 100644 --- a/src/OpenFOAM/containers/NamedEnum/NamedEnum.C +++ b/src/OpenFOAM/primitives/enums/NamedEnum.C @@ -25,14 +25,48 @@ License #include "NamedEnum.H" #include "dictionary.H" +#include "stdFoam.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -template -Foam::List Foam::NamedEnum::getNamesList() +template +Foam::NamedEnum::NamedEnum() +: + lookup_(2*nEnum) { - List lst(nEnum); + for (int enumi=0; enumi < nEnum; ++enumi) + { + if (names[enumi] && names[enumi][0]) + { + lookup_.insert(names[enumi], enumi); + } + else + { + // Bad name - generate error message + List goodNames(enumi); + + for (int i = 0; i < enumi; ++i) + { + goodNames[i] = names[i]; + } + + FatalErrorInFunction + << "Illegal enumeration name at position " << enumi << nl + << "after entries " << goodNames << nl + << "Possibly your NamedEnum::names array" + << " is not of size " << nEnum << endl + << abort(FatalError); + } + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::wordList Foam::NamedEnum::words() const +{ + List lst(nEnum); label count = 0; for (int enumi=0; enumi < nEnum; ++enumi) @@ -48,93 +82,74 @@ Foam::List Foam::NamedEnum::getNamesList() } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::NamedEnum::NamedEnum() -: - table_type(2*nEnum) +template +Foam::List Foam::NamedEnum::values() const { + List lst(nEnum); + + label count = 0; for (int enumi=0; enumi < nEnum; ++enumi) { if (names[enumi] && names[enumi][0]) { - insert(names[enumi], enumi); - } - else - { - // Bad name - generate error message - stringList goodNames(enumi); + auto iter = lookup_.cfind(names[enumi]); - for (int i = 0; i < enumi; ++i) + if (iter.found()) { - goodNames[i] = names[i]; + lst[count++] = iter.object(); } - - FatalErrorInFunction - << "Illegal enumeration name at position " << enumi << nl - << "after entries " << goodNames << nl - << "Possibly your NamedEnum::names array" - << " is not of size " << nEnum << endl - << abort(FatalError); } } + + lst.setSize(count); + return lst; } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -Enum Foam::NamedEnum::read(Istream& is) const +template +bool Foam::NamedEnum::hasName(const EnumType e) const { - const word enumName(is); - table_type::const_iterator iter = find(enumName); + const int enumValue(e); - if (!iter.found()) + forAllConstIters(lookup_, iter) { - FatalIOErrorInFunction(is) - << enumName << " is not in enumeration: " - << sortedToc() << exit(FatalIOError); + if (iter.object() == enumValue) + { + return true; + } } - - return Enum(iter.object()); + return false; } -template -void Foam::NamedEnum::write(const Enum e, Ostream& os) const -{ - os << names[int(e)]; -} - - -template -Enum Foam::NamedEnum::lookup +template +EnumType Foam::NamedEnum::lookup ( const word& key, const dictionary& dict ) const { const word enumName(dict.lookup(key)); - table_type::const_iterator iter = find(enumName); + auto iter = lookup_.cfind(enumName); if (!iter.found()) { FatalIOErrorInFunction(dict) << enumName << " is not in enumeration: " - << sortedToc() << exit(FatalIOError); + << lookup_.sortedToc() << nl + << exit(FatalIOError); } - return Enum(iter.object()); + return EnumType(iter.object()); } -template -Enum Foam::NamedEnum::lookupOrDefault +template +EnumType Foam::NamedEnum::lookupOrDefault ( const word& key, const dictionary& dict, - const enum_type deflt + const EnumType deflt ) const { if (dict.found(key)) @@ -148,36 +163,49 @@ Enum Foam::NamedEnum::lookupOrDefault } -template -Foam::List Foam::NamedEnum::enums() +template +EnumType Foam::NamedEnum::read(Istream& is) const { - List lst(nEnum); + const word enumName(is); + auto iter = lookup_.cfind(enumName); - label count = 0; - for (int enumi = 0; enumi < nEnum; ++enumi) + if (!iter.found()) { - if (names[enumi] && names[enumi][0]) - { - lst[count++] = Enum(enumi); - } + FatalIOErrorInFunction(is) + << enumName << " is not in enumeration: " + << lookup_.sortedToc() << nl + << exit(FatalIOError); } - lst.setSize(count); - return lst; + return EnumType(iter.object()); } -template -Foam::stringList Foam::NamedEnum::strings() +template +void Foam::NamedEnum::write +( + const EnumType e, + Ostream& os +) const { - return getNamesList(); + const int idx = int(e); + if (idx >= 0 && idx < nEnum) + { + os << names[idx]; + } } -template -Foam::wordList Foam::NamedEnum::words() +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const NamedEnum& wrapped +) { - return getNamesList(); + return wrapped.lookup_.writeKeys(os, 10); } diff --git a/src/OpenFOAM/containers/NamedEnum/NamedEnum.H b/src/OpenFOAM/primitives/enums/NamedEnum.H similarity index 66% rename from src/OpenFOAM/containers/NamedEnum/NamedEnum.H rename to src/OpenFOAM/primitives/enums/NamedEnum.H index 0c1c0826fa..13cff4eb44 100644 --- a/src/OpenFOAM/containers/NamedEnum/NamedEnum.H +++ b/src/OpenFOAM/primitives/enums/NamedEnum.H @@ -25,9 +25,8 @@ Class Foam::NamedEnum Description - A NamedEnum is a wrapper around a static list of names that represent - a particular enumeration. Internally it uses a HashTable for quicker - lookups. + A NamedEnum is a wrapper around a list of names that represent + particular enumeration values. SourceFiles NamedEnum.C @@ -38,7 +37,6 @@ SourceFiles #define NamedEnum_H #include "HashTable.H" -#include "stringList.H" #include "wordList.H" #include @@ -46,33 +44,32 @@ SourceFiles namespace Foam { +// Forward declarations class dictionary; +template class NamedEnum; + +template +Ostream& operator<<(Ostream& os, const NamedEnum& wrapped); -// Forward declaration -template class NamedEnum; /*---------------------------------------------------------------------------*\ Class NamedEnum Declaration \*---------------------------------------------------------------------------*/ -template +template class NamedEnum -: - public HashTable { //- The nEnum must be positive (non-zero) static_assert(nEnum > 0, "nEnum must be positive (non-zero)"); - //- The type of HashTable used for the lookup. - typedef HashTable table_type; + // Private Member Data + + //- The values for the enum + HashTable lookup_; // Private Member Functions - //- The names as a list of strings - template - static List getNamesList(); - //- Disallow default bitwise copy construct NamedEnum(const NamedEnum&) = delete; @@ -83,12 +80,12 @@ class NamedEnum public: //- The type of enumeration wrapped by NamedEnum - typedef Enum enum_type; + typedef EnumType value_type; // Static data members - //- The set of names corresponding to the enumeration Enum + //- The set of names corresponding to the enumeration EnumType static const char* names[nEnum]; @@ -100,17 +97,39 @@ public: // Member Functions - //- Read a word from Istream and return the corresponding - // enumeration element - enum_type read(Istream& is) const; + // Access - //- Write the name representation of the enumeration to an Ostream - void write(const enum_type e, Ostream& os) const; + //- The number of lookup names for the enumeration + inline label size() const; + + //- The list of enum names + inline wordList toc() const; + + //- The sorted list of enum names + inline wordList sortedToc() const; + + //- The list of enum names, in construction order + wordList words() const; + + //- The list of enum values, in construction order + List values() const; + + + // Query + + //- Test if there is an enumeration corresponding to the given name. + inline bool hasEnum(const word& enumName) const; + + //- Test if there is a name corresponding to the given enumeration. + bool hasName(const EnumType e) const; + + + // Lookup //- Lookup the key in the dictionary and return the corresponding // enumeration element based on its name. // Fatal if anything is incorrect. - enum_type lookup + EnumType lookup ( const word& key, const dictionary& dict @@ -120,42 +139,42 @@ public: // enumeration element based on its name. // Return the default value if the key was not found in the dictionary. // Fatal if enumerated name was incorrect. - enum_type lookupOrDefault + EnumType lookupOrDefault ( const word& key, const dictionary& dict, - const enum_type deflt + const EnumType deflt ) const; - //- List of enumerations - static List enums(); - //- The set of names as a list of strings - static stringList strings(); + // IO - //- The set of names as a list of words - static wordList words(); + //- Read a word from Istream and return the corresponding enumeration + EnumType read(Istream& is) const; + + //- 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; // Member Operators //- Return the enumeration element corresponding to the given name - inline const enum_type operator[](const char* name) const - { - return enum_type(table_type::operator[](name)); - } - - //- Return the enumeration element corresponding to the given name - inline const enum_type operator[](const word& name) const - { - return enum_type(table_type::operator[](name)); - } + inline const EnumType operator[](const word& name) const; //- Return the name of the given enumeration element - inline const char* operator[](const enum_type e) const - { - return names[int(e)]; - } + inline const char* operator[](const EnumType e) const; + + + // IOstream operators + + //- Write names to Ostream, as per writeKeys() with shortListLen=10 + friend Ostream& operator<< + ( + Ostream& os, + const NamedEnum& wrapped + ); + }; @@ -165,6 +184,8 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "NamedEnumI.H" + #ifdef NoRepository #include "NamedEnum.C" #endif diff --git a/src/OpenFOAM/primitives/enums/NamedEnumI.H b/src/OpenFOAM/primitives/enums/NamedEnumI.H new file mode 100644 index 0000000000..2e7c91b10d --- /dev/null +++ b/src/OpenFOAM/primitives/enums/NamedEnumI.H @@ -0,0 +1,81 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline Foam::label Foam::NamedEnum::size() const +{ + return lookup_.size(); +} + + +template +inline Foam::wordList Foam::NamedEnum::toc() const +{ + return lookup_.toc(); +} + + +template +inline Foam::wordList Foam::NamedEnum::sortedToc() const +{ + return lookup_.sortedToc(); +} + + +template +inline bool Foam::NamedEnum::hasEnum +( + const word& enumName +) const +{ + return lookup_.found(enumName); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +inline const EnumType Foam::NamedEnum::operator[] +( + const word& name +) const +{ + return EnumType(lookup_[name]); +} + + +template +inline const char* Foam::NamedEnum::operator[] +( + const EnumType e +) const +{ + return names[int(e)]; +} + + +// ************************************************************************* // diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C index 8a7027a59c..50c15be701 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C @@ -111,7 +111,7 @@ Foam::tmp Foam::temperatureCoupledBase::kappa { typedef compressible::turbulenceModel turbulenceModel; - word turbName(turbulenceModel::propertiesName); + const word turbName(turbulenceModel::propertiesName); if ( @@ -205,8 +205,8 @@ Foam::tmp Foam::temperatureCoupledBase::kappa << " on mesh " << mesh.name() << " patch " << patch_.name() << nl << "Please set 'kappaMethod' to one of " - << KMethodTypeNames_.toc() - << " and 'kappa' to the name of the volScalar" + << flatOutput(KMethodTypeNames_.sortedToc()) << nl + << "and 'kappa' to the name of the volScalar" << " or volSymmTensor field (if kappaMethod=lookup)" << exit(FatalError); } @@ -219,8 +219,8 @@ Foam::tmp Foam::temperatureCoupledBase::kappa FatalErrorInFunction << "Unimplemented method " << KMethodTypeNames_[method_] << nl << "Please set 'kappaMethod' to one of " - << KMethodTypeNames_.toc() - << " and 'kappa' to the name of the volScalar" + << flatOutput(KMethodTypeNames_.sortedToc()) << nl + << "and 'kappa' to the name of the volScalar" << " or volSymmTensor field (if kappaMethod=lookup)" << exit(FatalError); } diff --git a/src/conversion/fire/FIREMeshReader.C b/src/conversion/fire/FIREMeshReader.C index e79d70b060..c57a188615 100644 --- a/src/conversion/fire/FIREMeshReader.C +++ b/src/conversion/fire/FIREMeshReader.C @@ -375,7 +375,7 @@ bool Foam::fileFormats::FIREMeshReader::readGeometry(const scalar scaleFactor) IOstream::streamFormat fmt = IOstream::ASCII; const word ext = geometryFile_.ext(); - bool supported = FIRECore::file3dExtensions.found(ext); + bool supported = FIRECore::file3dExtensions.hasEnum(ext); if (supported) { FIRECore::fileExt3d fireFileType = FIRECore::file3dExtensions[ext]; diff --git a/src/conversion/fire/FIREMeshWriter.C b/src/conversion/fire/FIREMeshWriter.C index 29746005d0..9c6146c3e0 100644 --- a/src/conversion/fire/FIREMeshWriter.C +++ b/src/conversion/fire/FIREMeshWriter.C @@ -278,7 +278,7 @@ bool Foam::fileFormats::FIREMeshWriter::write(const fileName& meshName) const { const word ext = baseName.ext(); - if (FIRECore::file3dExtensions.found(ext)) + if (FIRECore::file3dExtensions.hasEnum(ext)) { FIRECore::fileExt3d fireFileType = FIRECore::file3dExtensions[ext]; if (fireFileType == FIRECore::POLY_ASCII) diff --git a/src/finiteVolume/functionObjects/volRegion/volRegion.C b/src/finiteVolume/functionObjects/volRegion/volRegion.C index 3a0dcede22..07d4c1775e 100644 --- a/src/finiteVolume/functionObjects/volRegion/volRegion.C +++ b/src/finiteVolume/functionObjects/volRegion/volRegion.C @@ -143,7 +143,7 @@ bool Foam::functionObjects::volRegion::read { FatalIOErrorInFunction(dict) << "Unknown region type. Valid region types are:" - << regionTypeNames_ + << regionTypeNames_.toc() << exit(FatalIOError); } } diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index f28944d995..3d39aa4655 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -564,9 +564,10 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise { FatalErrorInFunction << type() << " " << name() << ": " - << regionTypeNames_[regionType_] << "(" << regionName_ << "):" + << int(regionType_) << "(" << regionName_ << "):" << nl << " Unknown region type. Valid region types are:" - << regionTypeNames_.sortedToc() << nl << exit(FatalError); + << regionTypeNames_ << nl + << exit(FatalError); } } diff --git a/src/functionObjects/field/mapFields/mapFields.C b/src/functionObjects/field/mapFields/mapFields.C index 00a387ad6e..f0d250f659 100644 --- a/src/functionObjects/field/mapFields/mapFields.C +++ b/src/functionObjects/field/mapFields/mapFields.C @@ -71,14 +71,14 @@ void Foam::functionObjects::mapFields::createInterpolation ) ); const fvMesh& mapRegion = mapRegionPtr_(); - word mapMethodName(dict.lookup("mapMethod")); - if (!meshToMesh::interpolationMethodNames_.found(mapMethodName)) + const word mapMethodName(dict.lookup("mapMethod")); + if (!meshToMesh::interpolationMethodNames_.hasEnum(mapMethodName)) { FatalErrorInFunction << type() << " " << name() << ": unknown map method " << mapMethodName << nl << "Available methods include: " - << meshToMesh::interpolationMethodNames_.sortedToc() + << meshToMesh::interpolationMethodNames_ << exit(FatalError); } diff --git a/src/functionObjects/utilities/writeObjects/writeObjects.C b/src/functionObjects/utilities/writeObjects/writeObjects.C index aad0e40554..eade946402 100644 --- a/src/functionObjects/utilities/writeObjects/writeObjects.C +++ b/src/functionObjects/utilities/writeObjects/writeObjects.C @@ -196,7 +196,8 @@ bool Foam::functionObjects::writeObjects::write() FatalErrorInFunction << "Unknown writeOption " << writeOptionNames_[writeOption_] - << ". Valid writeOption types are" << writeOptionNames_ + << ". Valid writeOption types are " + << writeOptionNames_ << exit(FatalError); } } diff --git a/src/fvOptions/cellSetOption/cellSetOption.C b/src/fvOptions/cellSetOption/cellSetOption.C index 665b98343d..929b457a7e 100644 --- a/src/fvOptions/cellSetOption/cellSetOption.C +++ b/src/fvOptions/cellSetOption/cellSetOption.C @@ -82,7 +82,8 @@ void Foam::fv::cellSetOption::setSelection(const dictionary& dict) FatalErrorInFunction << "Unknown selectionMode " << selectionModeTypeNames_[selectionMode_] - << ". Valid selectionMode types are" << selectionModeTypeNames_ + << ". Valid selectionMode types are " + << selectionModeTypeNames_ << exit(FatalError); } } @@ -186,7 +187,8 @@ void Foam::fv::cellSetOption::setCellSet() FatalErrorInFunction << "Unknown selectionMode " << selectionModeTypeNames_[selectionMode_] - << ". Valid selectionMode types are" << selectionModeTypeNames_ + << ". Valid selectionMode types are " + << selectionModeTypeNames_ << exit(FatalError); } } diff --git a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C index 7607aacf79..e0c0549f2f 100644 --- a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C +++ b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C @@ -236,7 +236,7 @@ directionalPressureGradientExplicitSource << "Did not find mode " << model_ << nl << "Please set 'model' to one of " - << PressureDropModelNames_.toc() + << PressureDropModelNames_ << exit(FatalError); } diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C index 129d5b1699..bf8594073b 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C @@ -376,7 +376,8 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem() FatalErrorInFunction << "Unknown geometryMode " << geometryModeTypeNames_[gm] << ". Available geometry modes include " - << geometryModeTypeNames_ << exit(FatalError); + << geometryModeTypeNames_ + << exit(FatalError); } } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index 1972082d78..ac6be7983d 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -1070,7 +1070,7 @@ Foam::mappedPatchBase::mappedPatchBase { offsetMode_ = offsetModeNames_.read(dict.lookup("offsetMode")); - switch(offsetMode_) + switch (offsetMode_) { case UNIFORM: { @@ -1109,7 +1109,7 @@ Foam::mappedPatchBase::mappedPatchBase ( dict ) << "Please supply the offsetMode as one of " - << NamedEnum::words() + << offsetModeNames_ << exit(FatalIOError); } } diff --git a/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C b/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C index 2935936e8b..72afb55582 100644 --- a/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C +++ b/src/regionCoupled/derivedFvPatchFields/energyRegionCoupled/energyRegionCoupledFvPatchScalarField.C @@ -134,7 +134,7 @@ kappa() const << " on mesh " << this->db().name() << " patch " << patch().name() << " could not find a method in. Methods are: " - << methodTypeNames_.toc() + << methodTypeNames_ << " Not turbulenceModel or thermophysicalProperties" << " were found" << exit(FatalError); diff --git a/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationPropertiesPatch.C b/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationPropertiesPatch.C index d5785cbbd9..369c9788a2 100644 --- a/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationPropertiesPatch.C +++ b/src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/boundaryRadiationPropertiesPatch.C @@ -222,7 +222,8 @@ Foam::radiation::boundaryRadiationPropertiesPatch::emissivity default: { FatalErrorInFunction - << "Please set 'mode' to one of " << methodTypeNames_.toc() + << "Please set 'mode' to one of " + << methodTypeNames_ << exit(FatalError); } break; @@ -302,7 +303,7 @@ Foam::radiation::boundaryRadiationPropertiesPatch::absorptivity FatalErrorInFunction << "Unimplemented method " << method_ << endl << "Please set 'mode' to one of " - << methodTypeNames_.toc() + << methodTypeNames_ << exit(FatalError); } break; @@ -382,7 +383,7 @@ Foam::radiation::boundaryRadiationPropertiesPatch::transmissivity FatalErrorInFunction << "Unimplemented method " << method_ << endl << "Please set 'mode' to one of " - << methodTypeNames_.toc() + << methodTypeNames_ << exit(FatalError); } break;