diff --git a/src/OpenFOAM/fields/cloud/cloud.C b/src/OpenFOAM/fields/cloud/cloud.C index 172d6aac74..6d0aeb3dc0 100644 --- a/src/OpenFOAM/fields/cloud/cloud.C +++ b/src/OpenFOAM/fields/cloud/cloud.C @@ -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::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&) diff --git a/src/OpenFOAM/fields/cloud/cloud.H b/src/OpenFOAM/fields/cloud/cloud.H index 844cb9db4e..eab0f39042 100644 --- a/src/OpenFOAM/fields/cloud/cloud.H +++ b/src/OpenFOAM/fields/cloud/cloud.H @@ -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 geometryTypeNames; + + //- Runtime type information TypeName("cloud"); @@ -83,7 +94,7 @@ public: //- Destructor - virtual ~cloud(); + virtual ~cloud() = default; // Member Functions diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index d5da7fe151..a70703ca3e 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -79,7 +79,7 @@ Foam::Cloud::Cloud polyMesh_(pMesh), labels_(), globalPositionsPtr_(), - geometryType_(IOPosition>::geometryType::COORDINATES) + geometryType_(cloud::geometryType::COORDINATES) { checkPatches(); diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index 33d554c977..e1ce3d2ba6 100644 --- a/src/lagrangian/basic/Cloud/Cloud.H +++ b/src/lagrangian/basic/Cloud/Cloud.H @@ -109,7 +109,7 @@ class Cloud protected: //- Geometry type - typename IOPosition>::geometryType geometryType_; + cloud::geometryType geometryType_; public: diff --git a/src/lagrangian/basic/Cloud/CloudIO.C b/src/lagrangian/basic/Cloud/CloudIO.C index d5fe11ace8..9f600de036 100644 --- a/src/lagrangian/basic/Cloud/CloudIO.C +++ b/src/lagrangian/basic/Cloud/CloudIO.C @@ -57,11 +57,11 @@ void Foam::Cloud::readCloudUniformProperties() // Fall back to positions mode if the entry is not present for // backwards compatibility geometryType_ = - IOPosition>::geometryTypeNames_.lookupOrDefault + cloud::geometryTypeNames.lookupOrDefault ( "geometry", uniformPropsDict, - IOPosition>::geometryType::POSITIONS + cloud::geometryType::POSITIONS ); const word procName("processor" + Foam::name(Pstream::myProcNo())); @@ -104,7 +104,7 @@ void Foam::Cloud::writeCloudUniformProperties() const uniformPropsDict.add ( "geometry", - IOPosition>::geometryTypeNames_[geometryType_] + cloud::geometryTypeNames[geometryType_] ); forAll(np, i) @@ -146,8 +146,8 @@ void Foam::Cloud::initCloud(const bool checkClass) << "Assuming the initial cloud contains 0 particles." << endl; } - // Always operate in co-ordinates mode after reading - geometryType_ = IOPosition>::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::Cloud polyMesh_(pMesh), labels_(), cellWallFacesPtr_(), - geometryType_(IOPosition>::geometryType::COORDINATES) + geometryType_(cloud::geometryType::COORDINATES) { checkPatches(); diff --git a/src/lagrangian/basic/IOPosition/IOPosition.C b/src/lagrangian/basic/IOPosition/IOPosition.C index 959db07300..2a1cd0e917 100644 --- a/src/lagrangian/basic/IOPosition/IOPosition.C +++ b/src/lagrangian/basic/IOPosition/IOPosition.C @@ -23,31 +23,20 @@ License \*---------------------------------------------------------------------------*/ -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -template -const Foam::Enum::geometryType> -Foam::IOPosition::geometryTypeNames_ -{ - { geometryType::POSITIONS, "positions" }, - { geometryType::COORDINATES, "coordinates" } -}; - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::IOPosition::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::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::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::readData(Istream& is, CloudType& c) token firstToken(is); - bool newFormat = geometryType_ == geometryType::COORDINATES; + const bool newFormat = (geometryType_ == cloud::geometryType::COORDINATES); if (firstToken.isLabel()) { diff --git a/src/lagrangian/basic/IOPosition/IOPosition.H b/src/lagrangian/basic/IOPosition/IOPosition.H index 4f1ef401f4..ad96bc8dd0 100644 --- a/src/lagrangian/basic/IOPosition/IOPosition.H +++ b/src/lagrangian/basic/IOPosition/IOPosition.H @@ -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 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 ); diff --git a/src/lagrangian/basic/injectedParticle/injectedParticleCloud.C b/src/lagrangian/basic/injectedParticle/injectedParticleCloud.C index 91a4e49884..fa505da426 100644 --- a/src/lagrangian/basic/injectedParticle/injectedParticleCloud.C +++ b/src/lagrangian/basic/injectedParticle/injectedParticleCloud.C @@ -41,8 +41,7 @@ Foam::injectedParticleCloud::injectedParticleCloud : Cloud(mesh, cloudName, false) { - geometryType_ = - IOPosition>::geometryType::POSITIONS; + geometryType_ = cloud::geometryType::POSITIONS; if (readFields) { diff --git a/src/lagrangian/basic/particle/particleTemplates.C b/src/lagrangian/basic/particle/particleTemplates.C index 71472677d2..a96ba9f381 100644 --- a/src/lagrangian/basic/particle/particleTemplates.C +++ b/src/lagrangian/basic/particle/particleTemplates.C @@ -40,7 +40,7 @@ License template 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 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 ioP ( c, - IOPosition::geometryType::POSITIONS + cloud::geometryType::POSITIONS ); ioP.write(np > 0); } @@ -116,7 +116,7 @@ void Foam::particle::writeFields(const TrackCloudType& c) template void Foam::particle::writeObjects(const CloudType& c, objectRegistry& obr) { - label np = c.size(); + const label np = c.size(); IOField