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

This commit is contained in:
Mark Olesen
2017-07-03 21:43:33 +02:00
parent 575073890f
commit f55c568f13
179 changed files with 1595 additions and 2035 deletions

View File

@ -50,13 +50,16 @@ namespace functionObjects
}
}
const Foam::Enum<Foam::functionObjects::externalCoupled::stateEnd>
Foam::functionObjects::externalCoupled::stateEndNames_
{
{ stateEnd::REMOVE, "remove" },
{ stateEnd::DONE, "done" }
// 'IGNORE' is internal use only and thus without a name
};
const Foam::Enum
<
Foam::functionObjects::externalCoupled::stateEnd
>
Foam::functionObjects::externalCoupled::stateEndNames_
{
{ stateEnd::REMOVE, "remove" },
{ stateEnd::DONE, "done" }
// 'IGNORE' is internal use only and thus without a name
};
Foam::word Foam::functionObjects::externalCoupled::lockName = "OpenFOAM";

View File

@ -37,18 +37,16 @@ const Foam::word Foam::functionObjects::fieldAverageItem::EXT_PRIME2MEAN
"Prime2Mean"
);
template<>
const char* Foam::NamedEnum
<
Foam::functionObjects::fieldAverageItem::baseType,
2
>::names[] = { "iteration", "time"};
const Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::fieldAverageItem::baseType,
2
> Foam::functionObjects::fieldAverageItem::baseTypeNames_;
Foam::functionObjects::fieldAverageItem::baseType
>
Foam::functionObjects::fieldAverageItem::baseTypeNames_
{
{ baseType::ITER, "iteration" },
{ baseType::TIME, "time" },
};
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View File

@ -50,7 +50,7 @@ SourceFiles
#ifndef fieldAverageItem_H
#define fieldAverageItem_H
#include "NamedEnum.H"
#include "Enum.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -119,7 +119,7 @@ private:
word prime2MeanFieldName_;
//- Averaging base type names
static const NamedEnum<baseType, 2> baseTypeNames_;
static const Enum<baseType> baseTypeNames_;
//- Averaging base type
baseType base_;

View File

@ -47,7 +47,7 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem(Istream& is)
fieldName_ = entry.keyword();
mean_ = readBool(entry.lookup("mean"));
prime2Mean_ = readBool(entry.lookup("prime2Mean"));
base_ = baseTypeNames_[entry.lookup("base")];
base_ = baseTypeNames_.lookup("base", entry);
window_ = entry.lookupOrDefault<scalar>("window", -1.0);
windowName_ = entry.lookupOrDefault<word>("windowName", "");
@ -77,7 +77,7 @@ Foam::Istream& Foam::functionObjects::operator>>
faItem.fieldName_ = entry.keyword();
faItem.mean_ = readBool(entry.lookup("mean"));
faItem.prime2Mean_ = readBool(entry.lookup("prime2Mean"));
faItem.base_ = faItem.baseTypeNames_[entry.lookup("base")];
faItem.base_ = faItem.baseTypeNames_.lookup("base", entry);
faItem.window_ = entry.lookupOrDefault<scalar>("window", -1.0);
faItem.windowName_ = entry.lookupOrDefault<word>("windowName", "");

View File

@ -38,18 +38,15 @@ namespace functionObjects
}
}
template<>
const char* Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::fieldMinMax::modeType,
2
>::names[] = {"magnitude", "component"};
const Foam::NamedEnum
<
Foam::functionObjects::fieldMinMax::modeType,
2
> Foam::functionObjects::fieldMinMax::modeTypeNames_;
Foam::functionObjects::fieldMinMax::modeType
>
Foam::functionObjects::fieldMinMax::modeTypeNames_
{
{ modeType::mdMag, "magnitude" },
{ modeType::mdCmpt, "component" },
};
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -126,7 +123,7 @@ bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
location_ = dict.lookupOrDefault<Switch>("location", true);
mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")];
mode_ = modeTypeNames_.lookupOrDefault("mode", dict, modeType::mdMag);
dict.lookup("fields") >> fieldSet_;
return true;

View File

