Commit fe1f5ebe authored by mattijs's avatar mattijs
Browse files

Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev

parents bc3600f5 34c3702f
......@@ -76,7 +76,7 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
)
),
Ubar_(dict_.lookup("Ubar")),
gradPini_(readScalar(dict_.lookup("gradPini"))),
gradPini_(dict_.lookup("gradPini")),
gradP_(gradPini_),
flowDir_(Ubar_/mag(Ubar_)),
cellSource_(dict_.lookup("cellSource")),
......@@ -121,7 +121,7 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
propsDict.lookup("gradient") >> gradP_;
}
Info<< " Initial pressure gradient = " << gradP_ << endl;
Info<< " Initial pressure gradient = " << gradP_ << nl << endl;
}
......@@ -143,7 +143,7 @@ Foam::pressureGradientExplicitSource::Su() const
IOobject::NO_WRITE
),
mesh_,
dimensionedVector("zero", dimVelocity/dimTime, vector::zero)
dimensionedVector("zero", gradP_.dimensions(), vector::zero)
)
);
......@@ -153,7 +153,7 @@ Foam::pressureGradientExplicitSource::Su() const
{
label cellI = iter.key();
sourceField[cellI] = flowDir_*gradP_;
sourceField[cellI] = flowDir_*gradP_.value();
}
return tSource;
......@@ -201,10 +201,10 @@ void Foam::pressureGradientExplicitSource::update()
}
// Update pressure gradient
gradP_ += gradPplus;
gradP_.value() += gradPplus;
Info<< "Uncorrected Ubar = " << magUbarAve << tab
<< "Pressure gradient = " << gradP_ << endl;
<< "Pressure gradient = " << gradP_.value() << endl;
writeGradP();
}
......
......@@ -73,10 +73,10 @@ class pressureGradientExplicitSource
vector Ubar_;
//- Initial pressure gradient
scalar gradPini_;
dimensionedScalar gradPini_;
//- Pressure gradient
scalar gradP_;
dimensionedScalar gradP_;
//- Flow direction
vector flowDir_;
......
......@@ -36,43 +36,32 @@ License
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class ParcelType>
Foam::scalar Foam::KinematicCloud<ParcelType>::setNumberOfParticles
void Foam::KinematicCloud<ParcelType>::addNewParcel
(
const label nParcels,
const scalar pDiameter,
const scalar pVolumeFraction,
const scalar pRho,
const scalar pVolume
const vector& position,
const label cellId,
const scalar d,
const vector& U,
const scalar nParticles,
const scalar lagrangianDt
)
{
scalar nP = 0.0;
switch (parcelBasis_)
{
case pbMass:
{
nP = pVolumeFraction*massTotal_/nParcels
/(pRho*mathematicalConstant::pi/6.0*pow(pDiameter, 3));
break;
}
case pbNumber:
{
nP = pVolumeFraction*massTotal_/(pRho*pVolume);
break;
}
default:
{
nP = 0.0;
FatalErrorIn
(
"Foam::KinematicCloud<ParcelType>::setNumberOfParticles"
"(const label, const scalar, const scalar, const scalar, "
"const scalar)"
)<< "Unknown parcelBasis type" << nl
<< exit(FatalError);
}
}
ParcelType* pPtr = new ParcelType
(
*this,
parcelTypeId_,
position,
cellId,
d,
U,
nParticles,
constProps_
);
return nP;
scalar continuousDt = this->db().time().deltaT().value();
pPtr->stepFraction() = (continuousDt - lagrangianDt)/continuousDt;
addParticle(pPtr);
}
......@@ -107,14 +96,6 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
parcelTypeId_(readLabel(particleProperties_.lookup("parcelTypeId"))),
coupled_(particleProperties_.lookup("coupled")),
rndGen_(label(0)),
time0_(this->db().time().value()),
parcelBasisType_(particleProperties_.lookup("parcelBasisType")),
parcelBasis_(pbNumber),
massTotal_
(
dimensionedScalar(particleProperties_.lookup("massTotal")).value()
),
massInjected_(0.0),
rho_(rho),
U_(U),
mu_(mu),
......@@ -160,9 +141,6 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
particleProperties_.subDict("integrationSchemes")
)
),
nInjections_(0),
nParcelsAdded_(0),
nParcelsAddedTotal_(0),
UTrans_
(
IOobject
......@@ -191,27 +169,7 @@ Foam::KinematicCloud<ParcelType>::KinematicCloud
mesh_,
dimensionedScalar("zero", dimensionSet(1, 0, -1, 0, 0), 0.0)
)
{
if (parcelBasisType_ == "mass")
{
parcelBasis_ = pbMass;
}
else if (parcelBasisType_ == "number")
{
parcelBasis_ = pbNumber;
}
else
{
FatalErrorIn
(
"Foam::KinematicCloud<ParcelType>::KinematicCloud"
"(const word&, const volScalarField&"
", const volVectorField&, const volScalarField&, const "
"dimensionedVector&)"
)<< "parcelBasisType must be either 'number' or 'mass'" << nl
<< exit(FatalError);
}
}
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
......@@ -265,160 +223,19 @@ void Foam::KinematicCloud<ParcelType>::evolve()
g_.value()
);
inject();
if (coupled_)
{
resetSourceTerms();
}
Cloud<ParcelType>::move(td);
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::inject()
{
scalar time = this->db().time().value();
scalar pRho = constProps_.rho0();
this->injection().prepareForNextTimeStep(time0_, time);
// Number of parcels to introduce during this timestep
const label nParcels = this->injection().nParcels();
// Return if no parcels are required
if (!nParcels)
{
this->postInjectCheck();
return;
}
// Volume of particles to introduce during this timestep
scalar pVolume = this->injection().volume();
// Volume fraction to introduce during this timestep
scalar pVolumeFraction = this->injection().volumeFraction();
// Duration of injection period during this timestep
scalar deltaT = min
(
this->db().time().deltaT().value(),
min
(
time - this->injection().timeStart(),
this->injection().timeEnd() - time0_
)
);
// Pad injection time if injection starts during this timestep
scalar padTime = max
(
0.0,
this->injection().timeStart() - time0_
);
// Introduce new parcels linearly with time
for (label iParcel=0; iParcel<nParcels; iParcel++)
{
// Calculate the pseudo time of injection for parcel 'iParcel'
scalar timeInj = time0_ + padTime + deltaT*iParcel/nParcels;
// Determine injected parcel properties
vector pPosition = this->injection().position
(
iParcel,
timeInj,
this->meshInfo()
);
// Diameter of parcels
scalar pDiameter = this->injection().d0(iParcel, timeInj);
// Number of particles per parcel
scalar pNumberOfParticles = setNumberOfParticles
(
nParcels,
pDiameter,
pVolumeFraction,
pRho,
pVolume
);
// Velocity of parcels
vector pU = this->injection().velocity
(
iParcel,
timeInj,
this->meshInfo()
);
// Determine the injection cell
label pCell = -1;
this->injection().findInjectorCellAndPosition(pCell, pPosition);
if (pCell >= 0)
{
// construct the parcel that is to be injected
ParcelType* pPtr = new ParcelType
(
*this,
parcelTypeId_,
pPosition,
pCell,
pDiameter,
pU,
pNumberOfParticles,
constProps_
);
scalar dt = time - timeInj;
pPtr->stepFraction() = (this->db().time().deltaT().value() - dt)
/this->time().deltaT().value();
this->injectParcel(pPtr);
}
}
this->postInjectCheck();
this->injection().inject(td);
if (debug)
{
this->dumpParticlePositions();
}
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::injectParcel(ParcelType* p)
{
addParticle(p);
nParcelsAdded_++;
nParcelsAddedTotal_++;
massInjected_ += p->mass()*p->nParticle();
}
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::postInjectCheck()
{
if (nParcelsAdded_)
if (coupled_)
{
Pout<< "\n--> Cloud: " << this->name() << nl
<< " Added " << nParcelsAdded_
<< " new parcels" << nl << endl;
resetSourceTerms();
}
// Reset parcel counters
nParcelsAdded_ = 0;
// Set time for start of next injection
time0_ = this->db().time().value();
// Increment number of injections
nInjections_++;
Cloud<ParcelType>::move(td);
}
......@@ -427,9 +244,11 @@ void Foam::KinematicCloud<ParcelType>::info() const
{
Info<< "Cloud name: " << this->name() << nl
<< " Parcels added during this run = "
<< returnReduce(nParcelsAddedTotal_, sumOp<label>()) << nl
<< returnReduce(this->injection().nParcelsAddedTotal(), sumOp<label>())
<< nl
<< " Mass introduced during this run = "
<< returnReduce(massInjected_, sumOp<scalar>()) << nl
<< returnReduce(this->injection().massInjected(), sumOp<scalar>())
<< nl
<< " Current number of parcels = "
<< returnReduce(this->size(), sumOp<label>()) << nl
<< " Current mass in system = "
......@@ -445,7 +264,7 @@ void Foam::KinematicCloud<ParcelType>::dumpParticlePositions() const
(
this->db().time().path()/"parcelPositions_"
+ this->name() + "_"
+ name(this->nInjections_) + ".obj"
+ name(this->injection().nInjections()) + ".obj"
);
forAllConstIter(typename KinematicCloud<ParcelType>, *this, iter)
......
......@@ -85,19 +85,6 @@ class KinematicCloud
public kinematicCloud
{
public:
// Enumerations
//- Parcel basis representation options
// i.e constant number of particles OR constant mass per parcel
enum parcelBasis
{
pbNumber,
pbMass
};
private:
// Private data
......@@ -126,22 +113,6 @@ private:
//- Random number generator - used by some injection routines
Random rndGen_;
//- Time at beginning of timestep
scalar time0_;
// Injection properties
//- Parcel basis
const word parcelBasisType_;
parcelBasis parcelBasis_;
//- Total mass to inject [kg]
scalar massTotal_;
//- Total mass injected to date [kg]
scalar massInjected_;
// References to the carrier gas fields
......@@ -161,9 +132,8 @@ private:
const dimensionedVector& g_;
// Interpolation
dictionary interpolationSchemes_;
//- Interpolation schemes dictionary
dictionary interpolationSchemes_;
// References to the cloud sub-models
......@@ -190,17 +160,6 @@ private:
autoPtr<vectorIntegrationScheme> UIntegrator_;
// Counters
//- Number of injections counter
label nInjections_;
//- Running counters describing parcels added during each
// injection
label nParcelsAdded_;
label nParcelsAddedTotal_;
// Sources
//- Momentum
......@@ -219,30 +178,6 @@ private:
void operator=(const KinematicCloud&);
protected:
// Protected member functions
//- Set the number of particles per parcel
scalar setNumberOfParticles
(
const label nParcels,
const scalar pDiameter,
const scalar pVolumeFraction,
const scalar pRho,
const scalar pVolume
);
//- Inject more parcels
void inject();
//- Inject parcel if it is valid - delete otherwise
void injectParcel(ParcelType* p);
//- Post-injection checks
void postInjectCheck();
public:
// Constructors
......@@ -286,12 +221,6 @@ public:
//- Return refernce to the random object
inline Random& rndGen();
//- Return the start of injection interval time
inline scalar time0() const;
//- Return a reference to the mass of particles to introduce
inline scalar massTotal() const;
// References to the carrier gas fields
......@@ -380,15 +309,6 @@ public:
void dumpParticlePositions() const;
// Counters
//- Return the number of injections
inline label nInjections() const;
//- Return the total number parcels added
inline label nParcelsAddedTotal() const;
// Fields
//- Return the particle volume fraction field
......@@ -402,6 +322,17 @@ public:
// Cloud evolution functions
//- Add new parcel
void addNewParcel
(
const vector& position,
const label cellId,
const scalar d,
const vector& U,
const scalar nParticles,
const scalar lagrangianDt
);
//- Reset the spray source terms
void resetSourceTerms();
......
......@@ -155,41 +155,6 @@ Foam::KinematicCloud<ParcelType>::UIntegrator() const
}
template<class ParcelType>
inline Foam::label Foam::KinematicCloud<ParcelType>::nInjections() const
{
return nInjections_;
}
template<class ParcelType>
inline Foam::label Foam::KinematicCloud<ParcelType>::nParcelsAddedTotal() const
{
return nParcelsAddedTotal_;
}
template<class ParcelType>
inline Foam::scalar Foam::KinematicCloud<ParcelType>::time0() const
{
return time0_;
}
template<class ParcelType>
inline Foam::scalar Foam::KinematicCloud<ParcelType>::massTotal() const
{
return massTotal_;
}
template<class ParcelType>
inline Foam::scalar Foam::KinematicCloud<ParcelType>::massInjected() const
{
return massInjected_;
}
template<class ParcelType>
inline Foam::scalar Foam::KinematicCloud<ParcelType>::massInSystem() const
{
......
......@@ -29,6 +29,42 @@ License
#include "MassTransferModel.H"
#include "SurfaceReactionModel.H"
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::addNewParcel
(
const vector& position,
const label cellId,
const scalar d,
const vector& U,
const scalar nParticles,
const scalar lagrangianDt
)
{
ParcelType* pPtr = new ParcelType
(
*this,
this->parcelTypeId(),
position,
cellId,
d,
U,
nParticles,
composition().YGas0(),
composition().YLiquid0(),
composition().YSolid0(),
composition().YMixture0(),
constProps_
);
scalar continuousDt = this->db().time().deltaT().value();