mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Random numbers - updated dependent code from change cachedRandom->Random class
This commit is contained in:
@ -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()))
|
||||
|
||||
Reference in New Issue
Block a user