@ -78,7 +78,7 @@ SourceFiles
#define functionObjects_fieldMinMax_H
#include "Switch.H"
#include "NamedEnum.H"
#include "Enum.H"
#include "fvMeshFunctionObject.H"
#include "writeFile.H"
#include "vector.H"
@ -115,7 +115,7 @@ protected:
// Protected data
//- Mode type names
static const NamedEnum<modeType, 2> modeTypeNames_;
static const Enum<modeType> modeTypeNames_;
//- Switch to write location of min/max values
Switch location_;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,24 +40,19 @@ namespace fieldValues
}
}
template<>
const char* Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::fieldValues::fieldValueDelta::operationType,
5
>::names[] =
Foam::functionObjects::fieldValues::fieldValueDelta::operationType
>
Foam::functionObjects::fieldValues::fieldValueDelta::operationTypeNames_
{
"add",
"subtract",
"min",
"max",
"average"
{ operationType::opAdd, "add" },
{ operationType::opSubtract, "subtract" },
{ operationType::opMin, "min" },
{ operationType::opMax, "max" },
{ operationType::opAverage, "average" },
};
const Foam::NamedEnum
<
Foam::functionObjects::fieldValues::fieldValueDelta::operationType,
5
> Foam::functionObjects::fieldValues::fieldValueDelta::operationTypeNames_;
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
@ -151,7 +146,7 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::read
).ptr()
);
operation_ = operationTypeNames_.read(dict.lookup("operation"));
operation_ = operationTypeNames_.lookup("operation", dict);
return true;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,6 +85,7 @@ SourceFiles
#include "stateFunctionObject.H"
#include "writeFile.H"
#include "fieldValue.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -116,7 +117,7 @@ public:
};
//- Operation type names
static const NamedEnum<operationType, 5> operationTypeNames_;
static const Enum<operationType> operationTypeNames_;
private:

View File

@ -49,75 +49,54 @@ namespace fieldValues
}
}
template<>
const char* Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes,
4
>::names[] =
{
"faceZone",
"patch",
"surface",
"sampledSurface"
};
template<>
const char* Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
17
>::names[] =
{
"none",
"sum",
"weightedSum",
"sumMag",
"sumDirection",
"sumDirectionBalance",
"average",
"weightedAverage",
"areaAverage",
"weightedAreaAverage",
"areaIntegrate",
"weightedAreaIntegrate",
"min",
"max",
"CoV",
"areaNormalAverage",
"areaNormalIntegrate"
};
template<>
const char* Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationType,
2
>::names[] =
{
"none",
"sqrt"
};
const Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes,
4
> Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypeNames_;
const Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType,
17
> Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_;
const Foam::NamedEnum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationType,
2
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes
>
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationTypeNames_;
Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypeNames_
{
{ regionTypes::stFaceZone, "faceZone" },
{ regionTypes::stPatch, "patch" },
{ regionTypes::stSurface, "surface" },
{ regionTypes::stSampledSurface, "sampledSurface" },
};
const Foam::Enum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::operationType
>
Foam::functionObjects::fieldValues::surfaceFieldValue::operationTypeNames_
{
{ operationType::opNone, "none" },
{ operationType::opSum, "sum" },
{ operationType::opWeightedSum, "weightedSum" },
{ operationType::opSumMag, "sumMag" },
{ operationType::opSumDirection, "sumDirection" },
{ operationType::opSumDirectionBalance, "sumDirectionBalance" },
{ operationType::opAverage, "average" },
{ operationType::opWeightedAverage, "weightedAverage" },
{ operationType::opAreaAverage, "areaAverage" },
{ operationType::opWeightedAreaAverage, "weightedAreaAverage" },
{ operationType::opAreaIntegrate, "areaIntegrate" },
{ operationType::opWeightedAreaIntegrate, "weightedAreaIntegrate" },
{ operationType::opMin, "min" },
{ operationType::opMax, "max" },
{ operationType::opCoV, "CoV" },
{ operationType::opAreaNormalAverage, "areaNormalAverage" },
{ operationType::opAreaNormalIntegrate, "areaNormalIntegrate" },
};
const Foam::Enum
<
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationType
>
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationTypeNames_
{
{ postOperationType::postOpNone, "none" },
{ postOperationType::postOpSqrt, "sqrt" },
};
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -832,12 +811,16 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
)
:
fieldValue(name, runTime, dict, typeName),
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
operation_(operationTypeNames_.read(dict.lookup("operation"))),
regionType_(regionTypeNames_.lookup("regionType", dict)),
operation_(operationTypeNames_.lookup("operation", dict)),
postOperation_
(
postOperationTypeNames_
[dict.lookupOrDefault<word>("postOperation", "none")]
postOperationTypeNames_.lookupOrDefault
(
"postOperation",
dict,
postOperationType::postOpNone
)
),
weightFieldName_("none"),
writeArea_(dict.lookupOrDefault("writeArea", false)),
@ -859,12 +842,16 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
)
:
fieldValue(name, obr, dict, typeName),
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
operation_(operationTypeNames_.read(dict.lookup("operation"))),
regionType_(regionTypeNames_.lookup("regionType", dict)),
operation_(operationTypeNames_.lookup("operation", dict)),
postOperation_
(
postOperationTypeNames_
[dict.lookupOrDefault<word>("postOperation", "none")]
postOperationTypeNames_.lookupOrDefault
(
"postOperation",
dict,
postOperationType::postOpNone
)
),
weightFieldName_("none"),
writeArea_(dict.lookupOrDefault("writeArea", false)),

