diff --git a/src/OpenFOAM/fields/cloud/cloud.C b/src/OpenFOAM/fields/cloud/cloud.C index 172d6aac743c9ff6580d358fcea921bca0d897f7..6d0aeb3dc029c0b9b04bc5e8392aff6b8b32bfbb 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::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&) diff --git a/src/OpenFOAM/fields/cloud/cloud.H b/src/OpenFOAM/fields/cloud/cloud.H index 844cb9db4e5d71ac886e5ddcc90139e2eb2c2785..eab0f39042281fccef78af3ba4d61936fd514847 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<geometryType> 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 d5da7fe151075098e5641ad04798c13253b620a2..a70703ca3e39f8d1b7feb699f02d051b6d21dcd4 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -79,7 +79,7 @@ Foam::Cloud<ParticleType>::Cloud polyMesh_(pMesh), labels_(), globalPositionsPtr_(), - geometryType_(IOPosition<Cloud<ParticleType>>::geometryType::COORDINATES) + geometryType_(cloud::geometryType::COORDINATES) { checkPatches(); diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index 33d554c977b43bcca2231736bdec3825b0518611..e1ce3d2ba6e45691b0521fa8b1bdd2eeb4b7f0cf 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<Cloud<ParticleType>>::geometryType geometryType_; + cloud::geometryType geometryType_; public: diff --git a/src/lagrangian/basic/Cloud/CloudIO.C b/src/lagrangian/basic/Cloud/CloudIO.C index d5fe11ace8e11c295c055daad1890d9e5cfc3740..9f600de03690fd3ff3b19c4d4be9c925ced006ef 100644 --- a/src/lagrangian/basic/Cloud/CloudIO.C +++ b/src/lagrangian/basic/Cloud/CloudIO.C @@ -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(); diff --git a/src/lagrangian/basic/IOPosition/IOPosition.C b/src/lagrangian/basic/IOPosition/IOPosition.C index 959db07300a3819f46c876b201d3f507277b7436..2a1cd0e917ace8177b063e6cb5fb15188520a9d0 100644 --- a/src/lagrangian/basic/IOPosition/IOPosition.C +++ b/src/lagrangian/basic/IOPosition/IOPosition.C @@ -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,20 +64,20 @@ bool Foam::IOPosition<CloudType>::writeData(Ostream& os) const switch (geometryType_) { - case geometryType::POSITIONS: + case cloud::geometryType::COORDINATES: { forAllConstIters(cloud_, iter) { - iter().writePosition(os); + iter().writeCoordinates(os); os << nl; } break; } - case geometryType::COORDINATES: + case cloud::geometryType::POSITIONS: { forAllConstIters(cloud_, iter) { - iter().writeCoordinates(os); + iter().writePosition(os); os << nl; } break; @@ -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()) { diff --git a/src/lagrangian/basic/IOPosition/IOPosition.H b/src/lagrangian/basic/IOPosition/IOPosition.H index 4f1ef401f4d1a00cef1d1afa1f03f5ec70d746d5..ad96bc8dd0975e1dd90d1a2ea3c9ba673893b4b3 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<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 ); diff --git a/src/lagrangian/basic/injectedParticle/injectedParticleCloud.C b/src/lagrangian/basic/injectedParticle/injectedParticleCloud.C index 91a4e498848501ad981fe3b143549e98339e38c8..fa505da426749331daaf53526d86925cbee457a2 100644 --- a/src/lagrangian/basic/injectedParticle/injectedParticleCloud.C +++ b/src/lagrangian/basic/injectedParticle/injectedParticleCloud.C @@ -41,8 +41,7 @@ Foam::injectedParticleCloud::injectedParticleCloud : Cloud<injectedParticle>(mesh, cloudName, false) { - geometryType_ = - IOPosition<Cloud<injectedParticle>>::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 71472677d20d41e1ce926ebfac8315d1ea73a33c..a96ba9f381c0b0a8c4a3178243121a7ab983920a 100644 --- a/src/lagrangian/basic/particle/particleTemplates.C +++ b/src/lagrangian/basic/particle/particleTemplates.C @@ -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)); diff --git a/src/parallel/reconstruct/reconstruct/reconstructLagrangianPositions.C b/src/parallel/reconstruct/reconstruct/reconstructLagrangianPositions.C index 30622183ec0c1b462716955ab04e5229088780cf..1b5d017ef3b63b0b5d7b06022928c5a2b5d254d8 100644 --- a/src/parallel/reconstruct/reconstruct/reconstructLagrangianPositions.C +++ b/src/parallel/reconstruct/reconstruct/reconstructLagrangianPositions.C @@ -84,7 +84,7 @@ void Foam::reconstructLagrangianPositions IOPosition<Cloud<passiveParticle>> ( lagrangianPositions, - IOPosition<Cloud<passiveParticle>>::geometryType::POSITIONS + cloud::geometryType::POSITIONS ).write(); } }