mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Random numbers - updated dependent code from change cachedRandom->Random class
This commit is contained in:
@ -46,7 +46,7 @@ int main(int argc, char *argv[])
|
|||||||
scalarField samples(10000000);
|
scalarField samples(10000000);
|
||||||
forAll(samples, i)
|
forAll(samples, i)
|
||||||
{
|
{
|
||||||
samples[i] = rndGen.scalar01();
|
samples[i] = rndGen.sample01<scalar>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const scalar min = 0;
|
const scalar min = 0;
|
||||||
|
|||||||
@ -71,7 +71,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (label i = 0; i < randomDistributionTestSize; i++)
|
for (label i = 0; i < randomDistributionTestSize; i++)
|
||||||
{
|
{
|
||||||
dS.add(2.5*R.GaussNormal() + 8.5);
|
dS.add(2.5*R.GaussNormal<scalar>() + 8.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Mean " << dS.mean() << nl
|
Info<< "Mean " << dS.mean() << nl
|
||||||
@ -90,7 +90,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (label i = 0; i < randomDistributionTestSize; i++)
|
for (label i = 0; i < randomDistributionTestSize; i++)
|
||||||
{
|
{
|
||||||
dS2.add(1.5*R.GaussNormal() -6.0);
|
dS2.add(1.5*R.GaussNormal<scalar>() -6.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Mean " << dS2.mean() << nl
|
Info<< "Mean " << dS2.mean() << nl
|
||||||
@ -121,7 +121,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (label i = 0; i < randomDistributionTestSize; i++)
|
for (label i = 0; i < randomDistributionTestSize; i++)
|
||||||
{
|
{
|
||||||
dS.add(R.scalar01() + 10*Pstream::myProcNo());
|
dS.add(R.sample01<scalar>() + 10*Pstream::myProcNo());
|
||||||
}
|
}
|
||||||
|
|
||||||
Pout<< "Mean " << dS.mean() << nl
|
Pout<< "Mean " << dS.mean() << nl
|
||||||
@ -155,7 +155,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (label i = 0; i < randomDistributionTestSize; i++)
|
for (label i = 0; i < randomDistributionTestSize; i++)
|
||||||
{
|
{
|
||||||
dV.add(R.vector01());
|
dV.add(R.sample01<vector>());
|
||||||
|
|
||||||
// Adding separate GaussNormal components with component
|
// Adding separate GaussNormal components with component
|
||||||
// weights
|
// weights
|
||||||
@ -164,9 +164,9 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
vector
|
vector
|
||||||
(
|
(
|
||||||
R.GaussNormal()*3.0 + 1.5,
|
R.GaussNormal<scalar>()*3.0 + 1.5,
|
||||||
R.GaussNormal()*0.25 + 4.0,
|
R.GaussNormal<scalar>()*0.25 + 4.0,
|
||||||
R.GaussNormal()*3.0 - 1.5
|
R.GaussNormal<scalar>()*3.0 - 1.5
|
||||||
),
|
),
|
||||||
vector(1.0, 2.0, 5.0)
|
vector(1.0, 2.0, 5.0)
|
||||||
);
|
);
|
||||||
@ -225,7 +225,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (label i = 0; i < randomDistributionTestSize; i++)
|
for (label i = 0; i < randomDistributionTestSize; i++)
|
||||||
{
|
{
|
||||||
dT.add(R.tensor01());
|
dT.add(R.sample01<tensor>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Mean " << dT.mean() << nl
|
Info<< "Mean " << dT.mean() << nl
|
||||||
@ -249,7 +249,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (label i = 0; i < randomDistributionTestSize; i++)
|
for (label i = 0; i < randomDistributionTestSize; i++)
|
||||||
{
|
{
|
||||||
dSyT.add(R.symmTensor01());
|
dSyT.add(R.sample01<symmTensor>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Mean " << dSyT.mean() << nl
|
Info<< "Mean " << dSyT.mean() << nl
|
||||||
@ -273,7 +273,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (label i = 0; i < randomDistributionTestSize; i++)
|
for (label i = 0; i < randomDistributionTestSize; i++)
|
||||||
{
|
{
|
||||||
dSpT.add(R.sphericalTensor01());
|
dSpT.add(R.sample01<sphericalTensor>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Mean " << dSpT.mean() << nl
|
Info<< "Mean " << dSpT.mean() << nl
|
||||||
|
|||||||
@ -152,7 +152,7 @@ int main(int argc, char *argv[])
|
|||||||
Random rnd(123456);
|
Random rnd(123456);
|
||||||
for (int i=0; i<10; i++)
|
for (int i=0; i<10; i++)
|
||||||
{
|
{
|
||||||
scalar x = rnd.scalar01()*100;
|
scalar x = rnd.sample01<scalar>()*100;
|
||||||
|
|
||||||
scalar px = polyValue(x);
|
scalar px = polyValue(x);
|
||||||
scalar ipx = intPolyValue(x);
|
scalar ipx = intPolyValue(x);
|
||||||
|
|||||||
@ -293,9 +293,9 @@ inline Foam::point Foam::conformalVoronoiMesh::perturbPoint
|
|||||||
|
|
||||||
scalar pert = 1e-12*defaultCellSize();
|
scalar pert = 1e-12*defaultCellSize();
|
||||||
|
|
||||||
perturbedPt.x() += pert*(rndGen_.scalar01() - 0.5);
|
perturbedPt.x() += pert*(rndGen_.sample01<scalar>() - 0.5);
|
||||||
perturbedPt.y() += pert*(rndGen_.scalar01() - 0.5);
|
perturbedPt.y() += pert*(rndGen_.sample01<scalar>() - 0.5);
|
||||||
perturbedPt.z() += pert*(rndGen_.scalar01() - 0.5);
|
perturbedPt.z() += pert*(rndGen_.sample01<scalar>() - 0.5);
|
||||||
|
|
||||||
return perturbedPt;
|
return perturbedPt;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -553,11 +553,11 @@ bool Foam::autoDensity::fillBox
|
|||||||
+ vector
|
+ vector
|
||||||
(
|
(
|
||||||
delta.x()
|
delta.x()
|
||||||
*(i + 0.5 + 0.1*(rndGen().scalar01() - 0.5)),
|
*(i + 0.5 + 0.1*(rndGen().sample01<scalar>() - 0.5)),
|
||||||
delta.y()
|
delta.y()
|
||||||
*(j + 0.5 + 0.1*(rndGen().scalar01() - 0.5)),
|
*(j + 0.5 + 0.1*(rndGen().sample01<scalar>() - 0.5)),
|
||||||
delta.z()
|
delta.z()
|
||||||
*(k + 0.5 + 0.1*(rndGen().scalar01() - 0.5))
|
*(k + 0.5 + 0.1*(rndGen().sample01<scalar>() - 0.5))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -662,7 +662,7 @@ bool Foam::autoDensity::fillBox
|
|||||||
// TODO - is there a lot of cost in the 1/density calc? Could
|
// TODO - is there a lot of cost in the 1/density calc? Could
|
||||||
// assess on
|
// assess on
|
||||||
// (1/maxDensity)/(1/localDensity) = minVolume/localVolume
|
// (1/maxDensity)/(1/localDensity) = minVolume/localVolume
|
||||||
if (localDensity/maxDensity > rndGen().scalar01())
|
if (localDensity/maxDensity > rndGen().sample01<scalar>())
|
||||||
{
|
{
|
||||||
scalar localVolume = 1/localDensity;
|
scalar localVolume = 1/localDensity;
|
||||||
|
|
||||||
@ -675,7 +675,7 @@ bool Foam::autoDensity::fillBox
|
|||||||
scalar addProbability =
|
scalar addProbability =
|
||||||
(totalVolume - volumeAdded)/localVolume;
|
(totalVolume - volumeAdded)/localVolume;
|
||||||
|
|
||||||
scalar r = rndGen().scalar01();
|
scalar r = rndGen().sample01<scalar>();
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -729,7 +729,7 @@ bool Foam::autoDensity::fillBox
|
|||||||
{
|
{
|
||||||
trialPoints++;
|
trialPoints++;
|
||||||
|
|
||||||
point p = min + cmptMultiply(span, rndGen().vector01());
|
point p = min + cmptMultiply(span, rndGen().sample01<vector>());
|
||||||
|
|
||||||
scalar localSize = cellShapeControls().cellSize(p);
|
scalar localSize = cellShapeControls().cellSize(p);
|
||||||
|
|
||||||
@ -785,7 +785,7 @@ bool Foam::autoDensity::fillBox
|
|||||||
|
|
||||||
// Accept possible placements proportional to the relative local
|
// Accept possible placements proportional to the relative local
|
||||||
// density
|
// density
|
||||||
if (localDensity/maxDensity > rndGen().scalar01())
|
if (localDensity/maxDensity > rndGen().sample01<scalar>())
|
||||||
{
|
{
|
||||||
scalar localVolume = 1/localDensity;
|
scalar localVolume = 1/localDensity;
|
||||||
|
|
||||||
@ -798,7 +798,7 @@ bool Foam::autoDensity::fillBox
|
|||||||
scalar addProbability =
|
scalar addProbability =
|
||||||
(totalVolume - volumeAdded)/localVolume;
|
(totalVolume - volumeAdded)/localVolume;
|
||||||
|
|
||||||
scalar r = rndGen().scalar01();
|
scalar r = rndGen().sample01<scalar>();
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -129,9 +129,9 @@ List<Vb::Point> bodyCentredCubic::initialPoints() const
|
|||||||
|
|
||||||
if (randomiseInitialGrid_)
|
if (randomiseInitialGrid_)
|
||||||
{
|
{
|
||||||
pA.x() += pert*(rndGen().scalar01() - 0.5);
|
pA.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
pA.y() += pert*(rndGen().scalar01() - 0.5);
|
pA.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
pA.z() += pert*(rndGen().scalar01() - 0.5);
|
pA.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
@ -150,9 +150,9 @@ List<Vb::Point> bodyCentredCubic::initialPoints() const
|
|||||||
|
|
||||||
if (randomiseInitialGrid_)
|
if (randomiseInitialGrid_)
|
||||||
{
|
{
|
||||||
pB.x() += pert*(rndGen().scalar01() - 0.5);
|
pB.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
pB.y() += pert*(rndGen().scalar01() - 0.5);
|
pB.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
pB.z() += pert*(rndGen().scalar01() - 0.5);
|
pB.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
|
|||||||
@ -127,9 +127,9 @@ List<Vb::Point> faceCentredCubic::initialPoints() const
|
|||||||
|
|
||||||
if (randomiseInitialGrid_)
|
if (randomiseInitialGrid_)
|
||||||
{
|
{
|
||||||
p.x() += pert*(rndGen().scalar01() - 0.5);
|
p.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
p.y() += pert*(rndGen().scalar01() - 0.5);
|
p.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
p.z() += pert*(rndGen().scalar01() - 0.5);
|
p.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
@ -155,9 +155,9 @@ List<Vb::Point> faceCentredCubic::initialPoints() const
|
|||||||
|
|
||||||
if (randomiseInitialGrid_)
|
if (randomiseInitialGrid_)
|
||||||
{
|
{
|
||||||
p.x() += pert*(rndGen().scalar01() - 0.5);
|
p.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
p.y() += pert*(rndGen().scalar01() - 0.5);
|
p.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
p.z() += pert*(rndGen().scalar01() - 0.5);
|
p.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
@ -183,9 +183,9 @@ List<Vb::Point> faceCentredCubic::initialPoints() const
|
|||||||
|
|
||||||
if (randomiseInitialGrid_)
|
if (randomiseInitialGrid_)
|
||||||
{
|
{
|
||||||
p.x() += pert*(rndGen().scalar01() - 0.5);
|
p.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
p.y() += pert*(rndGen().scalar01() - 0.5);
|
p.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
p.z() += pert*(rndGen().scalar01() - 0.5);
|
p.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
@ -211,9 +211,9 @@ List<Vb::Point> faceCentredCubic::initialPoints() const
|
|||||||
|
|
||||||
if (randomiseInitialGrid_)
|
if (randomiseInitialGrid_)
|
||||||
{
|
{
|
||||||
p.x() += pert*(rndGen().scalar01() - 0.5);
|
p.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
p.y() += pert*(rndGen().scalar01() - 0.5);
|
p.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
p.z() += pert*(rndGen().scalar01() - 0.5);
|
p.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
|
|||||||
@ -198,9 +198,15 @@ List<Vb::Point> pointFile::initialPoints() const
|
|||||||
|
|
||||||
if (randomiseInitialGrid_)
|
if (randomiseInitialGrid_)
|
||||||
{
|
{
|
||||||
p.x() += randomPerturbationCoeff_*(rndGen().scalar01() - 0.5);
|
p.x() +=
|
||||||
p.y() += randomPerturbationCoeff_*(rndGen().scalar01() - 0.5);
|
randomPerturbationCoeff_
|
||||||
p.z() += randomPerturbationCoeff_*(rndGen().scalar01() - 0.5);
|
*(rndGen().sample01<scalar>() - 0.5);
|
||||||
|
p.y() +=
|
||||||
|
randomPerturbationCoeff_
|
||||||
|
*(rndGen().sample01<scalar>() - 0.5);
|
||||||
|
p.z() +=
|
||||||
|
randomPerturbationCoeff_
|
||||||
|
*(rndGen().sample01<scalar>() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
initialPoints.append(Vb::Point(p.x(), p.y(), p.z()));
|
initialPoints.append(Vb::Point(p.x(), p.y(), p.z()));
|
||||||
|
|||||||
@ -86,9 +86,9 @@ void rayShooting::splitLine
|
|||||||
{
|
{
|
||||||
Foam::point newPt
|
Foam::point newPt
|
||||||
(
|
(
|
||||||
midPoint.x() + pert*(rndGen().scalar01() - 0.5),
|
midPoint.x() + pert*(rndGen().sample01<scalar>() - 0.5),
|
||||||
midPoint.y() + pert*(rndGen().scalar01() - 0.5),
|
midPoint.y() + pert*(rndGen().sample01<scalar>() - 0.5),
|
||||||
midPoint.z() + pert*(rndGen().scalar01() - 0.5)
|
midPoint.z() + pert*(rndGen().sample01<scalar>() - 0.5)
|
||||||
);
|
);
|
||||||
|
|
||||||
if
|
if
|
||||||
|
|||||||
@ -128,9 +128,9 @@ List<Vb::Point> uniformGrid::initialPoints() const
|
|||||||
|
|
||||||
if (randomiseInitialGrid_)
|
if (randomiseInitialGrid_)
|
||||||
{
|
{
|
||||||
p.x() += pert*(rndGen().scalar01() - 0.5);
|
p.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
p.y() += pert*(rndGen().scalar01() - 0.5);
|
p.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
p.z() += pert*(rndGen().scalar01() - 0.5);
|
p.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if
|
if
|
||||||
|
|||||||
@ -264,8 +264,8 @@ void Foam::CV2D::insertGrid()
|
|||||||
|
|
||||||
if (meshControls().randomiseInitialGrid())
|
if (meshControls().randomiseInitialGrid())
|
||||||
{
|
{
|
||||||
p.x() += pert*(rndGen.scalar01() - 0.5);
|
p.x() += pert*(rndGen.sample01<scalar>() - 0.5);
|
||||||
p.y() += pert*(rndGen.scalar01() - 0.5);
|
p.y() += pert*(rndGen.sample01<scalar>() - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qSurf_.wellInside(p, 0.5*meshControls().minCellSize2()))
|
if (qSurf_.wellInside(p, 0.5*meshControls().minCellSize2()))
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
const fileName pdfPath = runTime.path()/"pdf";
|
const fileName pdfPath = runTime.path()/"pdf";
|
||||||
mkDir(pdfPath);
|
mkDir(pdfPath);
|
||||||
|
|
||||||
cachedRandom rndGen(label(0), -1);
|
Random rndGen;
|
||||||
|
|
||||||
autoPtr<distributionModels::distributionModel> p
|
autoPtr<distributionModels::distributionModel> p
|
||||||
(
|
(
|
||||||
|
|||||||
@ -783,7 +783,7 @@ labelPair edgeIntersectionsAndShuffleCGAL
|
|||||||
const edge& e = edges[edgeI];
|
const edge& e = edges[edgeI];
|
||||||
forAll(e, eI)
|
forAll(e, eI)
|
||||||
{
|
{
|
||||||
vector d = rndGen.vector01()-p05;
|
vector d = rndGen.sample01<vector>() - p05;
|
||||||
surf1Points[mp[e[eI]]] += surf1PointTol[e[eI]]*d;
|
surf1Points[mp[e[eI]]] += surf1PointTol[e[eI]]*d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,9 +125,9 @@ int main(int argc, char *argv[])
|
|||||||
<< "No eigenValues found, shape may have symmetry, "
|
<< "No eigenValues found, shape may have symmetry, "
|
||||||
<< "perturbing inertia tensor diagonal" << endl;
|
<< "perturbing inertia tensor diagonal" << endl;
|
||||||
|
|
||||||
J.xx() *= 1.0 + SMALL*rand.scalar01();
|
J.xx() *= 1.0 + SMALL*rand.sample01<scalar>();
|
||||||
J.yy() *= 1.0 + SMALL*rand.scalar01();
|
J.yy() *= 1.0 + SMALL*rand.sample01<scalar>();
|
||||||
J.zz() *= 1.0 + SMALL*rand.scalar01();
|
J.zz() *= 1.0 + SMALL*rand.sample01<scalar>();
|
||||||
|
|
||||||
eVal = eigenValues(J);
|
eVal = eigenValues(J);
|
||||||
|
|
||||||
|
|||||||
@ -111,7 +111,6 @@ $(sha1)/SHA1.C
|
|||||||
$(sha1)/SHA1Digest.C
|
$(sha1)/SHA1Digest.C
|
||||||
|
|
||||||
primitives/random/Random/Random.C
|
primitives/random/Random/Random.C
|
||||||
primitives/random/cachedRandom/cachedRandom.C
|
|
||||||
|
|
||||||
ranges = primitives/ranges
|
ranges = primitives/ranges
|
||||||
$(ranges)/labelRange/labelRange.C
|
$(ranges)/labelRange/labelRange.C
|
||||||
|
|||||||
@ -42,7 +42,6 @@ SourceFiles
|
|||||||
#include "point.H"
|
#include "point.H"
|
||||||
#include "primitiveFieldsFwd.H"
|
#include "primitiveFieldsFwd.H"
|
||||||
#include "pointHit.H"
|
#include "pointHit.H"
|
||||||
#include "cachedRandom.H"
|
|
||||||
#include "Random.H"
|
#include "Random.H"
|
||||||
#include "FixedList.H"
|
#include "FixedList.H"
|
||||||
#include "UList.H"
|
#include "UList.H"
|
||||||
@ -239,10 +238,6 @@ public:
|
|||||||
// uniform distribution
|
// uniform distribution
|
||||||
inline Point randomPoint(Random& rndGen) const;
|
inline Point randomPoint(Random& rndGen) const;
|
||||||
|
|
||||||
//- Return a random point in the tetrahedron from a
|
|
||||||
// uniform distribution
|
|
||||||
inline Point randomPoint(cachedRandom& rndGen) const;
|
|
||||||
|
|
||||||
//- Calculate the barycentric coordinates of the given
|
//- Calculate the barycentric coordinates of the given
|
||||||
// point, in the same order as a, b, c, d. Returns the
|
// point, in the same order as a, b, c, d. Returns the
|
||||||
// determinant of the solution.
|
// determinant of the solution.
|
||||||
|
|||||||
@ -249,42 +249,6 @@ inline Point Foam::tetrahedron<Point, PointRef>::randomPoint
|
|||||||
// Adapted from
|
// Adapted from
|
||||||
// http://vcg.isti.cnr.it/activities/geometryegraphics/pointintetraedro.html
|
// http://vcg.isti.cnr.it/activities/geometryegraphics/pointintetraedro.html
|
||||||
|
|
||||||
scalar s = rndGen.scalar01();
|
|
||||||
scalar t = rndGen.scalar01();
|
|
||||||
scalar u = rndGen.scalar01();
|
|
||||||
|
|
||||||
if (s + t > 1.0)
|
|
||||||
{
|
|
||||||
s = 1.0 - s;
|
|
||||||
t = 1.0 - t;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t + u > 1.0)
|
|
||||||
{
|
|
||||||
scalar tmp = u;
|
|
||||||
u = 1.0 - s - t;
|
|
||||||
t = 1.0 - tmp;
|
|
||||||
}
|
|
||||||
else if (s + t + u > 1.0)
|
|
||||||
{
|
|
||||||
scalar tmp = u;
|
|
||||||
u = s + t + u - 1.0;
|
|
||||||
s = 1.0 - t - tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (1 - s - t - u)*a_ + s*b_ + t*c_ + u*d_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Point, class PointRef>
|
|
||||||
inline Point Foam::tetrahedron<Point, PointRef>::randomPoint
|
|
||||||
(
|
|
||||||
cachedRandom& rndGen
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
// Adapted from
|
|
||||||
// http://vcg.isti.cnr.it/activities/geometryegraphics/pointintetraedro.html
|
|
||||||
|
|
||||||
scalar s = rndGen.sample01<scalar>();
|
scalar s = rndGen.sample01<scalar>();
|
||||||
scalar t = rndGen.sample01<scalar>();
|
scalar t = rndGen.sample01<scalar>();
|
||||||
scalar u = rndGen.sample01<scalar>();
|
scalar u = rndGen.sample01<scalar>();
|
||||||
|
|||||||
@ -40,7 +40,6 @@ SourceFiles
|
|||||||
#include "tensor.H"
|
#include "tensor.H"
|
||||||
#include "pointHit.H"
|
#include "pointHit.H"
|
||||||
#include "Random.H"
|
#include "Random.H"
|
||||||
#include "cachedRandom.H"
|
|
||||||
#include "FixedList.H"
|
#include "FixedList.H"
|
||||||
#include "UList.H"
|
#include "UList.H"
|
||||||
#include "linePointRef.H"
|
#include "linePointRef.H"
|
||||||
@ -238,10 +237,6 @@ public:
|
|||||||
// distribution
|
// distribution
|
||||||
inline Point randomPoint(Random& rndGen) const;
|
inline Point randomPoint(Random& rndGen) const;
|
||||||
|
|
||||||
//- Return a random point on the triangle from a uniform
|
|
||||||
// distribution
|
|
||||||
inline Point randomPoint(cachedRandom& rndGen) const;
|
|
||||||
|
|
||||||
//- Calculate the barycentric coordinates of the given
|
//- Calculate the barycentric coordinates of the given
|
||||||
// point, in the same order as a, b, c. Returns the
|
// point, in the same order as a, b, c. Returns the
|
||||||
// determinant of the solution.
|
// determinant of the solution.
|
||||||
|
|||||||
@ -249,25 +249,6 @@ inline Point Foam::triangle<Point, PointRef>::randomPoint(Random& rndGen) const
|
|||||||
// from "Graphics Gems", Academic Press, 1990
|
// from "Graphics Gems", Academic Press, 1990
|
||||||
// http://tog.acm.org/GraphicsGems/gems/TriPoints.c
|
// http://tog.acm.org/GraphicsGems/gems/TriPoints.c
|
||||||
|
|
||||||
scalar s = rndGen.scalar01();
|
|
||||||
|
|
||||||
scalar t = sqrt(rndGen.scalar01());
|
|
||||||
|
|
||||||
return (1 - t)*a_ + (1 - s)*t*b_ + s*t*c_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Point, class PointRef>
|
|
||||||
inline Point Foam::triangle<Point, PointRef>::randomPoint
|
|
||||||
(
|
|
||||||
cachedRandom& rndGen
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
// Generating Random Points in Triangles
|
|
||||||
// by Greg Turk
|
|
||||||
// from "Graphics Gems", Academic Press, 1990
|
|
||||||
// http://tog.acm.org/GraphicsGems/gems/TriPoints.c
|
|
||||||
|
|
||||||
scalar s = rndGen.sample01<scalar>();
|
scalar s = rndGen.sample01<scalar>();
|
||||||
|
|
||||||
scalar t = sqrt(rndGen.sample01<scalar>());
|
scalar t = sqrt(rndGen.sample01<scalar>());
|
||||||
|
|||||||
@ -335,7 +335,7 @@ public:
|
|||||||
label distanceCmp(const point& pt, const treeBoundBox& other) const;
|
label distanceCmp(const point& pt, const treeBoundBox& other) const;
|
||||||
|
|
||||||
//- Return slightly wider bounding box
|
//- Return slightly wider bounding box
|
||||||
// Extends all dimensions with s*span*Random::scalar01()
|
// Extends all dimensions with s*span*Random::sample01<scalar>()
|
||||||
// and guarantees in any direction s*mag(span) minimum width
|
// and guarantees in any direction s*mag(span) minimum width
|
||||||
inline treeBoundBox extend(Random& rndGen, const scalar s) const;
|
inline treeBoundBox extend(Random& rndGen, const scalar s) const;
|
||||||
|
|
||||||
|
|||||||
@ -336,8 +336,8 @@ inline Foam::treeBoundBox Foam::treeBoundBox::extend
|
|||||||
newSpan[dir] = Foam::max(newSpan[dir], minSpan);
|
newSpan[dir] = Foam::max(newSpan[dir], minSpan);
|
||||||
}
|
}
|
||||||
|
|
||||||
bb.min() -= cmptMultiply(s * rndGen.vector01(), newSpan);
|
bb.min() -= cmptMultiply(s*rndGen.sample01<vector>(), newSpan);
|
||||||
bb.max() += cmptMultiply(s * rndGen.vector01(), newSpan);
|
bb.max() += cmptMultiply(s*rndGen.sample01<vector>(), newSpan);
|
||||||
|
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,7 +129,7 @@ Foam::eddy::eddy
|
|||||||
const scalar x,
|
const scalar x,
|
||||||
const scalar sigmaX,
|
const scalar sigmaX,
|
||||||
const symmTensor& R,
|
const symmTensor& R,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
patchFaceI_(patchFaceI),
|
patchFaceI_(patchFaceI),
|
||||||
|
|||||||
@ -41,7 +41,7 @@ SourceFiles
|
|||||||
#include "vector.H"
|
#include "vector.H"
|
||||||
#include "point.H"
|
#include "point.H"
|
||||||
#include "tensor.H"
|
#include "tensor.H"
|
||||||
#include "cachedRandom.H"
|
#include "Random.H"
|
||||||
#include "coordinateSystem.H"
|
#include "coordinateSystem.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -112,7 +112,7 @@ class eddy
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Return a number with zero mean and unit variance
|
//- Return a number with zero mean and unit variance
|
||||||
inline scalar epsi(cachedRandom& rndGen) const;
|
inline scalar epsi(Random& rndGen) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -133,7 +133,7 @@ public:
|
|||||||
const scalar x, // distance from reference position
|
const scalar x, // distance from reference position
|
||||||
const scalar sigmaX, // length scale
|
const scalar sigmaX, // length scale
|
||||||
const symmTensor& R, // Stress tensor
|
const symmTensor& R, // Stress tensor
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct copy
|
//- Construct copy
|
||||||
@ -175,7 +175,7 @@ public:
|
|||||||
inline label dir1() const;
|
inline label dir1() const;
|
||||||
|
|
||||||
//- Return random vector of -1 and 1's
|
//- Return random vector of -1 and 1's
|
||||||
inline vector epsilon(cachedRandom& rndGen) const;
|
inline vector epsilon(Random& rndGen) const;
|
||||||
|
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|||||||
@ -29,7 +29,7 @@ using namespace Foam::constant;
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::scalar Foam::eddy::epsi(cachedRandom& rndGen) const
|
Foam::scalar Foam::eddy::epsi(Random& rndGen) const
|
||||||
{
|
{
|
||||||
// Random number with zero mean and unit variance
|
// Random number with zero mean and unit variance
|
||||||
return rndGen.sample01<scalar>() > 0.5 ? 1 : -1;
|
return rndGen.sample01<scalar>() > 0.5 ? 1 : -1;
|
||||||
@ -84,7 +84,7 @@ inline Foam::scalar Foam::eddy::c1() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::vector Foam::eddy::epsilon(cachedRandom& rndGen) const
|
Foam::vector Foam::eddy::epsilon(Random& rndGen) const
|
||||||
{
|
{
|
||||||
return vector(epsi(rndGen), epsi(rndGen), epsi(rndGen));
|
return vector(epsi(rndGen), epsi(rndGen), epsi(rndGen));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,7 +81,7 @@ SourceFiles
|
|||||||
#define turbulentDFSEMInletFvPatchVectorField_H
|
#define turbulentDFSEMInletFvPatchVectorField_H
|
||||||
|
|
||||||
#include "fixedValueFvPatchFields.H"
|
#include "fixedValueFvPatchFields.H"
|
||||||
#include "cachedRandom.H"
|
#include "Random.H"
|
||||||
#include "eddy.H"
|
#include "eddy.H"
|
||||||
#include "pointIndexHit.H"
|
#include "pointIndexHit.H"
|
||||||
#include "instantList.H"
|
#include "instantList.H"
|
||||||
@ -184,7 +184,7 @@ class turbulentDFSEMInletFvPatchVectorField
|
|||||||
scalar v0_;
|
scalar v0_;
|
||||||
|
|
||||||
//- Random number generator
|
//- Random number generator
|
||||||
cachedRandom rndGen_;
|
Random rndGen_;
|
||||||
|
|
||||||
//- Length scale per patch face
|
//- Length scale per patch face
|
||||||
scalarField sigmax_;
|
scalarField sigmax_;
|
||||||
|
|||||||
@ -166,7 +166,7 @@ void Foam::turbulentInletFvPatchField<Type>::updateCoeffs()
|
|||||||
|
|
||||||
forAll(patchField, facei)
|
forAll(patchField, facei)
|
||||||
{
|
{
|
||||||
ranGen_.randomise(randomField[facei]);
|
ranGen_.randomise01<Type>(randomField[facei]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Correction-factor to compensate for the loss of RMS fluctuation
|
// Correction-factor to compensate for the loss of RMS fluctuation
|
||||||
|
|||||||
@ -73,7 +73,7 @@ SourceFiles
|
|||||||
#include "fvMeshFunctionObject.H"
|
#include "fvMeshFunctionObject.H"
|
||||||
#include "writeFile.H"
|
#include "writeFile.H"
|
||||||
#include "scalarField.H"
|
#include "scalarField.H"
|
||||||
#include "cachedRandom.H"
|
#include "Random.H"
|
||||||
#include "Tuple2.H"
|
#include "Tuple2.H"
|
||||||
#include "writer.H"
|
#include "writer.H"
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ protected:
|
|||||||
word tagFieldName_;
|
word tagFieldName_;
|
||||||
|
|
||||||
//- Random number generator - used by distribution models
|
//- Random number generator - used by distribution models
|
||||||
cachedRandom rndGen_;
|
Random rndGen_;
|
||||||
|
|
||||||
//- Writer
|
//- Writer
|
||||||
autoPtr<writer<scalar>> writerPtr_;
|
autoPtr<writer<scalar>> writerPtr_;
|
||||||
|
|||||||
@ -47,7 +47,7 @@ bool Foam::functionObjects::randomise::calcRandomised()
|
|||||||
forAll(field, celli)
|
forAll(field, celli)
|
||||||
{
|
{
|
||||||
Type rndPert;
|
Type rndPert;
|
||||||
rand.randomise(rndPert);
|
rand.randomise01(rndPert);
|
||||||
rndPert = 2.0*rndPert - pTraits<Type>::one;
|
rndPert = 2.0*rndPert - pTraits<Type>::one;
|
||||||
rndPert /= mag(rndPert);
|
rndPert /= mag(rndPert);
|
||||||
rfield[celli] += magPerturbation_*rndPert;
|
rfield[celli] += magPerturbation_*rndPert;
|
||||||
|
|||||||
@ -152,7 +152,7 @@ void Foam::DSMCCloud<ParcelType>::initialise
|
|||||||
if
|
if
|
||||||
(
|
(
|
||||||
(particlesRequired - nParticlesToInsert)
|
(particlesRequired - nParticlesToInsert)
|
||||||
> rndGen_.scalar01()
|
> rndGen_.sample01<scalar>()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
nParticlesToInsert++;
|
nParticlesToInsert++;
|
||||||
@ -282,7 +282,7 @@ void Foam::DSMCCloud<ParcelType>::collisions()
|
|||||||
// subCell candidate selection procedure
|
// subCell candidate selection procedure
|
||||||
|
|
||||||
// Select the first collision candidate
|
// Select the first collision candidate
|
||||||
label candidateP = rndGen_.integer(0, nC - 1);
|
label candidateP = rndGen_.position<label>(0, nC - 1);
|
||||||
|
|
||||||
// Declare the second collision candidate
|
// Declare the second collision candidate
|
||||||
label candidateQ = -1;
|
label candidateQ = -1;
|
||||||
@ -298,7 +298,8 @@ void Foam::DSMCCloud<ParcelType>::collisions()
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
candidateQ = subCellPs[rndGen_.integer(0, nSC - 1)];
|
label i = rndGen_.position<label>(0, nSC - 1);
|
||||||
|
candidateQ = subCellPs[i];
|
||||||
} while (candidateP == candidateQ);
|
} while (candidateP == candidateQ);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -309,7 +310,7 @@ void Foam::DSMCCloud<ParcelType>::collisions()
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
candidateQ = rndGen_.integer(0, nC - 1);
|
candidateQ = rndGen_.position<label>(0, nC - 1);
|
||||||
} while (candidateP == candidateQ);
|
} while (candidateP == candidateQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,15 +318,15 @@ void Foam::DSMCCloud<ParcelType>::collisions()
|
|||||||
// uniform candidate selection procedure
|
// uniform candidate selection procedure
|
||||||
|
|
||||||
// // Select the first collision candidate
|
// // Select the first collision candidate
|
||||||
// label candidateP = rndGen_.integer(0, nC-1);
|
// label candidateP = rndGen_.position<label>(0, nC-1);
|
||||||
|
|
||||||
// // Select a possible second collision candidate
|
// // Select a possible second collision candidate
|
||||||
// label candidateQ = rndGen_.integer(0, nC-1);
|
// label candidateQ = rndGen_.position<label>(0, nC-1);
|
||||||
|
|
||||||
// // If the same candidate is chosen, choose again
|
// // If the same candidate is chosen, choose again
|
||||||
// while (candidateP == candidateQ)
|
// while (candidateP == candidateQ)
|
||||||
// {
|
// {
|
||||||
// candidateQ = rndGen_.integer(0, nC-1);
|
// candidateQ = rndGen_.position<label>(0, nC-1);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -348,7 +349,7 @@ void Foam::DSMCCloud<ParcelType>::collisions()
|
|||||||
sigmaTcRMax_[celli] = sigmaTcR;
|
sigmaTcRMax_[celli] = sigmaTcR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sigmaTcR/sigmaTcRMax) > rndGen_.scalar01())
|
if ((sigmaTcR/sigmaTcRMax) > rndGen_.sample01<scalar>())
|
||||||
{
|
{
|
||||||
binaryCollision().collide
|
binaryCollision().collide
|
||||||
(
|
(
|
||||||
@ -648,7 +649,7 @@ Foam::DSMCCloud<ParcelType>::DSMCCloud
|
|||||||
mesh_
|
mesh_
|
||||||
),
|
),
|
||||||
constProps_(),
|
constProps_(),
|
||||||
rndGen_(label(149382906) + 7183*Pstream::myProcNo()),
|
rndGen_(Pstream::myProcNo()),
|
||||||
boundaryT_
|
boundaryT_
|
||||||
(
|
(
|
||||||
volScalarField
|
volScalarField
|
||||||
@ -711,7 +712,7 @@ Foam::DSMCCloud<ParcelType>::DSMCCloud
|
|||||||
// and 1.
|
// and 1.
|
||||||
forAll(collisionSelectionRemainder_, i)
|
forAll(collisionSelectionRemainder_, i)
|
||||||
{
|
{
|
||||||
collisionSelectionRemainder_[i] = rndGen_.scalar01();
|
collisionSelectionRemainder_[i] = rndGen_.sample01<scalar>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readFields)
|
if (readFields)
|
||||||
@ -900,7 +901,7 @@ Foam::DSMCCloud<ParcelType>::DSMCCloud
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
constProps_(),
|
constProps_(),
|
||||||
rndGen_(label(971501) + 1526*Pstream::myProcNo()),
|
rndGen_(Pstream::myProcNo()),
|
||||||
boundaryT_
|
boundaryT_
|
||||||
(
|
(
|
||||||
volScalarField
|
volScalarField
|
||||||
@ -1039,12 +1040,7 @@ Foam::vector Foam::DSMCCloud<ParcelType>::equipartitionLinearVelocity
|
|||||||
{
|
{
|
||||||
return
|
return
|
||||||
sqrt(physicoChemical::k.value()*temperature/mass)
|
sqrt(physicoChemical::k.value()*temperature/mass)
|
||||||
*vector
|
*rndGen_.GaussNormal<vector>();
|
||||||
(
|
|
||||||
rndGen_.GaussNormal(),
|
|
||||||
rndGen_.GaussNormal(),
|
|
||||||
rndGen_.GaussNormal()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1064,7 +1060,9 @@ Foam::scalar Foam::DSMCCloud<ParcelType>::equipartitionInternalEnergy
|
|||||||
else if (iDof < 2.0 + SMALL && iDof > 2.0 - SMALL)
|
else if (iDof < 2.0 + SMALL && iDof > 2.0 - SMALL)
|
||||||
{
|
{
|
||||||
// Special case for iDof = 2, i.e. diatomics;
|
// Special case for iDof = 2, i.e. diatomics;
|
||||||
Ei = -log(rndGen_.scalar01())*physicoChemical::k.value()*temperature;
|
Ei =
|
||||||
|
-log(rndGen_.sample01<scalar>())
|
||||||
|
*physicoChemical::k.value()*temperature;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1074,9 +1072,9 @@ Foam::scalar Foam::DSMCCloud<ParcelType>::equipartitionInternalEnergy
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
energyRatio = 10*rndGen_.scalar01();
|
energyRatio = 10*rndGen_.sample01<scalar>();
|
||||||
P = pow((energyRatio/a), a)*exp(a - energyRatio);
|
P = pow((energyRatio/a), a)*exp(a - energyRatio);
|
||||||
} while (P < rndGen_.scalar01());
|
} while (P < rndGen_.sample01<scalar>());
|
||||||
|
|
||||||
Ei = energyRatio*physicoChemical::k.value()*temperature;
|
Ei = energyRatio*physicoChemical::k.value()*temperature;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,14 +39,14 @@ Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::energyRatio
|
|||||||
{
|
{
|
||||||
CloudType& cloud(this->owner());
|
CloudType& cloud(this->owner());
|
||||||
|
|
||||||
Random& rndGen(cloud.rndGen());
|
Random& rndGen = cloud.rndGen();
|
||||||
|
|
||||||
scalar ChiAMinusOne = ChiA - 1;
|
scalar ChiAMinusOne = ChiA - 1;
|
||||||
scalar ChiBMinusOne = ChiB - 1;
|
scalar ChiBMinusOne = ChiB - 1;
|
||||||
|
|
||||||
if (ChiAMinusOne < SMALL && ChiBMinusOne < SMALL)
|
if (ChiAMinusOne < SMALL && ChiBMinusOne < SMALL)
|
||||||
{
|
{
|
||||||
return rndGen.scalar01();
|
return rndGen.sample01<scalar>();
|
||||||
}
|
}
|
||||||
|
|
||||||
scalar energyRatio;
|
scalar energyRatio;
|
||||||
@ -56,7 +56,7 @@ Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::energyRatio
|
|||||||
{
|
{
|
||||||
P = 0;
|
P = 0;
|
||||||
|
|
||||||
energyRatio = rndGen.scalar01();
|
energyRatio = rndGen.sample01<scalar>();
|
||||||
|
|
||||||
if (ChiAMinusOne < SMALL)
|
if (ChiAMinusOne < SMALL)
|
||||||
{
|
{
|
||||||
@ -81,7 +81,7 @@ Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::energyRatio
|
|||||||
ChiBMinusOne
|
ChiBMinusOne
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} while (P < rndGen.scalar01());
|
} while (P < rndGen.sample01<scalar>());
|
||||||
|
|
||||||
return energyRatio;
|
return energyRatio;
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ void Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::collide
|
|||||||
scalar& EiP = pP.Ei();
|
scalar& EiP = pP.Ei();
|
||||||
scalar& EiQ = pQ.Ei();
|
scalar& EiQ = pQ.Ei();
|
||||||
|
|
||||||
Random& rndGen(cloud.rndGen());
|
Random& rndGen = cloud.rndGen();
|
||||||
|
|
||||||
scalar inverseCollisionNumber = 1/relaxationCollisionNumber_;
|
scalar inverseCollisionNumber = 1/relaxationCollisionNumber_;
|
||||||
|
|
||||||
@ -217,13 +217,14 @@ void Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::collide
|
|||||||
|
|
||||||
if (iDofP > 0)
|
if (iDofP > 0)
|
||||||
{
|
{
|
||||||
if (inverseCollisionNumber > rndGen.scalar01())
|
if (inverseCollisionNumber > rndGen.sample01<scalar>())
|
||||||
{
|
{
|
||||||
availableEnergy += preCollisionEiP;
|
availableEnergy += preCollisionEiP;
|
||||||
|
|
||||||
if (iDofP == 2)
|
if (iDofP == 2)
|
||||||
{
|
{
|
||||||
scalar energyRatio = 1.0 - pow(rndGen.scalar01(), (1.0/ChiB));
|
scalar energyRatio =
|
||||||
|
1.0 - pow(rndGen.sample01<scalar>(), (1.0/ChiB));
|
||||||
EiP = energyRatio*availableEnergy;
|
EiP = energyRatio*availableEnergy;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -238,13 +239,13 @@ void Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::collide
|
|||||||
|
|
||||||
if (iDofQ > 0)
|
if (iDofQ > 0)
|
||||||
{
|
{
|
||||||
if (inverseCollisionNumber > rndGen.scalar01())
|
if (inverseCollisionNumber > rndGen.sample01<scalar>())
|
||||||
{
|
{
|
||||||
availableEnergy += preCollisionEiQ;
|
availableEnergy += preCollisionEiQ;
|
||||||
|
|
||||||
if (iDofQ == 2)
|
if (iDofQ == 2)
|
||||||
{
|
{
|
||||||
scalar energyRatio = 1.0 - pow(rndGen.scalar01(), (1.0/ChiB));
|
scalar energyRatio = 1.0 - pow(rndGen.sample01<scalar>(), (1.0/ChiB));
|
||||||
EiQ = energyRatio*availableEnergy;
|
EiQ = energyRatio*availableEnergy;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -261,9 +262,9 @@ void Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::collide
|
|||||||
scalar cR = sqrt(2.0*availableEnergy/mR);
|
scalar cR = sqrt(2.0*availableEnergy/mR);
|
||||||
|
|
||||||
// Variable Hard Sphere collision part
|
// Variable Hard Sphere collision part
|
||||||
scalar cosTheta = 2.0*rndGen.scalar01() - 1.0;
|
scalar cosTheta = 2.0*rndGen.sample01<scalar>() - 1.0;
|
||||||
scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta);
|
scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta);
|
||||||
scalar phi = twoPi*rndGen.scalar01();
|
scalar phi = twoPi*rndGen.sample01<scalar>();
|
||||||
|
|
||||||
vector postCollisionRelU =
|
vector postCollisionRelU =
|
||||||
cR
|
cR
|
||||||
|
|||||||
@ -121,7 +121,7 @@ void Foam::VariableHardSphere<CloudType>::collide
|
|||||||
vector& UP = pP.U();
|
vector& UP = pP.U();
|
||||||
vector& UQ = pQ.U();
|
vector& UQ = pQ.U();
|
||||||
|
|
||||||
Random& rndGen(cloud.rndGen());
|
Random& rndGen = cloud.rndGen();
|
||||||
|
|
||||||
scalar mP = cloud.constProps(typeIdP).mass();
|
scalar mP = cloud.constProps(typeIdP).mass();
|
||||||
|
|
||||||
@ -131,11 +131,11 @@ void Foam::VariableHardSphere<CloudType>::collide
|
|||||||
|
|
||||||
scalar cR = mag(UP - UQ);
|
scalar cR = mag(UP - UQ);
|
||||||
|
|
||||||
scalar cosTheta = 2.0*rndGen.scalar01() - 1.0;
|
scalar cosTheta = 2.0*rndGen.sample01<scalar>() - 1.0;
|
||||||
|
|
||||||
scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta);
|
scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta);
|
||||||
|
|
||||||
scalar phi = twoPi*rndGen.scalar01();
|
scalar phi = twoPi*rndGen.sample01<scalar>();
|
||||||
|
|
||||||
vector postCollisionRelU =
|
vector postCollisionRelU =
|
||||||
cR
|
cR
|
||||||
|
|||||||
@ -147,7 +147,7 @@ void Foam::FreeStream<CloudType>::inflow()
|
|||||||
|
|
||||||
const scalar deltaT = mesh.time().deltaTValue();
|
const scalar deltaT = mesh.time().deltaTValue();
|
||||||
|
|
||||||
Random& rndGen(cloud.rndGen());
|
Random& rndGen = cloud.rndGen();
|
||||||
|
|
||||||
scalar sqrtPi = sqrt(pi);
|
scalar sqrtPi = sqrt(pi);
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ void Foam::FreeStream<CloudType>::inflow()
|
|||||||
|
|
||||||
// Add another particle with a probability proportional to the
|
// Add another particle with a probability proportional to the
|
||||||
// remainder of taking the integer part of faceAccumulator
|
// remainder of taking the integer part of faceAccumulator
|
||||||
if ((faceAccumulator - nI) > rndGen.scalar01())
|
if ((faceAccumulator - nI) > rndGen.sample01<scalar>())
|
||||||
{
|
{
|
||||||
nI++;
|
nI++;
|
||||||
}
|
}
|
||||||
@ -307,7 +307,7 @@ void Foam::FreeStream<CloudType>::inflow()
|
|||||||
// Choose a triangle to insert on, based on their relative
|
// Choose a triangle to insert on, based on their relative
|
||||||
// area
|
// area
|
||||||
|
|
||||||
scalar triSelection = rndGen.scalar01();
|
scalar triSelection = rndGen.sample01<scalar>();
|
||||||
|
|
||||||
// Selected triangle
|
// Selected triangle
|
||||||
label selectedTriI = -1;
|
label selectedTriI = -1;
|
||||||
@ -371,7 +371,7 @@ void Foam::FreeStream<CloudType>::inflow()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
uNormalThermal =
|
uNormalThermal =
|
||||||
randomScaling*(2.0*rndGen.scalar01() - 1);
|
randomScaling*(2.0*rndGen.sample01<scalar>() - 1);
|
||||||
|
|
||||||
uNormal = uNormalThermal + sCosTheta;
|
uNormal = uNormalThermal + sCosTheta;
|
||||||
|
|
||||||
@ -385,13 +385,13 @@ void Foam::FreeStream<CloudType>::inflow()
|
|||||||
*exp(uNormProbCoeffB - sqr(uNormalThermal));
|
*exp(uNormProbCoeffB - sqr(uNormalThermal));
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (P < rndGen.scalar01());
|
} while (P < rndGen.sample01<scalar>());
|
||||||
|
|
||||||
vector U =
|
vector U =
|
||||||
sqrt(physicoChemical::k.value()*faceTemperature/mass)
|
sqrt(physicoChemical::k.value()*faceTemperature/mass)
|
||||||
*(
|
*(
|
||||||
rndGen.GaussNormal()*t1
|
rndGen.GaussNormal<scalar>()*t1
|
||||||
+ rndGen.GaussNormal()*t2
|
+ rndGen.GaussNormal<scalar>()*t2
|
||||||
)
|
)
|
||||||
+ (t1 & faceVelocity)*t1
|
+ (t1 & faceVelocity)*t1
|
||||||
+ (t2 & faceVelocity)*t2
|
+ (t2 & faceVelocity)*t2
|
||||||
|
|||||||
@ -78,19 +78,18 @@ void Foam::MaxwellianThermal<CloudType>::correct
|
|||||||
|
|
||||||
CloudType& cloud(this->owner());
|
CloudType& cloud(this->owner());
|
||||||
|
|
||||||
Random& rndGen(cloud.rndGen());
|
Random& rndGen = cloud.rndGen();
|
||||||
|
|
||||||
while (mag(Ut) < SMALL)
|
while (mag(Ut) < SMALL)
|
||||||
{
|
{
|
||||||
// If the incident velocity is parallel to the face normal, no
|
// If the incident velocity is parallel to the face normal, no
|
||||||
// tangential direction can be chosen. Add a perturbation to the
|
// tangential direction can be chosen. Add a perturbation to the
|
||||||
// incoming velocity and recalculate.
|
// incoming velocity and recalculate.
|
||||||
|
|
||||||
U = vector
|
U = vector
|
||||||
(
|
(
|
||||||
U.x()*(0.8 + 0.2*rndGen.scalar01()),
|
U.x()*(0.8 + 0.2*rndGen.sample01<scalar>()),
|
||||||
U.y()*(0.8 + 0.2*rndGen.scalar01()),
|
U.y()*(0.8 + 0.2*rndGen.sample01<scalar>()),
|
||||||
U.z()*(0.8 + 0.2*rndGen.scalar01())
|
U.z()*(0.8 + 0.2*rndGen.sample01<scalar>())
|
||||||
);
|
);
|
||||||
|
|
||||||
U_dot_nw = U & nw;
|
U_dot_nw = U & nw;
|
||||||
@ -113,9 +112,9 @@ void Foam::MaxwellianThermal<CloudType>::correct
|
|||||||
U =
|
U =
|
||||||
sqrt(physicoChemical::k.value()*T/mass)
|
sqrt(physicoChemical::k.value()*T/mass)
|
||||||
*(
|
*(
|
||||||
rndGen.GaussNormal()*tw1
|
rndGen.GaussNormal<scalar>()*tw1
|
||||||
+ rndGen.GaussNormal()*tw2
|
+ rndGen.GaussNormal<scalar>()*tw2
|
||||||
- sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
|
- sqrt(-2.0*log(max(1 - rndGen.sample01<scalar>(), VSMALL)))*nw
|
||||||
);
|
);
|
||||||
|
|
||||||
U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
|
U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
|
||||||
|
|||||||
@ -73,9 +73,9 @@ void Foam::MixedDiffuseSpecular<CloudType>::correct
|
|||||||
|
|
||||||
CloudType& cloud(this->owner());
|
CloudType& cloud(this->owner());
|
||||||
|
|
||||||
Random& rndGen(cloud.rndGen());
|
Random& rndGen = cloud.rndGen();
|
||||||
|
|
||||||
if (diffuseFraction_ > rndGen.scalar01())
|
if (diffuseFraction_ > rndGen.sample01<scalar>())
|
||||||
{
|
{
|
||||||
// Diffuse reflection
|
// Diffuse reflection
|
||||||
|
|
||||||
@ -87,12 +87,11 @@ void Foam::MixedDiffuseSpecular<CloudType>::correct
|
|||||||
// If the incident velocity is parallel to the face normal, no
|
// If the incident velocity is parallel to the face normal, no
|
||||||
// tangential direction can be chosen. Add a perturbation to the
|
// tangential direction can be chosen. Add a perturbation to the
|
||||||
// incoming velocity and recalculate.
|
// incoming velocity and recalculate.
|
||||||
|
|
||||||
U = vector
|
U = vector
|
||||||
(
|
(
|
||||||
U.x()*(0.8 + 0.2*rndGen.scalar01()),
|
U.x()*(0.8 + 0.2*rndGen.sample01<scalar>()),
|
||||||
U.y()*(0.8 + 0.2*rndGen.scalar01()),
|
U.y()*(0.8 + 0.2*rndGen.sample01<scalar>()),
|
||||||
U.z()*(0.8 + 0.2*rndGen.scalar01())
|
U.z()*(0.8 + 0.2*rndGen.sample01<scalar>())
|
||||||
);
|
);
|
||||||
|
|
||||||
U_dot_nw = U & nw;
|
U_dot_nw = U & nw;
|
||||||
@ -115,9 +114,9 @@ void Foam::MixedDiffuseSpecular<CloudType>::correct
|
|||||||
U =
|
U =
|
||||||
sqrt(physicoChemical::k.value()*T/mass)
|
sqrt(physicoChemical::k.value()*T/mass)
|
||||||
*(
|
*(
|
||||||
rndGen.GaussNormal()*tw1
|
rndGen.GaussNormal<scalar>()*tw1
|
||||||
+ rndGen.GaussNormal()*tw2
|
+ rndGen.GaussNormal<scalar>()*tw2
|
||||||
- sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
|
- sqrt(-2.0*log(max(1 - rndGen.sample01<scalar>(), VSMALL)))*nw
|
||||||
);
|
);
|
||||||
|
|
||||||
U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
|
U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace distributionModels
|
|||||||
Foam::distributionModels::RosinRammler::RosinRammler
|
Foam::distributionModels::RosinRammler::RosinRammler
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModel(typeName, dict, rndGen),
|
distributionModel(typeName, dict, rndGen),
|
||||||
|
|||||||
@ -82,7 +82,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
RosinRammler(const dictionary& dict, cachedRandom& rndGen);
|
RosinRammler(const dictionary& dict, Random& rndGen);
|
||||||
|
|
||||||
//- Construct copy
|
//- Construct copy
|
||||||
RosinRammler(const RosinRammler& p);
|
RosinRammler(const RosinRammler& p);
|
||||||
|
|||||||
@ -78,7 +78,7 @@ void Foam::distributionModels::binned::initialise()
|
|||||||
Foam::distributionModels::binned::binned
|
Foam::distributionModels::binned::binned
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModel(typeName, dict, rndGen),
|
distributionModel(typeName, dict, rndGen),
|
||||||
@ -102,7 +102,7 @@ Foam::distributionModels::binned::binned
|
|||||||
(
|
(
|
||||||
const UList<scalar>& sampleData,
|
const UList<scalar>& sampleData,
|
||||||
const scalar binWidth,
|
const scalar binWidth,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModel(typeName, dictionary::null, rndGen),
|
distributionModel(typeName, dictionary::null, rndGen),
|
||||||
|
|||||||
@ -96,14 +96,14 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from dictionary
|
//- Construct from dictionary
|
||||||
binned(const dictionary& dict, cachedRandom& rndGen);
|
binned(const dictionary& dict, Random& rndGen);
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
binned
|
binned
|
||||||
(
|
(
|
||||||
const UList<scalar>& sampleData,
|
const UList<scalar>& sampleData,
|
||||||
const scalar binWidth,
|
const scalar binWidth,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct copy
|
//- Construct copy
|
||||||
|
|||||||
@ -66,7 +66,7 @@ Foam::distributionModels::distributionModel::distributionModel
|
|||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModelDict_(dict),
|
distributionModelDict_(dict),
|
||||||
|
|||||||
@ -55,7 +55,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "IOdictionary.H"
|
#include "IOdictionary.H"
|
||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
#include "cachedRandom.H"
|
#include "Random.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ protected:
|
|||||||
const dictionary distributionModelDict_;
|
const dictionary distributionModelDict_;
|
||||||
|
|
||||||
//- Reference to the random number generator
|
//- Reference to the random number generator
|
||||||
cachedRandom& rndGen_;
|
Random& rndGen_;
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
@ -102,7 +102,7 @@ public:
|
|||||||
dictionary,
|
dictionary,
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
),
|
),
|
||||||
(dict, rndGen)
|
(dict, rndGen)
|
||||||
);
|
);
|
||||||
@ -115,7 +115,7 @@ public:
|
|||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct copy
|
//- Construct copy
|
||||||
@ -129,7 +129,7 @@ public:
|
|||||||
static autoPtr<distributionModel> New
|
static autoPtr<distributionModel> New
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ Foam::autoPtr<Foam::distributionModels::distributionModel>
|
|||||||
Foam::distributionModels::distributionModel::New
|
Foam::distributionModels::distributionModel::New
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const word modelType(dict.lookup("type"));
|
const word modelType(dict.lookup("type"));
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace distributionModels
|
|||||||
Foam::distributionModels::exponential::exponential
|
Foam::distributionModels::exponential::exponential
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModel(typeName, dict, rndGen),
|
distributionModel(typeName, dict, rndGen),
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
exponential(const dictionary& dict, cachedRandom& rndGen);
|
exponential(const dictionary& dict, Random& rndGen);
|
||||||
|
|
||||||
//- Construct copy
|
//- Construct copy
|
||||||
exponential(const exponential& p);
|
exponential(const exponential& p);
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace distributionModels
|
|||||||
Foam::distributionModels::fixedValue::fixedValue
|
Foam::distributionModels::fixedValue::fixedValue
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModel(typeName, dict, rndGen),
|
distributionModel(typeName, dict, rndGen),
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
fixedValue(const dictionary& dict, cachedRandom& rndGen);
|
fixedValue(const dictionary& dict, Random& rndGen);
|
||||||
|
|
||||||
//- Construct copy
|
//- Construct copy
|
||||||
fixedValue(const fixedValue& p);
|
fixedValue(const fixedValue& p);
|
||||||
|
|||||||
@ -78,7 +78,7 @@ void Foam::distributionModels::general::initialise()
|
|||||||
Foam::distributionModels::general::general
|
Foam::distributionModels::general::general
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModel(typeName, dict, rndGen),
|
distributionModel(typeName, dict, rndGen),
|
||||||
@ -96,7 +96,7 @@ Foam::distributionModels::general::general
|
|||||||
(
|
(
|
||||||
const UList<scalar>& sampleData,
|
const UList<scalar>& sampleData,
|
||||||
const scalar binWidth,
|
const scalar binWidth,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModel(typeName, dictionary::null, rndGen),
|
distributionModel(typeName, dictionary::null, rndGen),
|
||||||
|
|||||||
@ -96,14 +96,14 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
general(const dictionary& dict, cachedRandom& rndGen);
|
general(const dictionary& dict, Random& rndGen);
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
general
|
general
|
||||||
(
|
(
|
||||||
const UList<scalar>& sampleData,
|
const UList<scalar>& sampleData,
|
||||||
const scalar binWidth,
|
const scalar binWidth,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct copy
|
//- Construct copy
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace distributionModels
|
|||||||
Foam::distributionModels::massRosinRammler::massRosinRammler
|
Foam::distributionModels::massRosinRammler::massRosinRammler
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModel(typeName, dict, rndGen),
|
distributionModel(typeName, dict, rndGen),
|
||||||
|
|||||||
@ -93,7 +93,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
massRosinRammler(const dictionary& dict, cachedRandom& rndGen);
|
massRosinRammler(const dictionary& dict, Random& rndGen);
|
||||||
|
|
||||||
//- Construct copy
|
//- Construct copy
|
||||||
massRosinRammler(const massRosinRammler& p);
|
massRosinRammler(const massRosinRammler& p);
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace distributionModels
|
|||||||
Foam::distributionModels::multiNormal::multiNormal
|
Foam::distributionModels::multiNormal::multiNormal
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModel(typeName, dict, rndGen),
|
distributionModel(typeName, dict, rndGen),
|
||||||
|
|||||||
@ -85,7 +85,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
multiNormal(const dictionary& dict, cachedRandom& rndGen);
|
multiNormal(const dictionary& dict, Random& rndGen);
|
||||||
|
|
||||||
//- Construct copy
|
//- Construct copy
|
||||||
multiNormal(const multiNormal& p);
|
multiNormal(const multiNormal& p);
|
||||||
|
|||||||
@ -43,7 +43,7 @@ namespace distributionModels
|
|||||||
Foam::distributionModels::normal::normal
|
Foam::distributionModels::normal::normal
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModel(typeName, dict, rndGen),
|
distributionModel(typeName, dict, rndGen),
|
||||||
|
|||||||
@ -85,7 +85,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
normal(const dictionary& dict, cachedRandom& rndGen);
|
normal(const dictionary& dict, Random& rndGen);
|
||||||
|
|
||||||
//- Construct copy
|
//- Construct copy
|
||||||
normal(const normal& p);
|
normal(const normal& p);
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace distributionModels
|
|||||||
Foam::distributionModels::uniform::uniform
|
Foam::distributionModels::uniform::uniform
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
distributionModel(typeName, dict, rndGen),
|
distributionModel(typeName, dict, rndGen),
|
||||||
|
|||||||
@ -70,7 +70,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
uniform(const dictionary& dict, cachedRandom& rndGen);
|
uniform(const dictionary& dict, Random& rndGen);
|
||||||
|
|
||||||
//- Construct copy
|
//- Construct copy
|
||||||
uniform(const uniform& p);
|
uniform(const uniform& p);
|
||||||
|
|||||||
@ -316,7 +316,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
|
|||||||
(
|
(
|
||||||
particleProperties_.subOrEmptyDict("subModels", solution_.active())
|
particleProperties_.subOrEmptyDict("subModels", solution_.active())
|
||||||
),
|
),
|
||||||
rndGen_(),
|
rndGen_(Pstream::myProcNo()),
|
||||||
cellOccupancyPtr_(),
|
cellOccupancyPtr_(),
|
||||||
cellLengthScale_(cbrt(mesh_.V())),
|
cellLengthScale_(cbrt(mesh_.V())),
|
||||||
rho_(rho),
|
rho_(rho),
|
||||||
|
|||||||
@ -59,7 +59,7 @@ SourceFiles
|
|||||||
#include "kinematicCloud.H"
|
#include "kinematicCloud.H"
|
||||||
#include "IOdictionary.H"
|
#include "IOdictionary.H"
|
||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
#include "cachedRandom.H"
|
#include "Random.H"
|
||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "fvMatrices.H"
|
#include "fvMatrices.H"
|
||||||
@ -163,7 +163,7 @@ protected:
|
|||||||
const dictionary subModelProperties_;
|
const dictionary subModelProperties_;
|
||||||
|
|
||||||
//- Random number generator - used by some injection routines
|
//- Random number generator - used by some injection routines
|
||||||
mutable cachedRandom rndGen_;
|
mutable Random rndGen_;
|
||||||
|
|
||||||
//- Cell occupancy information for each parcel, (demand driven)
|
//- Cell occupancy information for each parcel, (demand driven)
|
||||||
autoPtr<List<DynamicList<parcelType*>>> cellOccupancyPtr_;
|
autoPtr<List<DynamicList<parcelType*>>> cellOccupancyPtr_;
|
||||||
@ -366,7 +366,7 @@ public:
|
|||||||
// Cloud data
|
// Cloud data
|
||||||
|
|
||||||
//- Return reference to the random object
|
//- Return reference to the random object
|
||||||
inline cachedRandom& rndGen() const;
|
inline Random& rndGen() const;
|
||||||
|
|
||||||
//- Return the cell occupancy information for each
|
//- Return the cell occupancy information for each
|
||||||
// parcel, non-const access, the caller is
|
// parcel, non-const access, the caller is
|
||||||
|
|||||||
@ -356,7 +356,7 @@ inline Foam::scalar Foam::KinematicCloud<CloudType>::Dmax() const
|
|||||||
|
|
||||||
|
|
||||||
template<class CloudType>
|
template<class CloudType>
|
||||||
inline Foam::cachedRandom& Foam::KinematicCloud<CloudType>::rndGen() const
|
inline Foam::Random& Foam::KinematicCloud<CloudType>::rndGen() const
|
||||||
{
|
{
|
||||||
return rndGen_;
|
return rndGen_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -171,16 +171,16 @@ void Foam::ParticleCollector<CloudType>::initConcentricCircles()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// set 4 quadrants for single sector cases
|
// Set 4 quadrants for single sector cases
|
||||||
nS = 4;
|
nS = 4;
|
||||||
|
|
||||||
vector tangent = Zero;
|
vector tangent = Zero;
|
||||||
scalar magTangent = 0.0;
|
scalar magTangent = 0.0;
|
||||||
|
|
||||||
Random rnd(1234);
|
Random& rnd = this->owner().rndGen();
|
||||||
while (magTangent < SMALL)
|
while (magTangent < SMALL)
|
||||||
{
|
{
|
||||||
vector v = rnd.vector01();
|
vector v = rnd.sample01<vector>();
|
||||||
|
|
||||||
tangent = v - (v & normal_[0])*normal_[0];
|
tangent = v - (v & normal_[0])*normal_[0];
|
||||||
magTangent = mag(tangent);
|
magTangent = mag(tangent);
|
||||||
|
|||||||
@ -40,7 +40,7 @@ void Foam::CellZoneInjection<CloudType>::setPositions
|
|||||||
const fvMesh& mesh = this->owner().mesh();
|
const fvMesh& mesh = this->owner().mesh();
|
||||||
const scalarField& V = mesh.V();
|
const scalarField& V = mesh.V();
|
||||||
const label nCells = cellZoneCells.size();
|
const label nCells = cellZoneCells.size();
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
|
|
||||||
DynamicList<vector> positions(nCells); // initial size only
|
DynamicList<vector> positions(nCells); // initial size only
|
||||||
DynamicList<label> injectorCells(nCells); // initial size only
|
DynamicList<label> injectorCells(nCells); // initial size only
|
||||||
|
|||||||
@ -110,7 +110,7 @@ Foam::ConeInjection<CloudType>::ConeInjection
|
|||||||
vector tangent = Zero;
|
vector tangent = Zero;
|
||||||
scalar magTangent = 0.0;
|
scalar magTangent = 0.0;
|
||||||
|
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
while (magTangent < SMALL)
|
while (magTangent < SMALL)
|
||||||
{
|
{
|
||||||
vector v = rnd.sample01<vector>();
|
vector v = rnd.sample01<vector>();
|
||||||
@ -260,7 +260,7 @@ void Foam::ConeInjection<CloudType>::setProperties
|
|||||||
typename CloudType::parcelType& parcel
|
typename CloudType::parcelType& parcel
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
|
|
||||||
// Set particle velocity
|
// Set particle velocity
|
||||||
const label i = parcelI % positionAxis_.size();
|
const label i = parcelI % positionAxis_.size();
|
||||||
|
|||||||
@ -175,7 +175,7 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
|
|||||||
|
|
||||||
setFlowType();
|
setFlowType();
|
||||||
|
|
||||||
cachedRandom& rndGen = this->owner().rndGen();
|
Random& rndGen = this->owner().rndGen();
|
||||||
|
|
||||||
// Normalise direction vector
|
// Normalise direction vector
|
||||||
direction_ /= mag(direction_);
|
direction_ /= mag(direction_);
|
||||||
@ -321,7 +321,7 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell
|
|||||||
label& tetPti
|
label& tetPti
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cachedRandom& rndGen = this->owner().rndGen();
|
Random& rndGen = this->owner().rndGen();
|
||||||
|
|
||||||
scalar beta = mathematical::twoPi*rndGen.sample01<scalar>();
|
scalar beta = mathematical::twoPi*rndGen.sample01<scalar>();
|
||||||
normal_ = tanVec1_*cos(beta) + tanVec2_*sin(beta);
|
normal_ = tanVec1_*cos(beta) + tanVec2_*sin(beta);
|
||||||
@ -373,7 +373,7 @@ void Foam::ConeNozzleInjection<CloudType>::setProperties
|
|||||||
typename CloudType::parcelType& parcel
|
typename CloudType::parcelType& parcel
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cachedRandom& rndGen = this->owner().rndGen();
|
Random& rndGen = this->owner().rndGen();
|
||||||
|
|
||||||
// Set particle velocity
|
// Set particle velocity
|
||||||
const scalar deg2Rad = mathematical::pi/180.0;
|
const scalar deg2Rad = mathematical::pi/180.0;
|
||||||
|
|||||||
@ -205,7 +205,7 @@ Foam::label Foam::InflationInjection<CloudType>::parcelsToInject
|
|||||||
|
|
||||||
newParticles_.clear();
|
newParticles_.clear();
|
||||||
|
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
|
|
||||||
// Diameter factor, when splitting particles into 4, this is the
|
// Diameter factor, when splitting particles into 4, this is the
|
||||||
// factor that modifies the diameter.
|
// factor that modifies the diameter.
|
||||||
|
|||||||
@ -148,7 +148,7 @@ void Foam::InjectedParticleDistributionInjection<CloudType>::initialise()
|
|||||||
scalar minTime = GREAT;
|
scalar minTime = GREAT;
|
||||||
|
|
||||||
// Populate injector properties, filtering out invalid entries
|
// Populate injector properties, filtering out invalid entries
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
label injectori = 0;
|
label injectori = 0;
|
||||||
forAll(injDiameter, i)
|
forAll(injDiameter, i)
|
||||||
{
|
{
|
||||||
@ -448,7 +448,7 @@ void Foam::InjectedParticleDistributionInjection<CloudType>::setPositionAndCell
|
|||||||
label& tetPtI
|
label& tetPtI
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
currentInjectori_ = rnd.globalPosition<label>(0, position_.size() - 1);
|
currentInjectori_ = rnd.globalPosition<label>(0, position_.size() - 1);
|
||||||
currentSamplei_ = rnd.globalPosition<label>(0, resampleSize_ - 1);
|
currentSamplei_ = rnd.globalPosition<label>(0, resampleSize_ - 1);
|
||||||
|
|
||||||
|
|||||||
@ -182,7 +182,7 @@ void Foam::KinematicLookupTableInjection<CloudType>::setPositionAndCell
|
|||||||
label injectorI = 0;
|
label injectorI = 0;
|
||||||
if (randomise_)
|
if (randomise_)
|
||||||
{
|
{
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -162,7 +162,7 @@ Foam::label Foam::PatchFlowRateInjection<CloudType>::parcelsToInject
|
|||||||
|
|
||||||
scalar nParcels = parcelConcentration_*c*flowRate()*dt;
|
scalar nParcels = parcelConcentration_*c*flowRate()*dt;
|
||||||
|
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
|
|
||||||
label nParcelsToInject = floor(nParcels);
|
label nParcelsToInject = floor(nParcels);
|
||||||
|
|
||||||
|
|||||||
@ -121,7 +121,7 @@ Foam::label Foam::PatchInjection<CloudType>::parcelsToInject
|
|||||||
if ((time0 >= 0.0) && (time0 < duration_))
|
if ((time0 >= 0.0) && (time0 < duration_))
|
||||||
{
|
{
|
||||||
scalar nParcels = (time1 - time0)*parcelsPerSecond_;
|
scalar nParcels = (time1 - time0)*parcelsPerSecond_;
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
scalar rndPos = rnd.globalPosition(scalar(0), scalar(1));
|
scalar rndPos = rnd.globalPosition(scalar(0), scalar(1));
|
||||||
label nParcelsToInject = floor(nParcels);
|
label nParcelsToInject = floor(nParcels);
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ License
|
|||||||
#include "patchInjectionBase.H"
|
#include "patchInjectionBase.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "SubField.H"
|
#include "SubField.H"
|
||||||
#include "cachedRandom.H"
|
#include "Random.H"
|
||||||
#include "triPointRef.H"
|
#include "triPointRef.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "polyMeshTetDecomposition.H"
|
#include "polyMeshTetDecomposition.H"
|
||||||
@ -151,7 +151,7 @@ void Foam::patchInjectionBase::updateMesh(const polyMesh& mesh)
|
|||||||
void Foam::patchInjectionBase::setPositionAndCell
|
void Foam::patchInjectionBase::setPositionAndCell
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
cachedRandom& rnd,
|
Random& rnd,
|
||||||
vector& position,
|
vector& position,
|
||||||
label& cellOwner,
|
label& cellOwner,
|
||||||
label& tetFacei,
|
label& tetFacei,
|
||||||
|
|||||||
@ -54,7 +54,7 @@ namespace Foam
|
|||||||
// Forward class declarations
|
// Forward class declarations
|
||||||
class polyMesh;
|
class polyMesh;
|
||||||
class fvMesh;
|
class fvMesh;
|
||||||
class cachedRandom;
|
class Random;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class patchInjectionBase Declaration
|
Class patchInjectionBase Declaration
|
||||||
@ -118,7 +118,7 @@ public:
|
|||||||
virtual void setPositionAndCell
|
virtual void setPositionAndCell
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
cachedRandom& rnd,
|
Random& rnd,
|
||||||
vector& position,
|
vector& position,
|
||||||
label& cellOwner,
|
label& cellOwner,
|
||||||
label& tetFacei,
|
label& tetFacei,
|
||||||
|
|||||||
@ -71,7 +71,7 @@ Foam::scalar Foam::IsotropyModels::Stochastic<CloudType>::sampleGauss()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cachedRandom& rndGen = this->owner().rndGen();
|
Random& rndGen = this->owner().rndGen();
|
||||||
|
|
||||||
scalar f, m, x, y;
|
scalar f, m, x, y;
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ void Foam::IsotropyModels::Stochastic<CloudType>::calculate()
|
|||||||
{
|
{
|
||||||
const fvMesh& mesh = this->owner().mesh();
|
const fvMesh& mesh = this->owner().mesh();
|
||||||
const scalar deltaT(this->owner().db().time().deltaTValue());
|
const scalar deltaT(this->owner().db().time().deltaTValue());
|
||||||
cachedRandom& rndGen = this->owner().rndGen();
|
Random& rndGen = this->owner().rndGen();
|
||||||
|
|
||||||
const scalar oneBySqrtThree = sqrt(1.0/3.0);
|
const scalar oneBySqrtThree = sqrt(1.0/3.0);
|
||||||
|
|
||||||
|
|||||||
@ -181,7 +181,7 @@ void Foam::ReactingLookupTableInjection<CloudType>::setPositionAndCell
|
|||||||
label injectorI = 0;
|
label injectorI = 0;
|
||||||
if (randomise_)
|
if (randomise_)
|
||||||
{
|
{
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -187,7 +187,7 @@ void Foam::ReactingMultiphaseLookupTableInjection<CloudType>::setPositionAndCell
|
|||||||
label injectorI = 0;
|
label injectorI = 0;
|
||||||
if (randomise_)
|
if (randomise_)
|
||||||
{
|
{
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -182,7 +182,7 @@ void Foam::ThermoLookupTableInjection<CloudType>::setPositionAndCell
|
|||||||
label injectorI = 0;
|
label injectorI = 0;
|
||||||
if (randomise_)
|
if (randomise_)
|
||||||
{
|
{
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -101,7 +101,7 @@ protected:
|
|||||||
typedef typename CloudType::parcelType parcelType;
|
typedef typename CloudType::parcelType parcelType;
|
||||||
|
|
||||||
//- Reference to the cloud random number generator
|
//- Reference to the cloud random number generator
|
||||||
cachedRandom& rndGen_;
|
Random& rndGen_;
|
||||||
|
|
||||||
//- Reference to the cloud thermo package
|
//- Reference to the cloud thermo package
|
||||||
const SLGThermo& thermo_;
|
const SLGThermo& thermo_;
|
||||||
|
|||||||
@ -1041,11 +1041,11 @@ void Foam::moleculeCloud::createMolecule
|
|||||||
{
|
{
|
||||||
pi = equipartitionAngularMomentum(temperature, cP);
|
pi = equipartitionAngularMomentum(temperature, cP);
|
||||||
|
|
||||||
scalar phi(rndGen_.scalar01()*twoPi);
|
scalar phi(rndGen_.sample01<scalar>()*twoPi);
|
||||||
|
|
||||||
scalar theta(rndGen_.scalar01()*twoPi);
|
scalar theta(rndGen_.sample01<scalar>()*twoPi);
|
||||||
|
|
||||||
scalar psi(rndGen_.scalar01()*twoPi);
|
scalar psi(rndGen_.sample01<scalar>()*twoPi);
|
||||||
|
|
||||||
Q = tensor
|
Q = tensor
|
||||||
(
|
(
|
||||||
|
|||||||
@ -301,12 +301,9 @@ inline Foam::vector Foam::moleculeCloud::equipartitionLinearVelocity
|
|||||||
scalar mass
|
scalar mass
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return sqrt(physicoChemical::k.value()*temperature/mass)*vector
|
return
|
||||||
(
|
sqrt(physicoChemical::k.value()*temperature/mass)
|
||||||
rndGen_.GaussNormal(),
|
*rndGen_.GaussNormal<vector>();
|
||||||
rndGen_.GaussNormal(),
|
|
||||||
rndGen_.GaussNormal()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -323,17 +320,17 @@ inline Foam::vector Foam::moleculeCloud::equipartitionAngularMomentum
|
|||||||
return sqrtKbT*vector
|
return sqrtKbT*vector
|
||||||
(
|
(
|
||||||
0.0,
|
0.0,
|
||||||
sqrt(cP.momentOfInertia().yy())*rndGen_.GaussNormal(),
|
sqrt(cP.momentOfInertia().yy())*rndGen_.GaussNormal<scalar>(),
|
||||||
sqrt(cP.momentOfInertia().zz())*rndGen_.GaussNormal()
|
sqrt(cP.momentOfInertia().zz())*rndGen_.GaussNormal<scalar>()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return sqrtKbT*vector
|
return sqrtKbT*vector
|
||||||
(
|
(
|
||||||
sqrt(cP.momentOfInertia().xx())*rndGen_.GaussNormal(),
|
sqrt(cP.momentOfInertia().xx())*rndGen_.GaussNormal<scalar>(),
|
||||||
sqrt(cP.momentOfInertia().yy())*rndGen_.GaussNormal(),
|
sqrt(cP.momentOfInertia().yy())*rndGen_.GaussNormal<scalar>(),
|
||||||
sqrt(cP.momentOfInertia().zz())*rndGen_.GaussNormal()
|
sqrt(cP.momentOfInertia().zz())*rndGen_.GaussNormal<scalar>()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -136,7 +136,7 @@ public:
|
|||||||
const vector& injectionPos,
|
const vector& injectionPos,
|
||||||
const scalar pAmbient,
|
const scalar pAmbient,
|
||||||
const scalar chi,
|
const scalar chi,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
) const = 0;
|
) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -92,7 +92,7 @@ void Foam::BlobsSheetAtomization<CloudType>::update
|
|||||||
const vector& injectionPos,
|
const vector& injectionPos,
|
||||||
const scalar pAmbient,
|
const scalar pAmbient,
|
||||||
const scalar chi,
|
const scalar chi,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
scalar lBU =
|
scalar lBU =
|
||||||
|
|||||||
@ -122,7 +122,7 @@ public:
|
|||||||
const vector& injectionPos,
|
const vector& injectionPos,
|
||||||
const scalar pAmbient,
|
const scalar pAmbient,
|
||||||
const scalar chi,
|
const scalar chi,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
) const;
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ void Foam::LISAAtomization<CloudType>::update
|
|||||||
const vector& injectionPos,
|
const vector& injectionPos,
|
||||||
const scalar pAmbient,
|
const scalar pAmbient,
|
||||||
const scalar chi,
|
const scalar chi,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (volFlowRate < SMALL)
|
if (volFlowRate < SMALL)
|
||||||
|
|||||||
@ -142,7 +142,7 @@ public:
|
|||||||
const vector& injectionPos,
|
const vector& injectionPos,
|
||||||
const scalar pAmbient,
|
const scalar pAmbient,
|
||||||
const scalar chi,
|
const scalar chi,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
) const;
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -95,7 +95,7 @@ void Foam::NoAtomization<CloudType>::update
|
|||||||
const vector& injectionPos,
|
const vector& injectionPos,
|
||||||
const scalar pAmbient,
|
const scalar pAmbient,
|
||||||
const scalar chi,
|
const scalar chi,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@ -105,7 +105,7 @@ public:
|
|||||||
const vector& injectionPos,
|
const vector& injectionPos,
|
||||||
const scalar pAmbient,
|
const scalar pAmbient,
|
||||||
const scalar chi,
|
const scalar chi,
|
||||||
cachedRandom& rndGen
|
Random& rndGen
|
||||||
) const;
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -138,7 +138,7 @@ bool Foam::SHF<CloudType>::update
|
|||||||
scalar& massChild
|
scalar& massChild
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cachedRandom& rndGen = this->owner().rndGen();
|
Random& rndGen = this->owner().rndGen();
|
||||||
|
|
||||||
bool addChild = false;
|
bool addChild = false;
|
||||||
|
|
||||||
|
|||||||
@ -110,7 +110,7 @@ bool Foam::TAB<CloudType>::update
|
|||||||
scalar& massChild
|
scalar& massChild
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cachedRandom& rndGen = this->owner().rndGen();
|
Random& rndGen = this->owner().rndGen();
|
||||||
|
|
||||||
scalar r = 0.5*d;
|
scalar r = 0.5*d;
|
||||||
scalar r2 = r*r;
|
scalar r2 = r*r;
|
||||||
|
|||||||
@ -100,7 +100,7 @@ Foam::vector Foam::GradientDispersionRAS<CloudType>::update
|
|||||||
scalar& tTurb
|
scalar& tTurb
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
|
|
||||||
const scalar cps = 0.16432;
|
const scalar cps = 0.16432;
|
||||||
|
|
||||||
|
|||||||
@ -71,7 +71,7 @@ Foam::vector Foam::StochasticDispersionRAS<CloudType>::update
|
|||||||
scalar& tTurb
|
scalar& tTurb
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
|
|
||||||
const scalar cps = 0.16432;
|
const scalar cps = 0.16432;
|
||||||
|
|
||||||
|
|||||||
@ -206,7 +206,7 @@ Foam::forceSuSp Foam::BrownianMotionForce<CloudType>::calcCoupled
|
|||||||
|
|
||||||
// To generate a spherical distribution:
|
// To generate a spherical distribution:
|
||||||
|
|
||||||
cachedRandom& rnd = this->owner().rndGen();
|
Random& rnd = this->owner().rndGen();
|
||||||
|
|
||||||
const scalar theta = rnd.sample01<scalar>()*twoPi;
|
const scalar theta = rnd.sample01<scalar>()*twoPi;
|
||||||
const scalar u = 2*rnd.sample01<scalar>() - 1;
|
const scalar u = 2*rnd.sample01<scalar>() - 1;
|
||||||
|
|||||||
@ -46,7 +46,7 @@ SourceFiles
|
|||||||
#define BrownianMotionForce_H
|
#define BrownianMotionForce_H
|
||||||
|
|
||||||
#include "ParticleForce.H"
|
#include "ParticleForce.H"
|
||||||
#include "cachedRandom.H"
|
#include "Random.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ class BrownianMotionForce
|
|||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Reference to the cloud random number generator
|
//- Reference to the cloud random number generator
|
||||||
cachedRandom& rndGen_;
|
Random& rndGen_;
|
||||||
|
|
||||||
//- Molecular free path length [m]
|
//- Molecular free path length [m]
|
||||||
const scalar lambda_;
|
const scalar lambda_;
|
||||||
|
|||||||
@ -260,7 +260,7 @@ bool Foam::edgeIntersections::inlinePerturb
|
|||||||
if (perturbStart)
|
if (perturbStart)
|
||||||
{
|
{
|
||||||
// Perturb with something (hopefully) larger than tolerance.
|
// Perturb with something (hopefully) larger than tolerance.
|
||||||
scalar t = 4.0*(rndGen.scalar01() - 0.5);
|
scalar t = 4.0*(rndGen.sample01<scalar>() - 0.5);
|
||||||
points1[v0] += t*surf1PointTol[e[0]]*n;
|
points1[v0] += t*surf1PointTol[e[0]]*n;
|
||||||
|
|
||||||
const labelList& pEdges = surf1.pointEdges()[e[0]];
|
const labelList& pEdges = surf1.pointEdges()[e[0]];
|
||||||
@ -273,7 +273,7 @@ bool Foam::edgeIntersections::inlinePerturb
|
|||||||
if (perturbEnd)
|
if (perturbEnd)
|
||||||
{
|
{
|
||||||
// Perturb with something larger than tolerance.
|
// Perturb with something larger than tolerance.
|
||||||
scalar t = 4.0*(rndGen.scalar01() - 0.5);
|
scalar t = 4.0*(rndGen.sample01<scalar>() - 0.5);
|
||||||
points1[v1] += t*surf1PointTol[e[1]]*n;
|
points1[v1] += t*surf1PointTol[e[1]]*n;
|
||||||
|
|
||||||
const labelList& pEdges = surf1.pointEdges()[e[1]];
|
const labelList& pEdges = surf1.pointEdges()[e[1]];
|
||||||
@ -320,7 +320,7 @@ bool Foam::edgeIntersections::rotatePerturb
|
|||||||
//label pointi = e[0];
|
//label pointi = e[0];
|
||||||
|
|
||||||
// Generate random vector slightly larger than tolerance.
|
// Generate random vector slightly larger than tolerance.
|
||||||
vector rndVec = rndGen.vector01() - vector(0.5, 0.5, 0.5);
|
vector rndVec = rndGen.sample01<vector>() - vector(0.5, 0.5, 0.5);
|
||||||
|
|
||||||
// Make sure rndVec only perp to edge
|
// Make sure rndVec only perp to edge
|
||||||
vector n(points1[meshPoints[e[1]]] - points1[meshPoints[e[0]]]);
|
vector n(points1[meshPoints[e[1]]] - points1[meshPoints[e[0]]]);
|
||||||
@ -405,7 +405,8 @@ bool Foam::edgeIntersections::offsetPerturb
|
|||||||
if (nearType == triPointRef::POINT || nearType == triPointRef::EDGE)
|
if (nearType == triPointRef::POINT || nearType == triPointRef::EDGE)
|
||||||
{
|
{
|
||||||
// Shift edge towards tri centre
|
// Shift edge towards tri centre
|
||||||
vector offset = 0.01*rndGen.scalar01()*(ctr - pHit.hitPoint());
|
vector offset =
|
||||||
|
0.01*rndGen.sample01<scalar>()*(ctr - pHit.hitPoint());
|
||||||
|
|
||||||
// shift e[0]
|
// shift e[0]
|
||||||
points1[meshPoints[e[0]]] += offset;
|
points1[meshPoints[e[0]]] += offset;
|
||||||
|
|||||||
@ -40,9 +40,9 @@ complexVector UOprocess::WeinerProcess()
|
|||||||
{
|
{
|
||||||
return RootDeltaT*complexVector
|
return RootDeltaT*complexVector
|
||||||
(
|
(
|
||||||
complex(GaussGen.GaussNormal(), GaussGen.GaussNormal()),
|
complex(GaussGen.GaussNormal<scalar>(), GaussGen.GaussNormal<scalar>()),
|
||||||
complex(GaussGen.GaussNormal(), GaussGen.GaussNormal()),
|
complex(GaussGen.GaussNormal<scalar>(), GaussGen.GaussNormal<scalar>()),
|
||||||
complex(GaussGen.GaussNormal(), GaussGen.GaussNormal())
|
complex(GaussGen.GaussNormal<scalar>(), GaussGen.GaussNormal<scalar>())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ UOprocess::UOprocess
|
|||||||
const dictionary& UOdict
|
const dictionary& UOdict
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
GaussGen(label(0)),
|
GaussGen(),
|
||||||
Mesh(kmesh),
|
Mesh(kmesh),
|
||||||
DeltaT(deltaT),
|
DeltaT(deltaT),
|
||||||
RootDeltaT(sqrt(DeltaT)),
|
RootDeltaT(sqrt(DeltaT)),
|
||||||
|
|||||||
@ -51,8 +51,8 @@ Foam::vectorField Foam::turbGen::U()
|
|||||||
|
|
||||||
forAll(K, i)
|
forAll(K, i)
|
||||||
{
|
{
|
||||||
s[i] = RanGen.vector01();
|
s[i] = RanGen.sample01<vector>();
|
||||||
rndPhases[i] = RanGen.scalar01();
|
rndPhases[i] = RanGen.sample01<scalar>();
|
||||||
}
|
}
|
||||||
|
|
||||||
s = K ^ s;
|
s = K ^ s;
|
||||||
|
|||||||
@ -40,7 +40,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "force.H"
|
#include "force.H"
|
||||||
#include "distributionModel.H"
|
#include "distributionModel.H"
|
||||||
#include "cachedRandom.H"
|
#include "Random.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ private:
|
|||||||
scalar Ccf_;
|
scalar Ccf_;
|
||||||
|
|
||||||
//- Random number generator
|
//- Random number generator
|
||||||
cachedRandom rndGen_;
|
Random rndGen_;
|
||||||
|
|
||||||
//- Parcel size PDF model
|
//- Parcel size PDF model
|
||||||
const autoPtr<distributionModels::distributionModel> distribution_;
|
const autoPtr<distributionModels::distributionModel> distribution_;
|
||||||
|
|||||||
@ -42,7 +42,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "injectionModel.H"
|
#include "injectionModel.H"
|
||||||
#include "distributionModel.H"
|
#include "distributionModel.H"
|
||||||
#include "cachedRandom.H"
|
#include "Random.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ protected:
|
|||||||
scalar particlesPerParcel_;
|
scalar particlesPerParcel_;
|
||||||
|
|
||||||
//- Random number generator
|
//- Random number generator
|
||||||
cachedRandom rndGen_;
|
Random rndGen_;
|
||||||
|
|
||||||
//- Parcel size PDF model
|
//- Parcel size PDF model
|
||||||
const autoPtr<distributionModels::distributionModel>
|
const autoPtr<distributionModels::distributionModel>
|
||||||
|
|||||||
@ -65,7 +65,7 @@ Foam::labelList Foam::randomRenumber::renumber
|
|||||||
{
|
{
|
||||||
forAll(newToOld, i)
|
forAll(newToOld, i)
|
||||||
{
|
{
|
||||||
label j = rndGen.integer(0, newToOld.size()-1);
|
label j = rndGen.position<label>(0, newToOld.size()-1);
|
||||||
Swap(newToOld[i], newToOld[j]);
|
Swap(newToOld[i], newToOld[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -227,7 +227,7 @@ void Foam::patchSeedSet::calcSamples
|
|||||||
{
|
{
|
||||||
forAll(subset, i)
|
forAll(subset, i)
|
||||||
{
|
{
|
||||||
label j = rndGen.integer(0, subset.size()-1);
|
label j = rndGen.position<label>(0, subset.size()-1);
|
||||||
Swap(subset[i], subset[j]);
|
Swap(subset[i], subset[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user