mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added active flag to KinematicParcel
- used during parcel calc() function to flag whether the parcel should be tracked - if false, parcel not tracked, but sub-models are still active - useful, e.g. for particle 'stick' condition - NOTE: stored as a bool, but read/written as a label for restarts/post-processing
This commit is contained in:
@ -258,7 +258,10 @@ bool Foam::KinematicParcel<ParcelType>::move(TrackData& td)
|
||||
// face is hit
|
||||
label cellI = p.cell();
|
||||
|
||||
dt *= p.trackToFace(p.position() + dt*U_, td);
|
||||
if (p.active())
|
||||
{
|
||||
dt *= p.trackToFace(p.position() + dt*U_, td);
|
||||
}
|
||||
|
||||
tEnd -= dt;
|
||||
p.stepFraction() = 1.0 - tEnd/deltaT;
|
||||
@ -322,6 +325,7 @@ bool Foam::KinematicParcel<ParcelType>::hitPatch
|
||||
pp,
|
||||
this->face(),
|
||||
td.keepParticle,
|
||||
active_,
|
||||
U_
|
||||
);
|
||||
}
|
||||
|
||||
@ -194,6 +194,9 @@ protected:
|
||||
|
||||
// Parcel properties
|
||||
|
||||
//- Active flag - tracking inactive when active = false
|
||||
bool active_;
|
||||
|
||||
//- Parcel type id
|
||||
label typeId_;
|
||||
|
||||
@ -308,6 +311,9 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return const access to active flag
|
||||
inline bool active() const;
|
||||
|
||||
//- Return const access to type id
|
||||
inline label typeId() const;
|
||||
|
||||
@ -332,8 +338,11 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Return const access to active flag
|
||||
inline bool& active();
|
||||
|
||||
//- Return access to type id
|
||||
inline label typeId();
|
||||
inline label& typeId();
|
||||
|
||||
//- Return access to number of particles
|
||||
inline scalar& nParticle();
|
||||
|
||||
@ -75,6 +75,7 @@ inline Foam::KinematicParcel<ParcelType>::KinematicParcel
|
||||
)
|
||||
:
|
||||
Particle<ParcelType>(owner, position, cellI),
|
||||
active_(false),
|
||||
typeId_(owner.parcelTypeId()),
|
||||
nParticle_(0),
|
||||
d_(0.0),
|
||||
@ -102,6 +103,7 @@ inline Foam::KinematicParcel<ParcelType>::KinematicParcel
|
||||
)
|
||||
:
|
||||
Particle<ParcelType>(owner, position, cellI),
|
||||
active_(true),
|
||||
typeId_(typeId),
|
||||
nParticle_(nParticle0),
|
||||
d_(d0),
|
||||
@ -201,6 +203,13 @@ Foam::KinematicParcel<ParcelType>::trackData::g() const
|
||||
|
||||
// * * * * * * * * * * KinematicParcel Member Functions * * * * * * * * * * //
|
||||
|
||||
template <class ParcelType>
|
||||
inline bool Foam::KinematicParcel<ParcelType>::active() const
|
||||
{
|
||||
return active_;
|
||||
}
|
||||
|
||||
|
||||
template <class ParcelType>
|
||||
inline Foam::label Foam::KinematicParcel<ParcelType>::typeId() const
|
||||
{
|
||||
@ -251,7 +260,14 @@ inline const Foam::vector& Foam::KinematicParcel<ParcelType>::UTurb() const
|
||||
|
||||
|
||||
template <class ParcelType>
|
||||
inline Foam::label Foam::KinematicParcel<ParcelType>::typeId()
|
||||
inline bool& Foam::KinematicParcel<ParcelType>::active()
|
||||
{
|
||||
return active_;
|
||||
}
|
||||
|
||||
|
||||
template <class ParcelType>
|
||||
inline Foam::label& Foam::KinematicParcel<ParcelType>::typeId()
|
||||
{
|
||||
return typeId_;
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ License
|
||||
template <class ParcelType>
|
||||
Foam::string Foam::KinematicParcel<ParcelType>::propHeader =
|
||||
Particle<ParcelType>::propHeader
|
||||
+ " active"
|
||||
+ " typeId"
|
||||
+ " nParticle"
|
||||
+ " d"
|
||||
@ -53,6 +54,7 @@ Foam::KinematicParcel<ParcelType>::KinematicParcel
|
||||
)
|
||||
:
|
||||
Particle<ParcelType>(cloud, is, readFields),
|
||||
active_(false),
|
||||
typeId_(0),
|
||||
nParticle_(0.0),
|
||||
d_(0.0),
|
||||
@ -68,6 +70,7 @@ Foam::KinematicParcel<ParcelType>::KinematicParcel
|
||||
{
|
||||
if (is.format() == IOstream::ASCII)
|
||||
{
|
||||
active_ = readBool(is);
|
||||
typeId_ = readLabel(is);
|
||||
nParticle_ = readScalar(is);
|
||||
d_ = readScalar(is);
|
||||
@ -81,7 +84,8 @@ Foam::KinematicParcel<ParcelType>::KinematicParcel
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(&typeId_),
|
||||
sizeof(typeId_)
|
||||
sizeof(active_)
|
||||
+ sizeof(typeId_)
|
||||
+ sizeof(nParticle_)
|
||||
+ sizeof(d_)
|
||||
+ sizeof(U_)
|
||||
@ -111,6 +115,9 @@ void Foam::KinematicParcel<ParcelType>::readFields(Cloud<ParcelType>& c)
|
||||
|
||||
Particle<ParcelType>::readFields(c);
|
||||
|
||||
IOField<label> active(c.fieldIOobject("active", IOobject::MUST_READ));
|
||||
c.checkFieldIOobject(c, active);
|
||||
|
||||
IOField<label> typeId(c.fieldIOobject("typeId", IOobject::MUST_READ));
|
||||
c.checkFieldIOobject(c, typeId);
|
||||
|
||||
@ -138,6 +145,7 @@ void Foam::KinematicParcel<ParcelType>::readFields(Cloud<ParcelType>& c)
|
||||
{
|
||||
ParcelType& p = iter();
|
||||
|
||||
p.active_ = active[i];
|
||||
p.typeId_ = typeId[i];
|
||||
p.nParticle_ = nParticle[i];
|
||||
p.d_ = d[i];
|
||||
@ -157,6 +165,7 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const Cloud<ParcelType>& c)
|
||||
|
||||
label np = c.size();
|
||||
|
||||
IOField<label> active(c.fieldIOobject("active", IOobject::NO_READ), np);
|
||||
IOField<label> typeId(c.fieldIOobject("typeId", IOobject::NO_READ), np);
|
||||
IOField<scalar> nParticle
|
||||
(
|
||||
@ -174,6 +183,7 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const Cloud<ParcelType>& c)
|
||||
{
|
||||
const KinematicParcel<ParcelType>& p = iter();
|
||||
|
||||
active[i] = p.active();
|
||||
typeId[i] = p.typeId();
|
||||
nParticle[i] = p.nParticle();
|
||||
d[i] = p.d();
|
||||
@ -184,6 +194,7 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const Cloud<ParcelType>& c)
|
||||
i++;
|
||||
}
|
||||
|
||||
active.write();
|
||||
typeId.write();
|
||||
nParticle.write();
|
||||
d.write();
|
||||
@ -206,6 +217,7 @@ Foam::Ostream& Foam::operator<<
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
os << static_cast<const Particle<ParcelType>&>(p)
|
||||
<< token::SPACE << p.active()
|
||||
<< token::SPACE << p.typeId()
|
||||
<< token::SPACE << p.nParticle()
|
||||
<< token::SPACE << p.d()
|
||||
@ -219,8 +231,9 @@ Foam::Ostream& Foam::operator<<
|
||||
os << static_cast<const Particle<ParcelType>&>(p);
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(&p.typeId_),
|
||||
sizeof(p.typeId())
|
||||
reinterpret_cast<const char*>(&p.active_),
|
||||
sizeof(p.active())
|
||||
+ sizeof(p.typeId())
|
||||
+ sizeof(p.nParticle())
|
||||
+ sizeof(p.d())
|
||||
+ sizeof(p.U())
|
||||
|
||||
@ -140,6 +140,7 @@ bool Foam::LocalInteraction<CloudType>::correct
|
||||
const polyPatch& pp,
|
||||
const label faceId,
|
||||
bool& keepParticle,
|
||||
bool& active,
|
||||
vector& U
|
||||
) const
|
||||
{
|
||||
@ -158,18 +159,21 @@ bool Foam::LocalInteraction<CloudType>::correct
|
||||
case PatchInteractionModel<CloudType>::itEscape:
|
||||
{
|
||||
keepParticle = false;
|
||||
active = false;
|
||||
U = vector::zero;
|
||||
break;
|
||||
}
|
||||
case PatchInteractionModel<CloudType>::itStick:
|
||||
{
|
||||
keepParticle = true;
|
||||
active = false;
|
||||
U = vector::zero;
|
||||
break;
|
||||
}
|
||||
case PatchInteractionModel<CloudType>::itRebound:
|
||||
{
|
||||
keepParticle = true;
|
||||
active = true;
|
||||
|
||||
vector nw = pp.faceAreas()[pp.whichFace(faceId)];
|
||||
nw /= mag(nw);
|
||||
|
||||
@ -92,6 +92,7 @@ public:
|
||||
const polyPatch& pp,
|
||||
const label faceId,
|
||||
bool& keepParticle,
|
||||
bool& active,
|
||||
vector& U
|
||||
) const;
|
||||
};
|
||||
|
||||
@ -155,6 +155,7 @@ public:
|
||||
const polyPatch& pp,
|
||||
const label faceId,
|
||||
bool& keepParticle,
|
||||
bool& active,
|
||||
vector& U
|
||||
) const = 0;
|
||||
};
|
||||
|
||||
@ -61,10 +61,12 @@ bool Foam::Rebound<CloudType>::correct
|
||||
const polyPatch& pp,
|
||||
const label faceId,
|
||||
bool& keepParticle,
|
||||
bool& active,
|
||||
vector& U
|
||||
) const
|
||||
{
|
||||
keepParticle = true;
|
||||
active = true;
|
||||
|
||||
vector nw = pp.faceAreas()[pp.whichFace(faceId)];
|
||||
nw /= mag(nw);
|
||||
|
||||
@ -82,6 +82,7 @@ public:
|
||||
const polyPatch& pp,
|
||||
const label faceId,
|
||||
bool& keepParticle,
|
||||
bool& active,
|
||||
vector& U
|
||||
) const;
|
||||
};
|
||||
|
||||
@ -98,6 +98,7 @@ bool Foam::StandardWallInteraction<CloudType>::correct
|
||||
const polyPatch& pp,
|
||||
const label faceId,
|
||||
bool& keepParticle,
|
||||
bool& active,
|
||||
vector& U
|
||||
) const
|
||||
{
|
||||
@ -108,18 +109,21 @@ bool Foam::StandardWallInteraction<CloudType>::correct
|
||||
case PatchInteractionModel<CloudType>::itEscape:
|
||||
{
|
||||
keepParticle = false;
|
||||
active = false;
|
||||
U = vector::zero;
|
||||
break;
|
||||
}
|
||||
case PatchInteractionModel<CloudType>::itStick:
|
||||
{
|
||||
keepParticle = true;
|
||||
active = false;
|
||||
U = vector::zero;
|
||||
break;
|
||||
}
|
||||
case PatchInteractionModel<CloudType>::itRebound:
|
||||
{
|
||||
keepParticle = true;
|
||||
active = true;
|
||||
|
||||
vector nw = pp.faceAreas()[pp.whichFace(faceId)];
|
||||
nw /= mag(nw);
|
||||
|
||||
@ -102,6 +102,7 @@ public:
|
||||
const polyPatch& pp,
|
||||
const label faceId,
|
||||
bool& keepParticle,
|
||||
bool& active,
|
||||
vector& U
|
||||
) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user