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:
@ -33,25 +33,25 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(meshToMesh, 0);
|
||||
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::meshToMesh::interpolationMethod,
|
||||
4
|
||||
>::names[] =
|
||||
{
|
||||
"direct",
|
||||
"mapNearest",
|
||||
"cellVolumeWeight",
|
||||
"correctedCellVolumeWeight"
|
||||
};
|
||||
|
||||
const NamedEnum<meshToMesh::interpolationMethod, 4>
|
||||
meshToMesh::interpolationMethodNames_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::meshToMesh::interpolationMethod
|
||||
>
|
||||
Foam::meshToMesh::interpolationMethodNames_
|
||||
{
|
||||
{ interpolationMethod::imDirect, "direct" },
|
||||
{ interpolationMethod::imMapNearest, "mapNearest" },
|
||||
{ interpolationMethod::imCellVolumeWeight, "cellVolumeWeight" },
|
||||
{
|
||||
interpolationMethod::imCorrectedCellVolumeWeight,
|
||||
"correctedCellVolumeWeight"
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
|
||||
@ -46,7 +46,7 @@ SourceFiles
|
||||
#include "treeBoundBox.H"
|
||||
#include "mapDistribute.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "AMIPatchToPatchInterpolation.H"
|
||||
#include "pointList.H"
|
||||
|
||||
@ -74,8 +74,7 @@ public:
|
||||
imCorrectedCellVolumeWeight
|
||||
};
|
||||
|
||||
static const NamedEnum<interpolationMethod, 4>
|
||||
interpolationMethodNames_;
|
||||
static const Enum<interpolationMethod> interpolationMethodNames_;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@ -35,6 +35,18 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::sampledTriSurfaceMesh::samplingSource
|
||||
>
|
||||
Foam::sampledTriSurfaceMesh::samplingSourceNames_
|
||||
{
|
||||
{ samplingSource::cells, "cells" },
|
||||
{ samplingSource::insideCells, "insideCells" },
|
||||
{ samplingSource::boundaryFaces, "boundaryFaces" },
|
||||
};
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sampledTriSurfaceMesh, 0);
|
||||
@ -45,18 +57,6 @@ namespace Foam
|
||||
word
|
||||
);
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<sampledTriSurfaceMesh::samplingSource, 3>::names[] =
|
||||
{
|
||||
"cells",
|
||||
"insideCells",
|
||||
"boundaryFaces"
|
||||
};
|
||||
|
||||
const NamedEnum<sampledTriSurfaceMesh::samplingSource, 3>
|
||||
sampledTriSurfaceMesh::samplingSourceNames_;
|
||||
|
||||
|
||||
//- Private class for finding nearest
|
||||
// Comprising:
|
||||
// - global index
|
||||
@ -685,7 +685,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
|
||||
false
|
||||
)
|
||||
),
|
||||
sampleSource_(samplingSourceNames_[dict.lookup("source")]),
|
||||
sampleSource_(samplingSourceNames_.lookup("source", dict)),
|
||||
needsUpdate_(true),
|
||||
keepIds_(dict.lookupOrDefault<Switch>("keepIds", false)),
|
||||
originalIds_(),
|
||||
|
||||
@ -108,7 +108,7 @@ private:
|
||||
|
||||
// Private data
|
||||
|
||||
static const NamedEnum<samplingSource, 3> samplingSourceNames_;
|
||||
static const Enum<samplingSource> samplingSourceNames_;
|
||||
|
||||
//- Surface to sample on
|
||||
const triSurfaceMesh surface_;
|
||||
|
||||
@ -38,31 +38,32 @@ namespace Foam
|
||||
|
||||
// Create write methods
|
||||
defineSurfaceWriterWriteFields(nastranSurfaceWriter);
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<nastranSurfaceWriter::writeFormat, 3>::names[] =
|
||||
{
|
||||
"short",
|
||||
"long",
|
||||
"free"
|
||||
};
|
||||
|
||||
|
||||
const NamedEnum<nastranSurfaceWriter::writeFormat, 3>
|
||||
nastranSurfaceWriter::writeFormatNames_;
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<nastranSurfaceWriter::dataFormat, 2>::names[] =
|
||||
{
|
||||
"PLOAD2",
|
||||
"PLOAD4"
|
||||
};
|
||||
|
||||
const NamedEnum<nastranSurfaceWriter::dataFormat, 2>
|
||||
nastranSurfaceWriter::dataFormatNames_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::nastranSurfaceWriter::writeFormat
|
||||
>
|
||||
Foam::nastranSurfaceWriter::writeFormatNames_
|
||||
{
|
||||
{ writeFormat::wfShort, "short" },
|
||||
{ writeFormat::wfLong, "long" },
|
||||
{ writeFormat::wfFree, "free" },
|
||||
};
|
||||
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::nastranSurfaceWriter::dataFormat
|
||||
>
|
||||
Foam::nastranSurfaceWriter::dataFormatNames_
|
||||
{
|
||||
{ dataFormat::dfPLOAD2, "PLOAD2" },
|
||||
{ dataFormat::dfPLOAD4, "PLOAD4" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::nastranSurfaceWriter::formatOS(Ostream& os) const
|
||||
@ -405,18 +406,17 @@ Foam::nastranSurfaceWriter::nastranSurfaceWriter()
|
||||
Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options)
|
||||
:
|
||||
surfaceWriter(),
|
||||
writeFormat_(wfLong),
|
||||
writeFormat_(writeFormat::wfLong),
|
||||
fieldMap_(),
|
||||
scale_(options.lookupOrDefault("scale", 1.0)),
|
||||
separator_("")
|
||||
{
|
||||
if (options.found("format"))
|
||||
{
|
||||
writeFormat_ = writeFormatNames_.read
|
||||
(
|
||||
options.lookup("format")
|
||||
);
|
||||
}
|
||||
writeFormat_ = writeFormatNames_.lookupOrDefault
|
||||
(
|
||||
"format",
|
||||
options,
|
||||
writeFormat::wfLong
|
||||
);
|
||||
|
||||
if (writeFormat_ == wfFree)
|
||||
{
|
||||
|
||||
@ -56,7 +56,7 @@ SourceFiles
|
||||
#define nastranSurfaceWriter_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "OFstream.H"
|
||||
#include "HashTable.H"
|
||||
|
||||
@ -93,8 +93,8 @@ private:
|
||||
|
||||
// Private data
|
||||
|
||||
static const NamedEnum<writeFormat, 3> writeFormatNames_;
|
||||
static const NamedEnum<dataFormat, 2> dataFormatNames_;
|
||||
static const Enum<writeFormat> writeFormatNames_;
|
||||
static const Enum<dataFormat> dataFormatNames_;
|
||||
|
||||
//- Write option
|
||||
writeFormat writeFormat_;
|
||||
|
||||
@ -35,22 +35,22 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::discreteSurface::samplingSource
|
||||
>
|
||||
Foam::discreteSurface::samplingSourceNames_
|
||||
{
|
||||
{ samplingSource::cells, "cells" },
|
||||
{ samplingSource::insideCells, "insideCells" },
|
||||
{ samplingSource::boundaryFaces, "boundaryFaces" },
|
||||
};
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(discreteSurface, 0);
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<discreteSurface::samplingSource, 3>::names[] =
|
||||
{
|
||||
"cells",
|
||||
"insideCells",
|
||||
"boundaryFaces"
|
||||
};
|
||||
|
||||
const NamedEnum<discreteSurface::samplingSource, 3>
|
||||
discreteSurface::samplingSourceNames_;
|
||||
|
||||
|
||||
//- Private class for finding nearest
|
||||
// Comprising:
|
||||
// - global index
|
||||
@ -686,7 +686,7 @@ Foam::discreteSurface::discreteSurface
|
||||
false
|
||||
)
|
||||
),
|
||||
sampleSource_(samplingSourceNames_[dict.lookup("source")]),
|
||||
sampleSource_(samplingSourceNames_.lookup("source", dict)),
|
||||
needsUpdate_(true),
|
||||
keepIds_(dict.lookupOrDefault<Switch>("keepIds", false)),
|
||||
originalIds_(),
|
||||
|
||||
@ -107,7 +107,7 @@ private:
|
||||
|
||||
// Private data
|
||||
|
||||
static const NamedEnum<samplingSource, 3> samplingSourceNames_;
|
||||
static const Enum<samplingSource> samplingSourceNames_;
|
||||
|
||||
//- Reference to mesh
|
||||
const polyMesh& mesh_;
|
||||
|
||||
Reference in New Issue
Block a user