ENH: Updated diesel library for updated pdf/random containers

This commit is contained in:
andy
2010-10-20 16:04:34 +01:00
parent 114de08135
commit f52a56489c
46 changed files with 91 additions and 103 deletions

View File

@ -25,7 +25,6 @@ License
#include "commonRailInjector.H" #include "commonRailInjector.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "Random.H"
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -175,13 +174,13 @@ Foam::commonRailInjector::~commonRailInjector()
void Foam::commonRailInjector::setTangentialVectors() void Foam::commonRailInjector::setTangentialVectors()
{ {
Random rndGen(label(0)); cachedRandom rndGen(label(0), -1);
scalar magV = 0.0; scalar magV = 0.0;
vector tangent; vector tangent;
while (magV < SMALL) while (magV < SMALL)
{ {
vector testThis = rndGen.vector01(); vector testThis = rndGen.sample01<vector>();
tangent = testThis - (testThis & direction_)*direction_; tangent = testThis - (testThis & direction_)*direction_;
magV = mag(tangent); magV = mag(tangent);
@ -223,7 +222,7 @@ Foam::vector Foam::commonRailInjector::position
const vector& axisOfSymmetry, const vector& axisOfSymmetry,
const vector& axisOfWedge, const vector& axisOfWedge,
const vector& axisOfWedgeNormal, const vector& axisOfWedgeNormal,
Random& rndGen cachedRandom& rndGen
) const ) const
{ {
if (twoD) if (twoD)
@ -241,8 +240,8 @@ Foam::vector Foam::commonRailInjector::position
else else
{ {
// otherwise, disc injection // otherwise, disc injection
scalar iRadius = d_*rndGen.scalar01(); scalar iRadius = d_*rndGen.sample01<scalar>();
scalar iAngle = constant::mathematical::twoPi*rndGen.scalar01(); scalar iAngle = constant::mathematical::twoPi*rndGen.sample01<scalar>();
return return
( (

View File

@ -138,7 +138,7 @@ public:
const vector& axisOfSymmetry, const vector& axisOfSymmetry,
const vector& axisOfWedge, const vector& axisOfWedge,
const vector& axisOfWedgeNormal, const vector& axisOfWedgeNormal,
Random& rndGen cachedRandom& rndGen
) const; ) const;
//- Return the number of holes //- Return the number of holes

View File

@ -25,7 +25,6 @@ License
#include "definedInjector.H" #include "definedInjector.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "Random.H"
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -158,13 +157,13 @@ Foam::definedInjector::~definedInjector()
void Foam::definedInjector::setTangentialVectors() void Foam::definedInjector::setTangentialVectors()
{ {
Random rndGen(label(0)); cachedRandom rndGen(label(0), -1);
scalar magV = 0.0; scalar magV = 0.0;
vector tangent; vector tangent;
while (magV < SMALL) while (magV < SMALL)
{ {
vector testThis = rndGen.vector01(); vector testThis = rndGen.sample01<vector>();
tangent = testThis - (testThis & direction_)*direction_; tangent = testThis - (testThis & direction_)*direction_;
magV = mag(tangent); magV = mag(tangent);
@ -204,7 +203,7 @@ Foam::vector Foam::definedInjector::position
const vector& axisOfSymmetry, const vector& axisOfSymmetry,
const vector& axisOfWedge, const vector& axisOfWedge,
const vector& axisOfWedgeNormal, const vector& axisOfWedgeNormal,
Random& rndGen cachedRandom& rndGen
) const ) const
{ {
if (twoD) if (twoD)
@ -222,8 +221,8 @@ Foam::vector Foam::definedInjector::position
else else
{ {
// otherwise, disc injection // otherwise, disc injection
scalar iRadius = d_*rndGen.scalar01(); scalar iRadius = d_*rndGen.sample01<scalar>();
scalar iAngle = constant::mathematical::twoPi*rndGen.scalar01(); scalar iAngle = constant::mathematical::twoPi*rndGen.sample01<scalar>();
return return
( (

View File

@ -139,7 +139,7 @@ public:
const vector& axisOfSymmetry, const vector& axisOfSymmetry,
const vector& axisOfWedge, const vector& axisOfWedge,
const vector& axisOfWedgeNormal, const vector& axisOfWedgeNormal,
Random& rndGen cachedRandom& rndGen
) const; ) const;
//- Return the number of holes //- Return the number of holes

View File

@ -43,7 +43,7 @@ SourceFiles
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
#include "vector.H" #include "vector.H"
#include "scalarField.H" #include "scalarField.H"
#include "Random.H" #include "cachedRandom.H"
#include "liquidMixture.H" #include "liquidMixture.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -120,7 +120,7 @@ public:
const vector& axisOfSymmetry, const vector& axisOfSymmetry,
const vector& axisOfWedge, const vector& axisOfWedge,
const vector& axisOfWedgeNormal, const vector& axisOfWedgeNormal,
Random& rndGen cachedRandom& rndGen
) const = 0; ) const = 0;
//- Return the number of holes //- Return the number of holes

View File

@ -25,7 +25,6 @@ License
#include "multiHoleInjector.H" #include "multiHoleInjector.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "Random.H"
#include "unitConversion.H" #include "unitConversion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -194,7 +193,7 @@ void Foam::multiHoleInjector::setTangentialVectors()
position_[i] = centerPosition_ + 0.5*nozzleTipDiameter_*dp; position_[i] = centerPosition_ + 0.5*nozzleTipDiameter_*dp;
} }
Random rndGen(label(0)); cachedRandom rndGen(label(0), -1);
for (label i=0; i<nHoles_; i++) for (label i=0; i<nHoles_; i++)
{ {
@ -202,7 +201,7 @@ void Foam::multiHoleInjector::setTangentialVectors()
scalar magV = 0; scalar magV = 0;
while (magV < SMALL) while (magV < SMALL)
{ {
vector testThis = rndGen.vector01(); vector testThis = rndGen.sample01<vector>();
tangent = testThis - (testThis & direction_[i])*direction_[i]; tangent = testThis - (testThis & direction_[i])*direction_[i];
magV = mag(tangent); magV = mag(tangent);
@ -244,7 +243,7 @@ Foam::vector Foam::multiHoleInjector::position
const vector& axisOfSymmetry, const vector& axisOfSymmetry,
const vector& axisOfWedge, const vector& axisOfWedge,
const vector& axisOfWedgeNormal, const vector& axisOfWedgeNormal,
Random& rndGen cachedRandom& rndGen
) const ) const
{ {
if (twoD) if (twoD)
@ -262,8 +261,8 @@ Foam::vector Foam::multiHoleInjector::position
else else
{ {
// otherwise, disc injection // otherwise, disc injection
scalar iRadius = d_*rndGen.scalar01(); scalar iRadius = d_*rndGen.sample01<scalar>();
scalar iAngle = constant::mathematical::twoPi*rndGen.scalar01(); scalar iAngle = constant::mathematical::twoPi*rndGen.sample01<scalar>();
return return
( (

View File

@ -148,7 +148,7 @@ public:
const vector& axisOfSymmetry, const vector& axisOfSymmetry,
const vector& axisOfWedge, const vector& axisOfWedge,
const vector& axisOfWedgeNormal, const vector& axisOfWedgeNormal,
Random& rndGen cachedRandom& rndGen
) const; ) const;
//- Return the number of holes //- Return the number of holes

View File

@ -25,7 +25,6 @@ License
#include "swirlInjector.H" #include "swirlInjector.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "Random.H"
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -179,13 +178,13 @@ Foam::swirlInjector::~swirlInjector()
void Foam::swirlInjector::setTangentialVectors() void Foam::swirlInjector::setTangentialVectors()
{ {
Random rndGen(label(0)); cachedRandom rndGen(label(0), -1);
scalar magV = 0.0; scalar magV = 0.0;
vector tangent; vector tangent;
while (magV < SMALL) while (magV < SMALL)
{ {
vector testThis = rndGen.vector01(); vector testThis = rndGen.sample01<vector>();
tangent = testThis - (testThis & direction_)*direction_; tangent = testThis - (testThis & direction_)*direction_;
magV = mag(tangent); magV = mag(tangent);
@ -226,7 +225,7 @@ Foam::vector Foam::swirlInjector::position
const vector& axisOfSymmetry, const vector& axisOfSymmetry,
const vector& axisOfWedge, const vector& axisOfWedge,
const vector& axisOfWedgeNormal, const vector& axisOfWedgeNormal,
Random& rndGen cachedRandom& rndGen
) const ) const
{ {
if (twoD) if (twoD)
@ -244,8 +243,8 @@ Foam::vector Foam::swirlInjector::position
else else
{ {
// otherwise, disc injection // otherwise, disc injection
scalar iRadius = d_*rndGen.scalar01(); scalar iRadius = d_*rndGen.sample01<scalar>();
scalar iAngle = constant::mathematical::twoPi*rndGen.scalar01(); scalar iAngle = constant::mathematical::twoPi*rndGen.sample01<scalar>();
return return
( (

View File

@ -157,7 +157,7 @@ public:
const vector& axisOfSymmetry, const vector& axisOfSymmetry,
const vector& axisOfWedge, const vector& axisOfWedge,
const vector& axisOfWedgeNormal, const vector& axisOfWedgeNormal,
Random& rndGen cachedRandom& rndGen
) const; ) const;
//- Return the number of holes //- Return the number of holes

View File

@ -25,7 +25,6 @@ License
#include "unitInjector.H" #include "unitInjector.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "Random.H"
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -154,13 +153,13 @@ Foam::unitInjector::~unitInjector()
void Foam::unitInjector::setTangentialVectors() void Foam::unitInjector::setTangentialVectors()
{ {
Random rndGen(label(0)); cachedRandom rndGen(label(0), -1);
scalar magV = 0.0; scalar magV = 0.0;
vector tangent; vector tangent;
while (magV < SMALL) while (magV < SMALL)
{ {
vector testThis = rndGen.vector01(); vector testThis = rndGen.sample01<vector>();
tangent = testThis - (testThis & direction_)*direction_; tangent = testThis - (testThis & direction_)*direction_;
magV = mag(tangent); magV = mag(tangent);
@ -199,7 +198,7 @@ Foam::vector Foam::unitInjector::position
const vector& axisOfSymmetry, const vector& axisOfSymmetry,
const vector& axisOfWedge, const vector& axisOfWedge,
const vector& axisOfWedgeNormal, const vector& axisOfWedgeNormal,
Random& rndGen cachedRandom& rndGen
) const ) const
{ {
if (twoD) if (twoD)
@ -217,8 +216,8 @@ Foam::vector Foam::unitInjector::position
else else
{ {
// otherwise, disc injection // otherwise, disc injection
scalar iRadius = d_*rndGen.scalar01(); scalar iRadius = d_*rndGen.sample01<scalar>();
scalar iAngle = constant::mathematical::twoPi*rndGen.scalar01(); scalar iAngle = constant::mathematical::twoPi*rndGen.sample01<scalar>();
return return
( (

View File

@ -137,7 +137,7 @@ public:
const vector& axisOfSymmetry, const vector& axisOfSymmetry,
const vector& axisOfWedge, const vector& axisOfWedge,
const vector& axisOfWedgeNormal, const vector& axisOfWedgeNormal,
Random& rndGen cachedRandom& rndGen
) const; ) const;
//- Return the number of holes //- Return the number of holes

View File

@ -521,7 +521,7 @@ void Foam::parcel::updateParcelProperties
scalar Taverage = TDroplet + (Tg - TDroplet)/3.0; scalar Taverage = TDroplet + (Tg - TDroplet)/3.0;
// for a liquid Cl \approx Cp // for a liquid Cl \approx Cp
scalar liquidcL = sDB.fuels().cp(pg, TDroplet, X()); scalar liquidcL = sDB.fuels().Cp(pg, TDroplet, X());
cpMix = 0.0; cpMix = 0.0;
for (label i=0; i<Ns; i++) for (label i=0; i<Ns; i++)

View File

@ -65,7 +65,7 @@ void Foam::parcel::setRelaxationTimes
// calculate mixture properties // calculate mixture properties
scalar W = 0.0; scalar W = 0.0;
scalar kMixture = 0.0; scalar kMixture = 0.0;
scalar cpMixture = 0.0; scalar CpMixture = 0.0;
scalar muf = 0.0; scalar muf = 0.0;
for (label i=0; i<Ns; i++) for (label i=0; i<Ns; i++)
@ -74,7 +74,7 @@ void Foam::parcel::setRelaxationTimes
W += Y/sDB.gasProperties()[i].W(); W += Y/sDB.gasProperties()[i].W();
// Using mass-fractions to average... // Using mass-fractions to average...
kMixture += Y*sDB.gasProperties()[i].kappa(Tf); kMixture += Y*sDB.gasProperties()[i].kappa(Tf);
cpMixture += Y*sDB.gasProperties()[i].Cp(Tf); CpMixture += Y*sDB.gasProperties()[i].Cp(Tf);
muf += Y*sDB.gasProperties()[i].mu(Tf); muf += Y*sDB.gasProperties()[i].mu(Tf);
} }
W = 1.0/W; W = 1.0/W;
@ -98,7 +98,7 @@ void Foam::parcel::setRelaxationTimes
scalar nuf = muf/rho; scalar nuf = muf/rho;
scalar liquidDensity = fuels.rho(pressure, T(), X()); scalar liquidDensity = fuels.rho(pressure, T(), X());
scalar liquidcL = fuels.cp(pressure, T(), X()); scalar liquidcL = fuels.Cp(pressure, T(), X());
scalar heatOfVapour = fuels.hl(pressure, T(), X()); scalar heatOfVapour = fuels.hl(pressure, T(), X());
// calculate the partial rho of the fuel vapour // calculate the partial rho of the fuel vapour
@ -130,7 +130,7 @@ void Foam::parcel::setRelaxationTimes
} }
scalar Reynolds = Re(Up, nuf); scalar Reynolds = Re(Up, nuf);
scalar Prandtl = Pr(cpMixture, muf, kMixture); scalar Prandtl = Pr(CpMixture, muf, kMixture);
// calculate the characteritic times // calculate the characteritic times
@ -280,7 +280,7 @@ void Foam::parcel::setRelaxationTimes
tauBoiling[i] = sDB.evaporation().boilingTime tauBoiling[i] = sDB.evaporation().boilingTime
( (
fuels.properties()[i].rho(pressure, Td), fuels.properties()[i].rho(pressure, Td),
fuels.properties()[i].cp(pressure, Td), fuels.properties()[i].Cp(pressure, Td),
heatOfVapour, heatOfVapour,
kMixture, kMixture,
Nusselt, Nusselt,
@ -292,7 +292,7 @@ void Foam::parcel::setRelaxationTimes
tBoilingSurface, tBoilingSurface,
vapourSurfaceEnthalpy, vapourSurfaceEnthalpy,
vapourFarEnthalpy, vapourFarEnthalpy,
cpMixture, CpMixture,
temperature, temperature,
kLiquid kLiquid
); );

View File

@ -68,7 +68,7 @@ Foam::spray::spray
runTime_(U.time()), runTime_(U.time()),
time0_(runTime_.value()), time0_(runTime_.value()),
mesh_(U.mesh()), mesh_(U.mesh()),
rndGen_(label(0)), rndGen_(label(0), -1),
g_(g.value()), g_(g.value()),
U_(U), U_(U),

View File

@ -39,7 +39,7 @@ Description
#include "liquid.H" #include "liquid.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "liquidMixture.H" #include "liquidMixture.H"
#include "Random.H" #include "cachedRandom.H"
#include "thermoPhysicsTypes.H" #include "thermoPhysicsTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -76,7 +76,7 @@ class spray
const fvMesh& mesh_; const fvMesh& mesh_;
//- Random number generator //- Random number generator
Random rndGen_; cachedRandom rndGen_;
//- Acceleration due to gravity //- Acceleration due to gravity
const vector& g_; const vector& g_;
@ -250,7 +250,7 @@ public:
inline tmp<volScalarField> evaporationSource(const label i) const; inline tmp<volScalarField> evaporationSource(const label i) const;
inline tmp<volScalarField> heatTransferSource() const; inline tmp<volScalarField> heatTransferSource() const;
inline Random& rndGen(); inline cachedRandom& rndGen();
inline label subCycles() const; inline label subCycles() const;
inline const vector& g() const; inline const vector& g() const;

View File

@ -221,7 +221,7 @@ inline tmp<volScalarField> spray::heatTransferSource() const
} }
inline Random& spray::rndGen() inline cachedRandom& spray::rndGen()
{ {
return rndGen_; return rndGen_;
} }

View File

@ -54,7 +54,6 @@ Foam::LISA::LISA
: :
atomizationModel(dict, sm), atomizationModel(dict, sm),
coeffsDict_(dict.subDict(typeName + "Coeffs")), coeffsDict_(dict.subDict(typeName + "Coeffs")),
rndGen_(sm.rndGen()),
Cl_(readScalar(coeffsDict_.lookup("Cl"))), Cl_(readScalar(coeffsDict_.lookup("Cl"))),
cTau_(readScalar(coeffsDict_.lookup("cTau"))), cTau_(readScalar(coeffsDict_.lookup("cTau"))),
Q_(readScalar(coeffsDict_.lookup("Q"))), Q_(readScalar(coeffsDict_.lookup("Q"))),
@ -361,8 +360,8 @@ void Foam::LISA::atomizeParcel
do do
{ {
x = minValue + range*rndGen_.scalar01(); x = minValue + range*rndGen_.sample01<scalar>();
y = rndGen_.scalar01(); y = rndGen_.sample01<scalar>();
scalar xx = pow(x/dD, nExp); scalar xx = pow(x/dD, nExp);

View File

@ -68,7 +68,6 @@ private:
// Private data // Private data
dictionary coeffsDict_; dictionary coeffsDict_;
Random& rndGen_;
scalar Cl_; scalar Cl_;
scalar cTau_; scalar cTau_;
scalar Q_; scalar Q_;

View File

@ -55,7 +55,7 @@ protected:
const dictionary& dict_; const dictionary& dict_;
spray& spray_; spray& spray_;
Random& rndGen_; cachedRandom& rndGen_;
public: public:

View File

@ -56,8 +56,7 @@ Foam::blobsSheetAtomization::blobsSheetAtomization
atomizationModel(dict, sm), atomizationModel(dict, sm),
coeffsDict_(dict.subDict(typeName + "Coeffs")), coeffsDict_(dict.subDict(typeName + "Coeffs")),
B_(readScalar(coeffsDict_.lookup("B"))), B_(readScalar(coeffsDict_.lookup("B"))),
angle_(readScalar(coeffsDict_.lookup("angle"))), angle_(readScalar(coeffsDict_.lookup("angle")))
rndGen_(sm.rndGen())
{} {}

View File

@ -67,7 +67,6 @@ private:
dictionary coeffsDict_; dictionary coeffsDict_;
scalar B_; scalar B_;
scalar angle_; scalar angle_;
Random& rndGen_;
public: public:

View File

@ -53,7 +53,6 @@ Foam::SHF::SHF
breakupModel(dict, sm), breakupModel(dict, sm),
coeffsDict_(dict.subDict(typeName + "Coeffs")), coeffsDict_(dict.subDict(typeName + "Coeffs")),
g_(sm.g()), g_(sm.g()),
rndGen_(sm.rndGen()),
weCorrCoeff_(readScalar(coeffsDict_.lookup("weCorrCoeff"))), weCorrCoeff_(readScalar(coeffsDict_.lookup("weCorrCoeff"))),
weBuCrit_(readScalar(coeffsDict_.lookup("weBuCrit"))), weBuCrit_(readScalar(coeffsDict_.lookup("weBuCrit"))),
weBuBag_(readScalar(coeffsDict_.lookup("weBuBag"))), weBuBag_(readScalar(coeffsDict_.lookup("weBuBag"))),
@ -186,9 +185,9 @@ void Foam::SHF::breakupParcel
do do
{ {
x = cDmaxBM_*rndGen_.scalar01(); x = cDmaxBM_*rndGen_.sample01<scalar>();
d = sqr(x)*d05; d = sqr(x)*d05;
y = rndGen_.scalar01(); y = rndGen_.sample01<scalar>();
px = px =
x x
@ -217,9 +216,9 @@ void Foam::SHF::breakupParcel
do do
{ {
x = cDmaxS_*rndGen_.scalar01(); x = cDmaxS_*rndGen_.sample01<scalar>();
d = sqr(x)*d05; d = sqr(x)*d05;
y = rndGen_.scalar01(); y = rndGen_.sample01<scalar>();
px = px =
x x

View File

@ -66,8 +66,6 @@ private:
// reference to gravity // reference to gravity
const vector& g_; const vector& g_;
Random& rndGen_;
// model constants // model constants
scalar weCorrCoeff_; scalar weCorrCoeff_;

View File

@ -175,7 +175,7 @@ void Foam::TAB::breakupParcel
label n = 0; label n = 0;
bool found = false; bool found = false;
scalar random = rndGen_.scalar01(); scalar random = rndGen_.sample01<scalar>();
while (!found && (n<99)) while (!found && (n<99))
{ {
if (rrd_[n] > random) if (rrd_[n] > random)

View File

@ -56,7 +56,7 @@ protected:
const dictionary& dict_; const dictionary& dict_;
spray& spray_; spray& spray_;
Random& rndGen_; cachedRandom& rndGen_;
Switch includeOscillation_; Switch includeOscillation_;

View File

@ -48,7 +48,7 @@ Foam::ORourkeCollisionModel::ORourkeCollisionModel
( (
const dictionary& dict, const dictionary& dict,
spray& sm, spray& sm,
Random& rndGen cachedRandom& rndGen
) )
: :
collisionModel(dict, sm, rndGen), collisionModel(dict, sm, rndGen),

View File

@ -75,7 +75,7 @@ public:
( (
const dictionary& dict, const dictionary& dict,
spray& sm, spray& sm,
Random& rndGen cachedRandom& rndGen
); );

View File

@ -35,7 +35,7 @@ scalar mdMin = mMin/nMin;
scalar nu0 = 0.25*constant::mathematical::pi*sqr(sumD)*magVRel*dt/vols_[cell1]; scalar nu0 = 0.25*constant::mathematical::pi*sqr(sumD)*magVRel*dt/vols_[cell1];
scalar nu = nMin*nu0; scalar nu = nMin*nu0;
scalar collProb = exp(-nu); scalar collProb = exp(-nu);
scalar xx = rndGen_.scalar01(); scalar xx = rndGen_.sample01<scalar>();
if ((xx > collProb) && (mMin > VSMALL) && (mMax > VSMALL)) if ((xx > collProb) && (mMin > VSMALL) && (mMax > VSMALL))
{ {
@ -62,7 +62,7 @@ if ((xx > collProb) && (mMin > VSMALL) && (mMax > VSMALL))
scalar WeColl = max(1.0e-12, 0.5*rho*magVRel*magVRel*dMin/sigma); scalar WeColl = max(1.0e-12, 0.5*rho*magVRel*magVRel*dMin/sigma);
scalar coalesceProb = min(1.0, 2.4*f/WeColl); scalar coalesceProb = min(1.0, 2.4*f/WeColl);
scalar prob = rndGen_.scalar01(); scalar prob = rndGen_.sample01<scalar>();
// Coalescence // Coalescence
if (prob < coalesceProb && coalescence_) if (prob < coalesceProb && coalescence_)

View File

@ -41,7 +41,7 @@ Foam::collisionModel::collisionModel
( (
const dictionary& dict, const dictionary& dict,
spray& sm, spray& sm,
Random& rndGen cachedRandom& rndGen
) )
: :
dict_(dict), dict_(dict),

View File

@ -34,7 +34,7 @@ Description
#include "IOdictionary.H" #include "IOdictionary.H"
#include "spray.H" #include "spray.H"
#include "Random.H" #include "cachedRandom.H"
#include "Switch.H" #include "Switch.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
@ -56,7 +56,7 @@ protected:
// Protected data // Protected data
const dictionary& dict_; const dictionary& dict_;
spray& spray_; spray& spray_;
Random& rndGen_; cachedRandom& rndGen_;
//dictionary coeffsDict_; //dictionary coeffsDict_;
@ -76,7 +76,7 @@ public:
( (
const dictionary& dict, const dictionary& dict,
spray& sm, spray& sm,
Random& rndGen cachedRandom& rndGen
), ),
(dict, sm, rndGen) (dict, sm, rndGen)
); );
@ -89,7 +89,7 @@ public:
( (
const dictionary& dict, const dictionary& dict,
spray& sm, spray& sm,
Random& rndGen cachedRandom& rndGen
); );
@ -103,7 +103,7 @@ public:
( (
const dictionary& dict, const dictionary& dict,
spray& sm, spray& sm,
Random& rndGen cachedRandom& rndGen
); );

View File

@ -37,7 +37,7 @@ Foam::autoPtr<Foam::collisionModel> Foam::collisionModel::New
( (
const dictionary& dict, const dictionary& dict,
spray& sm, spray& sm,
Random& rndGen cachedRandom& rndGen
) )
{ {
const word modelType(dict.lookup("collisionModel")); const word modelType(dict.lookup("collisionModel"));

View File

@ -49,7 +49,7 @@ Foam::noCollision::noCollision
( (
const dictionary& dict, const dictionary& dict,
spray& sm, spray& sm,
Random& rndGen cachedRandom& rndGen
) )
: :
collisionModel(dict, sm, rndGen) collisionModel(dict, sm, rndGen)

View File

@ -62,7 +62,7 @@ public:
( (
const dictionary& dict, const dictionary& dict,
spray& sm, spray& sm,
Random& rndGen cachedRandom& rndGen
); );
//- Destructor //- Destructor

View File

@ -51,7 +51,7 @@ if (vAlign > 0)
pow(0.5*sumD/max(0.5*sumD, closestDist), cSpace_) pow(0.5*sumD/max(0.5*sumD, closestDist), cSpace_)
*exp(-cTime_*mag(alpha-beta)); *exp(-cTime_*mag(alpha-beta));
scalar xx = rndGen_.scalar01(); scalar xx = rndGen_.sample01<scalar>();
spray::iterator pMin = p1; spray::iterator pMin = p1;
spray::iterator pMax = p2; spray::iterator pMax = p2;
@ -106,7 +106,7 @@ if (vAlign > 0)
scalar coalesceProb = min(1.0, 2.4*f/WeColl); scalar coalesceProb = min(1.0, 2.4*f/WeColl);
scalar prob = rndGen_.scalar01(); scalar prob = rndGen_.sample01<scalar>();
// Coalescence // Coalescence
if ( prob < coalesceProb && coalescence_) if ( prob < coalesceProb && coalescence_)

View File

@ -48,7 +48,7 @@ Foam::trajectoryCollisionModel::trajectoryCollisionModel
( (
const dictionary& dict, const dictionary& dict,
spray& sm, spray& sm,
Random& rndGen cachedRandom& rndGen
) )
: :
collisionModel(dict, sm, rndGen), collisionModel(dict, sm, rndGen),

View File

@ -78,7 +78,7 @@ public:
( (
const dictionary& dict, const dictionary& dict,
spray& sm, spray& sm,
Random& rndGen cachedRandom& rndGen
); );

View File

@ -102,8 +102,8 @@ void Foam::gradientDispersionRAS::disperseParcels() const
scalar rsq = 10.0; scalar rsq = 10.0;
while ((rsq > 1.0) || (rsq == 0.0)) while ((rsq > 1.0) || (rsq == 0.0))
{ {
x1 = 2.0*spray_.rndGen().scalar01() - 1.0; x1 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
x2 = 2.0*spray_.rndGen().scalar01() - 1.0; x2 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
rsq = x1*x1 + x2*x2; rsq = x1*x1 + x2*x2;
} }

View File

@ -96,7 +96,7 @@ void Foam::stochasticDispersionRAS::disperseParcels() const
elmnt().tTurb() = 0.0; elmnt().tTurb() = 0.0;
scalar sigma = sqrt(2.0*k[cellI]/3.0); scalar sigma = sqrt(2.0*k[cellI]/3.0);
vector dir = 2.0*spray_.rndGen().vector01() - one; vector dir = 2.0*spray_.rndGen().sample01<vector>() - one;
dir /= mag(dir) + SMALL; dir /= mag(dir) + SMALL;
// numerical recipes... Ch. 7. Random Numbers... // numerical recipes... Ch. 7. Random Numbers...
@ -104,8 +104,8 @@ void Foam::stochasticDispersionRAS::disperseParcels() const
scalar rsq = 10.0; scalar rsq = 10.0;
while (rsq > 1.0 || rsq == 0.0) while (rsq > 1.0 || rsq == 0.0)
{ {
x1 = 2.0*spray_.rndGen().scalar01() - 1.0; x1 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
x2 = 2.0*spray_.rndGen().scalar01() - 1.0; x2 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
rsq = x1*x1 + x2*x2; rsq = x1*x1 + x2*x2;
} }

View File

@ -123,7 +123,7 @@ Foam::vector Foam::ChomiakInjector::direction
scalar alpha = sin(angle); scalar alpha = sin(angle);
scalar dcorr = cos(angle); scalar dcorr = cos(angle);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01(); scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector // randomly distributed vector normal to the injection vector
vector normal = vector::zero; vector normal = vector::zero;

View File

@ -105,7 +105,7 @@ Foam::scalar Foam::blobsSwirlInjector::d0
{ {
const injectorType& it = injectors_[n].properties(); const injectorType& it = injectors_[n].properties();
scalar c = rndGen_.scalar01(); scalar c = rndGen_.sample01<scalar>();
angle_ = degToRad(coneAngle_[n]/2.0 + c*coneInterval_[n]); angle_ = degToRad(coneAngle_[n]/2.0 + c*coneInterval_[n]);
@ -139,7 +139,7 @@ Foam::vector Foam::blobsSwirlInjector::direction
{ {
scalar alpha = sin(angle_); scalar alpha = sin(angle_);
scalar dcorr = cos(angle_); scalar dcorr = cos(angle_);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01(); scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector // randomly distributed vector normal to the injection vector
vector normal = vector::zero; vector normal = vector::zero;

View File

@ -130,11 +130,12 @@ Foam::vector Foam::constInjector::direction
*/ */
scalar angle = scalar angle =
rndGen_.scalar01()*sprayAngle_[n]*constant::mathematical::pi/360.0; rndGen_.sample01<scalar>()*sprayAngle_[n]
*constant::mathematical::pi/360.0;
scalar alpha = sin(angle); scalar alpha = sin(angle);
scalar dcorr = cos(angle); scalar dcorr = cos(angle);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01(); scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector // randomly distributed vector normal to the injection vector
vector normal = vector::zero; vector normal = vector::zero;

View File

@ -157,11 +157,11 @@ Foam::vector Foam::definedHollowConeInjector::direction
scalar angleOuter = it.getTableValue(outerConeAngle_, t); scalar angleOuter = it.getTableValue(outerConeAngle_, t);
// use random number to generate angle between inner/outer cone angles // use random number to generate angle between inner/outer cone angles
scalar angle = angleInner + rndGen_.scalar01()*(angleOuter - angleInner); scalar angle = rndGen_.position<scalar>(angleInner, angleOuter);
scalar alpha = sin(angle*constant::mathematical::pi/360.0); scalar alpha = sin(angle*constant::mathematical::pi/360.0);
scalar dcorr = cos(angle*constant::mathematical::pi/360.0); scalar dcorr = cos(angle*constant::mathematical::pi/360.0);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01(); scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector // randomly distributed vector normal to the injection vector
vector normal = vector::zero; vector normal = vector::zero;

View File

@ -90,7 +90,7 @@ Foam::scalar Foam::definedPressureSwirlInjector::d0
{ {
const injectorType& it = injectors_[n].properties(); const injectorType& it = injectors_[n].properties();
scalar c = rndGen_.scalar01(); scalar c = rndGen_.sample01<scalar>();
scalar coneAngle = it.getTableValue(coneAngle_, t); scalar coneAngle = it.getTableValue(coneAngle_, t);
scalar coneInterval = it.getTableValue(coneInterval_, t); scalar coneInterval = it.getTableValue(coneInterval_, t);
angle_ = coneAngle ; angle_ = coneAngle ;
@ -212,7 +212,7 @@ Foam::vector Foam::definedPressureSwirlInjector::direction
{ {
scalar alpha = sin(angle_); scalar alpha = sin(angle_);
scalar dcorr = cos(angle_); scalar dcorr = cos(angle_);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01(); scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector // randomly distributed vector normal to the injection vector
vector normal = vector::zero; vector normal = vector::zero;

View File

@ -124,11 +124,10 @@ Foam::vector Foam::hollowConeInjector::direction
const scalar d const scalar d
) const ) const
{ {
scalar angle = scalar angle = rndGen_.position<scalar>(innerAngle_[n], outerAngle_[n]);
innerAngle_[n] + rndGen_.scalar01()*(outerAngle_[n]-innerAngle_[n]);
scalar alpha = sin(angle*constant::mathematical::pi/360.0); scalar alpha = sin(angle*constant::mathematical::pi/360.0);
scalar dcorr = cos(angle*constant::mathematical::pi/360.0); scalar dcorr = cos(angle*constant::mathematical::pi/360.0);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01(); scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector // randomly distributed vector normal to the injection vector
vector normal = vector::zero; vector normal = vector::zero;

View File

@ -62,7 +62,7 @@ protected:
spray& sm_; spray& sm_;
const PtrList<injector>& injectors_; const PtrList<injector>& injectors_;
Random& rndGen_; cachedRandom& rndGen_;
public: public:

View File

@ -100,7 +100,7 @@ Foam::scalar Foam::pressureSwirlInjector::d0
{ {
const injectorType& it = injectors_[n].properties(); const injectorType& it = injectors_[n].properties();
scalar c = rndGen_.scalar01(); scalar c = rndGen_.sample01<scalar>();
angle_ = coneAngle_[n] + 2.0*coneInterval_[n]*(0.5 - c); angle_ = coneAngle_[n] + 2.0*coneInterval_[n]*(0.5 - c);
angle_ *= constant::mathematical::pi/360.0; angle_ *= constant::mathematical::pi/360.0;
@ -134,7 +134,7 @@ Foam::vector Foam::pressureSwirlInjector::direction
{ {
scalar alpha = sin(angle_); scalar alpha = sin(angle_);
scalar dcorr = cos(angle_); scalar dcorr = cos(angle_);
scalar beta = constant::mathematical::twoPi*rndGen_.scalar01(); scalar beta = constant::mathematical::twoPi*rndGen_.sample01<scalar>();
// randomly distributed vector normal to the injection vector // randomly distributed vector normal to the injection vector
vector normal = vector::zero; vector normal = vector::zero;