mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: reduce storage requirement for volumeType
- char instead of integer representation for the enumeration. - additional constructor as lookupOrDefault from dictionary entry.
This commit is contained in:
@ -32,7 +32,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(conformationSurfaces, 0);
|
||||
defineTypeNameAndDebug(conformationSurfaces, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -71,8 +71,7 @@ void Foam::conformationSurfaces::hasBoundedVolume
|
||||
|
||||
referenceVolumeTypes[s] = vTypes[0];
|
||||
|
||||
Info<< " is "
|
||||
<< volumeType::names[referenceVolumeTypes[s]]
|
||||
Info<< " is " << referenceVolumeTypes[s].str()
|
||||
<< " surface " << surface.name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "volumeType.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -34,12 +35,33 @@ const Foam::Enum
|
||||
Foam::volumeType::names
|
||||
{
|
||||
{ type::UNKNOWN, "unknown" },
|
||||
{ type::MIXED, "mixed" },
|
||||
{ type::INSIDE, "inside" },
|
||||
{ type::OUTSIDE, "outside" },
|
||||
{ type::MIXED, "mixed" },
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::volumeType::volumeType
|
||||
(
|
||||
const word& key,
|
||||
const dictionary& dict,
|
||||
const type deflt
|
||||
)
|
||||
:
|
||||
t_(names.lookupOrDefault(key, dict, deflt))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word& Foam::volumeType::str() const
|
||||
{
|
||||
return names[t_];
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, volumeType& vt)
|
||||
@ -47,10 +69,10 @@ Foam::Istream& Foam::operator>>(Istream& is, volumeType& vt)
|
||||
// Read beginning of volumeType
|
||||
is.readBegin("volumeType");
|
||||
|
||||
int type;
|
||||
is >> type;
|
||||
int val;
|
||||
is >> val;
|
||||
|
||||
vt.t_ = static_cast<volumeType::type>(type);
|
||||
vt.t_ = static_cast<volumeType::type>(val);
|
||||
|
||||
// Read end of volumeType
|
||||
is.readEnd("volumeType");
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,6 +25,8 @@ Class
|
||||
Foam::volumeType
|
||||
|
||||
Description
|
||||
An enumeration wrapper for classification of a location as being
|
||||
inside/outside of a volume.
|
||||
|
||||
SourceFiles
|
||||
volumeType.C
|
||||
@ -41,8 +43,8 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
// Forward declarations
|
||||
class dictionary;
|
||||
class volumeType;
|
||||
Istream& operator>>(Istream& is, volumeType& vt);
|
||||
Ostream& operator<<(Ostream& os, const volumeType& vt);
|
||||
@ -56,16 +58,18 @@ class volumeType
|
||||
{
|
||||
public:
|
||||
|
||||
//- Volume types
|
||||
enum type
|
||||
//- Volume classification types
|
||||
enum type : char
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
MIXED = 1,
|
||||
INSIDE = 2,
|
||||
OUTSIDE = 3
|
||||
UNKNOWN = 0, //!< Unknown state
|
||||
INSIDE = 0x1, //!< A location inside the volume
|
||||
OUTSIDE = 0x2, //!< A location outside the volume
|
||||
MIXED = 0x3 //!< A location that is partly inside and outside
|
||||
};
|
||||
|
||||
// Static data
|
||||
|
||||
//- Names for the classification enumeration
|
||||
static const Enum<volumeType> names;
|
||||
|
||||
|
||||
@ -81,18 +85,21 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
//- Construct null as UNKNOWN state
|
||||
volumeType()
|
||||
:
|
||||
t_(UNKNOWN)
|
||||
{}
|
||||
|
||||
//- Construct from components
|
||||
//- Construct from enumeration
|
||||
volumeType(type t)
|
||||
:
|
||||
t_(t)
|
||||
{}
|
||||
|
||||
//- Construct as lookupOrDefault by name from dictionary
|
||||
volumeType(const word& key, const dictionary& dict, const type deflt);
|
||||
|
||||
//- Construct from integer
|
||||
explicit volumeType(const int t)
|
||||
:
|
||||
@ -102,11 +109,15 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the enumeration
|
||||
operator type() const
|
||||
{
|
||||
return t_;
|
||||
}
|
||||
|
||||
//- The string representation of the volume type enumeration
|
||||
const word& str() const;
|
||||
|
||||
|
||||
// IOstream operators
|
||||
|
||||
|
||||
@ -227,14 +227,9 @@ Foam::refinementSurfaces::refinementSurfaces
|
||||
"gapLevel",
|
||||
nullGapLevel
|
||||
);
|
||||
globalGapMode[surfI] = volumeType::names
|
||||
[
|
||||
dict.lookupOrDefault<word>
|
||||
(
|
||||
"gapMode",
|
||||
volumeType::names[volumeType::MIXED]
|
||||
)
|
||||
];
|
||||
globalGapMode[surfI] =
|
||||
volumeType("gapMode", dict, volumeType::MIXED);
|
||||
|
||||
if
|
||||
(
|
||||
globalGapMode[surfI] == volumeType::UNKNOWN
|
||||
@ -248,7 +243,7 @@ Foam::refinementSurfaces::refinementSurfaces
|
||||
<< "Illegal gapLevel specification for surface "
|
||||
<< names_[surfI]
|
||||
<< " : gapLevel:" << globalGapLevel[surfI]
|
||||
<< " gapMode:" << volumeType::names[globalGapMode[surfI]]
|
||||
<< " gapMode:" << globalGapMode[surfI].str()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
@ -327,14 +322,9 @@ Foam::refinementSurfaces::refinementSurfaces
|
||||
regionGapLevel[surfI].insert(regionI, gapSpec);
|
||||
volumeType gapModeSpec
|
||||
(
|
||||
volumeType::names
|
||||
[
|
||||
regionDict.lookupOrDefault<word>
|
||||
(
|
||||
"gapMode",
|
||||
volumeType::names[volumeType::MIXED]
|
||||
)
|
||||
]
|
||||
"gapMode",
|
||||
regionDict,
|
||||
volumeType::MIXED
|
||||
);
|
||||
regionGapMode[surfI].insert(regionI, gapModeSpec);
|
||||
if
|
||||
@ -350,7 +340,7 @@ Foam::refinementSurfaces::refinementSurfaces
|
||||
<< "Illegal gapLevel specification for surface "
|
||||
<< names_[surfI]
|
||||
<< " : gapLevel:" << gapSpec
|
||||
<< " gapMode:" << volumeType::names[gapModeSpec]
|
||||
<< " gapMode:" << gapModeSpec.str()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -682,19 +682,9 @@ Foam::shellSurfaces::shellSurfaces
|
||||
extendedGapLevel_[shellI].setSize(regionNames.size());
|
||||
extendedGapLevel_[shellI] = gapSpec;
|
||||
|
||||
volumeType gapModeSpec
|
||||
(
|
||||
volumeType::names
|
||||
[
|
||||
dict.lookupOrDefault<word>
|
||||
(
|
||||
"gapMode",
|
||||
volumeType::names[volumeType::MIXED]
|
||||
)
|
||||
]
|
||||
);
|
||||
extendedGapMode_[shellI].setSize(regionNames.size());
|
||||
extendedGapMode_[shellI] = gapModeSpec;
|
||||
extendedGapMode_[shellI] =
|
||||
volumeType("gapMode", dict, volumeType::MIXED);
|
||||
|
||||
|
||||
// Override on a per-region basis?
|
||||
@ -721,23 +711,17 @@ Foam::shellSurfaces::shellSurfaces
|
||||
);
|
||||
extendedGapLevel_[shellI][regionI] = gapSpec;
|
||||
|
||||
volumeType gapModeSpec
|
||||
(
|
||||
volumeType::names
|
||||
[
|
||||
regionDict.lookupOrDefault<word>
|
||||
(
|
||||
"gapMode",
|
||||
volumeType::names[volumeType::MIXED]
|
||||
)
|
||||
]
|
||||
);
|
||||
extendedGapMode_[shellI][regionI] = gapModeSpec;
|
||||
extendedGapMode_[shellI][regionI] =
|
||||
volumeType
|
||||
(
|
||||
"gapMode",
|
||||
regionDict,
|
||||
volumeType::MIXED
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkGapLevels(dict, shellI, extendedGapLevel_[shellI]);
|
||||
|
||||
shellI++;
|
||||
|
||||
@ -644,8 +644,7 @@ void Foam::searchableSurfacesQueries::signedDistance
|
||||
<< " point:" << surfPoints[i]
|
||||
<< " surface:"
|
||||
<< allSurfaces[surfacesToTest[testI]].name()
|
||||
<< " volType:"
|
||||
<< volumeType::names[vT]
|
||||
<< " volType:" << vT.str()
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user