Commit 8d50450b authored by andy's avatar andy
Browse files

ENH: made functions public + added new average marcel mass calc

parent 9f7b8f6c
......@@ -158,45 +158,6 @@ void Foam::CellZoneInjection<CloudType>::setPositions
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class CloudType>
Foam::label Foam::CellZoneInjection<CloudType>::parcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((0.0 >= time0) && (0.0 < time1))
{
return positions_.size();
}
else
{
return 0;
}
}
template<class CloudType>
Foam::scalar Foam::CellZoneInjection<CloudType>::volumeToInject
(
const scalar time0,
const scalar time1
)
{
// All parcels introduced at SOI
if ((0.0 >= time0) && (0.0 < time1))
{
return this->volumeTotal_;
}
else
{
return 0.0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
......@@ -316,6 +277,43 @@ Foam::scalar Foam::CellZoneInjection<CloudType>::timeEnd() const
}
template<class CloudType>
Foam::label Foam::CellZoneInjection<CloudType>::parcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((0.0 >= time0) && (0.0 < time1))
{
return positions_.size();
}
else
{
return 0;
}
}
template<class CloudType>
Foam::scalar Foam::CellZoneInjection<CloudType>::volumeToInject
(
const scalar time0,
const scalar time1
)
{
// All parcels introduced at SOI
if ((0.0 >= time0) && (0.0 < time1))
{
return this->volumeTotal_;
}
else
{
return 0.0;
}
}
template<class CloudType>
void Foam::CellZoneInjection<CloudType>::setPositionAndCell
(
......
......@@ -95,25 +95,6 @@ class CellZoneInjection
void setPositions(const labelList& cellZoneCells);
protected:
// Protected member functions
//- Number of parcels to introduce over the time step relative to SOI
label parcelsToInject
(
const scalar time0,
const scalar time1
);
//- Volume of parcels to introduce over the time step relative to SOI
scalar volumeToInject
(
const scalar time0,
const scalar time1
);
public:
//- Runtime type information
......@@ -147,6 +128,12 @@ public:
//- Return the end-of-injection time
scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
label parcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
scalar volumeToInject(const scalar time0, const scalar time1);
// Injection geometry
......
......@@ -30,53 +30,6 @@ License
using namespace Foam::constant::mathematical;
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class CloudType>
Foam::label Foam::ConeInjection<CloudType>::parcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
{
const scalar targetVolume = flowRateProfile_().integrate(0, time1);
const label targetParcels =
parcelsPerInjector_*targetVolume/this->volumeTotal_;
const label nToInject = targetParcels - nInjected_;
nInjected_ += nToInject;
return positionAxis_.size()*nToInject;
}
else
{
return 0;
}
}
template<class CloudType>
Foam::scalar Foam::ConeInjection<CloudType>::volumeToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
{
return flowRateProfile_().integrate(time0, time1);
}
else
{
return 0.0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
......@@ -195,6 +148,51 @@ Foam::scalar Foam::ConeInjection<CloudType>::timeEnd() const
}
template<class CloudType>
Foam::label Foam::ConeInjection<CloudType>::parcelsToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
{
const scalar targetVolume = flowRateProfile_().integrate(0, time1);
const label targetParcels =
parcelsPerInjector_*targetVolume/this->volumeTotal_;
const label nToInject = targetParcels - nInjected_;
nInjected_ += nToInject;
return positionAxis_.size()*nToInject;
}
else
{
return 0;
}
}
template<class CloudType>
Foam::scalar Foam::ConeInjection<CloudType>::volumeToInject
(
const scalar time0,
const scalar time1
)
{
if ((time0 >= 0.0) && (time0 < duration_))
{
return flowRateProfile_().integrate(time0, time1);
}
else
{
return 0.0;
}
}
template<class CloudType>
void Foam::ConeInjection<CloudType>::setPositionAndCell
(
......
......@@ -113,17 +113,6 @@ class ConeInjection
vectorList tanVec2_;
protected:
// Protected Member Functions
//- Number of parcels to introduce over the time step relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce over the time step relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
public:
//- Runtime type information
......@@ -157,6 +146,13 @@ public:
//- Return the end-of-injection time
scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
// Injection geometry
......
......@@ -29,44 +29,6 @@ License
using namespace Foam::constant::mathematical;
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class CloudType>
Foam::label Foam::FieldActivatedInjection<CloudType>::parcelsToInject
(
const scalar time0,
const scalar time1
)
{
if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
{
return positions_.size();
}
else
{
return 0;
}
}
template<class CloudType>
Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject
(
const scalar time0,
const scalar time1
)
{
if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
{
return this->volumeTotal_/nParcelsPerInjector_;
}
else
{
return 0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
......@@ -180,16 +142,45 @@ Foam::FieldActivatedInjection<CloudType>::~FieldActivatedInjection()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
bool Foam::FieldActivatedInjection<CloudType>::active() const
Foam::scalar Foam::FieldActivatedInjection<CloudType>::timeEnd() const
{
return true;
return GREAT;
}
template<class CloudType>
Foam::scalar Foam::FieldActivatedInjection<CloudType>::timeEnd() const
Foam::label Foam::FieldActivatedInjection<CloudType>::parcelsToInject
(
const scalar time0,
const scalar time1
)
{
return GREAT;
if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
{
return positions_.size();
}
else
{
return 0;
}
}
template<class CloudType>
Foam::scalar Foam::FieldActivatedInjection<CloudType>::volumeToInject
(
const scalar time0,
const scalar time1
)
{
if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size())
{
return this->volumeTotal_/nParcelsPerInjector_;
}
else
{
return 0;
}
}
......
......@@ -115,17 +115,6 @@ class FieldActivatedInjection
sizeDistribution_;
protected:
// Protected Member Functions
//- Number of parcels to introduce over the time step relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce over the time step relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
public:
//- Runtime type information
......@@ -156,12 +145,15 @@ public:
// Member Functions
//- Flag to indicate whether model activates injection model
bool active() const;
//- Return the end-of-injection time
scalar timeEnd() const;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject(const scalar time0, const scalar time1);
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject(const scalar time0, const scalar time1);
// Injection geometry
......
......@@ -31,7 +31,129 @@ License
using namespace Foam::constant::mathematical;
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::InflationInjection<CloudType>::InflationInjection
(
const dictionary& dict,
CloudType& owner
)
:
InjectionModel<CloudType>(dict, owner, typeName),
generationSetName_(this->coeffDict().lookup("generationCellSet")),
inflationSetName_(this->coeffDict().lookup("inflationCellSet")),
generationCells_(),
inflationCells_(),
duration_(readScalar(this->coeffDict().lookup("duration"))),
flowRateProfile_
(
DataEntry<scalar>::New
(
"flowRateProfile",
this->coeffDict()
)
),
growthRate_
(
DataEntry<scalar>::New
(
"growthRate",
this->coeffDict()
)
),
newParticles_(),
volumeAccumulator_(0.0),
fraction_(1.0),
selfSeed_(this->coeffDict().lookupOrDefault("selfSeed", false)),
dSeed_(SMALL),
sizeDistribution_
(
distributionModels::distributionModel::New
(
this->coeffDict().subDict("sizeDistribution"),
owner.rndGen()
)
)
{
if (selfSeed_)
{
dSeed_ = readScalar(this->coeffDict().lookup("dSeed"));
}
cellSet generationCells(this->owner().mesh(), generationSetName_);
generationCells_ = generationCells.toc();
cellSet inflationCells(this->owner().mesh(), inflationSetName_);
// Union of cellSets
inflationCells |= generationCells;
inflationCells_ = inflationCells.toc();
if (Pstream::parRun())
{
scalar generationVolume = 0.0;
forAll(generationCells_, gCI)
{
label cI = generationCells_[gCI];
generationVolume += this->owner().mesh().cellVolumes()[cI];
}
scalar totalGenerationVolume = generationVolume;
reduce(totalGenerationVolume, sumOp<scalar>());
fraction_ = generationVolume/totalGenerationVolume;
}
// Set total volume/mass to inject
this->volumeTotal_ = fraction_*flowRateProfile_().integrate(0.0, duration_);
this->massTotal_ *= fraction_;
}
template<class CloudType>
Foam::InflationInjection<CloudType>::InflationInjection
(
const Foam::InflationInjection<CloudType>& im
)
:
InjectionModel<CloudType>(im),
generationSetName_(im.generationSetName_),
inflationSetName_(im.inflationSetName_),
generationCells_(im.generationCells_),
inflationCells_(im.inflationCells_),
duration_(im.duration_),
flowRateProfile_(im.flowRateProfile_().clone().ptr()),
growthRate_(im.growthRate_().clone().ptr()),
newParticles_(im.newParticles_),
volumeAccumulator_(im.volumeAccumulator_),
fraction_(im.fraction_),
selfSeed_(im.selfSeed_),
dSeed_(im.dSeed_),
sizeDistribution_(im.sizeDistribution_().clone().ptr())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::InflationInjection<CloudType>::~InflationInjection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
Foam::scalar Foam::InflationInjection<CloudType>::timeEnd() const
{
return this->SOI_ + duration_;
}
template<class CloudType>
Foam::label Foam::InflationInjection<CloudType>::parcelsToInject
......@@ -305,130 +427,6 @@ Foam::scalar Foam::InflationInjection<CloudType>::volumeToInject
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::InflationInjection<CloudType>::InflationInjection
(
const dictionary& dict,
CloudType& owner
)
:
InjectionModel<CloudType>(dict, owner, typeName),
generationSetName_(this->coeffDict().lookup("generationCellSet")),
inflationSetName_(this->coeffDict().lookup("inflationCellSet")),
generationCells_(),
inflationCells_(),
duration_(readScalar(this->coeffDict().lookup("duration"))),
flowRateProfile_
(
DataEntry<scalar>::New
(
"flowRateProfile",
this->coeffDict()
)
),
growthRate_
(
DataEntry<scalar>::New
(
"growthRate",
this->coeffDict()
)
),
newParticles_(),
volumeAccumulator_(0.0),
fraction_(1.0),
selfSeed_(this->coeffDict().lookupOrDefault("selfSeed", false)),
dSeed_(SMALL),
sizeDistribution_
(<