mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: upgrade from NamedEnum to Enum (issue #515)
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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)),
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -153,7 +153,7 @@ public:
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 13> operationTypeNames_;
|
||||
static const Enum<operationType> operationTypeNames_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user