using new setProperties method for new particles

This commit is contained in:
andy
2009-05-26 11:25:15 +01:00
parent 7209a42ec0
commit 48d003675a
10 changed files with 155 additions and 162 deletions

View File

@ -186,12 +186,14 @@ void Foam::ConeInjection<CloudType>::setPositionAndCell
template<class CloudType> template<class CloudType>
Foam::vector Foam::ConeInjection<CloudType>::velocity void Foam::ConeInjection<CloudType>::setProperties
( (
const label, const label parcelI,
const scalar time const scalar time,
typename CloudType::parcelType* pPtr
) )
{ {
// set particle velocity
const scalar deg2Rad = mathematicalConstant::pi/180.0; const scalar deg2Rad = mathematicalConstant::pi/180.0;
scalar t = time - this->SOI_; scalar t = time - this->SOI_;
@ -210,23 +212,15 @@ Foam::vector Foam::ConeInjection<CloudType>::velocity
dirVec += normal; dirVec += normal;
dirVec /= mag(dirVec); dirVec /= mag(dirVec);
return Umag_().value(t)*dirVec; pPtr->U() = Umag_().value(t)*dirVec;
// set particle diameter
pPtr->d() = parcelPDF_().sample();
} }
template<class CloudType> template<class CloudType>
Foam::scalar Foam::ConeInjection<CloudType>::d0 bool Foam::ConeInjection<CloudType>::validInjection(const label)
(
const label,
const scalar
) const
{
return parcelPDF_().sample();
}
template<class CloudType>
bool Foam::ConeInjection<CloudType>::validInjection(const label parcelI)
{ {
return true; return true;
} }

View File

@ -108,14 +108,14 @@ protected:
// Protected member functions // Protected member functions
//- Number of parcels to introduce over the time step //- Number of parcels to introduce over the time step relative to SOI
label parcelsToInject label parcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) const; ) const;
//- Number of parcels to introduce over the time step //- Number of parcels to introduce over the time step relative to SOI
scalar volumeToInject scalar volumeToInject
( (
const scalar time0, const scalar time0,
@ -155,7 +155,7 @@ public:
// Injection geometry // Injection geometry
//- Set the injection position and owner cell //- Set the injection position and owner cell
void setPositionAndCell virtual void setPositionAndCell
( (
const label parcelI, const label parcelI,
const scalar time, const scalar time,
@ -163,23 +163,21 @@ public:
label& cellOwner label& cellOwner
); );
//- Return the velocity of the parcel to introduce at a time virtual void setProperties
vector velocity
( (
const label parcelI, const label parcelI,
const scalar time const scalar time,
typename CloudType::parcelType* pPtr
); );
//- Return the diameter of the parcel to introduce at a time virtual bool fullyDescribed() const
scalar d0 {
( return false;
const label parcelI, }
const scalar time
) const;
//- Return flag to identify whether or not injection in cellI is //- Return flag to identify whether or not injection in cellI is
// permitted // permitted
bool validInjection(const label parcelI); virtual bool validInjection(const label parcelI);
}; };

View File

@ -181,24 +181,18 @@ void Foam::FieldActivatedInjection<CloudType>::setPositionAndCell
template<class CloudType> template<class CloudType>
Foam::vector Foam::FieldActivatedInjection<CloudType>::velocity void Foam::FieldActivatedInjection<CloudType>::setProperties
(
const label,
const scalar
)
{
return U0_;
}
template<class CloudType>
Foam::scalar Foam::FieldActivatedInjection<CloudType>::d0
( (
const label parcelI, const label parcelI,
const scalar const scalar,
) const typename CloudType::parcelType* pPtr
)
{ {
return diameters_[parcelI]; // set particle velocity
pPtr->U() = U0_;
// set particle diameter
pPtr->d() = diameters_[parcelI];
} }

View File