View File

@ -156,7 +156,7 @@ SourceFiles
#define functionObjects_surfaceFieldValue_H
#include "fieldValue.H"
#include "NamedEnum.H"
#include "Enum.H"
#include "meshedSurf.H"
#include "surfaceMesh.H"
#include "fvsPatchField.H"
@ -198,7 +198,7 @@ public:
};
//- Region type names
static const NamedEnum<regionTypes, 4> regionTypeNames_;
static const Enum<regionTypes> regionTypeNames_;
//- Operation type enumeration
@ -224,7 +224,7 @@ public:
};
//- Operation type names
static const NamedEnum<operationType, 17> operationTypeNames_;
static const Enum<operationType> operationTypeNames_;
//- Post-operation type enumeration
@ -235,7 +235,7 @@ public:
};
//- Operation type names
static const NamedEnum<postOperationType, 2> postOperationTypeNames_;
static const Enum<postOperationType> postOperationTypeNames_;
private:

View File

@ -43,35 +43,27 @@ namespace fieldValues
}
}
template<>
const char*
Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::fieldValues::volFieldValue::operationType,
13
>::names[] =
Foam::functionObjects::fieldValues::volFieldValue::operationType
>
Foam::functionObjects::fieldValues::volFieldValue::operationTypeNames_
{
"none",
"sum",
"weightedSum",
"sumMag",
"average",
"weightedAverage",
"volAverage",
"weightedVolAverage",
"volIntegrate",
"weightedVolIntegrate",
"min",
"max",
"CoV"
{ operationType::opNone, "none" },
{ operationType::opSum, "sum" },
{ operationType::opWeightedSum, "weightedSum" },
{ operationType::opSumMag, "sumMag" },
{ operationType::opAverage, "average" },
{ operationType::opWeightedAverage, "weightedAverage" },
{ operationType::opVolAverage, "volAverage" },
{ operationType::opWeightedVolAverage, "weightedVolAverage" },
{ operationType::opVolIntegrate, "volIntegrate" },
{ operationType::opWeightedVolIntegrate, "weightedVolIntegrate" },
{ operationType::opMin, "min" },
{ operationType::opMax, "max" },
{ operationType::opCoV, "CoV" },
};
const Foam::NamedEnum
<
Foam::functionObjects::fieldValues::volFieldValue::operationType,
13
> Foam::functionObjects::fieldValues::volFieldValue::operationTypeNames_;
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -198,7 +190,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
:
fieldValue(name, runTime, dict, typeName),
volRegion(fieldValue::mesh_, dict),
operation_(operationTypeNames_.read(dict.lookup("operation"))),
operation_(operationTypeNames_.lookup("operation", dict)),
weightFieldName_("none")
{
read(dict);
@ -215,7 +207,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
:
fieldValue(name, obr, dict, typeName),
volRegion(fieldValue::mesh_, dict),
operation_(operationTypeNames_.read(dict.lookup("operation"))),
operation_(operationTypeNames_.lookup("operation", dict)),
weightFieldName_("none")
{
read(dict);

View File

@ -153,7 +153,7 @@ public:
};
//- Operation type names
static const NamedEnum<operationType, 13> operationTypeNames_;
static const Enum<operationType> operationTypeNames_;
protected:

View File

@ -52,24 +52,20 @@ namespace functionObjects
dictionary
);
}
template<>
const char* NamedEnum
<
functionObjects::fluxSummary::modeType,
5
>::names[] =
{
"faceZone",
"faceZoneAndDirection",
"cellZoneAndDirection",
"surface",
"surfaceAndDirection"
};
}
const Foam::NamedEnum<Foam::functionObjects::fluxSummary::modeType, 5>
Foam::functionObjects::fluxSummary::modeTypeNames_;
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 * * * * * * * * * * * //
@ -823,7 +819,7 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
fvMeshFunctionObject::read(dict);
writeFile::read(dict);
mode_ = modeTypeNames_.read(dict.lookup("mode"));
mode_ = modeTypeNames_.lookup("mode", dict);
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
scaleFactor_ = dict.lookupOrDefault<scalar>("scaleFactor", 1.0);
tolerance_ = dict.lookupOrDefault<scalar>("tolerance", 0.8);

