mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'feature-random-numbers' into 'develop'
Updated random numbers See merge request !107
This commit is contained in:
@ -46,7 +46,7 @@ int main(int argc, char *argv[])
|
||||
scalarField samples(10000000);
|
||||
forAll(samples, i)
|
||||
{
|
||||
samples[i] = rndGen.scalar01();
|
||||
samples[i] = rndGen.sample01<scalar>();
|
||||
}
|
||||
|
||||
const scalar min = 0;
|
||||
|
||||
@ -71,7 +71,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
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
|
||||
@ -90,7 +90,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
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
|
||||
@ -121,7 +121,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
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
|
||||
@ -155,7 +155,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label i = 0; i < randomDistributionTestSize; i++)
|
||||
{
|
||||
dV.add(R.vector01());
|
||||
dV.add(R.sample01<vector>());
|
||||
|
||||
// Adding separate GaussNormal components with component
|
||||
// weights
|
||||
@ -164,9 +164,9 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
vector
|
||||
(
|
||||
R.GaussNormal()*3.0 + 1.5,
|
||||
R.GaussNormal()*0.25 + 4.0,
|
||||
R.GaussNormal()*3.0 - 1.5
|
||||
R.GaussNormal<scalar>()*3.0 + 1.5,
|
||||
R.GaussNormal<scalar>()*0.25 + 4.0,
|
||||
R.GaussNormal<scalar>()*3.0 - 1.5
|
||||
),
|
||||
vector(1.0, 2.0, 5.0)
|
||||
);
|
||||
@ -225,7 +225,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label i = 0; i < randomDistributionTestSize; i++)
|
||||
{
|
||||
dT.add(R.tensor01());
|
||||
dT.add(R.sample01<tensor>());
|
||||
}
|
||||
|
||||
Info<< "Mean " << dT.mean() << nl
|
||||
@ -249,7 +249,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label i = 0; i < randomDistributionTestSize; i++)
|
||||
{
|
||||
dSyT.add(R.symmTensor01());
|
||||
dSyT.add(R.sample01<symmTensor>());
|
||||
}
|
||||
|
||||
Info<< "Mean " << dSyT.mean() << nl
|
||||
@ -273,7 +273,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (label i = 0; i < randomDistributionTestSize; i++)
|
||||
{
|
||||
dSpT.add(R.sphericalTensor01());
|
||||
dSpT.add(R.sample01<sphericalTensor>());
|
||||
}
|
||||
|
||||
Info<< "Mean " << dSpT.mean() << nl
|
||||
|
||||
@ -152,7 +152,7 @@ int main(int argc, char *argv[])
|
||||
Random rnd(123456);
|
||||
for (int i=0; i<10; i++)
|
||||
{
|
||||
scalar x = rnd.scalar01()*100;
|
||||
scalar x = rnd.sample01<scalar>()*100;
|
||||
|
||||
scalar px = polyValue(x);
|
||||
scalar ipx = intPolyValue(x);
|
||||
|
||||
@ -293,9 +293,9 @@ inline Foam::point Foam::conformalVoronoiMesh::perturbPoint
|
||||
|
||||
scalar pert = 1e-12*defaultCellSize();
|
||||
|
||||
perturbedPt.x() += pert*(rndGen_.scalar01() - 0.5);
|
||||
perturbedPt.y() += pert*(rndGen_.scalar01() - 0.5);
|
||||
perturbedPt.z() += pert*(rndGen_.scalar01() - 0.5);
|
||||
perturbedPt.x() += pert*(rndGen_.sample01<scalar>() - 0.5);
|
||||
perturbedPt.y() += pert*(rndGen_.sample01<scalar>() - 0.5);
|
||||
perturbedPt.z() += pert*(rndGen_.sample01<scalar>() - 0.5);
|
||||
|
||||
return perturbedPt;
|
||||
}
|
||||
|
||||
@ -553,11 +553,11 @@ bool Foam::autoDensity::fillBox
|
||||
+ vector
|
||||
(
|
||||
delta.x()
|
||||
*(i + 0.5 + 0.1*(rndGen().scalar01() - 0.5)),
|
||||
*(i + 0.5 + 0.1*(rndGen().sample01<scalar>() - 0.5)),
|
||||
delta.y()
|
||||
*(j + 0.5 + 0.1*(rndGen().scalar01() - 0.5)),
|
||||
*(j + 0.5 + 0.1*(rndGen().sample01<scalar>() - 0.5)),
|
||||
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
|
||||
// assess on
|
||||
// (1/maxDensity)/(1/localDensity) = minVolume/localVolume
|
||||
if (localDensity/maxDensity > rndGen().scalar01())
|
||||
if (localDensity/maxDensity > rndGen().sample01<scalar>())
|
||||
{
|
||||
scalar localVolume = 1/localDensity;
|
||||
|
||||
@ -675,7 +675,7 @@ bool Foam::autoDensity::fillBox
|
||||
scalar addProbability =
|
||||
(totalVolume - volumeAdded)/localVolume;
|
||||
|
||||
scalar r = rndGen().scalar01();
|
||||
scalar r = rndGen().sample01<scalar>();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
@ -729,7 +729,7 @@ bool Foam::autoDensity::fillBox
|
||||
{
|
||||
trialPoints++;
|
||||
|
||||
point p = min + cmptMultiply(span, rndGen().vector01());
|
||||
point p = min + cmptMultiply(span, rndGen().sample01<vector>());
|
||||
|
||||
scalar localSize = cellShapeControls().cellSize(p);
|
||||
|
||||
@ -785,7 +785,7 @@ bool Foam::autoDensity::fillBox
|
||||
|
||||
// Accept possible placements proportional to the relative local
|
||||
// density
|
||||
if (localDensity/maxDensity > rndGen().scalar01())
|
||||
if (localDensity/maxDensity > rndGen().sample01<scalar>())
|
||||
{
|
||||
scalar localVolume = 1/localDensity;
|
||||
|
||||
@ -798,7 +798,7 @@ bool Foam::autoDensity::fillBox
|
||||
scalar addProbability =
|
||||
(totalVolume - volumeAdded)/localVolume;
|
||||
|
||||
scalar r = rndGen().scalar01();
|
||||
scalar r = rndGen().sample01<scalar>();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
|
||||
@ -129,9 +129,9 @@ List<Vb::Point> bodyCentredCubic::initialPoints() const
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
pA.x() += pert*(rndGen().scalar01() - 0.5);
|
||||
pA.y() += pert*(rndGen().scalar01() - 0.5);
|
||||
pA.z() += pert*(rndGen().scalar01() - 0.5);
|
||||
pA.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
pA.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
pA.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
@ -150,9 +150,9 @@ List<Vb::Point> bodyCentredCubic::initialPoints() const
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
pB.x() += pert*(rndGen().scalar01() - 0.5);
|
||||
pB.y() += pert*(rndGen().scalar01() - 0.5);
|
||||
pB.z() += pert*(rndGen().scalar01() - 0.5);
|
||||
pB.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
pB.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
pB.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
|
||||
@ -127,9 +127,9 @@ List<Vb::Point> faceCentredCubic::initialPoints() const
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
p.x() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.y() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.z() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
p.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
p.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
@ -155,9 +155,9 @@ List<Vb::Point> faceCentredCubic::initialPoints() const
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
p.x() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.y() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.z() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
p.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
p.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
@ -183,9 +183,9 @@ List<Vb::Point> faceCentredCubic::initialPoints() const
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
p.x() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.y() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.z() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
p.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
p.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
@ -211,9 +211,9 @@ List<Vb::Point> faceCentredCubic::initialPoints() const
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
p.x() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.y() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.z() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
p.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
p.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
|
||||
@ -198,9 +198,15 @@ List<Vb::Point> pointFile::initialPoints() const
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
p.x() += randomPerturbationCoeff_*(rndGen().scalar01() - 0.5);
|
||||
p.y() += randomPerturbationCoeff_*(rndGen().scalar01() - 0.5);
|
||||
p.z() += randomPerturbationCoeff_*(rndGen().scalar01() - 0.5);
|
||||
p.x() +=
|
||||
randomPerturbationCoeff_
|
||||
*(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()));
|
||||
|
||||
@ -86,9 +86,9 @@ void rayShooting::splitLine
|
||||
{
|
||||
Foam::point newPt
|
||||
(
|
||||
midPoint.x() + pert*(rndGen().scalar01() - 0.5),
|
||||
midPoint.y() + pert*(rndGen().scalar01() - 0.5),
|
||||
midPoint.z() + pert*(rndGen().scalar01() - 0.5)
|
||||
midPoint.x() + pert*(rndGen().sample01<scalar>() - 0.5),
|
||||
midPoint.y() + pert*(rndGen().sample01<scalar>() - 0.5),
|
||||
midPoint.z() + pert*(rndGen().sample01<scalar>() - 0.5)
|
||||
);
|
||||
|
||||
if
|
||||
|
||||
@ -128,9 +128,9 @@ List<Vb::Point> uniformGrid::initialPoints() const
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
p.x() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.y() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.z() += pert*(rndGen().scalar01() - 0.5);
|
||||
p.x() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
p.y() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
p.z() += pert*(rndGen().sample01<scalar>() - 0.5);
|
||||
}
|
||||
|
||||
if
|
||||
|
||||
@ -264,8 +264,8 @@ void Foam::CV2D::insertGrid()
|
||||
|
||||
if (meshControls().randomiseInitialGrid())
|
||||
{
|
||||
p.x() += pert*(rndGen.scalar01() - 0.5);
|
||||
p.y() += pert*(rndGen.scalar01() - 0.5);
|
||||
p.x() += pert*(rndGen.sample01<scalar>() - 0.5);
|
||||
p.y() += pert*(rndGen.sample01<scalar>() - 0.5);
|
||||
}
|
||||
|
||||
if (qSurf_.wellInside(p, 0.5*meshControls().minCellSize2()))
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
const fileName pdfPath = runTime.path()/"pdf";
|
||||
mkDir(pdfPath);
|
||||
|
||||
cachedRandom rndGen(label(0), -1);
|
||||
Random rndGen;
|
||||
|
||||
autoPtr<distributionModels::distributionModel> p
|
||||
(
|
||||
|
||||
@ -783,7 +783,7 @@ labelPair edgeIntersectionsAndShuffleCGAL
|
||||
const edge& e = edges[edgeI];
|
||||
forAll(e, eI)
|
||||
{
|
||||
vector d = rndGen.vector01()-p05;
|
||||
vector d = rndGen.sample01<vector>() - p05;
|
||||
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, "
|
||||
<< "perturbing inertia tensor diagonal" << endl;
|
||||
|
||||
J.xx() *= 1.0 + SMALL*rand.scalar01();
|
||||
J.yy() *= 1.0 + SMALL*rand.scalar01();
|
||||
J.zz() *= 1.0 + SMALL*rand.scalar01();
|
||||
J.xx() *= 1.0 + SMALL*rand.sample01<scalar>();
|
||||
J.yy() *= 1.0 + SMALL*rand.sample01<scalar>();
|
||||
J.zz() *= 1.0 + SMALL*rand.sample01<scalar>();
|
||||
|
||||
eVal = eigenValues(J);
|
||||
|
||||
|
||||
@ -59,7 +59,6 @@ Description
|
||||
#include <link.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#ifdef USE_RANDOM
|
||||
#include <climits>
|
||||
#if INT_MAX != 2147483647
|
||||
@ -1430,6 +1429,15 @@ Foam::fileNameList Foam::dlLoaded()
|
||||
return libs;
|
||||
}
|
||||
|
||||
Foam::label Foam::osRandomBufferSize()
|
||||
{
|
||||
#ifdef USE_RANDOM
|
||||
return sizeof(random_data);
|
||||
#else
|
||||
return sizeof(drand48_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Foam::osRandomSeed(const label seed)
|
||||
{
|
||||
@ -1461,4 +1469,42 @@ Foam::scalar Foam::osRandomDouble()
|
||||
}
|
||||
|
||||
|
||||
void Foam::osRandomSeed(const label seed, List<char>& buffer)
|
||||
{
|
||||
#ifdef USE_RANDOM
|
||||
srandom_r((unsigned int)seed, reinterpret_cast<random_data*>(buffer.begin()));
|
||||
#else
|
||||
srand48_r(seed, reinterpret_cast<drand48_data*>(buffer.begin()));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::osRandomInteger(List<char>& buffer)
|
||||
{
|
||||
#ifdef USE_RANDOM
|
||||
int32_t result;
|
||||
random_r(reinterpret_cast<random_data*>(buffer.begin()), &result);
|
||||
return result;
|
||||
#else
|
||||
long result;
|
||||
lrand48_r(reinterpret_cast<drand48_data*>(buffer.begin()), &result);
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::osRandomDouble(List<char>& buffer)
|
||||
{
|
||||
#ifdef USE_RANDOM
|
||||
int32_t result;
|
||||
random_r(reinterpret_cast<random_data*>(buffer.begin()), &result);
|
||||
return (scalar)result/INT_MAX;
|
||||
#else
|
||||
double result;
|
||||
drand48_r(reinterpret_cast<drand48_data*>(buffer.begin()), &result);
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -111,7 +111,6 @@ $(sha1)/SHA1.C
|
||||
$(sha1)/SHA1Digest.C
|
||||
|
||||
primitives/random/Random/Random.C
|
||||
primitives/random/cachedRandom/cachedRandom.C
|
||||
|
||||
ranges = primitives/ranges
|
||||
$(ranges)/labelRange/labelRange.C
|
||||
|
||||
@ -245,6 +245,18 @@ label osRandomInteger();
|
||||
//- Return random double precision (uniform distribution between 0 and 1)
|
||||
scalar osRandomDouble();
|
||||
|
||||
//- Return the size of the buffer for re-entrant random number generator
|
||||
label osRandomBufferSize();
|
||||
|
||||
//- Seed random number generator.
|
||||
void osRandomSeed(const label seed, List<char>& buffer);
|
||||
|
||||
//- Return random integer (uniform distribution between 0 and 2^31)
|
||||
label osRandomInteger(List<char>& buffer);
|
||||
|
||||
//- Return random double precision (uniform distribution between 0 and 1)
|
||||
scalar osRandomDouble(List<char>& buffer);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -42,7 +42,6 @@ SourceFiles
|
||||
#include "point.H"
|
||||
#include "primitiveFieldsFwd.H"
|
||||
#include "pointHit.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "Random.H"
|
||||
#include "FixedList.H"
|
||||
#include "UList.H"
|
||||
@ -239,10 +238,6 @@ public:
|
||||
// uniform distribution
|
||||
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
|
||||
// point, in the same order as a, b, c, d. Returns the
|
||||
// determinant of the solution.
|
||||
|
||||
@ -249,42 +249,6 @@ inline Point Foam::tetrahedron<Point, PointRef>::randomPoint
|
||||
// Adapted from
|
||||
// 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 t = rndGen.sample01<scalar>();
|
||||
scalar u = rndGen.sample01<scalar>();
|
||||
|
||||
@ -40,7 +40,6 @@ SourceFiles
|
||||
#include "tensor.H"
|
||||
#include "pointHit.H"
|
||||
#include "Random.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "FixedList.H"
|
||||
#include "UList.H"
|
||||
#include "linePointRef.H"
|
||||
@ -238,10 +237,6 @@ public:
|
||||
// distribution
|
||||
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
|
||||
// point, in the same order as a, b, c. Returns the
|
||||
// determinant of the solution.
|
||||
|
||||
@ -249,25 +249,6 @@ inline Point Foam::triangle<Point, PointRef>::randomPoint(Random& rndGen) const
|
||||
// from "Graphics Gems", Academic Press, 1990
|
||||
// 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 t = sqrt(rndGen.sample01<scalar>());
|
||||
|
||||
@ -335,7 +335,7 @@ public:
|
||||
label distanceCmp(const point& pt, const treeBoundBox& other) const;
|
||||
|
||||
//- 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
|
||||
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);
|
||||
}
|
||||
|
||||
bb.min() -= cmptMultiply(s * rndGen.vector01(), newSpan);
|
||||
bb.max() += cmptMultiply(s * rndGen.vector01(), newSpan);
|
||||
bb.min() -= cmptMultiply(s*rndGen.sample01<vector>(), newSpan);
|
||||
bb.max() += cmptMultiply(s*rndGen.sample01<vector>(), newSpan);
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,173 +25,237 @@ License
|
||||
|
||||
#include "Random.H"
|
||||
#include "OSspecific.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * //
|
||||
|
||||
#if INT_MAX != 2147483647
|
||||
# error "INT_MAX != 2147483647"
|
||||
# error "The random number generator may not work!"
|
||||
#endif
|
||||
Foam::scalar Foam::Random::scalar01()
|
||||
{
|
||||
return osRandomDouble(buffer_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Random::Random(const label seed)
|
||||
:
|
||||
buffer_(osRandomBufferSize()),
|
||||
seed_(seed),
|
||||
hasGaussSample_(false),
|
||||
gaussSample_(0)
|
||||
{
|
||||
// Initialise the random number generator
|
||||
osRandomSeed(seed_, buffer_);
|
||||
}
|
||||
|
||||
|
||||
Foam::Random::Random(const Random& r, const bool reset)
|
||||
:
|
||||
buffer_(r.buffer_),
|
||||
seed_(r.seed_),
|
||||
hasGaussSample_(r.hasGaussSample_),
|
||||
gaussSample_(r.gaussSample_)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
hasGaussSample_ = false;
|
||||
gaussSample_ = 0;
|
||||
|
||||
// Re-initialise the samples
|
||||
osRandomSeed(seed_, buffer_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Random::~Random()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Random::Random(const label seed)
|
||||
void Foam::Random::reset(const label seed)
|
||||
{
|
||||
if (seed > 1)
|
||||
{
|
||||
Seed = seed;
|
||||
}
|
||||
else
|
||||
{
|
||||
Seed = 1;
|
||||
}
|
||||
|
||||
osRandomSeed(Seed);
|
||||
seed_ = seed;
|
||||
osRandomSeed(seed_, buffer_);
|
||||
}
|
||||
|
||||
|
||||
int Foam::Random::bit()
|
||||
{
|
||||
if (osRandomInteger() > INT_MAX/2)
|
||||
return osRandomInteger(buffer_) & 1;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::Random::sample01()
|
||||
{
|
||||
return scalar01();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::Random::sample01()
|
||||
{
|
||||
return round(scalar01());
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::Random::GaussNormal()
|
||||
{
|
||||
if (hasGaussSample_)
|
||||
{
|
||||
return 1;
|
||||
hasGaussSample_ = false;
|
||||
return gaussSample_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::Random::scalar01()
|
||||
{
|
||||
return osRandomDouble();
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::Random::vector01()
|
||||
{
|
||||
vector rndVec;
|
||||
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
|
||||
{
|
||||
rndVec.component(cmpt) = scalar01();
|
||||
}
|
||||
|
||||
return rndVec;
|
||||
}
|
||||
|
||||
|
||||
Foam::sphericalTensor Foam::Random::sphericalTensor01()
|
||||
{
|
||||
sphericalTensor rndTen;
|
||||
rndTen.ii() = scalar01();
|
||||
|
||||
return rndTen;
|
||||
}
|
||||
|
||||
|
||||
Foam::symmTensor Foam::Random::symmTensor01()
|
||||
{
|
||||
symmTensor rndTen;
|
||||
for (direction cmpt=0; cmpt<symmTensor::nComponents; cmpt++)
|
||||
{
|
||||
rndTen.component(cmpt) = scalar01();
|
||||
}
|
||||
|
||||
return rndTen;
|
||||
}
|
||||
|
||||
|
||||
Foam::tensor Foam::Random::tensor01()
|
||||
{
|
||||
tensor rndTen;
|
||||
for (direction cmpt=0; cmpt<tensor::nComponents; cmpt++)
|
||||
{
|
||||
rndTen.component(cmpt) = scalar01();
|
||||
}
|
||||
|
||||
return rndTen;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::Random::integer(const label lower, const label upper)
|
||||
{
|
||||
return lower + (osRandomInteger() % (upper+1-lower));
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::Random::position(const vector& start, const vector& end)
|
||||
{
|
||||
vector rndVec(start);
|
||||
|
||||
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
|
||||
{
|
||||
rndVec.component(cmpt) +=
|
||||
scalar01()*(end.component(cmpt) - start.component(cmpt));
|
||||
}
|
||||
|
||||
return rndVec;
|
||||
}
|
||||
|
||||
|
||||
void Foam::Random::randomise(scalar& s)
|
||||
{
|
||||
s = scalar01();
|
||||
}
|
||||
|
||||
|
||||
void Foam::Random::randomise(vector& v)
|
||||
{
|
||||
v = vector01();
|
||||
}
|
||||
|
||||
|
||||
void Foam::Random::randomise(sphericalTensor& st)
|
||||
{
|
||||
st = sphericalTensor01();
|
||||
}
|
||||
|
||||
|
||||
void Foam::Random::randomise(symmTensor& st)
|
||||
{
|
||||
st = symmTensor01();
|
||||
}
|
||||
|
||||
|
||||
void Foam::Random::randomise(tensor& t)
|
||||
{
|
||||
t = tensor01();
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::Random::GaussNormal()
|
||||
{
|
||||
static int iset = 0;
|
||||
static scalar gset;
|
||||
scalar fac, rsq, v1, v2;
|
||||
|
||||
if (iset == 0)
|
||||
{
|
||||
scalar rsq, v1, v2;
|
||||
do
|
||||
{
|
||||
v1 = 2.0*scalar01() - 1.0;
|
||||
v2 = 2.0*scalar01() - 1.0;
|
||||
v1 = 2*scalar01() - 1;
|
||||
v2 = 2*scalar01() - 1;
|
||||
rsq = sqr(v1) + sqr(v2);
|
||||
} while (rsq >= 1.0 || rsq == 0.0);
|
||||
} while (rsq >= 1 || rsq == 0);
|
||||
|
||||
fac = sqrt(-2.0*log(rsq)/rsq);
|
||||
gset = v1*fac;
|
||||
iset = 1;
|
||||
scalar fac = sqrt(-2*log(rsq)/rsq);
|
||||
|
||||
gaussSample_ = v1*fac;
|
||||
hasGaussSample_ = true;
|
||||
|
||||
return v2*fac;
|
||||
}
|
||||
else
|
||||
{
|
||||
iset = 0;
|
||||
}
|
||||
|
||||
return gset;
|
||||
|
||||
template<>
|
||||
Foam::label Foam::Random::GaussNormal()
|
||||
{
|
||||
return round(GaussNormal<scalar>());
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::Random::position
|
||||
(
|
||||
const scalar& start,
|
||||
const scalar& end
|
||||
)
|
||||
{
|
||||
return start + scalar01()*(end - start);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::Random::position(const label& start, const label& end)
|
||||
{
|
||||
return start + round(scalar01()*(end - start));
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::Random::globalSample01()
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = scalar01();
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::Random::globalSample01()
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = scalar01();
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return round(value);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::Random::globalGaussNormal()
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = GaussNormal<scalar>();
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::Random::globalGaussNormal()
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = GaussNormal<scalar>();
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return round(value);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::Random::globalPosition
|
||||
(
|
||||
const scalar& start,
|
||||
const scalar& end
|
||||
)
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = scalar01()*(end - start);
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return start + value;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::Random::globalPosition
|
||||
(
|
||||
const label& start,
|
||||
const label& end
|
||||
)
|
||||
{
|
||||
label value = labelMin;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = round(scalar01()*(end - start));
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return start + value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,24 +25,29 @@ Class
|
||||
Foam::Random
|
||||
|
||||
Description
|
||||
Simple random number generator.
|
||||
Random number generator.
|
||||
|
||||
|
||||
SourceFiles
|
||||
RandomI.H
|
||||
Random.C
|
||||
RandomTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Random_H
|
||||
#define Random_H
|
||||
|
||||
#include "vector.H"
|
||||
#include "tensor.H"
|
||||
#include "List.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class Random;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Random Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -51,60 +56,165 @@ class Random
|
||||
{
|
||||
// Private data
|
||||
|
||||
label Seed;
|
||||
//- Buffer used by re-entrant random number generator
|
||||
List<char> buffer_;
|
||||
|
||||
//- Initial random number seed
|
||||
label seed_;
|
||||
|
||||
//- Indicator, which tells if there is a stored gaussian sample
|
||||
bool hasGaussSample_;
|
||||
|
||||
//- Stored sample value
|
||||
scalar gaussSample_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Returns the current sample
|
||||
scalar scalar01();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given seed
|
||||
Random(const label);
|
||||
//- Construct given seed and sample count
|
||||
Random(const label seed = 123456);
|
||||
|
||||
//- Copy constructor with optional reset of sampleI
|
||||
Random(const Random& r, const bool reset = false);
|
||||
|
||||
|
||||
// Destructor
|
||||
~Random();
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
int bit();
|
||||
// Access
|
||||
|
||||
//- Scalar [0..1] (so including 0,1)
|
||||
scalar scalar01();
|
||||
//- Return const access to the initial random number seed
|
||||
inline label seed() const;
|
||||
|
||||
//- Vector with every component scalar01
|
||||
vector vector01();
|
||||
//- Reset the random number generator seed
|
||||
void reset(const label seed);
|
||||
|
||||
//- sphericalTensor with every component scalar01
|
||||
sphericalTensor sphericalTensor01();
|
||||
|
||||
//- symmTensor with every component scalar01
|
||||
symmTensor symmTensor01();
|
||||
// Evaluation
|
||||
|
||||
//- Tensor with every component scalar01
|
||||
tensor tensor01();
|
||||
// Random numbers
|
||||
|
||||
//- Label [lower..upper]
|
||||
label integer(const label lower, const label upper);
|
||||
//- Return a random bit
|
||||
int bit();
|
||||
|
||||
vector position(const vector&, const vector&);
|
||||
//- Return a sample whose components lie in the range 0-1
|
||||
template<class Type>
|
||||
Type sample01();
|
||||
|
||||
void randomise(scalar&);
|
||||
void randomise(vector&);
|
||||
void randomise(sphericalTensor&);
|
||||
void randomise(symmTensor&);
|
||||
void randomise(tensor&);
|
||||
//- Return a sample whose components are normally distributed
|
||||
// with zero mean and unity variance N(0, 1)
|
||||
template<class Type>
|
||||
Type GaussNormal();
|
||||
|
||||
//- Return a normal Gaussian randon number
|
||||
// with zero mean and unity variance N(0, 1)
|
||||
scalar GaussNormal();
|
||||
//- Return a sample between start and end
|
||||
template<class Type>
|
||||
Type position(const Type& start, const Type& end);
|
||||
|
||||
//- Randomise value in the range 0-1
|
||||
template<class Type>
|
||||
void randomise01(Type& value);
|
||||
|
||||
//- Shuffle the values in the list
|
||||
template<class Type>
|
||||
void shuffle(UList<Type>& values);
|
||||
|
||||
|
||||
// Global random numbers - consistent across all processors
|
||||
|
||||
//- Return a sample whose components lie in the range 0-1
|
||||
template<class Type>
|
||||
Type globalSample01();
|
||||
|
||||
//- Return a sample whose components are normally distributed
|
||||
// with zero mean and unity variance N(0, 1)
|
||||
template<class Type>
|
||||
Type globalGaussNormal();
|
||||
|
||||
//- Return a sample between start and end
|
||||
template<class Type>
|
||||
Type globalPosition(const Type& start, const Type& end);
|
||||
|
||||
//- Randomise value in the range 0-1
|
||||
template<class Type>
|
||||
void globalRandomise01(Type& value);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Template specialisations
|
||||
|
||||
template<>
|
||||
scalar Random::sample01<scalar>();
|
||||
|
||||
template<>
|
||||
label Random::sample01<label>();
|
||||
|
||||
template<>
|
||||
scalar Random::GaussNormal<scalar>();
|
||||
|
||||
template<>
|
||||
label Random::GaussNormal<label>();
|
||||
|
||||
template<>
|
||||
scalar Random::position<scalar>
|
||||
(
|
||||
const scalar& start,
|
||||
const scalar& end
|
||||
);
|
||||
|
||||
template<>
|
||||
label Random::position<label>(const label& start, const label& end);
|
||||
|
||||
template<>
|
||||
scalar Random::globalSample01<scalar>();
|
||||
|
||||
template<>
|
||||
label Random::globalSample01<label>();
|
||||
|
||||
template<>
|
||||
scalar Random::globalGaussNormal<scalar>();
|
||||
|
||||
template<>
|
||||
label Random::globalGaussNormal<label>();
|
||||
|
||||
template<>
|
||||
scalar Random::globalPosition<scalar>
|
||||
(
|
||||
const scalar& start,
|
||||
const scalar& end
|
||||
);
|
||||
|
||||
template<>
|
||||
label Random::globalPosition<label>(const label& start, const label& end);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "RandomI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "RandomTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -23,32 +23,14 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cachedRandom.H"
|
||||
#include "Random.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::label Foam::cachedRandom::seed() const
|
||||
inline Foam::label Foam::Random::seed() const
|
||||
{
|
||||
return seed_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::scalarList& Foam::cachedRandom::samples() const
|
||||
{
|
||||
return samples_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::cachedRandom::sampleI() const
|
||||
{
|
||||
return sampleI_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label& Foam::cachedRandom::sampleI()
|
||||
{
|
||||
return sampleI_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,13 +23,13 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cachedRandom.H"
|
||||
#include "Random.H"
|
||||
#include "Pstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::cachedRandom::sample01()
|
||||
Type Foam::Random::sample01()
|
||||
{
|
||||
Type value;
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
@ -42,7 +42,7 @@ Type Foam::cachedRandom::sample01()
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::cachedRandom::GaussNormal()
|
||||
Type Foam::Random::GaussNormal()
|
||||
{
|
||||
Type value;
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
@ -55,7 +55,7 @@ Type Foam::cachedRandom::GaussNormal()
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::cachedRandom::position(const Type& start, const Type& end)
|
||||
Type Foam::Random::position(const Type& start, const Type& end)
|
||||
{
|
||||
Type value(start);
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
@ -69,14 +69,14 @@ Type Foam::cachedRandom::position(const Type& start, const Type& end)
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::cachedRandom::randomise01(Type& value)
|
||||
void Foam::Random::randomise01(Type& value)
|
||||
{
|
||||
value = sample01<Type>();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::cachedRandom::shuffle(UList<Type>& values)
|
||||
void Foam::Random::shuffle(UList<Type>& values)
|
||||
{
|
||||
const label nSample = values.size();
|
||||
label posI = nSample - 1;
|
||||
@ -93,7 +93,7 @@ void Foam::cachedRandom::shuffle(UList<Type>& values)
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::cachedRandom::globalSample01()
|
||||
Type Foam::Random::globalSample01()
|
||||
{
|
||||
Type value = -GREAT*pTraits<Type>::one;
|
||||
|
||||
@ -109,7 +109,7 @@ Type Foam::cachedRandom::globalSample01()
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::cachedRandom::globalGaussNormal()
|
||||
Type Foam::Random::globalGaussNormal()
|
||||
{
|
||||
Type value = -GREAT*pTraits<Type>::one;
|
||||
|
||||
@ -125,7 +125,7 @@ Type Foam::cachedRandom::globalGaussNormal()
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::cachedRandom::globalPosition(const Type& start, const Type& end)
|
||||
Type Foam::Random::globalPosition(const Type& start, const Type& end)
|
||||
{
|
||||
Type value = -GREAT*pTraits<Type>::one;
|
||||
|
||||
@ -141,7 +141,7 @@ Type Foam::cachedRandom::globalPosition(const Type& start, const Type& end)
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::cachedRandom::globalRandomise01(Type& value)
|
||||
void Foam::Random::globalRandomise01(Type& value)
|
||||
{
|
||||
value = -GREAT*pTraits<Type>::one;
|
||||
|
||||
@ -1,299 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cachedRandom.H"
|
||||
#include "OSspecific.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::cachedRandom::scalar01()
|
||||
{
|
||||
if (sampleI_ < 0)
|
||||
{
|
||||
return osRandomDouble();
|
||||
}
|
||||
|
||||
if (sampleI_ == samples_.size() - 1)
|
||||
{
|
||||
scalar s = samples_[sampleI_];
|
||||
sampleI_ = 0;
|
||||
return s;
|
||||
}
|
||||
else
|
||||
{
|
||||
scalar s = samples_[sampleI_];
|
||||
sampleI_++;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cachedRandom::cachedRandom(const label seed, const label count)
|
||||
:
|
||||
seed_(1),
|
||||
samples_(0),
|
||||
sampleI_(-1),
|
||||
hasGaussSample_(false),
|
||||
gaussSample_(0)
|
||||
{
|
||||
if (seed > 1)
|
||||
{
|
||||
seed_ = seed;
|
||||
}
|
||||
|
||||
// Initialise samples
|
||||
osRandomSeed(seed_);
|
||||
|
||||
// Samples will be cached if count > 0
|
||||
if (count > 0)
|
||||
{
|
||||
samples_.setSize(count);
|
||||
forAll(samples_, i)
|
||||
{
|
||||
samples_[i] = osRandomDouble();
|
||||
}
|
||||
|
||||
sampleI_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::cachedRandom::cachedRandom(const cachedRandom& cr, const bool reset)
|
||||
:
|
||||
seed_(cr.seed_),
|
||||
samples_(cr.samples_),
|
||||
sampleI_(cr.sampleI_),
|
||||
hasGaussSample_(cr.hasGaussSample_),
|
||||
gaussSample_(cr.gaussSample_)
|
||||
{
|
||||
//if (sampleI_ == -1)
|
||||
//{
|
||||
// WarningInFunction
|
||||
// << "Copy constructor called, but samples not being cached. "
|
||||
// << "This may lead to non-repeatable behaviour" << endl;
|
||||
//
|
||||
//}
|
||||
|
||||
if (reset)
|
||||
{
|
||||
hasGaussSample_ = false;
|
||||
gaussSample_ = 0;
|
||||
|
||||
if (samples_.size())
|
||||
{
|
||||
sampleI_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Re-initialise the samples
|
||||
osRandomSeed(seed_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cachedRandom::~cachedRandom()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::cachedRandom::sample01()
|
||||
{
|
||||
return scalar01();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::cachedRandom::sample01()
|
||||
{
|
||||
return round(scalar01());
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::cachedRandom::GaussNormal()
|
||||
{
|
||||
if (hasGaussSample_)
|
||||
{
|
||||
hasGaussSample_ = false;
|
||||
return gaussSample_;
|
||||
}
|
||||
else
|
||||
{
|
||||
scalar rsq, v1, v2;
|
||||
do
|
||||
{
|
||||
v1 = 2*scalar01() - 1;
|
||||
v2 = 2*scalar01() - 1;
|
||||
rsq = sqr(v1) + sqr(v2);
|
||||
} while (rsq >= 1 || rsq == 0);
|
||||
|
||||
scalar fac = sqrt(-2*log(rsq)/rsq);
|
||||
|
||||
gaussSample_ = v1*fac;
|
||||
hasGaussSample_ = true;
|
||||
|
||||
return v2*fac;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::cachedRandom::GaussNormal()
|
||||
{
|
||||
return round(GaussNormal<scalar>());
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::cachedRandom::position
|
||||
(
|
||||
const scalar& start,
|
||||
const scalar& end
|
||||
)
|
||||
{
|
||||
return start + scalar01()*(end - start);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::cachedRandom::position(const label& start, const label& end)
|
||||
{
|
||||
return start + round(scalar01()*(end - start));
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::cachedRandom::globalSample01()
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = scalar01();
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::cachedRandom::globalSample01()
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = scalar01();
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return round(value);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::cachedRandom::globalGaussNormal()
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = GaussNormal<scalar>();
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::cachedRandom::globalGaussNormal()
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = GaussNormal<scalar>();
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return round(value);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::cachedRandom::globalPosition
|
||||
(
|
||||
const scalar& start,
|
||||
const scalar& end
|
||||
)
|
||||
{
|
||||
scalar value = -GREAT;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = scalar01()*(end - start);
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return start + value;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::label Foam::cachedRandom::globalPosition
|
||||
(
|
||||
const label& start,
|
||||
const label& end
|
||||
)
|
||||
{
|
||||
label value = labelMin;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
value = round(scalar01()*(end - start));
|
||||
}
|
||||
|
||||
Pstream::scatter(value);
|
||||
|
||||
return start + value;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,238 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::cachedRandom
|
||||
|
||||
Description
|
||||
Random number generator.
|
||||
|
||||
Pre-computes and caches samples on construction, so that when sample01()
|
||||
is called, the function simply returns the next (pre-computed) sample. On
|
||||
reaching the last sample, the sample sequence is repeated.
|
||||
|
||||
Constructed using a seed and sample count. If the supplied count is
|
||||
negative, no caching is performed, and a new sample is generated on each
|
||||
call to sample01().
|
||||
|
||||
Note: the copy constructor cannot be used if count = -1.
|
||||
|
||||
SourceFiles
|
||||
cachedRandomI.H
|
||||
cachedRandom.C
|
||||
cachedRandomTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cachedRandom_H
|
||||
#define cachedRandom_H
|
||||
|
||||
#include "scalarList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class cachedRandom;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cachedRandom Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cachedRandom
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Initial random number seed
|
||||
label seed_;
|
||||
|
||||
//- List of scalar samples
|
||||
scalarList samples_;
|
||||
|
||||
//- Current sample marker
|
||||
label sampleI_;
|
||||
|
||||
//- Indicator, which tells if there is a stored gaussian sample
|
||||
bool hasGaussSample_;
|
||||
|
||||
//- Stored sample value
|
||||
scalar gaussSample_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Returns the current sample
|
||||
scalar scalar01();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given seed and sample count
|
||||
cachedRandom(const label seed, const label count);
|
||||
|
||||
//- Copy constructor with optional reset of sampleI
|
||||
cachedRandom(const cachedRandom& cr, const bool reset = false);
|
||||
|
||||
|
||||
// Destructor
|
||||
~cachedRandom();
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return const access to the initial random number seed
|
||||
inline label seed() const;
|
||||
|
||||
//- Return const access to the list of samples
|
||||
inline const scalarList& samples() const;
|
||||
|
||||
//- Return the current sample marker
|
||||
inline label sampleI() const;
|
||||
|
||||
|
||||
// Manipulation
|
||||
|
||||
//- Return non-const access to the sample marker
|
||||
inline label& sampleI();
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
// Random numbers
|
||||
|
||||
//- Return a sample whose components lie in the range 0-1
|
||||
template<class Type>
|
||||
Type sample01();
|
||||
|
||||
//- Return a sample whose components are normally distributed
|
||||
// with zero mean and unity variance N(0, 1)
|
||||
template<class Type>
|
||||
Type GaussNormal();
|
||||
|
||||
//- Return a sample between start and end
|
||||
template<class Type>
|
||||
Type position(const Type& start, const Type& end);
|
||||
|
||||
//- Randomise value in the range 0-1
|
||||
template<class Type>
|
||||
void randomise01(Type& value);
|
||||
|
||||
//- Shuffle the values in the list
|
||||
template<class Type>
|
||||
void shuffle(UList<Type>& values);
|
||||
|
||||
|
||||
// Global random numbers - consistent across all processors
|
||||
|
||||
//- Return a sample whose components lie in the range 0-1
|
||||
template<class Type>
|
||||
Type globalSample01();
|
||||
|
||||
//- Return a sample whose components are normally distributed
|
||||
// with zero mean and unity variance N(0, 1)
|
||||
template<class Type>
|
||||
Type globalGaussNormal();
|
||||
|
||||
//- Return a sample between start and end
|
||||
template<class Type>
|
||||
Type globalPosition(const Type& start, const Type& end);
|
||||
|
||||
//- Randomise value in the range 0-1
|
||||
template<class Type>
|
||||
void globalRandomise01(Type& value);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Template specialisations
|
||||
|
||||
template<>
|
||||
scalar cachedRandom::sample01<scalar>();
|
||||
|
||||
template<>
|
||||
label cachedRandom::sample01<label>();
|
||||
|
||||
template<>
|
||||
scalar cachedRandom::GaussNormal<scalar>();
|
||||
|
||||
template<>
|
||||
label cachedRandom::GaussNormal<label>();
|
||||
|
||||
template<>
|
||||
scalar cachedRandom::position<scalar>
|
||||
(
|
||||
const scalar& start,
|
||||
const scalar& end
|
||||
);
|
||||
|
||||
template<>
|
||||
label cachedRandom::position<label>(const label& start, const label& end);
|
||||
|
||||
template<>
|
||||
scalar cachedRandom::globalSample01<scalar>();
|
||||
|
||||
template<>
|
||||
label cachedRandom::globalSample01<label>();
|
||||
|
||||
template<>
|
||||
scalar cachedRandom::globalGaussNormal<scalar>();
|
||||
|
||||
template<>
|
||||
label cachedRandom::globalGaussNormal<label>();
|
||||
|
||||
template<>
|
||||
scalar cachedRandom::globalPosition<scalar>
|
||||
(
|
||||
const scalar& start,
|
||||
const scalar& end
|
||||
);
|
||||
|
||||
template<>
|
||||
label cachedRandom::globalPosition<label>(const label& start, const label& end);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "cachedRandomI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "cachedRandomTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -129,7 +129,7 @@ Foam::eddy::eddy
|
||||
const scalar x,
|
||||
const scalar sigmaX,
|
||||
const symmTensor& R,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
patchFaceI_(patchFaceI),
|
||||
|
||||
@ -41,7 +41,7 @@ SourceFiles
|
||||
#include "vector.H"
|
||||
#include "point.H"
|
||||
#include "tensor.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "Random.H"
|
||||
#include "coordinateSystem.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -112,7 +112,7 @@ class eddy
|
||||
) const;
|
||||
|
||||
//- Return a number with zero mean and unit variance
|
||||
inline scalar epsi(cachedRandom& rndGen) const;
|
||||
inline scalar epsi(Random& rndGen) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -133,7 +133,7 @@ public:
|
||||
const scalar x, // distance from reference position
|
||||
const scalar sigmaX, // length scale
|
||||
const symmTensor& R, // Stress tensor
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
);
|
||||
|
||||
//- Construct copy
|
||||
@ -175,7 +175,7 @@ public:
|
||||
inline label dir1() const;
|
||||
|
||||
//- Return random vector of -1 and 1's
|
||||
inline vector epsilon(cachedRandom& rndGen) const;
|
||||
inline vector epsilon(Random& rndGen) const;
|
||||
|
||||
|
||||
// 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
|
||||
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));
|
||||
}
|
||||
|
||||
@ -746,7 +746,7 @@ turbulentDFSEMInletFvPatchVectorField
|
||||
nCellPerEddy_(5),
|
||||
patchNormal_(vector::zero),
|
||||
v0_(0),
|
||||
rndGen_(0, -1),
|
||||
rndGen_(Pstream::myProcNo()),
|
||||
sigmax_(size(), 0),
|
||||
maxSigmaX_(0),
|
||||
nEddy_(0),
|
||||
|
||||
@ -81,7 +81,7 @@ SourceFiles
|
||||
#define turbulentDFSEMInletFvPatchVectorField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "Random.H"
|
||||
#include "eddy.H"
|
||||
#include "pointIndexHit.H"
|
||||
#include "instantList.H"
|
||||
@ -184,7 +184,7 @@ class turbulentDFSEMInletFvPatchVectorField
|
||||
scalar v0_;
|
||||
|
||||
//- Random number generator
|
||||
cachedRandom rndGen_;
|
||||
Random rndGen_;
|
||||
|
||||
//- Length scale per patch face
|
||||
scalarField sigmax_;
|
||||
|
||||
@ -166,7 +166,7 @@ void Foam::turbulentInletFvPatchField<Type>::updateCoeffs()
|
||||
|
||||
forAll(patchField, facei)
|
||||
{
|
||||
ranGen_.randomise(randomField[facei]);
|
||||
ranGen_.randomise01<Type>(randomField[facei]);
|
||||
}
|
||||
|
||||
// Correction-factor to compensate for the loss of RMS fluctuation
|
||||
|
||||
@ -71,7 +71,6 @@ SourceFiles
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "vectorList.H"
|
||||
#include "globalIndex.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "eulerianParticle.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "injectedParticleCloud.H"
|
||||
|
||||
@ -61,7 +61,7 @@ Foam::functionObjects::particleDistribution::particleDistribution
|
||||
cloudName_("unknown-cloudName"),
|
||||
nameVsBinWidth_(),
|
||||
tagFieldName_("none"),
|
||||
rndGen_(1234, -1),
|
||||
rndGen_(),
|
||||
writerPtr_(nullptr)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
@ -73,7 +73,7 @@ SourceFiles
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "scalarField.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "Random.H"
|
||||
#include "Tuple2.H"
|
||||
#include "writer.H"
|
||||
|
||||
@ -107,7 +107,7 @@ protected:
|
||||
word tagFieldName_;
|
||||
|
||||
//- Random number generator - used by distribution models
|
||||
cachedRandom rndGen_;
|
||||
Random rndGen_;
|
||||
|
||||
//- Writer
|
||||
autoPtr<writer<scalar>> writerPtr_;
|
||||
|
||||
@ -47,7 +47,7 @@ bool Foam::functionObjects::randomise::calcRandomised()
|
||||
forAll(field, celli)
|
||||
{
|
||||
Type rndPert;
|
||||
rand.randomise(rndPert);
|
||||
rand.randomise01(rndPert);
|
||||
rndPert = 2.0*rndPert - pTraits<Type>::one;
|
||||
rndPert /= mag(rndPert);
|
||||
rfield[celli] += magPerturbation_*rndPert;
|
||||
|
||||
@ -152,7 +152,7 @@ void Foam::DSMCCloud<ParcelType>::initialise
|
||||
if
|
||||
(
|
||||
(particlesRequired - nParticlesToInsert)
|
||||
> rndGen_.scalar01()
|
||||
> rndGen_.sample01<scalar>()
|
||||
)
|
||||
{
|
||||
nParticlesToInsert++;
|
||||
@ -282,7 +282,7 @@ void Foam::DSMCCloud<ParcelType>::collisions()
|
||||
// subCell candidate selection procedure
|
||||
|
||||
// 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
|
||||
label candidateQ = -1;
|
||||
@ -298,7 +298,8 @@ void Foam::DSMCCloud<ParcelType>::collisions()
|
||||
|
||||
do
|
||||
{
|
||||
candidateQ = subCellPs[rndGen_.integer(0, nSC - 1)];
|
||||
label i = rndGen_.position<label>(0, nSC - 1);
|
||||
candidateQ = subCellPs[i];
|
||||
} while (candidateP == candidateQ);
|
||||
}
|
||||
else
|
||||
@ -309,7 +310,7 @@ void Foam::DSMCCloud<ParcelType>::collisions()
|
||||
|
||||
do
|
||||
{
|
||||
candidateQ = rndGen_.integer(0, nC - 1);
|
||||
candidateQ = rndGen_.position<label>(0, nC - 1);
|
||||
} while (candidateP == candidateQ);
|
||||
}
|
||||
|
||||
@ -317,15 +318,15 @@ void Foam::DSMCCloud<ParcelType>::collisions()
|
||||
// uniform candidate selection procedure
|
||||
|
||||
// // 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
|
||||
// label candidateQ = rndGen_.integer(0, nC-1);
|
||||
// label candidateQ = rndGen_.position<label>(0, nC-1);
|
||||
|
||||
// // If the same candidate is chosen, choose again
|
||||
// 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;
|
||||
}
|
||||
|
||||
if ((sigmaTcR/sigmaTcRMax) > rndGen_.scalar01())
|
||||
if ((sigmaTcR/sigmaTcRMax) > rndGen_.sample01<scalar>())
|
||||
{
|
||||
binaryCollision().collide
|
||||
(
|
||||
@ -648,7 +649,7 @@ Foam::DSMCCloud<ParcelType>::DSMCCloud
|
||||
mesh_
|
||||
),
|
||||
constProps_(),
|
||||
rndGen_(label(149382906) + 7183*Pstream::myProcNo()),
|
||||
rndGen_(Pstream::myProcNo()),
|
||||
boundaryT_
|
||||
(
|
||||
volScalarField
|
||||
@ -711,7 +712,7 @@ Foam::DSMCCloud<ParcelType>::DSMCCloud
|
||||
// and 1.
|
||||
forAll(collisionSelectionRemainder_, i)
|
||||
{
|
||||
collisionSelectionRemainder_[i] = rndGen_.scalar01();
|
||||
collisionSelectionRemainder_[i] = rndGen_.sample01<scalar>();
|
||||
}
|
||||
|
||||
if (readFields)
|
||||
@ -900,7 +901,7 @@ Foam::DSMCCloud<ParcelType>::DSMCCloud
|
||||
)
|
||||
),
|
||||
constProps_(),
|
||||
rndGen_(label(971501) + 1526*Pstream::myProcNo()),
|
||||
rndGen_(Pstream::myProcNo()),
|
||||
boundaryT_
|
||||
(
|
||||
volScalarField
|
||||
@ -1039,12 +1040,7 @@ Foam::vector Foam::DSMCCloud<ParcelType>::equipartitionLinearVelocity
|
||||
{
|
||||
return
|
||||
sqrt(physicoChemical::k.value()*temperature/mass)
|
||||
*vector
|
||||
(
|
||||
rndGen_.GaussNormal(),
|
||||
rndGen_.GaussNormal(),
|
||||
rndGen_.GaussNormal()
|
||||
);
|
||||
*rndGen_.GaussNormal<vector>();
|
||||
}
|
||||
|
||||
|
||||
@ -1064,7 +1060,9 @@ Foam::scalar Foam::DSMCCloud<ParcelType>::equipartitionInternalEnergy
|
||||
else if (iDof < 2.0 + SMALL && iDof > 2.0 - SMALL)
|
||||
{
|
||||
// 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
|
||||
{
|
||||
@ -1074,9 +1072,9 @@ Foam::scalar Foam::DSMCCloud<ParcelType>::equipartitionInternalEnergy
|
||||
|
||||
do
|
||||
{
|
||||
energyRatio = 10*rndGen_.scalar01();
|
||||
energyRatio = 10*rndGen_.sample01<scalar>();
|
||||
P = pow((energyRatio/a), a)*exp(a - energyRatio);
|
||||
} while (P < rndGen_.scalar01());
|
||||
} while (P < rndGen_.sample01<scalar>());
|
||||
|
||||
Ei = energyRatio*physicoChemical::k.value()*temperature;
|
||||
}
|
||||
|
||||
@ -39,14 +39,14 @@ Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::energyRatio
|
||||
{
|
||||
CloudType& cloud(this->owner());
|
||||
|
||||
Random& rndGen(cloud.rndGen());
|
||||
Random& rndGen = cloud.rndGen();
|
||||
|
||||
scalar ChiAMinusOne = ChiA - 1;
|
||||
scalar ChiBMinusOne = ChiB - 1;
|
||||
|
||||
if (ChiAMinusOne < SMALL && ChiBMinusOne < SMALL)
|
||||
{
|
||||
return rndGen.scalar01();
|
||||
return rndGen.sample01<scalar>();
|
||||
}
|
||||
|
||||
scalar energyRatio;
|
||||
@ -56,7 +56,7 @@ Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::energyRatio
|
||||
{
|
||||
P = 0;
|
||||
|
||||
energyRatio = rndGen.scalar01();
|
||||
energyRatio = rndGen.sample01<scalar>();
|
||||
|
||||
if (ChiAMinusOne < SMALL)
|
||||
{
|
||||
@ -81,7 +81,7 @@ Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::energyRatio
|
||||
ChiBMinusOne
|
||||
);
|
||||
}
|
||||
} while (P < rndGen.scalar01());
|
||||
} while (P < rndGen.sample01<scalar>());
|
||||
|
||||
return energyRatio;
|
||||
}
|
||||
@ -186,7 +186,7 @@ void Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::collide
|
||||
scalar& EiP = pP.Ei();
|
||||
scalar& EiQ = pQ.Ei();
|
||||
|
||||
Random& rndGen(cloud.rndGen());
|
||||
Random& rndGen = cloud.rndGen();
|
||||
|
||||
scalar inverseCollisionNumber = 1/relaxationCollisionNumber_;
|
||||
|
||||
@ -217,13 +217,14 @@ void Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::collide
|
||||
|
||||
if (iDofP > 0)
|
||||
{
|
||||
if (inverseCollisionNumber > rndGen.scalar01())
|
||||
if (inverseCollisionNumber > rndGen.sample01<scalar>())
|
||||
{
|
||||
availableEnergy += preCollisionEiP;
|
||||
|
||||
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;
|
||||
}
|
||||
else
|
||||
@ -238,13 +239,13 @@ void Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::collide
|
||||
|
||||
if (iDofQ > 0)
|
||||
{
|
||||
if (inverseCollisionNumber > rndGen.scalar01())
|
||||
if (inverseCollisionNumber > rndGen.sample01<scalar>())
|
||||
{
|
||||
availableEnergy += preCollisionEiQ;
|
||||
|
||||
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;
|
||||
}
|
||||
else
|
||||
@ -261,9 +262,9 @@ void Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::collide
|
||||
scalar cR = sqrt(2.0*availableEnergy/mR);
|
||||
|
||||
// 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 phi = twoPi*rndGen.scalar01();
|
||||
scalar phi = twoPi*rndGen.sample01<scalar>();
|
||||
|
||||
vector postCollisionRelU =
|
||||
cR
|
||||
|
||||
@ -121,7 +121,7 @@ void Foam::VariableHardSphere<CloudType>::collide
|
||||
vector& UP = pP.U();
|
||||
vector& UQ = pQ.U();
|
||||
|
||||
Random& rndGen(cloud.rndGen());
|
||||
Random& rndGen = cloud.rndGen();
|
||||
|
||||
scalar mP = cloud.constProps(typeIdP).mass();
|
||||
|
||||
@ -131,11 +131,11 @@ void Foam::VariableHardSphere<CloudType>::collide
|
||||
|
||||
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 phi = twoPi*rndGen.scalar01();
|
||||
scalar phi = twoPi*rndGen.sample01<scalar>();
|
||||
|
||||
vector postCollisionRelU =
|
||||
cR
|
||||
|
||||
@ -147,7 +147,7 @@ void Foam::FreeStream<CloudType>::inflow()
|
||||
|
||||
const scalar deltaT = mesh.time().deltaTValue();
|
||||
|
||||
Random& rndGen(cloud.rndGen());
|
||||
Random& rndGen = cloud.rndGen();
|
||||
|
||||
scalar sqrtPi = sqrt(pi);
|
||||
|
||||
@ -291,7 +291,7 @@ void Foam::FreeStream<CloudType>::inflow()
|
||||
|
||||
// Add another particle with a probability proportional to the
|
||||
// remainder of taking the integer part of faceAccumulator
|
||||
if ((faceAccumulator - nI) > rndGen.scalar01())
|
||||
if ((faceAccumulator - nI) > rndGen.sample01<scalar>())
|
||||
{
|
||||
nI++;
|
||||
}
|
||||
@ -307,7 +307,7 @@ void Foam::FreeStream<CloudType>::inflow()
|
||||
// Choose a triangle to insert on, based on their relative
|
||||
// area
|
||||
|
||||
scalar triSelection = rndGen.scalar01();
|
||||
scalar triSelection = rndGen.sample01<scalar>();
|
||||
|
||||
// Selected triangle
|
||||
label selectedTriI = -1;
|
||||
@ -371,7 +371,7 @@ void Foam::FreeStream<CloudType>::inflow()
|
||||
do
|
||||
{
|
||||
uNormalThermal =
|
||||
randomScaling*(2.0*rndGen.scalar01() - 1);
|
||||
randomScaling*(2.0*rndGen.sample01<scalar>() - 1);
|
||||
|
||||
uNormal = uNormalThermal + sCosTheta;
|
||||
|
||||
@ -385,13 +385,13 @@ void Foam::FreeStream<CloudType>::inflow()
|
||||
*exp(uNormProbCoeffB - sqr(uNormalThermal));
|
||||
}
|
||||
|
||||
} while (P < rndGen.scalar01());
|
||||
} while (P < rndGen.sample01<scalar>());
|
||||
|
||||
vector U =
|
||||
sqrt(physicoChemical::k.value()*faceTemperature/mass)
|
||||
*(
|
||||
rndGen.GaussNormal()*t1
|
||||
+ rndGen.GaussNormal()*t2
|
||||
rndGen.GaussNormal<scalar>()*t1
|
||||
+ rndGen.GaussNormal<scalar>()*t2
|
||||
)
|
||||
+ (t1 & faceVelocity)*t1
|
||||
+ (t2 & faceVelocity)*t2
|
||||
|
||||
@ -78,19 +78,18 @@ void Foam::MaxwellianThermal<CloudType>::correct
|
||||
|
||||
CloudType& cloud(this->owner());
|
||||
|
||||
Random& rndGen(cloud.rndGen());
|
||||
Random& rndGen = cloud.rndGen();
|
||||
|
||||
while (mag(Ut) < SMALL)
|
||||
{
|
||||
// If the incident velocity is parallel to the face normal, no
|
||||
// tangential direction can be chosen. Add a perturbation to the
|
||||
// incoming velocity and recalculate.
|
||||
|
||||
U = vector
|
||||
(
|
||||
U.x()*(0.8 + 0.2*rndGen.scalar01()),
|
||||
U.y()*(0.8 + 0.2*rndGen.scalar01()),
|
||||
U.z()*(0.8 + 0.2*rndGen.scalar01())
|
||||
U.x()*(0.8 + 0.2*rndGen.sample01<scalar>()),
|
||||
U.y()*(0.8 + 0.2*rndGen.sample01<scalar>()),
|
||||
U.z()*(0.8 + 0.2*rndGen.sample01<scalar>())
|
||||
);
|
||||
|
||||
U_dot_nw = U & nw;
|
||||
@ -113,9 +112,9 @@ void Foam::MaxwellianThermal<CloudType>::correct
|
||||
U =
|
||||
sqrt(physicoChemical::k.value()*T/mass)
|
||||
*(
|
||||
rndGen.GaussNormal()*tw1
|
||||
+ rndGen.GaussNormal()*tw2
|
||||
- sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
|
||||
rndGen.GaussNormal<scalar>()*tw1
|
||||
+ rndGen.GaussNormal<scalar>()*tw2
|
||||
- sqrt(-2.0*log(max(1 - rndGen.sample01<scalar>(), VSMALL)))*nw
|
||||
);
|
||||
|
||||
U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
|
||||
|
||||
@ -73,9 +73,9 @@ void Foam::MixedDiffuseSpecular<CloudType>::correct
|
||||
|
||||
CloudType& cloud(this->owner());
|
||||
|
||||
Random& rndGen(cloud.rndGen());
|
||||
Random& rndGen = cloud.rndGen();
|
||||
|
||||
if (diffuseFraction_ > rndGen.scalar01())
|
||||
if (diffuseFraction_ > rndGen.sample01<scalar>())
|
||||
{
|
||||
// Diffuse reflection
|
||||
|
||||
@ -87,12 +87,11 @@ void Foam::MixedDiffuseSpecular<CloudType>::correct
|
||||
// If the incident velocity is parallel to the face normal, no
|
||||
// tangential direction can be chosen. Add a perturbation to the
|
||||
// incoming velocity and recalculate.
|
||||
|
||||
U = vector
|
||||
(
|
||||
U.x()*(0.8 + 0.2*rndGen.scalar01()),
|
||||
U.y()*(0.8 + 0.2*rndGen.scalar01()),
|
||||
U.z()*(0.8 + 0.2*rndGen.scalar01())
|
||||
U.x()*(0.8 + 0.2*rndGen.sample01<scalar>()),
|
||||
U.y()*(0.8 + 0.2*rndGen.sample01<scalar>()),
|
||||
U.z()*(0.8 + 0.2*rndGen.sample01<scalar>())
|
||||
);
|
||||
|
||||
U_dot_nw = U & nw;
|
||||
@ -115,9 +114,9 @@ void Foam::MixedDiffuseSpecular<CloudType>::correct
|
||||
U =
|
||||
sqrt(physicoChemical::k.value()*T/mass)
|
||||
*(
|
||||
rndGen.GaussNormal()*tw1
|
||||
+ rndGen.GaussNormal()*tw2
|
||||
- sqrt(-2.0*log(max(1 - rndGen.scalar01(), VSMALL)))*nw
|
||||
rndGen.GaussNormal<scalar>()*tw1
|
||||
+ rndGen.GaussNormal<scalar>()*tw2
|
||||
- sqrt(-2.0*log(max(1 - rndGen.sample01<scalar>(), VSMALL)))*nw
|
||||
);
|
||||
|
||||
U += cloud.boundaryU().boundaryField()[wppIndex][wppLocalFace];
|
||||
|
||||
@ -42,7 +42,7 @@ namespace distributionModels
|
||||
Foam::distributionModels::RosinRammler::RosinRammler
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
|
||||
@ -82,7 +82,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
RosinRammler(const dictionary& dict, cachedRandom& rndGen);
|
||||
RosinRammler(const dictionary& dict, Random& rndGen);
|
||||
|
||||
//- Construct copy
|
||||
RosinRammler(const RosinRammler& p);
|
||||
|
||||
@ -78,7 +78,7 @@ void Foam::distributionModels::binned::initialise()
|
||||
Foam::distributionModels::binned::binned
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
@ -102,7 +102,7 @@ Foam::distributionModels::binned::binned
|
||||
(
|
||||
const UList<scalar>& sampleData,
|
||||
const scalar binWidth,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dictionary::null, rndGen),
|
||||
|
||||
@ -96,14 +96,14 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
binned(const dictionary& dict, cachedRandom& rndGen);
|
||||
binned(const dictionary& dict, Random& rndGen);
|
||||
|
||||
//- Construct from components
|
||||
binned
|
||||
(
|
||||
const UList<scalar>& sampleData,
|
||||
const scalar binWidth,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
);
|
||||
|
||||
//- Construct copy
|
||||
|
||||
@ -66,7 +66,7 @@ Foam::distributionModels::distributionModel::distributionModel
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModelDict_(dict),
|
||||
|
||||
@ -55,7 +55,7 @@ SourceFiles
|
||||
|
||||
#include "IOdictionary.H"
|
||||
#include "autoPtr.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "Random.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -79,7 +79,7 @@ protected:
|
||||
const dictionary distributionModelDict_;
|
||||
|
||||
//- Reference to the random number generator
|
||||
cachedRandom& rndGen_;
|
||||
Random& rndGen_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
@ -102,7 +102,7 @@ public:
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
),
|
||||
(dict, rndGen)
|
||||
);
|
||||
@ -115,7 +115,7 @@ public:
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
);
|
||||
|
||||
//- Construct copy
|
||||
@ -129,7 +129,7 @@ public:
|
||||
static autoPtr<distributionModel> New
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ Foam::autoPtr<Foam::distributionModels::distributionModel>
|
||||
Foam::distributionModels::distributionModel::New
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
{
|
||||
const word modelType(dict.lookup("type"));
|
||||
|
||||
@ -42,7 +42,7 @@ namespace distributionModels
|
||||
Foam::distributionModels::exponential::exponential
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
|
||||
@ -75,7 +75,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
exponential(const dictionary& dict, cachedRandom& rndGen);
|
||||
exponential(const dictionary& dict, Random& rndGen);
|
||||
|
||||
//- Construct copy
|
||||
exponential(const exponential& p);
|
||||
|
||||
@ -42,7 +42,7 @@ namespace distributionModels
|
||||
Foam::distributionModels::fixedValue::fixedValue
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
|
||||
@ -66,7 +66,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
fixedValue(const dictionary& dict, cachedRandom& rndGen);
|
||||
fixedValue(const dictionary& dict, Random& rndGen);
|
||||
|
||||
//- Construct copy
|
||||
fixedValue(const fixedValue& p);
|
||||
|
||||
@ -78,7 +78,7 @@ void Foam::distributionModels::general::initialise()
|
||||
Foam::distributionModels::general::general
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
@ -96,7 +96,7 @@ Foam::distributionModels::general::general
|
||||
(
|
||||
const UList<scalar>& sampleData,
|
||||
const scalar binWidth,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dictionary::null, rndGen),
|
||||
|
||||
@ -96,14 +96,14 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
general(const dictionary& dict, cachedRandom& rndGen);
|
||||
general(const dictionary& dict, Random& rndGen);
|
||||
|
||||
//- Construct from components
|
||||
general
|
||||
(
|
||||
const UList<scalar>& sampleData,
|
||||
const scalar binWidth,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
);
|
||||
|
||||
//- Construct copy
|
||||
|
||||
@ -42,7 +42,7 @@ namespace distributionModels
|
||||
Foam::distributionModels::massRosinRammler::massRosinRammler
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
|
||||
@ -93,7 +93,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
massRosinRammler(const dictionary& dict, cachedRandom& rndGen);
|
||||
massRosinRammler(const dictionary& dict, Random& rndGen);
|
||||
|
||||
//- Construct copy
|
||||
massRosinRammler(const massRosinRammler& p);
|
||||
|
||||
@ -42,7 +42,7 @@ namespace distributionModels
|
||||
Foam::distributionModels::multiNormal::multiNormal
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
|
||||
@ -85,7 +85,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
multiNormal(const dictionary& dict, cachedRandom& rndGen);
|
||||
multiNormal(const dictionary& dict, Random& rndGen);
|
||||
|
||||
//- Construct copy
|
||||
multiNormal(const multiNormal& p);
|
||||
|
||||
@ -43,7 +43,7 @@ namespace distributionModels
|
||||
Foam::distributionModels::normal::normal
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
|
||||
@ -85,7 +85,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
normal(const dictionary& dict, cachedRandom& rndGen);
|
||||
normal(const dictionary& dict, Random& rndGen);
|
||||
|
||||
//- Construct copy
|
||||
normal(const normal& p);
|
||||
|
||||
@ -42,7 +42,7 @@ namespace distributionModels
|
||||
Foam::distributionModels::uniform::uniform
|
||||
(
|
||||
const dictionary& dict,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
|
||||
@ -70,7 +70,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
uniform(const dictionary& dict, cachedRandom& rndGen);
|
||||
uniform(const dictionary& dict, Random& rndGen);
|
||||
|
||||
//- Construct copy
|
||||
uniform(const uniform& p);
|
||||
|
||||
@ -316,13 +316,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
|
||||
(
|
||||
particleProperties_.subOrEmptyDict("subModels", solution_.active())
|
||||
),
|
||||
rndGen_
|
||||
(
|
||||
label(0),
|
||||
solution_.steadyState() ?
|
||||
particleProperties_.lookupOrDefault<label>("randomSampleSize", 100000)
|
||||
: -1
|
||||
),
|
||||
rndGen_(Pstream::myProcNo()),
|
||||
cellOccupancyPtr_(),
|
||||
cellLengthScale_(cbrt(mesh_.V())),
|
||||
rho_(rho),
|
||||
@ -515,7 +509,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
|
||||
solution_(mesh),
|
||||
constProps_(),
|
||||
subModelProperties_(dictionary::null),
|
||||
rndGen_(0, 0),
|
||||
rndGen_(),
|
||||
cellOccupancyPtr_(nullptr),
|
||||
cellLengthScale_(c.cellLengthScale_),
|
||||
rho_(c.rho_),
|
||||
|
||||
@ -59,7 +59,7 @@ SourceFiles
|
||||
#include "kinematicCloud.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "autoPtr.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "Random.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "fvMatrices.H"
|
||||
@ -163,7 +163,7 @@ protected:
|
||||
const dictionary subModelProperties_;
|
||||
|
||||
//- Random number generator - used by some injection routines
|
||||
mutable cachedRandom rndGen_;
|
||||
mutable Random rndGen_;
|
||||
|
||||
//- Cell occupancy information for each parcel, (demand driven)
|
||||
autoPtr<List<DynamicList<parcelType*>>> cellOccupancyPtr_;
|
||||
@ -366,7 +366,7 @@ public:
|
||||
// Cloud data
|
||||
|
||||
//- Return reference to the random object
|
||||
inline cachedRandom& rndGen() const;
|
||||
inline Random& rndGen() const;
|
||||
|
||||
//- Return the cell occupancy information for each
|
||||
// parcel, non-const access, the caller is
|
||||
|
||||
@ -356,7 +356,7 @@ inline Foam::scalar Foam::KinematicCloud<CloudType>::Dmax() const
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
inline Foam::cachedRandom& Foam::KinematicCloud<CloudType>::rndGen() const
|
||||
inline Foam::Random& Foam::KinematicCloud<CloudType>::rndGen() const
|
||||
{
|
||||
return rndGen_;
|
||||
}
|
||||
|
||||
@ -171,16 +171,16 @@ void Foam::ParticleCollector<CloudType>::initConcentricCircles()
|
||||
}
|
||||
else
|
||||
{
|
||||
// set 4 quadrants for single sector cases
|
||||
// Set 4 quadrants for single sector cases
|
||||
nS = 4;
|
||||
|
||||
vector tangent = Zero;
|
||||
scalar magTangent = 0.0;
|
||||
|
||||
Random rnd(1234);
|
||||
Random& rnd = this->owner().rndGen();
|
||||
while (magTangent < SMALL)
|
||||
{
|
||||
vector v = rnd.vector01();
|
||||
vector v = rnd.sample01<vector>();
|
||||
|
||||
tangent = v - (v & normal_[0])*normal_[0];
|
||||
magTangent = mag(tangent);
|
||||
|
||||
@ -40,7 +40,7 @@ void Foam::CellZoneInjection<CloudType>::setPositions
|
||||
const fvMesh& mesh = this->owner().mesh();
|
||||
const scalarField& V = mesh.V();
|
||||
const label nCells = cellZoneCells.size();
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
|
||||
DynamicList<vector> positions(nCells); // initial size only
|
||||
DynamicList<label> injectorCells(nCells); // initial size only
|
||||
|
||||
@ -110,7 +110,7 @@ Foam::ConeInjection<CloudType>::ConeInjection
|
||||
vector tangent = Zero;
|
||||
scalar magTangent = 0.0;
|
||||
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
while (magTangent < SMALL)
|
||||
{
|
||||
vector v = rnd.sample01<vector>();
|
||||
@ -260,7 +260,7 @@ void Foam::ConeInjection<CloudType>::setProperties
|
||||
typename CloudType::parcelType& parcel
|
||||
)
|
||||
{
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
|
||||
// Set particle velocity
|
||||
const label i = parcelI % positionAxis_.size();
|
||||
|
||||
@ -175,7 +175,7 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
|
||||
|
||||
setFlowType();
|
||||
|
||||
cachedRandom& rndGen = this->owner().rndGen();
|
||||
Random& rndGen = this->owner().rndGen();
|
||||
|
||||
// Normalise direction vector
|
||||
direction_ /= mag(direction_);
|
||||
@ -321,7 +321,7 @@ void Foam::ConeNozzleInjection<CloudType>::setPositionAndCell
|
||||
label& tetPti
|
||||
)
|
||||
{
|
||||
cachedRandom& rndGen = this->owner().rndGen();
|
||||
Random& rndGen = this->owner().rndGen();
|
||||
|
||||
scalar beta = mathematical::twoPi*rndGen.sample01<scalar>();
|
||||
normal_ = tanVec1_*cos(beta) + tanVec2_*sin(beta);
|
||||
@ -373,7 +373,7 @@ void Foam::ConeNozzleInjection<CloudType>::setProperties
|
||||
typename CloudType::parcelType& parcel
|
||||
)
|
||||
{
|
||||
cachedRandom& rndGen = this->owner().rndGen();
|
||||
Random& rndGen = this->owner().rndGen();
|
||||
|
||||
// Set particle velocity
|
||||
const scalar deg2Rad = mathematical::pi/180.0;
|
||||
|
||||
@ -205,7 +205,7 @@ Foam::label Foam::InflationInjection<CloudType>::parcelsToInject
|
||||
|
||||
newParticles_.clear();
|
||||
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
|
||||
// Diameter factor, when splitting particles into 4, this is the
|
||||
// factor that modifies the diameter.
|
||||
|
||||
@ -148,7 +148,7 @@ void Foam::InjectedParticleDistributionInjection<CloudType>::initialise()
|
||||
scalar minTime = GREAT;
|
||||
|
||||
// Populate injector properties, filtering out invalid entries
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
label injectori = 0;
|
||||
forAll(injDiameter, i)
|
||||
{
|
||||
@ -448,7 +448,7 @@ void Foam::InjectedParticleDistributionInjection<CloudType>::setPositionAndCell
|
||||
label& tetPtI
|
||||
)
|
||||
{
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
currentInjectori_ = rnd.globalPosition<label>(0, position_.size() - 1);
|
||||
currentSamplei_ = rnd.globalPosition<label>(0, resampleSize_ - 1);
|
||||
|
||||
|
||||
@ -182,7 +182,7 @@ void Foam::KinematicLookupTableInjection<CloudType>::setPositionAndCell
|
||||
label injectorI = 0;
|
||||
if (randomise_)
|
||||
{
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
||||
}
|
||||
else
|
||||
|
||||
@ -162,7 +162,7 @@ Foam::label Foam::PatchFlowRateInjection<CloudType>::parcelsToInject
|
||||
|
||||
scalar nParcels = parcelConcentration_*c*flowRate()*dt;
|
||||
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
|
||||
label nParcelsToInject = floor(nParcels);
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ Foam::label Foam::PatchInjection<CloudType>::parcelsToInject
|
||||
if ((time0 >= 0.0) && (time0 < duration_))
|
||||
{
|
||||
scalar nParcels = (time1 - time0)*parcelsPerSecond_;
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
scalar rndPos = rnd.globalPosition(scalar(0), scalar(1));
|
||||
label nParcelsToInject = floor(nParcels);
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
#include "patchInjectionBase.H"
|
||||
#include "polyMesh.H"
|
||||
#include "SubField.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "Random.H"
|
||||
#include "triPointRef.H"
|
||||
#include "volFields.H"
|
||||
#include "polyMeshTetDecomposition.H"
|
||||
@ -151,7 +151,7 @@ void Foam::patchInjectionBase::updateMesh(const polyMesh& mesh)
|
||||
void Foam::patchInjectionBase::setPositionAndCell
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
cachedRandom& rnd,
|
||||
Random& rnd,
|
||||
vector& position,
|
||||
label& cellOwner,
|
||||
label& tetFacei,
|
||||
|
||||
@ -54,7 +54,7 @@ namespace Foam
|
||||
// Forward class declarations
|
||||
class polyMesh;
|
||||
class fvMesh;
|
||||
class cachedRandom;
|
||||
class Random;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class patchInjectionBase Declaration
|
||||
@ -118,7 +118,7 @@ public:
|
||||
virtual void setPositionAndCell
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
cachedRandom& rnd,
|
||||
Random& rnd,
|
||||
vector& position,
|
||||
label& cellOwner,
|
||||
label& tetFacei,
|
||||
|
||||
@ -71,7 +71,7 @@ Foam::scalar Foam::IsotropyModels::Stochastic<CloudType>::sampleGauss()
|
||||
}
|
||||
else
|
||||
{
|
||||
cachedRandom& rndGen = this->owner().rndGen();
|
||||
Random& rndGen = this->owner().rndGen();
|
||||
|
||||
scalar f, m, x, y;
|
||||
|
||||
@ -98,7 +98,7 @@ void Foam::IsotropyModels::Stochastic<CloudType>::calculate()
|
||||
{
|
||||
const fvMesh& mesh = this->owner().mesh();
|
||||
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);
|
||||
|
||||
|
||||
@ -181,7 +181,7 @@ void Foam::ReactingLookupTableInjection<CloudType>::setPositionAndCell
|
||||
label injectorI = 0;
|
||||
if (randomise_)
|
||||
{
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
||||
}
|
||||
else
|
||||
|
||||
@ -187,7 +187,7 @@ void Foam::ReactingMultiphaseLookupTableInjection<CloudType>::setPositionAndCell
|
||||
label injectorI = 0;
|
||||
if (randomise_)
|
||||
{
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
||||
}
|
||||
else
|
||||
|
||||
@ -182,7 +182,7 @@ void Foam::ThermoLookupTableInjection<CloudType>::setPositionAndCell
|
||||
label injectorI = 0;
|
||||
if (randomise_)
|
||||
{
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
injectorI = rnd.position<label>(0, injectorCells_.size() - 1);
|
||||
}
|
||||
else
|
||||
|
||||
@ -101,7 +101,7 @@ protected:
|
||||
typedef typename CloudType::parcelType parcelType;
|
||||
|
||||
//- Reference to the cloud random number generator
|
||||
cachedRandom& rndGen_;
|
||||
Random& rndGen_;
|
||||
|
||||
//- Reference to the cloud thermo package
|
||||
const SLGThermo& thermo_;
|
||||
|
||||
@ -1041,11 +1041,11 @@ void Foam::moleculeCloud::createMolecule
|
||||
{
|
||||
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
|
||||
(
|
||||
|
||||
@ -301,12 +301,9 @@ inline Foam::vector Foam::moleculeCloud::equipartitionLinearVelocity
|
||||
scalar mass
|
||||
)
|
||||
{
|
||||
return sqrt(physicoChemical::k.value()*temperature/mass)*vector
|
||||
(
|
||||
rndGen_.GaussNormal(),
|
||||
rndGen_.GaussNormal(),
|
||||
rndGen_.GaussNormal()
|
||||
);
|
||||
return
|
||||
sqrt(physicoChemical::k.value()*temperature/mass)
|
||||
*rndGen_.GaussNormal<vector>();
|
||||
}
|
||||
|
||||
|
||||
@ -323,17 +320,17 @@ inline Foam::vector Foam::moleculeCloud::equipartitionAngularMomentum
|
||||
return sqrtKbT*vector
|
||||
(
|
||||
0.0,
|
||||
sqrt(cP.momentOfInertia().yy())*rndGen_.GaussNormal(),
|
||||
sqrt(cP.momentOfInertia().zz())*rndGen_.GaussNormal()
|
||||
sqrt(cP.momentOfInertia().yy())*rndGen_.GaussNormal<scalar>(),
|
||||
sqrt(cP.momentOfInertia().zz())*rndGen_.GaussNormal<scalar>()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return sqrtKbT*vector
|
||||
(
|
||||
sqrt(cP.momentOfInertia().xx())*rndGen_.GaussNormal(),
|
||||
sqrt(cP.momentOfInertia().yy())*rndGen_.GaussNormal(),
|
||||
sqrt(cP.momentOfInertia().zz())*rndGen_.GaussNormal()
|
||||
sqrt(cP.momentOfInertia().xx())*rndGen_.GaussNormal<scalar>(),
|
||||
sqrt(cP.momentOfInertia().yy())*rndGen_.GaussNormal<scalar>(),
|
||||
sqrt(cP.momentOfInertia().zz())*rndGen_.GaussNormal<scalar>()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ public:
|
||||
const vector& injectionPos,
|
||||
const scalar pAmbient,
|
||||
const scalar chi,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
) const = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ void Foam::BlobsSheetAtomization<CloudType>::update
|
||||
const vector& injectionPos,
|
||||
const scalar pAmbient,
|
||||
const scalar chi,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
) const
|
||||
{
|
||||
scalar lBU =
|
||||
|
||||
@ -122,7 +122,7 @@ public:
|
||||
const vector& injectionPos,
|
||||
const scalar pAmbient,
|
||||
const scalar chi,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
@ -118,7 +118,7 @@ void Foam::LISAAtomization<CloudType>::update
|
||||
const vector& injectionPos,
|
||||
const scalar pAmbient,
|
||||
const scalar chi,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
) const
|
||||
{
|
||||
if (volFlowRate < SMALL)
|
||||
|
||||
@ -142,7 +142,7 @@ public:
|
||||
const vector& injectionPos,
|
||||
const scalar pAmbient,
|
||||
const scalar chi,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ void Foam::NoAtomization<CloudType>::update
|
||||
const vector& injectionPos,
|
||||
const scalar pAmbient,
|
||||
const scalar chi,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
) const
|
||||
{}
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ public:
|
||||
const vector& injectionPos,
|
||||
const scalar pAmbient,
|
||||
const scalar chi,
|
||||
cachedRandom& rndGen
|
||||
Random& rndGen
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
@ -138,7 +138,7 @@ bool Foam::SHF<CloudType>::update
|
||||
scalar& massChild
|
||||
)
|
||||
{
|
||||
cachedRandom& rndGen = this->owner().rndGen();
|
||||
Random& rndGen = this->owner().rndGen();
|
||||
|
||||
bool addChild = false;
|
||||
|
||||
|
||||
@ -110,7 +110,7 @@ bool Foam::TAB<CloudType>::update
|
||||
scalar& massChild
|
||||
)
|
||||
{
|
||||
cachedRandom& rndGen = this->owner().rndGen();
|
||||
Random& rndGen = this->owner().rndGen();
|
||||
|
||||
scalar r = 0.5*d;
|
||||
scalar r2 = r*r;
|
||||
|
||||
@ -100,7 +100,7 @@ Foam::vector Foam::GradientDispersionRAS<CloudType>::update
|
||||
scalar& tTurb
|
||||
)
|
||||
{
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
|
||||
const scalar cps = 0.16432;
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ Foam::vector Foam::StochasticDispersionRAS<CloudType>::update
|
||||
scalar& tTurb
|
||||
)
|
||||
{
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
|
||||
const scalar cps = 0.16432;
|
||||
|
||||
|
||||
@ -206,7 +206,7 @@ Foam::forceSuSp Foam::BrownianMotionForce<CloudType>::calcCoupled
|
||||
|
||||
// To generate a spherical distribution:
|
||||
|
||||
cachedRandom& rnd = this->owner().rndGen();
|
||||
Random& rnd = this->owner().rndGen();
|
||||
|
||||
const scalar theta = rnd.sample01<scalar>()*twoPi;
|
||||
const scalar u = 2*rnd.sample01<scalar>() - 1;
|
||||
|
||||
@ -46,7 +46,7 @@ SourceFiles
|
||||
#define BrownianMotionForce_H
|
||||
|
||||
#include "ParticleForce.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "Random.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -65,7 +65,7 @@ class BrownianMotionForce
|
||||
// Private data
|
||||
|
||||
//- Reference to the cloud random number generator
|
||||
cachedRandom& rndGen_;
|
||||
Random& rndGen_;
|
||||
|
||||
//- Molecular free path length [m]
|
||||
const scalar lambda_;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user