@ -113,14 +113,14 @@ protected:
// Protected member functions // Protected member functions
//- Number of parcels to introduce over the time step //- Number of parcels to introduce over the time step relative to SOI
label parcelsToInject label parcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) const; ) const;
//- Volume of parcels to introduce over the time step //- Volume of parcels to introduce over the time step relative to SOI
scalar volumeToInject scalar volumeToInject
( (
const scalar time0, const scalar time0,
@ -160,7 +160,7 @@ public:
// Injection geometry // Injection geometry
//- Set the injection position and owner cell //- Set the injection position and owner cell
void setPositionAndCell virtual void setPositionAndCell
( (
const label parcelI, const label parcelI,
const scalar time, const scalar time,
@ -168,23 +168,21 @@ public:
label& cellOwner label& cellOwner
); );
//- Return the velocity of the parcel to introduce at a time virtual void setProperties
vector velocity
( (
const label parcelI, const label parcelI,
const scalar time const scalar time,
typename CloudType::parcelType* pPtr
); );
//- Return the diameter of the parcel to introduce at a time virtual bool fullyDescribed() const
scalar d0 {
( return false;
const label parcelI, }
const scalar time
) const;
//- Return flag to identify whether or not injection in cellI is //- Return flag to identify whether or not injection in cellI is
// permitted // permitted
bool validInjection(const label parcelI); virtual bool validInjection(const label parcelI);
}; };

View File

