Commit f55c568f authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: upgrade from NamedEnum to Enum (issue #515)

parent 57507389
......@@ -43,26 +43,17 @@ using namespace Foam::constant::mathematical;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* Foam::NamedEnum
const Foam::Enum
<
Foam::compressible::
alphatWallBoilingWallFunctionFvPatchScalarField::phaseType,
2
>::names[] =
{
"vapor",
"liquid"
};
const Foam::NamedEnum
<
Foam::compressible::
alphatWallBoilingWallFunctionFvPatchScalarField::phaseType,
2
alphatWallBoilingWallFunctionFvPatchScalarField::phaseType
>
Foam::compressible::
alphatWallBoilingWallFunctionFvPatchScalarField::phaseTypeNames_;
alphatWallBoilingWallFunctionFvPatchScalarField::phaseTypeNames_
{
{ phaseType::vaporPhase, "vapor" },
{ phaseType::liquidPhase, "liquid" },
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -111,7 +102,7 @@ alphatWallBoilingWallFunctionFvPatchScalarField
)
:
alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField(p, iF, dict),
phaseType_(phaseTypeNames_.read(dict.lookup("phaseType"))),
phaseType_(phaseTypeNames_.lookup("phaseType", dict)),
relax_(dict.lookupOrDefault<scalar>("relax", 0.5)),
AbyV_(p.size(), 0),
alphatConv_(p.size(), 0),
......
......@@ -164,7 +164,7 @@ private:
// Private data
//- Heat source type names
static const NamedEnum<phaseType, 2> phaseTypeNames_;
static const Enum<phaseType> phaseTypeNames_;
//- Heat source type
phaseType phaseType_;
......
......@@ -69,18 +69,12 @@ enum ExtrudeMode
SURFACE
};
namespace Foam
static const Enum<ExtrudeMode> ExtrudeModeNames
{
template<>
const char* NamedEnum<ExtrudeMode, 3>::names[] =
{
"mesh",
"patch",
"surface"
};
}
static const NamedEnum<ExtrudeMode, 3> ExtrudeModeNames;
{ ExtrudeMode::MESH, "mesh" },
{ ExtrudeMode::PATCH, "patch" },
{ ExtrudeMode::SURFACE, "surface" },
};
void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
......@@ -305,9 +299,10 @@ int main(int argc, char *argv[])
const Switch flipNormals(dict.lookup("flipNormals"));
// What to extrude
const ExtrudeMode mode = ExtrudeModeNames.read
const ExtrudeMode mode = ExtrudeModeNames.lookup
(
dict.lookup("constructFrom")
"constructFrom",
dict
);
// Any merging of small edges
......
......@@ -60,17 +60,11 @@ enum ExtrudeMode
MESHEDSURFACE
};
namespace Foam
static const Enum<ExtrudeMode> ExtrudeModeNames
{
template<>
const char* NamedEnum<ExtrudeMode, 2>::names[] =
{
"polyMesh2D",
"MeshedSurface"
};
}
static const NamedEnum<ExtrudeMode, 2> ExtrudeModeNames;
{ ExtrudeMode::POLYMESH2D, "polyMesh2D" },
{ ExtrudeMode::MESHEDSURFACE, "MeshedSurface" },
};
//pointField moveInitialPoints
......
......@@ -42,24 +42,20 @@ License
namespace Foam
{
defineTypeNameAndDebug(conformalVoronoiMesh, 0);
template<>
const char* NamedEnum
<
conformalVoronoiMesh::dualMeshPointType,
5
>::names[] =
{
"internal",
"surface",
"featureEdge",
"featurePoint",
"constrained"
};
}
const Foam::NamedEnum<Foam::conformalVoronoiMesh::dualMeshPointType, 5>
Foam::conformalVoronoiMesh::dualMeshPointTypeNames_;
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 * * * * * * * * * * * * //
......
......@@ -122,7 +122,7 @@ public:
constrained = 4
};
static const NamedEnum<dualMeshPointType, 5> dualMeshPointTypeNames_;
static const Enum<dualMeshPointType> dualMeshPointTypeNames_;
private:
......
......@@ -27,20 +27,19 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char*
Foam::NamedEnum<Foam::indexedCellEnum::cellTypes, 6>::names[] =
const Foam::Enum
<
Foam::indexedCellEnum::cellTypes
>
Foam::indexedCellEnum::cellTypesNames_
{
"Unassigned",
"Internal",
"Surface",
"FeatureEdge",
"FeaturePoint",
"Far"
{ cellTypes::ctUnassigned, "Unassigned" },
{ cellTypes::ctFar, "Far" },
{ cellTypes::ctInternal, "Internal" },
{ cellTypes::ctSurface, "Surface" },
{ cellTypes::ctFeatureEdge, "FeatureEdge" },
{ cellTypes::ctFeaturePoint,"FeaturePoint" },
};
const Foam::NamedEnum<Foam::indexedCellEnum::cellTypes, 6>
cellTypesNames_;
// ************************************************************************* //
......@@ -34,7 +34,7 @@ SourceFiles
#ifndef indexedCellEnum_H
#define indexedCellEnum_H
#include "NamedEnum.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -47,7 +47,6 @@ class indexedCellEnum
{
public:
enum cellTypes
{
ctUnassigned = INT_MIN,
......@@ -58,7 +57,7 @@ public:
ctFeaturePoint = INT_MIN + 5
};
static const Foam::NamedEnum<cellTypes, 6> cellTypesNames_;
static const Enum<cellTypes> cellTypesNames_;
};
......
......@@ -28,42 +28,42 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char*
Foam::NamedEnum<Foam::indexedVertexEnum::vertexType, 15>::names[] =
const Foam::Enum
<
Foam::indexedVertexEnum::vertexType
>
Foam::indexedVertexEnum::vertexTypeNames_
{
"Unassigned",
"Internal",
"InternalNearBoundary",
"InternalSurface",
"InternalSurfaceBaffle",
"ExternalSurfaceBaffle",
"InternalFeatureEdge",
"InternalFeatureEdgeBaffle",
"ExternalFeatureEdgeBaffle",
"InternalFeaturePoint",
"ExternalSurface",
"ExternalFeatureEdge",
"ExternalFeaturePoint",
"Far",
"Constrained"
{ vertexType::vtUnassigned, "Unassigned" },
{ vertexType::vtInternal, "Internal" },
{ vertexType::vtInternalNearBoundary, "InternalNearBoundary" },
{ vertexType::vtInternalSurface, "InternalSurface" },
{ vertexType::vtInternalSurfaceBaffle, "InternalSurfaceBaffle" },
{ vertexType::vtExternalSurfaceBaffle, "ExternalSurfaceBaffle" },
{ vertexType::vtInternalFeatureEdge, "InternalFeatureEdge" },
{ vertexType::vtInternalFeatureEdgeBaffle, "InternalFeatureEdgeBaffle" },
{ vertexType::vtExternalFeatureEdgeBaffle, "ExternalFeatureEdgeBaffle" },
{ vertexType::vtInternalFeaturePoint, "InternalFeaturePoint" },
{ vertexType::vtExternalSurface, "ExternalSurface" },
{ vertexType::vtExternalFeatureEdge, "ExternalFeatureEdge" },
{ vertexType::vtExternalFeaturePoint, "ExternalFeaturePoint" },
{ vertexType::vtFar, "Far" },
{ vertexType::vtConstrained, "Constrained" },
};
const Foam::NamedEnum<Foam::indexedVertexEnum::vertexType, 15>
Foam::indexedVertexEnum::vertexTypeNames_;
template<>
const char*
Foam::NamedEnum<Foam::indexedVertexEnum::vertexMotion, 2>::names[] =
const Foam::Enum
<
Foam::indexedVertexEnum::vertexMotion
>
Foam::indexedVertexEnum::vertexMotionNames_
{
"fixed",
"movable"
{ vertexMotion::fixed, "fixed" },
{ vertexMotion::movable, "movable" },
};
const Foam::NamedEnum<Foam::indexedVertexEnum::vertexMotion, 2>
vertexMotionNames_;
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
......
......@@ -34,7 +34,7 @@ SourceFiles
#ifndef indexedVertexEnum_H
#define indexedVertexEnum_H
#include "NamedEnum.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -72,9 +72,9 @@ public:
movable = 1
};
static const Foam::NamedEnum<vertexType, 15> vertexTypeNames_;
static const Enum<vertexType> vertexTypeNames_;
static const Foam::NamedEnum<vertexMotion, 2> vertexMotionNames_;
static const Enum<vertexMotion> vertexMotionNames_;
friend Ostream& operator<<(Foam::Ostream&, const vertexType&);
......
......@@ -848,7 +848,7 @@ int main(int argc, char *argv[])
(
meshRefinement::readFlags
(
meshRefinement::IOdebugTypeNames,
meshRefinement::debugTypeNames,
flags
)
);
......@@ -873,7 +873,7 @@ int main(int argc, char *argv[])
(
meshRefinement::readFlags
(
meshRefinement::IOwriteTypeNames,
meshRefinement::writeTypeNames,
flags
)
)
......@@ -892,7 +892,7 @@ int main(int argc, char *argv[])
(
meshRefinement::readFlags
(
meshRefinement::IOoutputTypeNames,
meshRefinement::outputTypeNames,
flags
)
)
......
......@@ -33,23 +33,14 @@ License
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::vector::components,
3
>::names[] =
{
"x",
"y",
"z"
};
}
const Foam::NamedEnum<Foam::vector::components, 3>
Foam::channelIndex::vectorComponentsNames_;
const Foam::Enum
<
Foam::vector::components
>
Foam::channelIndex::vectorComponentsNames_
(
Foam::vector::components::X, { "x", "y", "z" }
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -233,7 +224,7 @@ Foam::channelIndex::channelIndex
)
:
symmetric_(readBool(dict.lookup("symmetric"))),
dir_(vectorComponentsNames_.read(dict.lookup("component")))
dir_(vectorComponentsNames_.lookup("component", dict))
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
......
......@@ -55,7 +55,7 @@ class channelIndex
// Private data
static const NamedEnum<vector::components, 3> vectorComponentsNames_;
static const Enum<vector::components> vectorComponentsNames_;
//- Is mesh symmetric
const bool symmetric_;
......
......@@ -29,24 +29,19 @@ License
#include "polyMesh.H"
#include "regionProperties.H"
using namespace Foam;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
const Foam::Enum
<
Foam::solverTemplate::solverType
>
Foam::solverTemplate::solverTypeNames_
{
template<>
const char* Foam::NamedEnum<Foam::solverTemplate::solverType, 4>::names[] =
{
"compressible",
"incompressible",
"buoyant",
"unknown"
};
}
const Foam::NamedEnum<Foam::solverTemplate::solverType, 4>
Foam::solverTemplate::solverTypeNames_;
{ solverType::stCompressible, "compressible" },
{ solverType::stIncompressible, "incompressible" },
{ solverType::stBuoyant, "buoyant" },
{ solverType::stUnknown, "unknown" },
};
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -261,7 +256,7 @@ Foam::solverTemplate::solverTemplate
Info<< "Selecting " << solverName << ": ";
solverType_ = solverTypeNames_.read(solverDict.lookup("solverType"));
solverType_ = solverTypeNames_.lookup("solverType", solverDict);
Info<< solverTypeNames_[solverType_];
multiRegion_ = readBool(solverDict.lookup("multiRegion"));
......@@ -366,7 +361,7 @@ bool Foam::solverTemplate::multiRegion() const
}
label Foam::solverTemplate::nRegion() const
Foam::label Foam::solverTemplate::nRegion() const
{
return regionTypes_.size();
}
......
......@@ -36,7 +36,7 @@ Description
#include "wordList.H"
#include "dimensionSet.H"
#include "IOobject.H"
#include "NamedEnum.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -65,7 +65,7 @@ public:
};
//- Solver type names
static const NamedEnum<solverType, 4> solverTypeNames_;
static const Enum<solverType> solverTypeNames_;
private:
......
......@@ -59,7 +59,12 @@ class shapeSelector
static const Foam::Enum<shapeType> shapeTypeNames;
};
const Foam::Enum<shapeSelector::shapeType> shapeSelector::shapeTypeNames
const Foam::Enum
<
shapeSelector::shapeType
>
shapeSelector::shapeTypeNames
{
{ shapeSelector::shapeType::PLANE, "plane" },
{ shapeSelector::shapeType::SPHERE, "sphere" },
......
......@@ -41,22 +41,16 @@ namespace Foam
dictionary
);
}
template<>
const char* Foam::NamedEnum
<
Foam::tabulatedWallFunctions::general::interpolationType,
1
>::names[] =
{
"linear"
};
}
const
Foam::NamedEnum<Foam::tabulatedWallFunctions::general::interpolationType, 1>
Foam::tabulatedWallFunctions::general::interpolationTypeNames_;
const Foam::Enum
<
Foam::tabulatedWallFunctions::general::interpolationType
>
Foam::tabulatedWallFunctions::general::interpolationTypeNames_
{
{ interpolationType::itLinear, "linear" },
};
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
......@@ -138,7 +132,7 @@ Foam::tabulatedWallFunctions::general::general
)
:
tabulatedWallFunction(dict, mesh, typeName),
interpType_(interpolationTypeNames_[coeffDict_.lookup("interpType")]),
interpType_(interpolationTypeNames_.lookup("interpType", coeffDict_)),
yPlus_(),
uPlus_(),
log10YPlus_(coeffDict_.lookup("log10YPlus")),
......
......@@ -63,7 +63,7 @@ SourceFiles
#define general_H
#include "tabulatedWallFunction.H"
#include "NamedEnum.H"
#include "Enum.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -91,7 +91,7 @@ public:
itLinear
};
static const NamedEnum<interpolationType, 1> interpolationTypeNames_;
static const Enum<interpolationType> interpolationTypeNames_;
protected:
......
......@@ -45,25 +45,22 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //