ENH: simplify construction of zero-sized Clouds

- use Foam::zero as a dispatch tag

FIX: return moleculeCloud::constProps() List by reference not copy

STYLE: range-for when iterating cloud parcels

STYLE: more consistent typedefs / declarations for Clouds
This commit is contained in:
Mark Olesen 2023-12-13 11:07:13 +01:00
parent 0352a224b7
commit c9a9309b8c
46 changed files with 377 additions and 502 deletions

View File

@ -329,7 +329,7 @@ Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T)
:
radiationModel(typeName, T),
mode_(powerDistNames_.get("mode", *this)),
DTRMCloud_(mesh_, "DTRMCloud", IDLList<DTRMParticle>()),
DTRMCloud_(mesh_, Foam::zero{}, "DTRMCloud"), // Empty cloud
nParticles_(0),
ndTheta_(get<label>("nTheta")),
ndr_(get<label>("nr")),
@ -427,7 +427,7 @@ Foam::radiation::laserDTRM::laserDTRM
:
radiationModel(typeName, dict, T),
mode_(powerDistNames_.get("mode", *this)),
DTRMCloud_(mesh_, "DTRMCloud", IDLList<DTRMParticle>()),
DTRMCloud_(mesh_, Foam::zero{}, "DTRMCloud"), // Empty cloud
nParticles_(0),
ndTheta_(get<label>("nTheta")),
ndr_(get<label>("nr")),

View File

@ -1,3 +1,3 @@
Test-passiveParticle.C
Test-passiveParticle.cxx
EXE = $(FOAM_USER_APPBIN)/Test-passiveParticle

View File

@ -24,7 +24,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
testPassiveParticle
Test-passiveParticle
Description
Test cloud of passive particles.
@ -50,12 +50,8 @@ int main(int argc, char *argv[])
{
// Start with empty cloud
passiveParticleCloud particles
(
mesh,
cloudName,
IDLList<passiveParticle>()
);
passiveParticleCloud particles(mesh, Foam::zero{}, cloudName);
Pout<< "Starting particles:" << particles.size() << endl;
Pout<< "Adding a particle." << endl;

View File

@ -227,19 +227,21 @@ Foam::parLagrangianDistributor::distributeLagrangianPositions
pBufs.finishedSends();
// The cloud name
const word cloudName = lpi.name();
{
// Temporarily rename original cloud so we can construct a new one
// (to distribute the positions) without getting a duplicate
// registration warning
const word cloudName = lpi.name();
lpi.rename(cloudName + "_old");
// New cloud on tgtMesh
// New empty cloud on tgtMesh
passivePositionParticleCloud lagrangianPositions
(
tgtMesh_,
cloudName,
IDLList<passivePositionParticle>()
Foam::zero{},
cloudName
);
// Retrieve from receive buffers
@ -310,11 +312,11 @@ Foam::parLagrangianDistributor::distributeLagrangianPositions
// ).objectPath()
// );
//}
// Restore cloud name
lpi.rename(cloudName);
}
// Restore cloud name
lpi.rename(cloudName);
// The constructMap is in linear (processor) order
return autoPtr<mapDistributeBase>::New

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,6 +34,7 @@ namespace Foam
defineTemplateTypeNameAndDebug(Cloud<passivePositionParticle>, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::passivePositionParticleCloud::passivePositionParticleCloud
@ -52,15 +53,4 @@ Foam::passivePositionParticleCloud::passivePositionParticleCloud
}
Foam::passivePositionParticleCloud::passivePositionParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<passivePositionParticle>& particles
)
:
Cloud<passivePositionParticle>(mesh, cloudName, particles)
{}
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef passivePositionParticleCloud_H
#define passivePositionParticleCloud_H
#ifndef Foam_passivePositionParticleCloud_H
#define Foam_passivePositionParticleCloud_H
#include "Cloud.H"
#include "passivePositionParticle.H"
@ -53,23 +53,21 @@ class passivePositionParticleCloud
:
public Cloud<passivePositionParticle>
{
// Private Member Functions
//- No copy construct
passivePositionParticleCloud
(
const passivePositionParticleCloud&
) = delete;
//- No copy assignment
void operator=(const passivePositionParticleCloud&) = delete;
public:
//- Type of parcel within the cloud
typedef passivePositionParticle parcelType;
//- No copy construct
passivePositionParticleCloud(const passivePositionParticleCloud&) = delete;
//- No copy assignment
void operator=(const passivePositionParticleCloud&) = delete;
// Constructors
//- Construct given mesh
//- Read construct
explicit passivePositionParticleCloud
(
const polyMesh& mesh,
@ -77,13 +75,16 @@ public:
bool readFields = true
);
//- Construct from mesh, cloud name, and a list of particles
//- Construct without particles
passivePositionParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<passivePositionParticle>& particles
);
const Foam::zero,
const word& cloudName = cloud::defaultName
)
:
Cloud<passivePositionParticle>(mesh, Foam::zero{}, cloudName)
{}
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef unmappedPassivePositionParticleCloud_H
#define unmappedPassivePositionParticleCloud_H
#ifndef Foam_unmappedPassivePositionParticleCloud_H
#define Foam_unmappedPassivePositionParticleCloud_H
#include "passivePositionParticleCloud.H"
@ -54,12 +54,11 @@ class unmappedPassivePositionParticleCloud
:
public passivePositionParticleCloud
{
public:
// Constructors
//- Construct given mesh
//- Read construct
explicit unmappedPassivePositionParticleCloud
(
const polyMesh& mesh,
@ -70,15 +69,15 @@ public:
passivePositionParticleCloud(mesh, cloudName, readFields)
{}
//- Construct from mesh, cloud name, and a list of particles
//- Construct without particles
unmappedPassivePositionParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<passivePositionParticle>& particles
const Foam::zero,
const word& cloudName = cloud::defaultName
)
:
passivePositionParticleCloud(mesh, cloudName, particles)
passivePositionParticleCloud(mesh, Foam::zero{}, cloudName)
{}
@ -89,7 +88,7 @@ public:
// Member Functions
//- Switch off remapping of cells of particles when
// mesh topology changes
//- mesh topology changes
virtual void autoMap(const mapPolyMesh&)
{}

View File

@ -133,6 +133,7 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
cloudDir,
false
);
Info<< " read " << sourceParcels.size()
<< " parcels from source mesh." << endl;
@ -140,8 +141,8 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
passiveParticleCloud targetParcels
(
meshTarget,
cloudDir,
IDLList<passiveParticle>()
Foam::zero{},
cloudDir
);
passiveParticle::trackingData td(targetParcels);

