Commit 208f6302 authored by andy's avatar andy
Browse files

ENH: Refactored Kinematic cloud/parcels - torque, force and angularMomentum...

ENH: Refactored Kinematic cloud/parcels - torque, force and angularMomentum moved to Colliding level
parent 6eca86fb
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -234,4 +234,16 @@ void Foam::CollidingCloud<CloudType>::motion(TrackData& td)
}
template<class CloudType>
void Foam::CollidingCloud<CloudType>::info()
{
CloudType::info();
scalar rotationalKineticEnergy = rotationalKineticEnergyOfSystem();
reduce(rotationalKineticEnergy, sumOp<scalar>());
Info<< " Rotational kinetic energy = "
<< rotationalKineticEnergy << nl;
}
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -197,8 +197,13 @@ public:
inline CollisionModel<CollidingCloud<CloudType> >&
collision();
// Check
// Evolution
//- Total rotational kinetic energy in the system
inline scalar rotationalKineticEnergyOfSystem() const;
// Cloud evolution functions
//- Store the current cloud state
void storeState();
......@@ -212,6 +217,12 @@ public:
//- Particle motion
template<class TrackData>
void motion(TrackData& td);
// I-O
//- Print cloud information
void info();
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -49,4 +49,22 @@ Foam::CollidingCloud<CloudType>::collision()
}
template<class CloudType>
inline Foam::scalar
Foam::CollidingCloud<CloudType>::rotationalKineticEnergyOfSystem() const
{
scalar rotationalKineticEnergy = 0.0;
forAllConstIter(typename CollidingCloud<CloudType>, *this, iter)
{
const parcelType& p = iter();
rotationalKineticEnergy +=
p.nParticle()*0.5*p.momentOfInertia()*(p.omega() & p.omega());
}
return rotationalKineticEnergy;
}
// ************************************************************************* //
......@@ -864,9 +864,6 @@ void Foam::KinematicCloud<CloudType>::info()
scalar linearKineticEnergy = linearKineticEnergyOfSystem();
reduce(linearKineticEnergy, sumOp<scalar>());
scalar rotationalKineticEnergy = rotationalKineticEnergyOfSystem();
reduce(rotationalKineticEnergy, sumOp<scalar>());
Info<< "Cloud: " << this->name() << nl
<< " Current number of parcels = "
<< returnReduce(this->size(), sumOp<label>()) << nl
......@@ -877,9 +874,7 @@ void Foam::KinematicCloud<CloudType>::info()
<< " |Linear momentum| = "
<< mag(linearMomentum) << nl
<< " Linear kinetic energy = "
<< linearKineticEnergy << nl
<< " Rotational kinetic energy = "
<< rotationalKineticEnergy << nl;
<< linearKineticEnergy << nl;
injectors_.info(Info);
this->surfaceFilm().info(Info);
......
......@@ -487,9 +487,6 @@ public:
//- Total linear kinetic energy in the system
inline scalar linearKineticEnergyOfSystem() const;
//- Total rotational kinetic energy in the system
inline scalar rotationalKineticEnergyOfSystem() const;
//- Penetration for fraction [0-1] of the current total mass
inline scalar penetration(const scalar fraction) const;
......
......@@ -307,24 +307,6 @@ Foam::KinematicCloud<CloudType>::linearKineticEnergyOfSystem() const
}
template<class CloudType>
inline Foam::scalar
Foam::KinematicCloud<CloudType>::rotationalKineticEnergyOfSystem() const
{
scalar rotationalKineticEnergy = 0.0;
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
{
const parcelType& p = iter();
rotationalKineticEnergy +=
p.nParticle()*0.5*p.momentOfInertia()*(p.omega() & p.omega());
}
return rotationalKineticEnergy;
}
template<class CloudType>
inline Foam::scalar Foam::KinematicCloud<CloudType>::Dij
(
......
......@@ -86,7 +86,7 @@ public:
virtual scalar linearKineticEnergyOfSystem() const = 0;
//- Total rotational kinetic energy in the system
virtual scalar rotationalKineticEnergyOfSystem() const = 0;
// virtual scalar rotationalKineticEnergyOfSystem() const = 0;
//- Penetration for percentage of the current total mass
// virtual scalar penetration(const scalar& fraction) const = 0;
......
......@@ -34,6 +34,9 @@ Foam::CollidingParcel<ParcelType>::CollidingParcel
)
:
ParcelType(p),
f_(p.f_),
angularMomentum_(p.angularMomentum_),
torque_(p.torque_),
collisionRecords_(p.collisionRecords_)
{}
......@@ -46,6 +49,9 @@ Foam::CollidingParcel<ParcelType>::CollidingParcel
)
:
ParcelType(p, mesh),
f_(p.f_),
angularMomentum_(p.angularMomentum_),
torque_(p.torque_),
collisionRecords_(p.collisionRecords_)
{}
......@@ -166,6 +172,29 @@ bool Foam::CollidingParcel<ParcelType>::move
}
template<class ParcelType>
void Foam::CollidingParcel<ParcelType>::transformProperties(const tensor& T)
{
ParcelType::transformProperties(T);
f_ = transform(T, f_);
angularMomentum_ = transform(T, angularMomentum_);
torque_ = transform(T, torque_);
}
template<class ParcelType>
void Foam::CollidingParcel<ParcelType>::transformProperties
(
const vector& separation
)
{
ParcelType::transformProperties(separation);
}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "CollidingParcelIO.C"
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -66,7 +66,7 @@ Ostream& operator<<
);
/*---------------------------------------------------------------------------*\
Class CollidingParcel Declaration
Class CollidingParcel Declaration
\*---------------------------------------------------------------------------*/
template<class ParcelType>
......@@ -78,6 +78,16 @@ protected:
// Protected data
//- Force on particle due to collisions [N]
vector f_;
//- Angular momentum of Parcel in global reference frame [kg m2/s]
vector angularMomentum_;
//- Torque on particle due to collisions in global
// reference frame [Nm]
vector torque_;
//- Particle collision records
collisionRecordList collisionRecords_;
......@@ -93,7 +103,10 @@ public:
AddToPropertyList
(
ParcelType,
" collisionRecordsPairAccessed"
" (fx fy fz)"
+ " (angularMomentumx angularMomentumy angularMomentumz)"
+ " (torquex torquey torquez)"
+ " collisionRecordsPairAccessed"
+ " collisionRecordsPairOrigProcOfOther"
+ " collisionRecordsPairOrigIdOfOther"
+ " (collisionRecordsPairData)"
......@@ -188,12 +201,33 @@ public:
// Access
//- Return const access to force
inline const vector& f() const;
//- Return const access to angular momentum
inline const vector& angularMomentum() const;
//- Return const access to torque
inline const vector& torque() const;
//- Return const access to the collision records
inline const collisionRecordList& collisionRecords() const;
//- Return access to force
inline vector& f();
//- Return access to angular momentum
inline vector& angularMomentum();
//- Return access to torque
inline vector& torque();
//- Return access to collision records
inline collisionRecordList& collisionRecords();
//- Particle angular velocity
inline vector omega() const;
// Tracking
......@@ -201,6 +235,14 @@ public:
template<class TrackData>
bool move(TrackData& td, const scalar trackTime);
//- Transform the physical properties of the particle
// according to the given transformation tensor
virtual void transformProperties(const tensor& T);
//- Transform the physical properties of the particle
// according to the given separation vector
virtual void transformProperties(const vector& separation);
// I-O
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -36,6 +36,9 @@ inline Foam::CollidingParcel<ParcelType>::CollidingParcel
)
:
ParcelType(owner, position, cellI, tetFaceI, tetPtI),
f_(vector::zero),
angularMomentum_(vector::zero),
torque_(vector::zero),
collisionRecords_()
{}
......@@ -70,18 +73,39 @@ inline Foam::CollidingParcel<ParcelType>::CollidingParcel
nParticle0,
d0,
dTarget0,
U0,
f0,
angularMomentum0,
torque0,
constProps
),
f_(f0),
angularMomentum_(angularMomentum0),
torque_(torque0),
collisionRecords_()
{}
// * * * * * * * CollidingParcel Member Functions * * * * * * * //
template<class ParcelType>
inline const Foam::vector& Foam::CollidingParcel<ParcelType>::f() const
{
return f_;
}
template<class ParcelType>
inline const Foam::vector&
Foam::CollidingParcel<ParcelType>::angularMomentum() const
{
return angularMomentum_;
}
template<class ParcelType>
inline const Foam::vector& Foam::CollidingParcel<ParcelType>::torque() const
{
return torque_;
}
template<class ParcelType>
inline const Foam::collisionRecordList&
......@@ -91,6 +115,27 @@ Foam::CollidingParcel<ParcelType>::collisionRecords() const
}
template<class ParcelType>
inline Foam::vector& Foam::CollidingParcel<ParcelType>::f()
{
return f_;
}
template<class ParcelType>
inline Foam::vector& Foam::CollidingParcel<ParcelType>::angularMomentum()
{
return angularMomentum_;
}
template<class ParcelType>
inline Foam::vector& Foam::CollidingParcel<ParcelType>::torque()
{
return torque_;
}
template<class ParcelType>
inline Foam::collisionRecordList&
Foam::CollidingParcel<ParcelType>::collisionRecords()
......@@ -99,4 +144,11 @@ Foam::CollidingParcel<ParcelType>::collisionRecords()
}
template<class ParcelType>
inline Foam::vector Foam::CollidingParcel<ParcelType>::omega() const
{
return angularMomentum_/this->momentOfInertia();
}
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -45,10 +45,30 @@ Foam::CollidingParcel<ParcelType>::CollidingParcel
)
:
ParcelType(mesh, is, readFields),
f_(vector::zero),
angularMomentum_(vector::zero),
torque_(vector::zero),
collisionRecords_()
{
if (readFields)
{
if (is.format() == IOstream::ASCII)
{
is >> f_;
is >> angularMomentum_;
is >> torque_;
}
else
{
is.read
(
reinterpret_cast<char*>(&f_),
+ sizeof(f_)
+ sizeof(angularMomentum_)
+ sizeof(torque_)
);
}
is >> collisionRecords_;
}
......@@ -72,6 +92,18 @@ void Foam::CollidingParcel<ParcelType>::readFields(CloudType& c)
ParcelType::readFields(c);
IOField<vector> f(c.fieldIOobject("f", IOobject::MUST_READ));
c.checkFieldIOobject(c, f);
IOField<vector> angularMomentum
(
c.fieldIOobject("angularMomentum", IOobject::MUST_READ)
);
c.checkFieldIOobject(c, angularMomentum);
IOField<vector> torque(c.fieldIOobject("torque", IOobject::MUST_READ));
c.checkFieldIOobject(c, torque);
labelFieldCompactIOField collisionRecordsPairAccessed
(
c.fieldIOobject("collisionRecordsPairAccessed", IOobject::MUST_READ)
......@@ -128,6 +160,10 @@ void Foam::CollidingParcel<ParcelType>::readFields(CloudType& c)
{
CollidingParcel<ParcelType>& p = iter();
p.f_ = f[i];
p.angularMomentum_ = angularMomentum[i];
p.torque_ = torque[i];
p.collisionRecords_ = collisionRecordList
(
collisionRecordsPairAccessed[i],
......@@ -152,6 +188,14 @@ void Foam::CollidingParcel<ParcelType>::writeFields(const CloudType& c)
label np = c.size();
IOField<vector> f(c.fieldIOobject("f", IOobject::NO_READ), np);
IOField<vector> angularMomentum
(
c.fieldIOobject("angularMomentum", IOobject::NO_READ),
np
);
IOField<vector> torque(c.fieldIOobject("torque", IOobject::NO_READ), np);
labelFieldCompactIOField collisionRecordsPairAccessed
(
c.fieldIOobject("collisionRecordsPairAccessed", IOobject::NO_READ),
......@@ -198,6 +242,10 @@ void Foam::CollidingParcel<ParcelType>::writeFields(const CloudType& c)
{
const CollidingParcel<ParcelType>& p = iter();
f[i] = p.f();
angularMomentum[i] = p.angularMomentum();
torque[i] = p.torque();
collisionRecordsPairAccessed[i] = p.collisionRecords().pairAccessed();
collisionRecordsPairOrigProcOfOther[i] =
p.collisionRecords().pairOrigProcOfOther();
......@@ -211,6 +259,10 @@ void Foam::CollidingParcel<ParcelType>::writeFields(const CloudType& c)
i++;
}
f.write();
angularMomentum.write();
torque.write();
collisionRecordsPairAccessed.write();
collisionRecordsPairOrigProcOfOther.write();
collisionRecordsPairOrigIdOfOther.write();
......@@ -233,12 +285,22 @@ Foam::Ostream& Foam::operator<<
if (os.format() == IOstream::ASCII)
{
os << static_cast<const ParcelType&>(p)
<< token::SPACE << p.f()
<< token::SPACE << p.angularMomentum()
<< token::SPACE << p.torque()
<< token::SPACE << p.collisionRecords();
}
else
{
os << static_cast<const ParcelType&>(p)
<< p.collisionRecords();
os << static_cast<const ParcelType&>(p);
os.write
(
reinterpret_cast<const char*>(&p.f_),
+ sizeof(p.f())
+ sizeof(p.angularMomentum())
+ sizeof(p.torque())
);
os << p.collisionRecords();
}
// Check state of Ostream
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -213,9 +213,6 @@ Foam::KinematicParcel<ParcelType>::KinematicParcel
d_(p.d_),
dTarget_(p.dTarget_),
U_(p.U_),
f_(p.f_),
angularMomentum_(p.angularMomentum_),
torque_(p.torque_),
rho_(p.rho_),
age_(p.age_),
tTurb_(p.tTurb_),
......@@ -240,9 +237,6 @@ Foam::KinematicParcel<ParcelType>::KinematicParcel
d_(p.d_),
dTarget_(p.dTarget_),
U_(p.U_),
f_(p.f_),
angularMomentum_(p.angularMomentum_),
torque_(p.torque_),
rho_(p.rho_),
age_(p.age_),
tTurb_(p.tTurb_),
......@@ -437,12 +431,6 @@ void Foam::KinematicParcel<ParcelType>::transformProperties(const tensor& T)
ParcelType::transformProperties(T);
U_ = transform(T, U_);
f_ = transform(T, f_);
angularMomentum_ = transform(T, angularMomentum_);
torque_ = transform(T, torque_);
}
......
......@@ -261,17 +261,6 @@ protected:
//- Velocity of Parcel [m/s]
vector U_;
//- Force on particle due to collisions [N]
vector f_;
//- Angular momentum of Parcel in global reference frame
// [kg m2/s]
vector angularMomentum_;
//- Torque on particle due to collisions in global
// reference frame [Nm]
vector torque_;
//- Density [kg/m3]
scalar rho_;