ENH: add basic zero-initialized constructors for particle classes

- for the most basic level construction with mesh and position only.
This commit is contained in:
Mark Olesen
2019-08-02 17:23:00 +02:00
committed by Andrew Heather
parent 037be8dbb0
commit 1d8ea9182b
8 changed files with 107 additions and 36 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -63,6 +63,21 @@ public:
// Constructors
//- Construct from a position and a cell.
// Searches for the rest of the required topology.
// Other properties are zero initialised.
indexedParticle
(
const polyMesh& mesh,
const vector& position,
const label celli = -1,
const label index = 0
)
:
particle(mesh, position, celli),
index_(index)
{}
//- Construct from components
indexedParticle
(
@ -103,7 +118,7 @@ public:
}
// Member functions
// Member Functions
label index() const
{

View File

@ -108,6 +108,16 @@ public:
// Constructors
//- Construct from a position and a cell.
// Searches for the rest of the required topology.
// Other properties are zero initialised.
inline injectedParticle
(
const polyMesh& mesh,
const vector& position,
const label celli = -1
);
//- Construct from components
inline injectedParticle
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,6 +26,22 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::injectedParticle::injectedParticle
(
const polyMesh& mesh,
const vector& position,
const label celli
)
:
particle(mesh, position, celli),
position_(position),
tag_(0),
soi_(0),
d_(0),
U_(Zero)
{}
inline Foam::injectedParticle::injectedParticle
(
const polyMesh& mesh,

View File

@ -366,16 +366,16 @@ public:
const label tetPti
);
//- Construct from a position and a cell, searching for the rest of the
// required topology
//- Construct from a position and a cell.
// Searches for the rest of the required topology.
particle
(
const polyMesh& mesh,
const vector& position,
const label celli
const label celli = -1
);
//- Construct from components
//- Construct from position components
particle
(
const polyMesh& mesh,
@ -408,8 +408,7 @@ public:
return autoPtr<particle>::New(*this);
}
//- Factory class to read-construct particles used for
// parallel transfer
//- Factory class to read-construct particles (for parallel transfer)
class iNew
{
const polyMesh& mesh_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -73,18 +73,19 @@ public:
{}
//- Construct from a position and a cell, searching for the rest of the
// required topology
//- Construct from a position and a cell.
// Searches for the rest of the required topology.
passiveParticle
(
const polyMesh& mesh,
const vector& position,
const label celli
const label celli = -1
)
:
particle(mesh, position, celli)
{}
//- Construct from Istream
passiveParticle
(
@ -97,12 +98,14 @@ public:
particle(mesh, is, readFields, newFormat)
{}
//- Construct as copy
passiveParticle(const passiveParticle& p)
:
particle(p)
{}
//- Construct and return a clone
virtual autoPtr<particle> clone() const
{
@ -110,8 +113,7 @@ public:
}
//- Factory class to read-construct particles used for
// parallel transfer
//- Factory class to read-construct particles (for parallel transfer)
class iNew
{
const polyMesh& mesh_;
@ -125,13 +127,9 @@ public:
autoPtr<passiveParticle> operator()(Istream& is) const
{
return autoPtr<passiveParticle>
(
new passiveParticle(mesh_, is, true)
);
return autoPtr<passiveParticle>::New(mesh_, is, true);
}
};
};

View File

@ -51,11 +51,9 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class solidParticleCloud;
// Forward declaration of friend functions and operators
class solidParticle;
Ostream& operator<<(Ostream&, const solidParticle&);
@ -69,7 +67,7 @@ class solidParticle
:
public particle
{
// Private data
// Private Data
//- Diameter
scalar d_;
@ -131,6 +129,16 @@ public:
// Constructors
//- Construct from a position and a cell
// Searches for the rest of the required topology.
// Other properties are zero initialised.
inline solidParticle
(
const polyMesh& mesh,
const vector& position,
const label celli = -1
);
//- Construct from components
inline solidParticle
(
@ -158,8 +166,7 @@ public:
return autoPtr<particle>(new solidParticle(*this));
}
//- Factory class to read-construct particles used for
// parallel transfer
//- Factory class to read-construct particles (for parallel transfer)
class iNew
{
const polyMesh& mesh_;
@ -173,10 +180,7 @@ public:
autoPtr<solidParticle> operator()(Istream& is) const
{
return autoPtr<solidParticle>
(
new solidParticle(mesh_, is, true)
);
return autoPtr<solidParticle>::New(mesh_, is, true);
}
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -44,6 +44,19 @@ inline Foam::solidParticle::trackingData::trackingData
{}
inline Foam::solidParticle::solidParticle
(
const polyMesh& mesh,
const vector& position,
const label celli
)
:
particle(mesh, position, celli),
d_(0),
U_(Zero)
{}
inline Foam::solidParticle::solidParticle
(
const polyMesh& mesh,