View File

@ -124,7 +124,7 @@ public:
};
//- Mode type names
static const NamedEnum<modeType, 5> modeTypeNames_;
static const Enum<modeType> modeTypeNames_;
protected:

View File

@ -48,7 +48,10 @@ namespace functionObjects
}
const Foam::Enum<Foam::functionObjects::setFlow::modeType>
const Foam::Enum
<
Foam::functionObjects::setFlow::modeType
>
Foam::functionObjects::setFlow::modeTypeNames
{
{ functionObjects::setFlow::modeType::FUNCTION, "function" },

View File

@ -110,7 +110,7 @@ class setFlow
VORTEX3D
};
static const Foam::Enum<modeType> modeTypeNames;
static const Enum<modeType> modeTypeNames;
// Private Data

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -45,51 +45,39 @@ namespace functionObjects
}
}
template<>
const char* Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::turbulenceFields::compressibleField,
9
>::names[] =
Foam::functionObjects::turbulenceFields::compressibleField
>
Foam::functionObjects::turbulenceFields::compressibleFieldNames_
{
"k",
"epsilon",
"omega",
"mut",
"muEff",
"alphat",
"alphaEff",
"R",
"devRhoReff"
{ compressibleField::cfK, "k" },
{ compressibleField::cfEpsilon, "epsilon" },
{ compressibleField::cfOmega, "omega" },
{ compressibleField::cfMut, "mut" },
{ compressibleField::cfMuEff, "muEff" },
{ compressibleField::cfAlphat, "alphat" },
{ compressibleField::cfAlphaEff, "alphaEff" },
{ compressibleField::cfR, "R" },
{ compressibleField::cfDevRhoReff, "devRhoReff" },
};
const Foam::NamedEnum
<
Foam::functionObjects::turbulenceFields::compressibleField,
9
> Foam::functionObjects::turbulenceFields::compressibleFieldNames_;
template<>
const char* Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::turbulenceFields::incompressibleField,
7
>::names[] =
Foam::functionObjects::turbulenceFields::incompressibleField
>
Foam::functionObjects::turbulenceFields::incompressibleFieldNames_
{
"k",
"epsilon",
"omega",
"nut",
"nuEff",
"R",
"devReff"
{ incompressibleField::ifK, "k" },
{ incompressibleField::ifEpsilon, "epsilon" },
{ incompressibleField::ifOmega, "omega" },
{ incompressibleField::ifNut, "nut" },
{ incompressibleField::ifNuEff, "nuEff" },
{ incompressibleField::ifR, "R" },
{ incompressibleField::ifDevReff, "devReff" },
};
const Foam::NamedEnum
<
Foam::functionObjects::turbulenceFields::incompressibleField,
7
> Foam::functionObjects::turbulenceFields::incompressibleFieldNames_;
const Foam::word Foam::functionObjects::turbulenceFields::modelName
(

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -90,7 +90,7 @@ SourceFiles
#include "fvMeshFunctionObject.H"
#include "HashSet.H"
#include "NamedEnum.H"
#include "Enum.H"
#include "volFieldsFwd.H"
#include "Switch.H"
@ -123,7 +123,7 @@ public:
cfR,
cfDevRhoReff
};
static const NamedEnum<compressibleField, 9> compressibleFieldNames_;
static const Enum<compressibleField> compressibleFieldNames_;
enum incompressibleField
{
@ -135,7 +135,7 @@ public:
ifR,
ifDevReff
};
static const NamedEnum<incompressibleField, 7> incompressibleFieldNames_;
static const Enum<incompressibleField> incompressibleFieldNames_;
static const word modelName;

View File

