mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: relocate geometryType enum to cloud class (issue #721)
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,11 +31,19 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(cloud, 0);
|
||||
|
||||
const word cloud::prefix("lagrangian");
|
||||
word cloud::defaultName("defaultCloud");
|
||||
}
|
||||
|
||||
const Foam::word Foam::cloud::prefix("lagrangian");
|
||||
Foam::word Foam::cloud::defaultName("defaultCloud");
|
||||
|
||||
const Foam::Enum<Foam::cloud::geometryType>
|
||||
Foam::cloud::geometryTypeNames
|
||||
{
|
||||
{ geometryType::COORDINATES, "coordinates" },
|
||||
{ geometryType::POSITIONS, "positions" }
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName)
|
||||
@ -55,12 +63,6 @@ Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cloud::~cloud()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::cloud::autoMap(const mapPolyMesh&)
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::cloud
|
||||
|
||||
Description
|
||||
A cloud is a collection of lagrangian particles
|
||||
A cloud is a registry collection of lagrangian particles.
|
||||
|
||||
SourceFiles
|
||||
cloud.C
|
||||
@ -36,6 +36,7 @@ SourceFiles
|
||||
#define cloud_H
|
||||
|
||||
#include "objectRegistry.H"
|
||||
#include "Enum.H"
|
||||
#include "IOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -58,14 +59,24 @@ class cloud
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
cloud(const cloud&);
|
||||
cloud(const cloud&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const cloud&);
|
||||
void operator=(const cloud&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Cloud geometry type (internal or IO representations)
|
||||
enum class geometryType
|
||||
{
|
||||
COORDINATES, //!< barycentric coordinates
|
||||
POSITIONS //!< positions
|
||||
};
|
||||
|
||||
static const Enum<geometryType> geometryTypeNames;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("cloud");
|
||||
|
||||
@ -83,7 +94,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~cloud();
|
||||
virtual ~cloud() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -79,7 +79,7 @@ Foam::Cloud<ParticleType>::Cloud
|
||||
polyMesh_(pMesh),
|
||||
labels_(),
|
||||
globalPositionsPtr_(),
|
||||
geometryType_(IOPosition<Cloud<ParticleType>>::geometryType::COORDINATES)
|
||||
geometryType_(cloud::geometryType::COORDINATES)
|
||||
{
|
||||
checkPatches();
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ class Cloud
|
||||
protected:
|
||||
|
||||
//- Geometry type
|
||||
typename IOPosition<Cloud<ParticleType>>::geometryType geometryType_;
|
||||
cloud::geometryType geometryType_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -57,11 +57,11 @@ void Foam::Cloud<ParticleType>::readCloudUniformProperties()
|
||||
// Fall back to positions mode if the entry is not present for
|
||||
// backwards compatibility
|
||||
geometryType_ =
|
||||
IOPosition<Cloud<ParticleType>>::geometryTypeNames_.lookupOrDefault
|
||||
cloud::geometryTypeNames.lookupOrDefault
|
||||
(
|
||||
"geometry",
|
||||
uniformPropsDict,
|
||||
IOPosition<Cloud<ParticleType>>::geometryType::POSITIONS
|
||||
cloud::geometryType::POSITIONS
|
||||
);
|
||||
|
||||
const word procName("processor" + Foam::name(Pstream::myProcNo()));
|
||||
@ -104,7 +104,7 @@ void Foam::Cloud<ParticleType>::writeCloudUniformProperties() const
|
||||
uniformPropsDict.add
|
||||
(
|
||||
"geometry",
|
||||
IOPosition<Cloud<ParticleType>>::geometryTypeNames_[geometryType_]
|
||||
cloud::geometryTypeNames[geometryType_]
|
||||
);
|
||||
|
||||
forAll(np, i)
|
||||
@ -146,8 +146,8 @@ void Foam::Cloud<ParticleType>::initCloud(const bool checkClass)
|
||||
<< "Assuming the initial cloud contains 0 particles." << endl;
|
||||
}
|
||||
|
||||
// Always operate in co-ordinates mode after reading
|
||||
geometryType_ = IOPosition<Cloud<ParticleType>>::geometryType::COORDINATES;
|
||||
// Always operate in coordinates mode after reading
|
||||
geometryType_ = cloud::geometryType::COORDINATES;
|
||||
|
||||
// Ask for the tetBasePtIs to trigger all processors to build
|
||||
// them, otherwise, if some processors have no particles then
|
||||
@ -170,7 +170,7 @@ Foam::Cloud<ParticleType>::Cloud
|
||||
polyMesh_(pMesh),
|
||||
labels_(),
|
||||
cellWallFacesPtr_(),
|
||||
geometryType_(IOPosition<Cloud<ParticleType>>::geometryType::COORDINATES)
|
||||
geometryType_(cloud::geometryType::COORDINATES)
|
||||
{
|
||||
checkPatches();
|
||||
|
||||
|
||||
@ -23,31 +23,20 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
const Foam::Enum<typename Foam::IOPosition<CloudType>::geometryType>
|
||||
Foam::IOPosition<CloudType>::geometryTypeNames_
|
||||
{
|
||||
{ geometryType::POSITIONS, "positions" },
|
||||
{ geometryType::COORDINATES, "coordinates" }
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
Foam::IOPosition<CloudType>::IOPosition
|
||||
(
|
||||
const CloudType& c,
|
||||
const geometryType& geomType
|
||||
const cloud::geometryType& geomType
|
||||
)
|
||||
:
|
||||
regIOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
geometryTypeNames_[geomType],
|
||||
cloud::geometryTypeNames[geomType],
|
||||
c.time().timeName(),
|
||||
c,
|
||||
IOobject::MUST_READ,
|
||||
@ -75,16 +64,7 @@ bool Foam::IOPosition<CloudType>::writeData(Ostream& os) const
|
||||
|
||||
switch (geometryType_)
|
||||
{
|
||||
case geometryType::POSITIONS:
|
||||
{
|
||||
forAllConstIters(cloud_, iter)
|
||||
{
|
||||
iter().writePosition(os);
|
||||
os << nl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case geometryType::COORDINATES:
|
||||
case cloud::geometryType::COORDINATES:
|
||||
{
|
||||
forAllConstIters(cloud_, iter)
|
||||
{
|
||||
@ -93,6 +73,15 @@ bool Foam::IOPosition<CloudType>::writeData(Ostream& os) const
|
||||
}
|
||||
break;
|
||||
}
|
||||
case cloud::geometryType::POSITIONS:
|
||||
{
|
||||
forAllConstIters(cloud_, iter)
|
||||
{
|
||||
iter().writePosition(os);
|
||||
os << nl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
os << token::END_LIST << endl;
|
||||
@ -108,7 +97,7 @@ void Foam::IOPosition<CloudType>::readData(Istream& is, CloudType& c)
|
||||
|
||||
token firstToken(is);
|
||||
|
||||
bool newFormat = geometryType_ == geometryType::COORDINATES;
|
||||
const bool newFormat = (geometryType_ == cloud::geometryType::COORDINATES);
|
||||
|
||||
if (firstToken.isLabel())
|
||||
{
|
||||
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
#ifndef IOPosition_H
|
||||
#define IOPosition_H
|
||||
|
||||
#include "cloud.H"
|
||||
#include "regIOobject.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -52,22 +52,9 @@ class IOPosition
|
||||
:
|
||||
public regIOobject
|
||||
{
|
||||
public:
|
||||
|
||||
enum class geometryType
|
||||
{
|
||||
POSITIONS,
|
||||
COORDINATES
|
||||
};
|
||||
|
||||
static const Enum<geometryType> geometryTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
geometryType geometryType_;
|
||||
cloud::geometryType geometryType_;
|
||||
|
||||
//- Reference to the cloud
|
||||
const CloudType& cloud_;
|
||||
@ -90,7 +77,8 @@ public:
|
||||
IOPosition
|
||||
(
|
||||
const CloudType& c,
|
||||
const geometryType& geomType = geometryType::COORDINATES
|
||||
const cloud::geometryType& geomType
|
||||
= cloud::geometryType::COORDINATES
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -41,8 +41,7 @@ Foam::injectedParticleCloud::injectedParticleCloud
|
||||
:
|
||||
Cloud<injectedParticle>(mesh, cloudName, false)
|
||||
{
|
||||
geometryType_ =
|
||||
IOPosition<Cloud<injectedParticle>>::geometryType::POSITIONS;
|
||||
geometryType_ = cloud::geometryType::POSITIONS;
|
||||
|
||||
if (readFields)
|
||||
{
|
||||
|
||||
@ -40,7 +40,7 @@ License
|
||||
template<class TrackCloudType>
|
||||
void Foam::particle::readFields(TrackCloudType& c)
|
||||
{
|
||||
bool valid = c.size();
|
||||
const bool valid = c.size();
|
||||
|
||||
IOobject procIO(c.fieldIOobject("origProcId", IOobject::MUST_READ));
|
||||
|
||||
@ -70,7 +70,7 @@ void Foam::particle::readFields(TrackCloudType& c)
|
||||
template<class TrackCloudType>
|
||||
void Foam::particle::writeFields(const TrackCloudType& c)
|
||||
{
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
if (writeLagrangianCoordinates)
|
||||
{
|
||||
@ -84,7 +84,7 @@ void Foam::particle::writeFields(const TrackCloudType& c)
|
||||
IOPosition<TrackCloudType> ioP
|
||||
(
|
||||
c,
|
||||
IOPosition<TrackCloudType>::geometryType::POSITIONS
|
||||
cloud::geometryType::POSITIONS
|
||||
);
|
||||
ioP.write(np > 0);
|
||||
}
|
||||
@ -116,7 +116,7 @@ void Foam::particle::writeFields(const TrackCloudType& c)
|
||||
template<class CloudType>
|
||||
void Foam::particle::writeObjects(const CloudType& c, objectRegistry& obr)
|
||||
{
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
IOField<label>& origProc(cloud::createIOField<label>("origProc", np, obr));
|
||||
IOField<label>& origId(cloud::createIOField<label>("origId", np, obr));
|
||||
|
||||
@ -84,7 +84,7 @@ void Foam::reconstructLagrangianPositions
|
||||
IOPosition<Cloud<passiveParticle>>
|
||||
(
|
||||
lagrangianPositions,
|
||||
IOPosition<Cloud<passiveParticle>>::geometryType::POSITIONS
|
||||
cloud::geometryType::POSITIONS
|
||||
).write();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user