View File

@ -129,6 +129,7 @@ void mapLagrangian(const meshToMesh& interp)
cloudDir,
false
);
Info<< " read " << sourceParcels.size()
<< " parcels from source mesh." << endl;
@ -136,8 +137,8 @@ void mapLagrangian(const meshToMesh& interp)
passiveParticleCloud targetParcels
(
meshTarget,
cloudDir,
IDLList<passiveParticle>()
Foam::zero{},
cloudDir
);
passiveParticle::trackingData td(targetParcels);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,6 +37,7 @@ namespace Foam
}
const Foam::word Foam::cloud::prefix("lagrangian");
Foam::word Foam::cloud::defaultName("defaultCloud");
const Foam::Enum<Foam::cloud::geometryType>
@ -51,7 +52,7 @@ Foam::cloud::geometryTypeNames
Foam::cloud::cloud(const objectRegistry& obr)
:
cloud(obr, defaultName)
cloud(obr, cloud::defaultName)
{}
@ -61,12 +62,13 @@ Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName)
(
IOobject
(
cloudName,
(cloudName.empty() ? cloud::defaultName : cloudName),
obr.time().timeName(),
prefix,
cloud::prefix,
obr,
IOobject::NO_READ,
IOobject::AUTO_WRITE
IOobject::AUTO_WRITE,
IOobject::REGISTER
)
)
{}

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cloud_H
#define cloud_H
#ifndef Foam_cloud_H
#define Foam_cloud_H
#include "objectRegistry.H"
#include "Enum.H"
@ -59,16 +59,6 @@ class cloud
:
public objectRegistry
{
// Private Member Functions
//- No copy construct
cloud(const cloud&) = delete;
//- No copy assignment
void operator=(const cloud&) = delete;
public:
//- Cloud geometry type (internal or IO representations)
@ -78,11 +68,11 @@ public:
POSITIONS //!< positions
};
//- Named enumerations "coordinates", "positions"
static const Enum<geometryType> geometryTypeNames;
//- Runtime type information
TypeName("cloud");
// Static Data Members
//- The prefix to local: %lagrangian
static const word prefix;
@ -91,12 +81,25 @@ public:
static word defaultName;
//- Runtime type information
TypeName("cloud");
// Generated Methods
//- No copy construct
cloud(const cloud&) = delete;
//- No copy assignment
void operator=(const cloud&) = delete;
// Constructors
//- Construct for given objectRegistry and default cloud name
//- Construct for given objectRegistry. Uses default cloud name
explicit cloud(const objectRegistry& obr);
//- Construct for given objectRegistry and named cloud instance
//- Construct for given objectRegistry and named cloud
cloud(const objectRegistry& obr, const word& cloudName);
@ -139,7 +142,7 @@ public:
//- Locate an IOField within object registry
// \return nullptr if not found or wrong type
template<class Type>
inline static const IOField<Type>* findIOField
static const IOField<Type>* findIOField
(
const word& fieldName,
const objectRegistry& obr
@ -150,7 +153,7 @@ public:
//- Locate the "position" IOField within object registry
// \return nullptr if not found or wrong type
inline static const IOField<point>* findIOPosition
static const IOField<point>* findIOPosition
(
const objectRegistry& obr
)
@ -161,7 +164,7 @@ public:
//- Lookup an IOField within object registry
// Fatal if not found or wrong type
template<class Type>
inline static const IOField<Type>& lookupIOField
static const IOField<Type>& lookupIOField
(
const word& fieldName,
const objectRegistry& obr

View File

@ -61,13 +61,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
DebugInFunction << "nPatchFaces: " << globalWalls.totalSize() << endl;
// Construct cloud
Cloud<findCellParticle> cloud
(
mesh_,
cloud::defaultName,
IDLList<findCellParticle>()
);
// Start with empty cloud
Cloud<findCellParticle> cloud(mesh_, Foam::zero{}, cloud::defaultName);
// Add particles to track to sample locations
nPatchFaces = 0;

View File

@ -47,13 +47,8 @@ namespace functionObjects
void Foam::functionObjects::streamLine::track()
{
IDLList<streamLineParticle> initialParticles;
streamLineParticleCloud particles
(
mesh_,
cloudName_,
initialParticles
);
// Start with empty cloud
streamLineParticleCloud particles(mesh_, Foam::zero{}, cloudName_);
const sampledSet& seedPoints = sampledSetPoints();

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,15 +54,4 @@ Foam::streamLineParticleCloud::streamLineParticleCloud
}
Foam::streamLineParticleCloud::streamLineParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<streamLineParticle>& particles
)
:
Cloud<streamLineParticle>(mesh, cloudName, particles)
{}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -56,22 +56,19 @@ class streamLineParticleCloud
{
public:
//- Type of parcel the cloud was instantiated for
//- Type of parcel within the cloud
typedef streamLineParticle parcelType;
//- No copy construct
streamLineParticleCloud(const streamLineParticleCloud&) = delete;
// Generated Methods
//- No copy construct
streamLineParticleCloud(const streamLineParticleCloud&) = delete;
//- No copy assignment
void operator=(const streamLineParticleCloud&) = delete;
//- No copy assignment
void operator=(const streamLineParticleCloud&) = delete;
// Constructors
//- Construct given mesh
//- Read construct
explicit streamLineParticleCloud
(
const polyMesh& mesh,
@ -79,13 +76,16 @@ public:
bool readFields = true
);
//- Construct from mesh, cloud name, and a list of particles
//- Construct without particles
streamLineParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<streamLineParticle>& particles
);
const Foam::zero,
const word& cloudName = cloud::defaultName
)
:
Cloud<streamLineParticle>(mesh, Foam::zero{}, cloudName)
{}
};