@ -47,46 +47,27 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam
const Foam::Enum
<
Foam::functionObjects::fieldVisualisationBase::colourByType
>
Foam::functionObjects::fieldVisualisationBase::colourByTypeNames
{
template<>
const char* NamedEnum
<
functionObjects::fieldVisualisationBase::colourByType,
2
>::names[] =
{
"colour",
"field"
};
{ colourByType::cbColour, "colour" },
{ colourByType::cbField, "field" },
};
template<>
const char* NamedEnum
<
functionObjects::fieldVisualisationBase::colourMapType,
4
>::names[] =
{
"rainbow",
"blueWhiteRed",
"fire",
"greyscale"
};
}
const Foam::NamedEnum
<
Foam::functionObjects::fieldVisualisationBase::colourByType,
2
>
Foam::functionObjects::fieldVisualisationBase::colourByTypeNames;
const Foam::NamedEnum
<
Foam::functionObjects::fieldVisualisationBase::colourMapType,
4
>
Foam::functionObjects::fieldVisualisationBase::colourMapTypeNames;
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 * * * * * * * * * * * //
@ -508,7 +489,7 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase
colourMap_(cmRainbow),
range_()
{
colourBy_ = colourByTypeNames.read(dict.lookup("colourBy"));
colourBy_ = colourByTypeNames.lookup("colourBy", dict);
switch (colourBy_)
{
@ -523,7 +504,7 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase
if (dict.found("colourMap"))
{
colourMap_ = colourMapTypeNames.read(dict.lookup("colourMap"));
colourMap_ = colourMapTypeNames.lookup("colourMap", dict);
}
const dictionary& sbarDict = dict.subDict("scalarBar");

View File

@ -37,7 +37,7 @@ SourceFiles
#include "dictionary.H"
#include "Tuple2.H"
#include "NamedEnum.H"
#include "Enum.H"
#include "vector.H"
#include "HashPtrTable.H"
#include "Function1.H"
@ -78,7 +78,7 @@ public:
cbField
};
static const NamedEnum<colourByType, 2> colourByTypeNames;
static const Enum<colourByType> colourByTypeNames;
enum colourMapType
{
@ -88,7 +88,7 @@ public:
cmGreyscale
};
static const NamedEnum<colourMapType, 4> colourMapTypeNames;
static const Enum<colourMapType> colourMapTypeNames;
private:

View File

@ -32,27 +32,16 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* NamedEnum
<
functionObjects::runTimePostPro::geometryBase::renderModeType,
3
>::names[] =
{
"flat",
"gouraud",
"phong"
};
}
const Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::runTimePostPro::geometryBase::renderModeType,
3
Foam::functionObjects::runTimePostPro::geometryBase::renderModeType
>
Foam::functionObjects::runTimePostPro::geometryBase::renderModeTypeNames;
Foam::functionObjects::runTimePostPro::geometryBase::renderModeTypeNames
{
{ renderModeType::rmFlat, "flat" },
{ renderModeType::rmGouraud, "gouraud" },
{ renderModeType::rmPhong, "phong" },
};
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -104,7 +93,7 @@ Foam::functionObjects::runTimePostPro::geometryBase::geometryBase
{
if (dict.found("renderMode"))
{
renderMode_ = renderModeTypeNames.read(dict.lookup("renderMode"));
renderMode_ = renderModeTypeNames.lookup("renderMode", dict);
}
if (dict.found("opacity"))

View File

@ -39,7 +39,7 @@ SourceFiles
#include "vector.H"
#include "Function1.H"
#include "HashPtrTable.H"
#include "NamedEnum.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -75,7 +75,7 @@ public:
rmPhong //!< Phong shading
};
static const NamedEnum<renderModeType, 3> renderModeTypeNames;
static const Enum<renderModeType> renderModeTypeNames;
private:

View File

@ -48,27 +48,19 @@ namespace runTimePostPro
defineRunTimeSelectionTable(pathline, dictionary);
}
}
template<>
const char* NamedEnum
<
functionObjects::runTimePostPro::pathline::representationType,
4
>::names[] =
{
"none",
"line",
"tube",
"vector"
};
}
const Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::runTimePostPro::pathline::representationType,
4
Foam::functionObjects::runTimePostPro::pathline::representationType
>
Foam::functionObjects::runTimePostPro::pathline::representationTypeNames;
Foam::functionObjects::runTimePostPro::pathline::representationTypeNames
{
{ representationType::rtNone, "none" },
{ representationType::rtLine, "line" },
{ representationType::rtTube, "tube" },
{ representationType::rtVector, "vector" },
};
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -137,7 +129,7 @@ Foam::functionObjects::runTimePostPro::pathline::pathline
geometryBase(parent, dict, colours),
representation_
(
representationTypeNames.read(dict.lookup("representation"))
representationTypeNames.lookup("representation", dict)
),
tubeRadius_(0.0),
lineColour_(nullptr)

