Commit 4fbde908 authored by andy's avatar andy
Browse files

ENH: Re-worked lagrangian/dieselSpray

parent d3b48fea
if (isA<wallPolyPatch>(pbMesh[patch(face())]))
{
keepParcel = sDB.wall().wallTreatment(*this, face());
td.keepParticle = sDB.wall().wallTreatment(*this, face());
if (sDB.twoD())
{
......@@ -50,5 +50,5 @@ else if (isA<symmetryPolyPatch>(pbMesh[patch(face())]))
else if (isType<polyPatch>(pbMesh[patch(face())]))
{
// Parcel has hit an inlet or outlet or some such so throw it away
keepParcel = false;
td.keepParticle = false;
}
......@@ -39,15 +39,15 @@ License
namespace Foam
{
defineParticleTypeNameAndDebug(parcel, 0);
defineTemplateTypeNameAndDebug(Cloud<parcel>, 0);
// defineParticleTypeNameAndDebug(parcel, 0);
// defineTemplateTypeNameAndDebug(Cloud<parcel>, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::parcel::parcel
(
const Cloud<parcel>& cloud,
const polyMesh& mesh,
const vector& position,
const label cellI,
const label tetFaceI,
......@@ -69,11 +69,8 @@ Foam::parcel::parcel
const List<word>& liquidNames
)
:
Particle<parcel>(cloud, position, cellI, tetFaceI, tetPtI),
liquidComponents_
(
liquidNames
),
particle(mesh, position, cellI, tetFaceI, tetPtI),
liquidComponents_(liquidNames),
d_(d),
T_(T),
m_(m),
......@@ -94,11 +91,14 @@ Foam::parcel::parcel
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::parcel::move(spray& sDB, const scalar trackTime)
bool Foam::parcel::move(trackingData& td, const scalar trackTime)
{
const polyMesh& mesh = cloud().pMesh();
const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
td.switchProcessor = false;
td.keepParticle = true;
const polyBoundaryMesh& pbMesh = mesh_.boundaryMesh();
spray& sDB = td.cloud();
const liquidMixtureProperties& fuels = sDB.fuels();
label Nf = fuels.components().size();
......@@ -139,8 +139,6 @@ bool Foam::parcel::move(spray& sDB, const scalar trackTime)
scalarField tauEvaporation(Nf, GREAT);
scalarField tauBoiling(Nf, GREAT);
bool keepParcel = true;
setRelaxationTimes
(
cell(),
......@@ -185,7 +183,6 @@ bool Foam::parcel::move(spray& sDB, const scalar trackTime)
// (10 000 seems high enough)
dtMax = max(dtMax, 1.0e-4*tEnd);
bool switchProcessor = false;
vector planeNormal = vector::zero;
if (sDB.twoD())
{
......@@ -194,7 +191,7 @@ bool Foam::parcel::move(spray& sDB, const scalar trackTime)
}
// move the parcel until there is no 'timeLeft'
while (keepParcel && tEnd > SMALL && !switchProcessor)
while (td.keepParticle && !td.switchProcessor && tEnd > SMALL)
{
// set the lagrangian time-step
scalar dt = min(dtMax, tEnd);
......@@ -205,10 +202,10 @@ bool Foam::parcel::move(spray& sDB, const scalar trackTime)
scalar p = sDB.p()[cellI];
// track parcel to face, or end of trajectory
if (keepParcel)
if (td.keepParticle)
{
// Track and adjust the time step if the trajectory is not completed
dt *= trackToFace(position() + dt*U_, sDB);
dt *= trackToFace(position() + dt*U_, td);
// Decrement the end-time acording to how much time the track took
tEnd -= dt;
......@@ -218,11 +215,11 @@ bool Foam::parcel::move(spray& sDB, const scalar trackTime)
if (onBoundary()) // hit face
{
# include "boundaryTreatment.H"
#include "boundaryTreatment.H"
}
}
if (keepParcel && sDB.twoD())
if (td.keepParticle && sDB.twoD())
{
scalar z = position() & sDB.axisOfSymmetry();
vector r = position() - z*sDB.axisOfSymmetry();
......@@ -297,7 +294,7 @@ bool Foam::parcel::move(spray& sDB, const scalar trackTime)
// remove parcel if it is 'small'
if (m() < 1.0e-12)
{
keepParcel = false;
td.keepParticle = false;
// ... and add the removed 'stuff' to the gas
forAll(nMass, i)
......@@ -309,19 +306,19 @@ bool Foam::parcel::move(spray& sDB, const scalar trackTime)
sDB.shs()[cellI] += m()*(nH + nPE);
}
if (onBoundary() && keepParcel)
if (onBoundary() && td.keepParticle)
{
if (face() > -1)
{
if (isA<processorPolyPatch>(pbMesh[patch(face())]))
{
switchProcessor = true;
td.switchProcessor = true;
}
}
}
}
return keepParcel;
return td.keepParticle;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -32,7 +32,7 @@ Description
#ifndef parcel_H
#define parcel_H
#include "Particle.H"
#include "particle.H"
#include "contiguous.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -48,7 +48,7 @@ class spray;
class parcel
:
public Particle<parcel>
public particle
{
// Private member data
......@@ -142,13 +142,25 @@ public:
friend class Cloud<parcel>;
//- Class used to pass tracking data to the trackToFace function
class trackingData
:
public particle::TrackingData<spray>
{
public:
trackingData(spray& cloud)
:
particle::TrackingData<spray>(cloud)
{}
};
// Constructors
//- Construct from components
parcel
(
const Cloud<parcel>& cloud,
const polyMesh& mesh,
const vector& position,
const label cellI,
const label tetFaceI,
......@@ -173,11 +185,30 @@ public:
//- Construct from Istream reading field values if required
parcel
(
const Cloud<parcel>& cloud,
const polyMesh& mesh,
Istream& is,
bool readFields = true
);
//- Factory class to read-construct particles used for
// parallel transfer
class iNew
{
const polyMesh& mesh_;
public:
iNew(const polyMesh& mesh)
:
mesh_(mesh)
{}
autoPtr<parcel> operator()(Istream& is) const
{
return autoPtr<parcel>(new parcel(mesh_, is, true));
}
};
// Member Functions
......@@ -349,7 +380,7 @@ public:
// Parcel operations
bool move(spray& sprayData, const scalar trackTime);
bool move(trackingData& td, const scalar trackTime);
//- Transform the position and physical properties of the particle
// according to the given transformation tensor
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -23,182 +23,205 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const List<word>& parcel::liquidNames() const
inline const Foam::List<Foam::word>& Foam::parcel::liquidNames() const
{
return liquidComponents_;
}
inline const List<word>& parcel::fuelNames() const
inline const Foam::List<Foam::word>& Foam::parcel::fuelNames() const
{
return liquidComponents_;
}
inline scalar parcel::d() const
inline Foam::scalar Foam::parcel::d() const
{
return d_;
}
inline scalar& parcel::d()
inline Foam::scalar& Foam::parcel::d()
{
return d_;
}
inline scalar parcel::T() const
inline Foam::scalar Foam::parcel::T() const
{
return T_;
}
inline scalar& parcel::T()
inline Foam::scalar& Foam::parcel::T()
{
return T_;
}
inline scalar parcel::m() const
inline Foam::scalar Foam::parcel::m() const
{
return m_;
}
inline scalar& parcel::m()
inline Foam::scalar& Foam::parcel::m()
{
return m_;
}
inline scalar parcel::dev() const
inline Foam::scalar Foam::parcel::dev() const
{
return y_;
}
inline scalar& parcel::dev()
inline Foam::scalar& Foam::parcel::dev()
{
return y_;
}
inline scalar parcel::ddev() const
inline Foam::scalar Foam::parcel::ddev() const
{
return yDot_;
}
inline scalar& parcel::ddev()
inline Foam::scalar& Foam::parcel::ddev()
{
return yDot_;
}
inline scalar parcel::ct() const
inline Foam::scalar Foam::parcel::ct() const
{
return ct_;
}
inline scalar& parcel::ct()
inline Foam::scalar& Foam::parcel::ct()
{
return ct_;
}
inline scalar& parcel::ms()
inline Foam::scalar& Foam::parcel::ms()
{
return ms_;
}
inline scalar parcel::ms() const
inline Foam::scalar Foam::parcel::ms() const
{
return ms_;
}
inline scalar& parcel::tTurb()
inline Foam::scalar& Foam::parcel::tTurb()
{
return tTurb_;
}
inline scalar parcel::tTurb() const
inline Foam::scalar Foam::parcel::tTurb() const
{
return tTurb_;
}
inline scalar& parcel::liquidCore()
inline Foam::scalar& Foam::parcel::liquidCore()
{
return liquidCore_;
}
inline scalar parcel::liquidCore() const
inline Foam::scalar Foam::parcel::liquidCore() const
{
return liquidCore_;
}
inline scalar& parcel::injector()
inline Foam::scalar& Foam::parcel::injector()
{
return injector_;
}
inline scalar parcel::injector() const
inline Foam::scalar Foam::parcel::injector() const
{
return injector_;
}
inline const vector& parcel::U() const
inline const Foam::vector& Foam::parcel::U() const
{
return U_;
}
inline vector& parcel::U()
inline Foam::vector& Foam::parcel::U()
{
return U_;
}
inline const vector& parcel::Uturb() const
inline const Foam::vector& Foam::parcel::Uturb() const
{
return Uturb_;
}
inline vector& parcel::Uturb()
inline Foam::vector& Foam::parcel::Uturb()
{
return Uturb_;
}
inline const vector& parcel::n() const
inline const Foam::vector& Foam::parcel::n() const
{
return n_;
}
inline vector& parcel::n()
inline Foam::vector& Foam::parcel::n()
{
return n_;
}
inline const scalarField& parcel::X() const
inline const Foam::scalarField& Foam::parcel::X() const
{
return X_;
}
inline scalarField& parcel::X()
inline Foam::scalarField& Foam::parcel::X()
{
return X_;
}
inline scalar& parcel::tMom()
inline Foam::scalar& Foam::parcel::tMom()
{
return tMom_;
}
inline scalar parcel::tMom() const
inline Foam::scalar Foam::parcel::tMom() const
{
return tMom_;
}
inline vector parcel::Urel(const vector& U) const
inline Foam::vector Foam::parcel::Urel(const vector& U) const
{
return U_ - U;
}
inline void parcel::correctNormal
(
const vector& sym
)
inline void Foam::parcel::correctNormal(const vector& sym)
{
scalar d = position() & sym;
n_ = position() - d*sym;
......@@ -206,8 +229,4 @@ inline void parcel::correctNormal
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -30,17 +30,18 @@ License
Foam::parcel::parcel
(
const Cloud<parcel>& cloud,
const polyMesh& mesh,
Istream& is,
bool readFields
)
:
Particle<parcel>(cloud, is, readFields),
particle(mesh, is, readFields),
liquidComponents_
(
(cloud.pMesh().lookupObject<dictionary>("thermophysicalProperties"))
.lookup("liquidComponents")
(
mesh.lookupObject<dictionary>("thermophysicalProperties")
).lookup("liquidComponents")
),
X_(liquidComponents_.size(), 0.0),
......@@ -102,7 +103,7 @@ void Foam::parcel::readFields(Cloud<parcel>& c)
return;
}
Particle<parcel>::readFields(c);
particle::readFields(c);
IOField<scalar> d(c.fieldIOobject("d", IOobject::MUST_READ));
c.checkFieldIOobject(c, d);
......@@ -195,7 +196,7 @@ void Foam::parcel::readFields(Cloud<parcel>& c)
void Foam::parcel::writeFields(const Cloud<parcel>& c)
{
Particle<parcel>::writeFields(c);
particle::writeFields(c);
label np = c.size();
......@@ -289,10 +290,9 @@ void Foam::parcel::writeFields(const Cloud<parcel>& c)
Foam::Ostream& Foam::operator<<(Ostream& os, const parcel& p)
{
if (os.format() == IOstream::ASCII)
{
os << static_cast<const Particle<parcel>&>(p)
os << static_cast<const particle&>(p)
<< token::SPACE << p.d_
<< token::SPACE << p.T_
<< token::SPACE << p.m_
......@@ -310,7 +310,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const parcel& p)
}
else
{
os << static_cast<const Particle<parcel>&>(p);
os << static_cast<const particle>(p);
os.write
(
reinterpret_cast<const char*>(&p.d_),
......
......@@ -23,7 +23,7 @@ if (!foundCell)
{
injectionPosition = it->position(n);
findCellFacePt
mesh_.findCellFacePt
(
injectionPosition,
injectorCell,
......
......@@ -46,6 +46,7 @@ License
namespace Foam
{
defineTemplateTypeNameAndDebug(Cloud<parcel>, 0);
defineTemplateTypeNameAndDebug(IOPtrList<injector>, 0);
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -36,6 +36,8 @@ void Foam::spray::inject()
scalar time = runTime_.value();
scalar time0 = time0_;
parcel::trackingData td(*this);
// Inject the parcels for each injector sequentially
forAll(injectors_, i)
{
......@@ -111,7 +113,7 @@ void Foam::spray::inject()
label injectorTetFaceI = -1;
label injectorTetPtI = -1;
findCellFacePt
mesh_.findCellFacePt
(
injectionPosition,
injectorCell,
......@@ -119,7 +121,7 @@ void Foam::spray::inject()
injectorTetPtI