View File

@ -142,12 +142,11 @@ void Foam::functionObjects::wallBoundedStreamLine::track()
// Find nearest wall particle for the seedPoints
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IDLList<wallBoundedStreamLineParticle> initialParticles;
wallBoundedStreamLineParticleCloud particles
(
mesh_,
cloudName_,
initialParticles
Foam::zero{},
cloudName_
);
{

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,15 +53,4 @@ Foam::wallBoundedStreamLineParticleCloud::wallBoundedStreamLineParticleCloud
}
Foam::wallBoundedStreamLineParticleCloud::wallBoundedStreamLineParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<wallBoundedStreamLineParticle>& particles
)
:
Cloud<wallBoundedStreamLineParticle>(mesh, cloudName, particles)
{}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,7 +28,7 @@ Class
Foam::wallBoundedStreamLineParticleCloud
Description
A Cloud of streamLine particles
A Cloud of wall-bounded streamLine particles
SourceFiles
streamLineCloud.C
@ -56,10 +56,9 @@ class wallBoundedStreamLineParticleCloud
{
public:
//- Type of parcel the cloud was instantiated for
//- Type of parcel within the cloud
typedef wallBoundedStreamLineParticle parcelType;
// Generated Methods
//- No copy construct
@ -74,7 +73,7 @@ public:
// Constructors
//- Construct given mesh
//- Read construct
explicit wallBoundedStreamLineParticleCloud
(
const polyMesh& mesh,
@ -82,13 +81,16 @@ public:
bool readFields = true
);
//- Construct from mesh, cloud name, and a list of particles
//- Construct without particles
wallBoundedStreamLineParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<wallBoundedStreamLineParticle>& particles
);
const Foam::zero,
const word& cloudName = cloud::defaultName
)
:
Cloud<wallBoundedStreamLineParticle>(mesh, Foam::zero{}, cloudName)
{}
};

View File