View File

@ -35,7 +35,7 @@ SourceFiles
#define functionObjects_runTimePostPro_pathline_H
#include "geometryBase.H"
#include "NamedEnum.H"
#include "Enum.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -71,7 +71,7 @@ public:
rtVector
};
static const NamedEnum<representationType, 4> representationTypeNames;
static const Enum<representationType> representationTypeNames;
private:

View File

@ -48,24 +48,17 @@ namespace runTimePostPro
defineRunTimeSelectionTable(pointData, dictionary);
}
}
template<>
const char* NamedEnum
<
functionObjects::runTimePostPro::pointData::representationType,
2
>::names[] =
{
"sphere",
"vector"
};
}
const Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::runTimePostPro::pointData::representationType,
2
Foam::functionObjects::runTimePostPro::pointData::representationType
>
Foam::functionObjects::runTimePostPro::pointData::representationTypeNames;
Foam::functionObjects::runTimePostPro::pointData::representationTypeNames
{
{ representationType::rtSphere, "sphere" },
{ representationType::rtVector, "vector" },
};
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -106,7 +99,7 @@ Foam::functionObjects::runTimePostPro::pointData::pointData
geometryBase(parent, dict, colours),
representation_
(
representationTypeNames.read(dict.lookup("representation"))
representationTypeNames.lookup("representation", dict)
),
maxGlyphLength_(readScalar(dict.lookup("maxGlyphLength"))),
pointColour_(nullptr)

View File

@ -35,7 +35,7 @@ SourceFiles
#define functionObjects_runTimePostPro_pointData_H
#include "geometryBase.H"
#include "NamedEnum.H"
#include "Enum.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -69,7 +69,7 @@ public:
rtVector //!< Vector
};
static const NamedEnum<representationType, 2> representationTypeNames;
static const Enum<representationType> representationTypeNames;
private:

View File

@ -62,7 +62,7 @@ SourceFiles
#include "vector.H"
#include "point.H"
#include "boundBox.H"
#include "NamedEnum.H"
#include "Enum.H"
#include "HashPtrTable.H"
#include "vector.H"

View File

@ -48,27 +48,21 @@ namespace runTimePostPro
defineRunTimeSelectionTable(surface, dictionary);
}
}
template<>
const char* NamedEnum
<
functionObjects::runTimePostPro::surface::representationType,
5
>::names[] =
{
"none",
"wireframe",
"surface",
"surfaceWithEdges",
"glyph"
};
}
const Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::runTimePostPro::surface::representationType,
5
Foam::functionObjects::runTimePostPro::surface::representationType
>
Foam::functionObjects::runTimePostPro::surface::representationTypeNames;
Foam::functionObjects::runTimePostPro::surface::representationTypeNames
{
{ representationType::rtNone, "none" },
{ representationType::rtWireframe, "wireframe" },
{ representationType::rtSurface, "surface" },
{ representationType::rtSurfaceWithEdges, "surfaceWithEdges" },
{ representationType::rtGlyph, "glyph" },
};
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -155,7 +149,7 @@ Foam::functionObjects::runTimePostPro::surface::surface
geometryBase(parent, dict, colours),
representation_
(
representationTypeNames.read(dict.lookup("representation"))
representationTypeNames.lookup("representation", dict)
),
featureEdges_(false),
surfaceColour_(nullptr),

View File

@ -35,7 +35,7 @@ SourceFiles
#define functionObjects_runTimePostPro_surface_H
#include "geometryBase.H"
#include "NamedEnum.H"
#include "Enum.H"
#include "runTimeSelectionTables.H"
#include "vtkSmartPointer.h"
@ -74,7 +74,7 @@ public:
rtGlyph
};
static const NamedEnum<representationType, 5> representationTypeNames;
static const Enum<representationType> representationTypeNames;
private:

View File

