Commit 1d8ea918 authored by Mark OLESEN's avatar Mark OLESEN Committed by Andrew Heather
Browse files

ENH: add basic zero-initialized constructors for particle classes

- for the most basic level construction with mesh and position only.
parent 037be8db
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -43,6 +43,10 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class passivePositionParticle;
Ostream& operator<<(Ostream& os, const passivePositionParticle& ppi);
/*---------------------------------------------------------------------------*\
Class passivePositionParticle Declaration
\*---------------------------------------------------------------------------*/
......@@ -51,7 +55,7 @@ class passivePositionParticle
:
public passiveParticle
{
// Private member data
// Private Member Data
//- Cached position
point position_;
......@@ -74,6 +78,19 @@ public:
position_(position())
{}
//- Construct from a position and a cell.
// Searches for the rest of the required topology.
passivePositionParticle
(
const polyMesh& mesh,
const vector& position,
const label celli = -1
)
:
passiveParticle(mesh, position, celli),
position_(position)
{}
//- Construct as copy
passivePositionParticle(const passivePositionParticle& p)
:
......@@ -88,8 +105,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_;
......
......@@ -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
{
......
......@@ -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
(
......
......@@ -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,
......
......@@ -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_;
......
......@@ -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);
}
};
};
......
......@@ -51,11 +51,9 @@ SourceFiles
namespace Foam
{
class solidParticleCloud;
// Forward declaration of friend functions and operators
// Forward Declarations
class solidParticleCloud;
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);
}
};
......
......@@ -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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment