diff --git a/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C b/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C index 3735f340bb..18631da635 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C @@ -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(); } diff --git a/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.H b/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.H index ce322332ee..5046df3f1c 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.H @@ -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_; diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index cfd9bef857..8a8723a539 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -36,43 +36,32 @@ License // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // template -Foam::scalar Foam::KinematicCloud::setNumberOfParticles +void Foam::KinematicCloud::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::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::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::KinematicCloud particleProperties_.subDict("integrationSchemes") ) ), - nInjections_(0), - nParcelsAdded_(0), - nParcelsAddedTotal_(0), UTrans_ ( IOobject @@ -191,27 +169,7 @@ Foam::KinematicCloud::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::KinematicCloud" - "(const word&, const volScalarField&" - ", const volVectorField&, const volScalarField&, const " - "dimensionedVector&)" - )<< "parcelBasisType must be either 'number' or 'mass'" << nl - << exit(FatalError); - } -} +{} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -265,7 +223,12 @@ void Foam::KinematicCloud::evolve() g_.value() ); - inject(); + this->injection().inject(td); + + if (debug) + { + this->dumpParticlePositions(); + } if (coupled_) { @@ -276,160 +239,16 @@ void Foam::KinematicCloud::evolve() } -template -void Foam::KinematicCloud::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; iParcelinjection().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(); - - if (debug) - { - this->dumpParticlePositions(); - } -} - - -template -void Foam::KinematicCloud::injectParcel(ParcelType* p) -{ - addParticle(p); - nParcelsAdded_++; - nParcelsAddedTotal_++; - massInjected_ += p->mass()*p->nParticle(); -} - - -template -void Foam::KinematicCloud::postInjectCheck() -{ - if (nParcelsAdded_) - { - Pout<< "\n--> Cloud: " << this->name() << nl - << " Added " << nParcelsAdded_ - << " new parcels" << nl << endl; - } - - // Reset parcel counters - nParcelsAdded_ = 0; - - // Set time for start of next injection - time0_ = this->db().time().value(); - - // Increment number of injections - nInjections_++; -} - - template void Foam::KinematicCloud::info() const { Info<< "Cloud name: " << this->name() << nl << " Parcels added during this run = " - << returnReduce(nParcelsAddedTotal_, sumOp