@ -48,23 +48,17 @@ namespace functionObjects
}
}
template<>
const char* Foam::NamedEnum
<
Foam::functionObjects::abort::actionType,
3
>::names[] =
{
"noWriteNow",
"writeNow",
"nextWrite"
};
const Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::abort::actionType,
3
> Foam::functionObjects::abort::actionTypeNames_;
Foam::Time::stopAtControls
>
Foam::functionObjects::abort::actionNames_
{
{ Time::stopAtControls::saNoWriteNow, "noWriteNow" },
{ Time::stopAtControls::saWriteNow, "writeNow" },
{ Time::stopAtControls::saNextWrite, "nextWrite" },
};
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -94,7 +88,7 @@ Foam::functionObjects::abort::abort
functionObject(name),
time_(runTime),
abortFile_("$FOAM_CASE/" + name),
action_(nextWrite)
action_(Time::stopAtControls::saNextWrite)
{
abortFile_.expand();
read(dict);
@ -116,14 +110,12 @@ bool Foam::functionObjects::abort::read(const dictionary& dict)
{
functionObject::read(dict);
if (dict.found("action"))
{
action_ = actionTypeNames_.read(dict.lookup("action"));
}
else
{
action_ = nextWrite;
}
action_ = actionNames_.lookupOrDefault
(
"action",
dict,
Time::stopAtControls::saNextWrite
);
if (dict.readIfPresent("file", abortFile_))
{
@ -143,9 +135,9 @@ bool Foam::functionObjects::abort::execute()
{
switch (action_)
{
case noWriteNow :
case Time::saNoWriteNow :
{
if (time_.stopAt(Time::saNoWriteNow))
if (time_.stopAt(action_))
{
Info<< "USER REQUESTED ABORT (timeIndex="
<< time_.timeIndex()
@ -155,9 +147,9 @@ bool Foam::functionObjects::abort::execute()
break;
}
case writeNow :
case Time::saWriteNow :
{
if (time_.stopAt(Time::saWriteNow))
if (time_.stopAt(action_))
{
Info<< "USER REQUESTED ABORT (timeIndex="
<< time_.timeIndex()
@ -167,9 +159,9 @@ bool Foam::functionObjects::abort::execute()
break;
}
case nextWrite :
case Time::saNextWrite :
{
if (time_.stopAt(Time::saNextWrite))
if (time_.stopAt(action_))
{
Info<< "USER REQUESTED ABORT (timeIndex="
<< time_.timeIndex()
@ -178,6 +170,11 @@ bool Foam::functionObjects::abort::execute()
}
break;
}
default:
{
// Invalid choices already filtered out by Enum
}
}
}

View File

@ -45,7 +45,7 @@ SourceFiles
#define functionObjects_abort_H
#include "functionObject.H"
#include "NamedEnum.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -62,33 +62,19 @@ class abort
:
public functionObject
{
public:
// Public data
//- Enumeration defining the type of action
enum actionType
{
noWriteNow, //!< stop immediately without writing data
writeNow, //!< write data and stop immediately
nextWrite //!< stop the next time data are written
};
private:
// Private data
//- A subset of Time stopAtControls
static const Enum<Time::stopAtControls> actionNames_;
//- Reference to the Time
const Time& time_;
//- The fully-qualified name of the abort file
fileName abortFile_;
//- Action type names
static const NamedEnum<actionType, 3> actionTypeNames_;
//- The type of action
actionType action_;
Time::stopAtControls action_;
// Private Member Functions
@ -97,10 +83,10 @@ private:
void removeFile() const;
//- Disallow default bitwise copy construct
abort(const abort&);
abort(const abort&) = delete;
//- Disallow default bitwise assignment
void operator=(const abort&);
void operator=(const abort&) = delete;
public:
@ -127,7 +113,7 @@ public:
// Member Functions
//- Read the dictionary settings
virtual bool read(const dictionary&);
virtual bool read(const dictionary& dict);
//- Execute, check existence of abort file and take action
virtual bool execute();

View File

@ -47,32 +47,21 @@ namespace runTimeControls
}
}
}
template<>
const char* Foam::NamedEnum
<
Foam
::functionObjects
::runTimeControls
::equationInitialResidualCondition
::operatingMode,
2
>::names[] =
{
"minimum",
"maximum"
};
const Foam::NamedEnum
const Foam::Enum
<
Foam
::functionObjects
::runTimeControls
::equationInitialResidualCondition
::operatingMode,
2
::operatingMode
>
Foam::functionObjects::runTimeControls::equationInitialResidualCondition::
operatingModeNames;
operatingModeNames
{
{ operatingMode::omMin, "minimum" },
{ operatingMode::omMax, "maximum" },
};
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -90,7 +79,7 @@ equationInitialResidualCondition
fieldNames_(dict.lookup("fields")),
value_(readScalar(dict.lookup("value"))),
timeStart_(dict.lookupOrDefault("timeStart", -GREAT)),
mode_(operatingModeNames.read(dict.lookup("mode")))
mode_(operatingModeNames.lookup("mode", dict))
{
if (fieldNames_.size())
{

View File

@ -37,7 +37,7 @@ SourceFiles
#define functionObjects_runTimeControls_equationInitialResidualCondition_H
#include "runTimeCondition.H"
#include "NamedEnum.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -64,7 +64,7 @@ public:
omMax //!< Maximum
};
static const NamedEnum<operatingMode, 2> operatingModeNames;
static const Enum<operatingMode> operatingModeNames;
protected:

View File

@ -57,27 +57,19 @@ namespace runTimeControls
}
}
template<>
const char* Foam::NamedEnum
<
Foam::functionObjects::runTimeControls::minMaxCondition::modeType,
2
>::names[] =
{
"minimum",
"maximum"
};
const Foam::NamedEnum
const Foam::Enum
<
Foam
::functionObjects
::runTimeControls
::minMaxCondition
::modeType,
2
::modeType
>
Foam::functionObjects::runTimeControls::minMaxCondition::modeTypeNames_;
Foam::functionObjects::runTimeControls::minMaxCondition::modeTypeNames_
{
{ modeType::mdMin, "minimum" },
{ modeType::mdMax, "maximum" },
};
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -92,7 +84,7 @@ Foam::functionObjects::runTimeControls::minMaxCondition::minMaxCondition
:
runTimeCondition(name, obr, dict, state),
functionObjectName_(dict.lookup("functionObject")),
mode_(modeTypeNames_.read(dict.lookup("mode"))),
mode_(modeTypeNames_.lookup("mode", dict)),
fieldNames_(dict.lookup("fields")),
value_(readScalar(dict.lookup("value")))
{}

View File

@ -38,7 +38,7 @@ SourceFiles
#define functionObjects_runTimeControls_minMaxCondition_H
#include "runTimeCondition.H"
#include "NamedEnum.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -68,7 +68,7 @@ public:
mdMax //!< Maximum
};
static const NamedEnum<modeType, 2> modeTypeNames_;
static const Enum<modeType> modeTypeNames_;
protected:

View File

@ -37,7 +37,6 @@ SourceFiles
#define functionObjects_runTimeConditions_minTimeStepCondition_H
#include "runTimeCondition.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -45,24 +45,17 @@ namespace functionObjects
}
}
template<>
const char* Foam::NamedEnum
const Foam::Enum
<
Foam::functionObjects::writeObjects::writeOption,
3
>::names[] =
Foam::functionObjects::writeObjects::writeOption
>
Foam::functionObjects::writeObjects::writeOptionNames_
{
"autoWrite",
"noWrite",
"anyWrite"
{ writeOption::AUTO_WRITE, "autoWrite" },
{ writeOption::NO_WRITE, "noWrite" },
{ writeOption::ANY_WRITE, "anyWrite" },
};
const Foam::NamedEnum
<
Foam::functionObjects::writeObjects::writeOption,
3
> Foam::functionObjects::writeObjects::writeOptionNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -114,14 +107,12 @@ bool Foam::functionObjects::writeObjects::read(const dictionary& dict)
dict.lookup("objects") >> objectNames_;
}
if (dict.found("writeOption"))
{
writeOption_ = writeOptionNames_.read(dict.lookup("writeOption"));
}
else
{
writeOption_ = ANY_WRITE;
}
writeOption_ = writeOptionNames_.lookupOrDefault
(
"writeOption",
dict,
writeOption::ANY_WRITE
);
return true;
}

View File

@ -84,8 +84,8 @@ SourceFiles
#define functionObjects_writeObjects_H
#include "functionObject.H"
#include "wordReList.H"
#include "NamedEnum.H"
#include "wordRes.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -119,7 +119,7 @@ public:
ANY_WRITE
};
static const NamedEnum<writeOption, 3> writeOptionNames_;
static const Enum<writeOption> writeOptionNames_;
private:
@ -138,10 +138,10 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
writeObjects(const writeObjects&);
writeObjects(const writeObjects&) = delete;
//- Disallow default bitwise assignment
void operator=(const writeObjects&);
void operator=(const writeObjects&) = delete;
public: