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

View File

@ -108,14 +108,14 @@ protected:
// 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
(
const scalar time0,
const scalar time1
) const;
//- Number of parcels to introduce over the time step
//- Number of parcels to introduce over the time step relative to SOI
scalar volumeToInject
(
const scalar time0,
@ -155,7 +155,7 @@ public:
// Injection geometry
//- Set the injection position and owner cell
void setPositionAndCell
virtual void setPositionAndCell
(
const label parcelI,
const scalar time,
@ -163,23 +163,21 @@ public:
label& cellOwner
);
//- Return the velocity of the parcel to introduce at a time
vector velocity
virtual void setProperties
(
const label parcelI,
const scalar time
const scalar time,
typename CloudType::parcelType* pPtr
);
//- Return the diameter of the parcel to introduce at a time
scalar d0
(
const label parcelI,
const scalar time
) const;
virtual bool fullyDescribed() const
{
return false;
}
//- Return flag to identify whether or not injection in cellI is
// 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>
Foam::vector Foam::FieldActivatedInjection<CloudType>::velocity
(
const label,
const scalar
)
{
return U0_;
}
template<class CloudType>
Foam::scalar Foam::FieldActivatedInjection<CloudType>::d0
void Foam::FieldActivatedInjection<CloudType>::setProperties
(
const label parcelI,
const scalar
) const
const scalar,
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
//- Number of parcels to introduce over the time step
//- Number of parcels to introduce over the time step relative to SOI
label parcelsToInject
(
const scalar time0,
const scalar time1
) const;
//- Volume of parcels to introduce over the time step
//- Volume of parcels to introduce over the time step relative to SOI
scalar volumeToInject
(
const scalar time0,
@ -160,7 +160,7 @@ public:
// Injection geometry
//- Set the injection position and owner cell
void setPositionAndCell
virtual void setPositionAndCell
(
const label parcelI,
const scalar time,
@ -168,23 +168,21 @@ public:
label& cellOwner
);
//- Return the velocity of the parcel to introduce at a time
vector velocity
virtual void setProperties
(
const label parcelI,
const scalar time
const scalar time,
typename CloudType::parcelType* pPtr
);
//- Return the diameter of the parcel to introduce at a time
scalar d0
(
const label parcelI,
const scalar time
) const;
virtual bool fullyDescribed() const
{
return false;
}
//- Return flag to identify whether or not injection in cellI is
// 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>
void Foam::InjectionModel<CloudType>::prepareForNextTimeStep
(
const scalar time0,
const scalar time1,
const scalar time,
label& newParcels,
scalar& newVolume
)
@ -99,15 +98,15 @@ void Foam::InjectionModel<CloudType>::prepareForNextTimeStep
newVolume = 0.0;
// Return if not started injection event
if (time1 < SOI_)
if (time < SOI_)
{
timeStep0_ = time1;
timeStep0_ = time;
return;
}
// Make times relative to SOI
scalar t0 = timeStep0_ - SOI_;
scalar t1 = time1 - SOI_;
scalar t1 = time - SOI_;
// Number of parcels to inject
newParcels = parcelsToInject(t0, t1);
@ -123,7 +122,7 @@ void Foam::InjectionModel<CloudType>::prepareForNextTimeStep
else
{
// 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 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();
// Prepare for next time step
label newParcels = 0;
scalar newVolume = 0.0;
prepareForNextTimeStep(time0_, time, newParcels, newVolume);
prepareForNextTimeStep(time, newParcels, newVolume);
// Return if no parcels are required
if (newParcels == 0)
@ -363,18 +371,11 @@ void Foam::InjectionModel<CloudType>::inject(TrackData& td)
return;
}
// Particle density given by constant properties
const scalar rho = td.constProps().rho0();
// Volume fraction to introduce during this timestep
const scalar volFraction = volumeFraction(newVolume);
// Duration of injection period during this timestep
const scalar deltaT = min
(
continuousDt,
min(time - SOI_, timeEnd() - time0_)
);
const scalar deltaT = min(carrierDt, min(time - SOI_, timeEnd() - time0_));
// Pad injection time if injection starts during this timestep
const scalar padTime = max(0.0, SOI_ - time0_);
@ -383,44 +384,56 @@ void Foam::InjectionModel<CloudType>::inject(TrackData& td)
label parcelsAdded = 0;
for (label parcelI=0; parcelI<newParcels; parcelI++)
{
// Calculate the pseudo time of injection for parcel 'parcelI'
scalar timeInj = time0_ + padTime + deltaT*parcelI/newParcels;
// Determine the injection position and owner cell
label cellI = -1;
vector pos = vector::zero;
setPositionAndCell(parcelI, timeInj, pos, cellI);
if (cellI > -1)
if (validInjection(parcelI))
{
if (validInjection(parcelI))
// Calculate the pseudo time of injection for parcel 'parcelI'
scalar timeInj = time0_ + padTime + deltaT*parcelI/newParcels;
// Determine the injection position and owner cell
label cellI = -1;
vector pos = vector::zero;
setPositionAndCell(parcelI, timeInj, pos, cellI);
if (cellI > -1)
{
// Diameter of parcels
scalar d = d0(parcelI, timeInj);
// Number of particles per parcel
scalar nP = setNumberOfParticles
(
newParcels,
newVolume,
volFraction,
d,
rho
);
// Velocity of parcels
vector U = velocity(parcelI, timeInj);
// Lagrangian timestep
scalar dt = time - timeInj;
// Apply corrections for 2-D cases
// Apply corrections to position for 2-D cases
meshTools::constrainToMeshCentre(mesh, pos);
meshTools::constrainDirection(mesh, mesh.solutionD(), U);
// 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
pPtr->nParticle() =
setNumberOfParticles
(
newParcels,
newVolume,
volFraction,
pPtr->d(),
pPtr->rho()
);
// Add the new parcel
td.cloud().addNewParcel(pos, cellI, d, U, nP, dt);
massInjected_ += nP*rho*mathematicalConstant::pi*pow3(d)/6.0;
td.cloud().addParticle(pPtr);
massInjected_ += pPtr->nParticle()*pPtr->mass();
parcelsAdded++;
}
}

View File

@ -93,6 +93,9 @@ protected:
// Protected data
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
// Global injection properties
//- Start of injection [s]
@ -132,14 +135,14 @@ protected:
// 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
(
const scalar time0,
const scalar time1
) 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
(
const scalar time0,
@ -153,8 +156,7 @@ protected:
//- Determine properties for next time step/injection interval
virtual void prepareForNextTimeStep
(
const scalar time0,
const scalar time1,
const scalar time,
label& newParcels,
scalar& newVolume
);
@ -291,6 +293,15 @@ public:
label& cellOwner
) = 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
virtual vector velocity
(
@ -304,6 +315,7 @@ public:
const label parcelI,
const scalar time
) const = 0;
*/
};

View File

@ -130,7 +130,7 @@ template<class CloudType>
Foam::scalar Foam::ManualInjection<CloudType>::timeEnd() const
{
// Not used
return 0.0;
return this->SOI_;
}
@ -149,24 +149,18 @@ void Foam::ManualInjection<CloudType>::setPositionAndCell
template<class CloudType>
Foam::vector Foam::ManualInjection<CloudType>::velocity
(
const label,
const scalar
)
{
return U0_;
}
template<class CloudType>
Foam::scalar Foam::ManualInjection<CloudType>::d0
void Foam::ManualInjection<CloudType>::setProperties
(
const label parcelI,
const scalar
) const
const scalar,
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
//- Number of parcels to introduce over the time step
//- Number of parcels to introduce over the time step relative to SOI
label parcelsToInject
(
const scalar time0,
const scalar time1
) const;
//- Volume of parcels to introduce over the time step
//- Volume of parcels to introduce over the time step relative to SOI
scalar volumeToInject
(
const scalar time0,
@ -132,7 +132,7 @@ public:
// Injection geometry
//- Set the injection position and owner cell
void setPositionAndCell
virtual void setPositionAndCell
(
const label parcelI,
const scalar time,
@ -140,23 +140,21 @@ public:
label& cellOwner
);
//- Return the velocity of the parcel to introduce at a time
vector velocity
virtual void setProperties
(
const label parcelI,
const scalar time
const scalar time,
typename CloudType::parcelType* pPtr
);
//- Return the diameter of the parcel to introduce at a time
scalar d0
(
const label parcelI,
const scalar time
) const;
virtual bool fullyDescribed() const
{
return false;
}
//- Return flag to identify whether or not injection in cellI is
// 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>
Foam::vector Foam::NoInjection<CloudType>::velocity
void Foam::NoInjection<CloudType>::setProperties
(
const label,
const scalar
const label parcelI,
const scalar,
typename CloudType::parcelType* pPtr
)
{
return vector::zero;
}
// set particle velocity
pPtr->U() = vector::zero;
template<class CloudType>
Foam::scalar Foam::NoInjection<CloudType>::d0
(
const label,
const scalar
) const
{
return 0.0;
// set particle diameter
pPtr->d() = 0.0;
}

View File

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