@ -88,8 +88,7 @@ void Foam::InjectionModel<CloudType>::writeProps()
template<class CloudType> template<class CloudType>
void Foam::InjectionModel<CloudType>::prepareForNextTimeStep void Foam::InjectionModel<CloudType>::prepareForNextTimeStep
( (
const scalar time0, const scalar time,
const scalar time1,
label& newParcels, label& newParcels,
scalar& newVolume scalar& newVolume
) )
@ -99,15 +98,15 @@ void Foam::InjectionModel<CloudType>::prepareForNextTimeStep
newVolume = 0.0; newVolume = 0.0;
// Return if not started injection event // Return if not started injection event
if (time1 < SOI_) if (time < SOI_)
{ {
timeStep0_ = time1; timeStep0_ = time;
return; return;
} }
// Make times relative to SOI // Make times relative to SOI
scalar t0 = timeStep0_ - SOI_; scalar t0 = timeStep0_ - SOI_;
scalar t1 = time1 - SOI_; scalar t1 = time - SOI_;
// Number of parcels to inject // Number of parcels to inject
newParcels = parcelsToInject(t0, t1); newParcels = parcelsToInject(t0, t1);
@ -123,7 +122,7 @@ void Foam::InjectionModel<CloudType>::prepareForNextTimeStep
else else
{ {
// advance value of timeStep0_ // advance value of timeStep0_
timeStep0_ = time1; timeStep0_ = time;
} }
} }
@ -348,13 +347,22 @@ void Foam::InjectionModel<CloudType>::inject(TrackData& td)
} }
const scalar time = owner_.db().time().value(); const scalar time = owner_.db().time().value();
const scalar continuousDt = owner_.db().time().deltaT().value(); /*
// Return if not started injection event
if (time < SOI_)
{
timeStep0_ = time;
postInjectCheck(0);
return;
}
*/
const scalar carrierDt = owner_.db().time().deltaT().value();
const polyMesh& mesh = owner_.mesh(); const polyMesh& mesh = owner_.mesh();
// Prepare for next time step // Prepare for next time step
label newParcels = 0; label newParcels = 0;
scalar newVolume = 0.0; scalar newVolume = 0.0;
prepareForNextTimeStep(time0_, time, newParcels, newVolume); prepareForNextTimeStep(time, newParcels, newVolume);
// Return if no parcels are required // Return if no parcels are required
if (newParcels == 0) if (newParcels == 0)
@ -363,18 +371,11 @@ void Foam::InjectionModel<CloudType>::inject(TrackData& td)
return; return;
} }
// Particle density given by constant properties
const scalar rho = td.constProps().rho0();
// Volume fraction to introduce during this timestep // Volume fraction to introduce during this timestep
const scalar volFraction = volumeFraction(newVolume); const scalar volFraction = volumeFraction(newVolume);
// Duration of injection period during this timestep // Duration of injection period during this timestep
const scalar deltaT = min const scalar deltaT = min(carrierDt, min(time - SOI_, timeEnd() - time0_));
(
continuousDt,
min(time - SOI_, timeEnd() - time0_)
);
// Pad injection time if injection starts during this timestep // Pad injection time if injection starts during this timestep
const scalar padTime = max(0.0, SOI_ - time0_); const scalar padTime = max(0.0, SOI_ - time0_);
@ -382,6 +383,8 @@ void Foam::InjectionModel<CloudType>::inject(TrackData& td)
// Introduce new parcels linearly across carrier phase timestep // Introduce new parcels linearly across carrier phase timestep
label parcelsAdded = 0; label parcelsAdded = 0;
for (label parcelI=0; parcelI<newParcels; parcelI++) for (label parcelI=0; parcelI<newParcels; parcelI++)
{
if (validInjection(parcelI))
{ {
// Calculate the pseudo time of injection for parcel 'parcelI' // Calculate the pseudo time of injection for parcel 'parcelI'
scalar timeInj = time0_ + padTime + deltaT*parcelI/newParcels; scalar timeInj = time0_ + padTime + deltaT*parcelI/newParcels;
@ -393,34 +396,44 @@ void Foam::InjectionModel<CloudType>::inject(TrackData& td)
if (cellI > -1) if (cellI > -1)
{ {
if (validInjection(parcelI)) // Lagrangian timestep
{ scalar dt = time - timeInj;
// Diameter of parcels
scalar d = d0(parcelI, timeInj); // Apply corrections to position for 2-D cases
meshTools::constrainToMeshCentre(mesh, pos);
// Create a new parcel
parcelType* pPtr = new parcelType(td.cloud(), pos, cellI);
// Assign new parcel properties in injection model
setProperties(parcelI, timeInj, pPtr);
// Check new parcel properties
td.cloud().checkParcelProperties(pPtr, dt, fullyDescribed());
// Apply correction to velocity for 2-D cases
meshTools::constrainDirection
(
mesh,
mesh.solutionD(),
pPtr->U()
);
// Number of particles per parcel // Number of particles per parcel
scalar nP = setNumberOfParticles pPtr->nParticle() =
setNumberOfParticles
( (
newParcels, newParcels,
newVolume, newVolume,
volFraction, volFraction,
d, pPtr->d(),
rho pPtr->rho()
); );
// Velocity of parcels
vector U = velocity(parcelI, timeInj);
// Lagrangian timestep
scalar dt = time - timeInj;
// Apply corrections for 2-D cases
meshTools::constrainToMeshCentre(mesh, pos);
meshTools::constrainDirection(mesh, mesh.solutionD(), U);
// Add the new parcel // Add the new parcel
td.cloud().addNewParcel(pos, cellI, d, U, nP, dt); td.cloud().addParticle(pPtr);
massInjected_ += nP*rho*mathematicalConstant::pi*pow3(d)/6.0;
massInjected_ += pPtr->nParticle()*pPtr->mass();
parcelsAdded++; parcelsAdded++;
} }
} }

View File

@ -93,6 +93,9 @@ protected:
// Protected data // Protected data
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
// Global injection properties // Global injection properties
//- Start of injection [s] //- Start of injection [s]
@ -132,14 +135,14 @@ protected:
// Protected member functions // Protected member functions
//- Number of parcels to introduce over the time step //- Number of parcels to introduce over the time step relative to SOI
virtual label parcelsToInject virtual label parcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) const = 0; ) const = 0;
//- Volume of parcels to introduce over the time step //- Volume of parcels to introduce over the time step relative to SOI
virtual scalar volumeToInject virtual scalar volumeToInject
( (
const scalar time0, const scalar time0,
@ -153,8 +156,7 @@ protected:
//- Determine properties for next time step/injection interval //- Determine properties for next time step/injection interval
virtual void prepareForNextTimeStep virtual void prepareForNextTimeStep
( (
const scalar time0, const scalar time,
const scalar time1,
label& newParcels, label& newParcels,
scalar& newVolume scalar& newVolume
); );
@ -291,6 +293,15 @@ public:
label& cellOwner label& cellOwner
) = 0; ) = 0;
virtual void setProperties
(
const label parcelI,
const scalar time,
typename CloudType::parcelType* pPtr
) = 0;
virtual bool fullyDescribed() const = 0;
/*
//- Return the velocity of the parcel to introduce at a time //- Return the velocity of the parcel to introduce at a time
virtual vector velocity virtual vector velocity
( (
@ -304,6 +315,7 @@ public:
const label parcelI, const label parcelI,
const scalar time const scalar time
) const = 0; ) const = 0;
*/
}; };

View File

@ -130,7 +130,7 @@ template<class CloudType>
Foam::scalar Foam::ManualInjection<CloudType>::timeEnd() const Foam::scalar Foam::ManualInjection<CloudType>::timeEnd() const
{ {
// Not used // Not used
return 0.0; return this->SOI_;
} }
@ -149,24 +149,18 @@ void Foam::ManualInjection<CloudType>::setPositionAndCell
template<class CloudType> template<class CloudType>
Foam::vector Foam::ManualInjection<CloudType>::velocity void Foam::ManualInjection<CloudType>::setProperties
(
const label,
const scalar
)
{
return U0_;
}
template<class CloudType>
Foam::scalar Foam::ManualInjection<CloudType>::d0
( (
const label parcelI, const label parcelI,
const scalar const scalar,
) const typename CloudType::parcelType* pPtr
)
{ {
return diameters_[parcelI]; // set particle velocity
pPtr->U() = U0_;
// set particle diameter
pPtr->d() = diameters_[parcelI];
} }

View File

@ -85,14 +85,14 @@ protected:
// Protected member functions // Protected member functions
//- Number of parcels to introduce over the time step //- Number of parcels to introduce over the time step relative to SOI
label parcelsToInject label parcelsToInject
( (
const scalar time0, const scalar time0,
const scalar time1 const scalar time1
) const; ) const;
//- Volume of parcels to introduce over the time step //- Volume of parcels to introduce over the time step relative to SOI
scalar volumeToInject scalar volumeToInject
( (
const scalar time0, const scalar time0,
@ -132,7 +132,7 @@ public:
// Injection geometry // Injection geometry
//- Set the injection position and owner cell //- Set the injection position and owner cell
void setPositionAndCell virtual void setPositionAndCell
( (
const label parcelI, const label parcelI,
const scalar time, const scalar time,
@ -140,23 +140,21 @@ public:
label& cellOwner label& cellOwner
); );
//- Return the velocity of the parcel to introduce at a time virtual void setProperties
vector velocity
( (
const label parcelI, const label parcelI,
const scalar time const scalar time,
typename CloudType::parcelType* pPtr
); );
//- Return the diameter of the parcel to introduce at a time virtual bool fullyDescribed() const
scalar d0 {
( return false;
const label parcelI, }
const scalar time
) const;
//- Return flag to identify whether or not injection in cellI is //- Return flag to identify whether or not injection in cellI is
// permitted // permitted
bool validInjection(const label parcelI); virtual bool validInjection(const label parcelI);
}; };

View File

@ -99,24 +99,18 @@ void Foam::NoInjection<CloudType>::setPositionAndCell
template<class CloudType> template<class CloudType>
Foam::vector Foam::NoInjection<CloudType>::velocity void Foam::NoInjection<CloudType>::setProperties
( (
const label, const label parcelI,
const scalar const scalar,
typename CloudType::parcelType* pPtr
) )
{ {
return vector::zero; // set particle velocity
} pPtr->U() = vector::zero;
// set particle diameter
template<class CloudType> pPtr->d() = 0.0;
Foam::scalar Foam::NoInjection<CloudType>::d0
(
const label,
const scalar
) const
{
return 0.0;
} }

View File

@ -56,14 +56,14 @@ protected:
// Protected member functions // Protected member functions
//- Number of parcels to introduce over the time step //- Number of parcels to introduce over the time step relative to SOI
label parcelsToInject label parcelsToInject
( (
const scalar, const scalar,
const scalar const scalar
) const; ) const;
//- Volume of parcels to introduce over the time step //- Volume of parcels to introduce over the time step relative to SOI
scalar volumeToInject scalar volumeToInject
( (
const scalar, const scalar,
@ -103,7 +103,7 @@ public:
// Injection geometry // Injection geometry
//- Set the injection position and owner cell //- Set the injection position and owner cell
void setPositionAndCell virtual void setPositionAndCell
( (
const label parcelI, const label parcelI,
const scalar time, const scalar time,
@ -111,19 +111,17 @@ public:
label& cellOwner label& cellOwner
); );
//- Return the velocity of the parcel to introduce at a time virtual void setProperties
vector velocity
( (
const label parcelI, const label parcelI,
const scalar time const scalar time,
typename CloudType::parcelType* pPtr
); );
//- Return the diameter of the parcel to introduce at a time virtual bool fullyDescribed() const
scalar d0 {
( return false;
const label parcelI, }
const scalar time
) const;
//- Return flag to identify whether or not injection in cellI is //- Return flag to identify whether or not injection in cellI is
// permitted // permitted