@ -59,6 +59,25 @@ void Foam::Cloud<ParticleType>::checkPatches() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParticleType>
Foam::Cloud<ParticleType>::Cloud
(
const polyMesh& pMesh,
const Foam::zero,
const word& cloudName
)
:
cloud(pMesh, cloudName),
polyMesh_(pMesh),
geometryType_(cloud::geometryType::COORDINATES)
{
checkPatches();
(void)polyMesh_.tetBasePtIs();
(void)polyMesh_.oldCellCentres();
}
template<class ParticleType>
Foam::Cloud<ParticleType>::Cloud
(
@ -67,21 +86,8 @@ Foam::Cloud<ParticleType>::Cloud
const IDLList<ParticleType>& particles
)
:
cloud(pMesh, cloudName),
IDLList<ParticleType>(),
polyMesh_(pMesh),
labels_(),
globalPositionsPtr_(),
geometryType_(cloud::geometryType::COORDINATES)
Cloud<ParticleType>(pMesh, Foam::zero{}, cloudName)
{
checkPatches();
(void)polyMesh_.oldCellCentres();
// Ask for the tetBasePtIs to trigger all processors to build
// them, otherwise, if some processors have no particles then
// there is a comms mismatch.
(void)polyMesh_.tetBasePtIs();
if (particles.size())
{
IDLList<ParticleType>::operator=(particles);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2022 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,7 +67,7 @@ class Cloud
public cloud,
public IDLList<ParticleType>
{
// Private data
// Private Data
//- Reference to the mesh database
const polyMesh& polyMesh_;
@ -130,6 +130,14 @@ public:
// Constructors
//- Construct without particles
Cloud
(
const polyMesh& mesh,
const Foam::zero,
const word& cloudName
);
//- Construct from mesh and a list of particles
Cloud
(
@ -138,12 +146,12 @@ public:
const IDLList<ParticleType>& particles
);
//- Construct from mesh by reading from file with given cloud instance
// Optionally disable checking of class name for post-processing
//- Read construct from file(s) with given cloud instance.
Cloud
(
const polyMesh& pMesh,
const word& cloudName,
//! Disable checking of class name (eg, for post-processing)
const bool checkClass = true
);
@ -153,7 +161,7 @@ public:
// Access
//- Return the polyMesh reference
const polyMesh& pMesh() const
const polyMesh& pMesh() const noexcept
{
return polyMesh_;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017, 2020 OpenFOAM Foundation
Copyright (C) 2017-2022 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,7 +49,7 @@ void Foam::Cloud<ParticleType>::readCloudUniformProperties()
time().timeName(),
"uniform"/cloud::prefix/name(),
db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::MUST_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
);
@ -104,6 +104,7 @@ void Foam::Cloud<ParticleType>::writeCloudUniformProperties() const
labelList np(Pstream::nProcs(), Zero);
np[Pstream::myProcNo()] = ParticleType::particleCount_;
// FIXME: replace with Pstream::allGatherList(np);
Pstream::listCombineReduce(np, maxEqOp<label>());
uniformPropsDict.add
@ -114,9 +115,8 @@ void Foam::Cloud<ParticleType>::writeCloudUniformProperties() const
forAll(np, i)
{
word procName("processor" + Foam::name(i));
uniformPropsDict.add(procName, dictionary());
uniformPropsDict.subDict(procName).add("particleCount", np[i]);
const word procName("processor" + Foam::name(i));
uniformPropsDict.subDictOrAdd(procName).add("particleCount", np[i]);
}
uniformPropsDict.writeObject
@ -169,17 +169,8 @@ Foam::Cloud<ParticleType>::Cloud
const bool checkClass
)
:
cloud(pMesh, cloudName),
polyMesh_(pMesh),
labels_(),
cellWallFacesPtr_(),
geometryType_(cloud::geometryType::COORDINATES)
Cloud<ParticleType>(pMesh, Foam::zero{}, cloudName)
{
checkPatches();
(void)polyMesh_.tetBasePtIs();
(void)polyMesh_.oldCellCentres();
initCloud(checkClass);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -72,18 +72,18 @@ bool Foam::IOPosition<CloudType>::writeData(Ostream& os) const
{
case cloud::geometryType::COORDINATES:
{
forAllConstIters(cloud_, iter)
for (const auto& p : cloud_)
{
iter().writeCoordinates(os);
p.writeCoordinates(os);
os << nl;
}
break;
}
case cloud::geometryType::POSITIONS:
{
forAllConstIters(cloud_, iter)
for (const auto& p : cloud_)
{
iter().writePosition(os);
p.writePosition(os);
os << nl;
}
break;

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef IOPosition_H
#define IOPosition_H
#ifndef Foam_IOPosition_H
#define Foam_IOPosition_H
#include "cloud.H"
#include "regIOobject.H"
@ -55,7 +55,7 @@ class IOPosition
:
public regIOobject
{
// Private data
// Private Data
cloud::geometryType geometryType_;
@ -65,7 +65,7 @@ class IOPosition
public:
// Static data
// Static Data
//- Runtime type name information. Use cloud type.
virtual const word& type() const
@ -77,7 +77,7 @@ public:
// Constructors
//- Construct from cloud
IOPosition
explicit IOPosition
(
const CloudType& c,
cloud::geometryType geomType = cloud::geometryType::COORDINATES

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef indexedParticleCloud_H
#define indexedParticleCloud_H
#ifndef Foam_indexedParticleCloud_H
#define Foam_indexedParticleCloud_H
#include "Cloud.H"
#include "indexedParticle.H"
@ -53,26 +53,38 @@ class indexedParticleCloud
:
public Cloud<indexedParticle>
{
// Private Member Functions
//- No copy construct
indexedParticleCloud(const indexedParticleCloud&) = delete;
//- No copy assignment
void operator=(const indexedParticleCloud&) = delete;
public:
//- Type of parcel within the cloud
typedef indexedParticle parcelType;
//- No copy construct
indexedParticleCloud(const indexedParticleCloud&) = delete;
//- No copy assignment
void operator=(const indexedParticleCloud&) = delete;
// Constructors
//- Construct given mesh
//- Read construct
explicit indexedParticleCloud
(
const polyMesh& mesh,
const word& cloudName = cloud::defaultName,
bool readFields = true
);
//- Construct without particles
explicit indexedParticleCloud
(
const polyMesh& mesh,
const Foam::zero,
const word& cloudName = cloud::defaultName
)
:
Cloud<indexedParticle>(mesh, Foam::zero{}, cloudName)
{}
};

View File

@ -27,11 +27,14 @@ License
#include "injectedParticleCloud.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(Cloud<injectedParticle>, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::injectedParticleCloud::injectedParticleCloud
@ -62,12 +65,6 @@ Foam::injectedParticleCloud::injectedParticleCloud
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::injectedParticleCloud::~injectedParticleCloud()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::injectedParticleCloud::readObjects(const objectRegistry& obr)

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef injectedParticleCloud_H
#define injectedParticleCloud_H
#ifndef Foam_injectedParticleCloud_H
#define Foam_injectedParticleCloud_H
#include "Cloud.H"
#include "injectedParticle.H"
@ -46,7 +46,6 @@ SourceFiles
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class injectedParticleCloud Declaration
\*---------------------------------------------------------------------------*/
@ -55,30 +54,39 @@ class injectedParticleCloud
:
public Cloud<injectedParticle>
{
private:
// Private Member Functions
//- No copy construct
injectedParticleCloud(const injectedParticleCloud&) = delete;
//- No copy assignment
void operator=(const injectedParticleCloud&) = delete;
public:
//- Type of parcel within the cloud
typedef injectedParticle parcelType;
//- No copy construct
injectedParticleCloud(const injectedParticleCloud&) = delete;
//- No copy assignment
void operator=(const injectedParticleCloud&) = delete;
// Constructors
//- Construct from mesh and cloud name
//- Read construct
injectedParticleCloud
(
const polyMesh& mesh,
const word& name,
const word& cloudName,
const bool readFields = true
);
//- Construct without particles
injectedParticleCloud
(
const polyMesh& mesh,
const Foam::zero,
const word& cloudName = cloud::defaultName
)
:
Cloud<injectedParticle>(mesh, Foam::zero{}, cloudName)
{}
//- Copy constructor with new name
injectedParticleCloud(const injectedParticleCloud& c, const word& name);
@ -93,18 +101,16 @@ public:
//- Destructor
virtual ~injectedParticleCloud();
virtual ~injectedParticleCloud() = default;
// Member Functions
// I-O
//- Read particle fields as objects from the obr registry
virtual void readObjects(const objectRegistry& obr);
//- Read particle fields as objects from the obr registry
virtual void readObjects(const objectRegistry& obr);
//- Write particle fields as objects into the obr registry
virtual void writeObjects(objectRegistry& obr) const;
//- Write particle fields as objects into the obr registry
virtual void writeObjects(objectRegistry& obr) const;
};

View File

@ -52,15 +52,4 @@ Foam::passiveParticleCloud::passiveParticleCloud
}
Foam::passiveParticleCloud::passiveParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<passiveParticle>& particles
)
:
Cloud<passiveParticle>(mesh, cloudName, particles)
{}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef passiveParticleCloud_H
#define passiveParticleCloud_H
#ifndef Foam_passiveParticleCloud_H
#define Foam_passiveParticleCloud_H
#include "Cloud.H"
#include "passiveParticle.H"
@ -54,20 +54,21 @@ class passiveParticleCloud
:
public Cloud<passiveParticle>
{
// Private Member Functions
//- No copy construct
passiveParticleCloud(const passiveParticleCloud&) = delete;
//- No copy assignment
void operator=(const passiveParticleCloud&) = delete;
public:
//- Type of parcel within the cloud
typedef passiveParticle parcelType;
//- No copy construct
passiveParticleCloud(const passiveParticleCloud&) = delete;
//- No copy assignment
void operator=(const passiveParticleCloud&) = delete;
// Constructors
//- Construct given mesh
//- Read construct
explicit passiveParticleCloud
(
const polyMesh& mesh,
@ -75,13 +76,16 @@ public:
bool readFields = true
);
//- Construct from mesh, cloud name, and a list of particles
//- Construct without particles
passiveParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<passiveParticle>& particles
);
const Foam::zero,
const word& cloudName = cloud::defaultName
)
:
Cloud<passiveParticle>(mesh, Foam::zero{}, cloudName)
{}
};

View File

@ -92,10 +92,8 @@ void Foam::HeatTransferCoeff<CloudType>::postEvolve
const_cast<typename parcelType::trackingData&>(td);
label parceli = 0;
forAllConstIters(c, parcelIter)
for (const parcelType& p : c)
{
const parcelType& p = parcelIter();
scalar Ts, rhos, mus, Pr, kappas;
p.template calcSurfaceValues<CloudType>
(

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,10 +85,8 @@ void Foam::KinematicReynoldsNumber<CloudType>::postEvolve
Re.resize(c.size());
label parceli = 0;
forAllConstIters(c, parcelIter)
for (const parcelType& p : c)
{
const parcelType& p = parcelIter();
Re[parceli++] = p.Re(td);
}

View File

@ -87,10 +87,8 @@ void Foam::KinematicWeberNumber<CloudType>::postEvolve
We.resize(c.size());
label parceli = 0;
forAllConstIters(c, parcelIter)
for (const parcelType& p : c)
{
const parcelType& p = parcelIter();
We[parceli++] = p.We(td, sigma_);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -92,10 +92,8 @@ void Foam::NusseltNumber<CloudType>::postEvolve
const_cast<typename parcelType::trackingData&>(td);
label parceli = 0;
forAllConstIters(c, parcelIter)
for (const parcelType& p : c)
{
const parcelType& p = parcelIter();
scalar Ts, rhos, mus, Pr, kappas;
p.template calcSurfaceValues<CloudType>
(

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -92,10 +92,8 @@ void Foam::ParticleDose<CloudType>::postEvolve
const auto& G = mesh.lookupObject<volScalarField>(GName_);
label parceli = 0;
forAllConstIters(c, parcelIter)
for (const parcelType& p : c)
{
const parcelType& p = parcelIter();
D[parceli] += G[p.cell()]*mesh.time().deltaTValue();
parceli++;
}

View File

@ -93,10 +93,8 @@ void Foam::ReactingWeberNumber<CloudType>::postEvolve
const auto& rhoInterp = td.rhoInterp();
label parceli = 0;
forAllConstIters(c, parcelIter)
for (const parcelType& p : c)
{
const parcelType& p = parcelIter();
const auto& coords = p.coordinates();
const auto& tetIs = p.currentTetIndices();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -89,10 +89,8 @@ void Foam::ThermoReynoldsNumber<CloudType>::postEvolve
const_cast<typename parcelType::trackingData&>(td);
label parceli = 0;
forAllConstIters(c, parcelIter)
for (const parcelType& p : c)
{
const parcelType& p = parcelIter();
scalar Ts, rhos, mus, Pr, kappas;
p.template calcSurfaceValues<CloudType>
(

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef moleculeCloud_H
#define moleculeCloud_H
#ifndef Foam_moleculeCloud_H
#define Foam_moleculeCloud_H
#include "Cloud.H"
#include "molecule.H"
@ -133,18 +133,22 @@ class moleculeCloud
const molecule::constantProperties& cP
);
//- No copy construct
moleculeCloud(const moleculeCloud&) = delete;
//- No copy assignment
void operator=(const moleculeCloud&) = delete;
public:
//- Type of parcel within the cloud
typedef molecule parcelType;
//- No copy construct
moleculeCloud(const moleculeCloud&) = delete;
//- No copy assignment
void operator=(const moleculeCloud&) = delete;
// Constructors
//- Construct given mesh and potential references
//- Read construct given mesh and potential references
moleculeCloud
(
const polyMesh& mesh,
@ -152,7 +156,7 @@ public:
bool readFields = true
);
//- Construct given mesh, potential and mdInitialiseDict
//- Read construct given mesh, potential and mdInitialiseDict
moleculeCloud
(
const polyMesh& mesh,
@ -178,19 +182,32 @@ public:
// Access
inline const polyMesh& mesh() const;
// Same as pMesh()
const polyMesh& mesh() const noexcept { return mesh_; }
inline const potential& pot() const;
const potential& pot() const { return pot_; }
inline const List<DynamicList<molecule*>>& cellOccupancy() const;
const List<DynamicList<molecule*>>& cellOccupancy() const
{
return cellOccupancy_;
}
inline const InteractionLists<molecule>& il() const;
const InteractionLists<molecule>& il() const
{
return il_;
}
inline const List<molecule::constantProperties> constProps() const;
const List<molecule::constantProperties>& constProps() const
{
return constPropList_;
}
inline const molecule::constantProperties& constProps(label id) const;
const molecule::constantProperties& constProps(label id) const
{
return constPropList_[id];
}
inline Random& rndGen();
Random& rndGen() { return rndGen_; }
// Member Operators

View File

@ -338,52 +338,4 @@ inline Foam::vector Foam::moleculeCloud::equipartitionAngularMomentum
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::polyMesh& Foam::moleculeCloud::mesh() const
{
return mesh_;
}
inline const Foam::potential& Foam::moleculeCloud::pot() const
{
return pot_;
}
inline const Foam::List<Foam::DynamicList<Foam::molecule*>>&
Foam::moleculeCloud::cellOccupancy() const
{
return cellOccupancy_;
}
inline const Foam::InteractionLists<Foam::molecule>&
Foam::moleculeCloud::il() const
{
return il_;
}
inline const Foam::List<Foam::molecule::constantProperties>
Foam::moleculeCloud::constProps() const
{
return constPropList_;
}
inline const Foam::molecule::constantProperties&
Foam::moleculeCloud::constProps(label id) const
{
return constPropList_[id];
}
inline Foam::Random& Foam::moleculeCloud::rndGen()
{
return rndGen_;
}
// ************************************************************************* //

View File

@ -31,14 +31,13 @@ Description
A Cloud of solid particles
SourceFiles
solidParticleCloudI.H
solidParticleCloud.C
solidParticleCloudIO.C
\*---------------------------------------------------------------------------*/
#ifndef solidParticleCloud_H
#define solidParticleCloud_H
#ifndef Foam_solidParticleCloud_H
#define Foam_solidParticleCloud_H
#include "Cloud.H"
#include "solidParticle.H"
@ -60,7 +59,7 @@ class solidParticleCloud
:
public Cloud<solidParticle>
{
// Private data
// Private Data
const fvMesh& mesh_;
@ -71,20 +70,21 @@ class solidParticleCloud
scalar mu_;
// Private Member Functions
//- No copy construct
solidParticleCloud(const solidParticleCloud&) = delete;
//- No copy assignment
void operator=(const solidParticleCloud&) = delete;
public:
//- Type of parcel within the cloud
typedef solidParticle parcelType;
//- No copy construct
solidParticleCloud(const solidParticleCloud&) = delete;
//- No copy assignment
void operator=(const solidParticleCloud&) = delete;
// Constructors
//- Construct given mesh
//- Read construct
explicit solidParticleCloud
(
const fvMesh& mesh,
@ -95,20 +95,20 @@ public:
// Member Functions
// Access
// Access
inline const fvMesh& mesh() const;
const fvMesh& mesh() const { return mesh_; }
inline scalar rhop() const;
inline scalar e() const;
inline scalar mu() const;
scalar rhop() const noexcept { return rhop_; }
scalar e() const noexcept { return e_; }
scalar mu() const noexcept { return mu_; }
// Edit
// Edit
//- Move the particles under the influence of the given
// gravitational acceleration
void move(const dimensionedVector& g);
//- Move the particles under the influence of the given
//- gravitational acceleration
void move(const dimensionedVector& g);
};
@ -118,10 +118,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "solidParticleCloudI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,53 +1 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::fvMesh& Foam::solidParticleCloud::mesh() const
{
return mesh_;
}
inline Foam::scalar Foam::solidParticleCloud::rhop() const
{
return rhop_;
}
inline Foam::scalar Foam::solidParticleCloud::e() const
{
return e_;
}
inline Foam::scalar Foam::solidParticleCloud::mu() const
{
return mu_;
}
// ************************************************************************* //
#warning File removed - left for old dependency check only

View File

@ -337,8 +337,8 @@ void Foam::meshRefinement::markFeatureCellLevel
Cloud<trackedParticle> startPointCloud
(
mesh_,
"startPointCloud",
IDLList<trackedParticle>()
Foam::zero{},
"startPointCloud"
);
@ -492,12 +492,8 @@ void Foam::meshRefinement::markFeatureCellLevel
}
Cloud<trackedParticle> cloud
(
mesh_,
"featureCloud",
IDLList<trackedParticle>()
);
// Start with empty cloud
Cloud<trackedParticle> cloud(mesh_, Foam::zero{}, "featureCloud");
if (debug&meshRefinement::FEATURESEEDS)
{

View File

@ -44,7 +44,7 @@ Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
)
:
procMesh_(procMesh),
positions_(procMesh, cloudName, IDLList<passiveParticle>()),
positions_(procMesh, Foam::zero{}, cloudName), // Empty cloud
particleIndices_(lagrangianPositions.size())
{
label pi = 0;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,11 +58,12 @@ Foam::label Foam::lagrangianReconstructor::reconstructPositions
const word& cloudName
) const
{
// Start with empty cloud
passivePositionParticleCloud lagrangianPositions
(
mesh_,
cloudName,
IDLList<passivePositionParticle>()
Foam::zero{},
cloudName
);
forAll(procMeshes_, meshi)
@ -78,10 +79,8 @@ Foam::label Foam::lagrangianReconstructor::reconstructPositions
// - written in the old format
passivePositionParticleCloud lpi(procMeshes_[meshi], cloudName, false);
forAllConstIters(lpi, iter)
for (const passivePositionParticle& ppi : lpi)
{
const passivePositionParticle& ppi = *iter;
const label mappedCell =
(
(ppi.cell() >= 0)

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,15 +52,4 @@ Foam::passivePositionParticleCloud::passivePositionParticleCloud
}
Foam::passivePositionParticleCloud::passivePositionParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<passivePositionParticle>& particles
)
:
Cloud<passivePositionParticle>(mesh, cloudName, particles)
{}
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef passivePositionParticleCloud_H
#define passivePositionParticleCloud_H
#ifndef Foam_passivePositionParticleCloud_H
#define Foam_passivePositionParticleCloud_H
#include "Cloud.H"
#include "passivePositionParticle.H"
@ -53,21 +53,21 @@ class passivePositionParticleCloud
:
public Cloud<passivePositionParticle>
{
// Private Member Functions
//- No copy construct
passivePositionParticleCloud(const passivePositionParticleCloud&) =
delete;
//- No copy assignment
void operator=(const passivePositionParticleCloud&) = delete;
public:
//- Type of parcel within the cloud
typedef passivePositionParticle parcelType;
//- No copy construct
passivePositionParticleCloud(const passivePositionParticleCloud&) = delete;
//- No copy assignment
void operator=(const passivePositionParticleCloud&) = delete;
// Constructors
//- Construct given mesh
//- Read construct
explicit passivePositionParticleCloud
(
const polyMesh& mesh,
@ -75,13 +75,16 @@ public:
bool readFields = true
);
//- Construct from mesh, cloud name, and a list of particles
//- Construct without particles
passivePositionParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<passivePositionParticle>& particles
);
const Foam::zero,
const word& cloudName = cloud::defaultName
)
:
Cloud<passivePositionParticle>(mesh, Foam::zero{}, cloudName)
{}
};

View File

@ -42,6 +42,15 @@ Foam::word Foam::surfaceRegistry::defaultName("default");
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceRegistry::surfaceRegistry
(
const objectRegistry& obr
)
:
surfaceRegistry(obr, surfaceRegistry::defaultName)
{}
Foam::surfaceRegistry::surfaceRegistry
(
const objectRegistry& obr,
@ -52,12 +61,13 @@ Foam::surfaceRegistry::surfaceRegistry
(
IOobject
(
(surfName.size() ? surfName : defaultName),
(surfName.empty() ? surfaceRegistry::defaultName : surfName),
obr.time().timeName(),
prefix,
surfaceRegistry::prefix,
obr,
IOobjectOption::NO_READ,
IOobjectOption::NO_WRITE
IOobjectOption::NO_WRITE,
IOobjectOption::REGISTER
)
)
{}

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef surfaceRegistry_H
#define surfaceRegistry_H
#ifndef Foam_surfaceRegistry_H
#define Foam_surfaceRegistry_H
#include "objectRegistry.H"
@ -53,20 +53,9 @@ class surfaceRegistry
:
public objectRegistry
{
// Private Member Functions
//- No copy construct
surfaceRegistry(const surfaceRegistry&) = delete;
//- No copy assignment
surfaceRegistry& operator=(const surfaceRegistry&) = delete;
public:
//- Runtime type information
TypeName("surfaceRegistry");
// Static Data Members
//- The prefix to local: %surfaces
static const word prefix;
@ -75,19 +64,30 @@ public:
static word defaultName;
//- Runtime type information
TypeName("surfaceRegistry");
// Generated Methods
//- No copy construct
surfaceRegistry(const surfaceRegistry&) = delete;
//- No copy assignment
surfaceRegistry& operator=(const surfaceRegistry&) = delete;
// Constructors
//- Construct for the given objectRegistry and named surface
surfaceRegistry
(
const objectRegistry& obr,
const word& surfName = word::null
);
//- Construct for given objectRegistry. Uses default surface name
explicit surfaceRegistry(const objectRegistry& obr);
//- Construct for given objectRegistry and named surface
surfaceRegistry(const objectRegistry& obr, const word& surfName);
//- Destructor
virtual ~surfaceRegistry() = default;
};