ENH: Store and access random number generator in conformalVoronoiMesh.

This commit is contained in:
graham
2010-11-04 16:51:37 +00:00
parent 111a1b4f1d
commit 594e90d2bb
14 changed files with 30 additions and 25 deletions

View File

@ -38,6 +38,7 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh
:
HTriangulation(),
runTime_(runTime),
rndGen_(7864293),
allGeometry_
(
IOobject
@ -828,11 +829,9 @@ Foam::conformalVoronoiMesh::featurePointTree() const
{
if (featurePointTreePtr_.empty())
{
Random rndGen(92561);
treeBoundBox overallBb
(
treeBoundBox(geometryToConformTo_.bounds()).extend(rndGen, 1E-4)
treeBoundBox(geometryToConformTo_.bounds()).extend(rndGen_, 1E-4)
);
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);

View File

@ -110,6 +110,9 @@ private:
//- The time registry of the application
const Time& runTime_;
//- Random number generator
mutable Random rndGen_;
//- All geometry of the meshing process, including surfaces to be
// conformed to and those to be used for refinement
searchableSurfaces allGeometry_;
@ -701,6 +704,9 @@ public:
//- Return the Time object
inline const Time& time() const;
//- Return the random number generator
inline Random& rndGen() const;
//- Return the conformationSurfaces object
inline const conformationSurfaces& geometryToConformTo() const;

View File

@ -122,10 +122,11 @@ void Foam::conformalVoronoiMesh::calcDualMesh
<< "A mesh could not be produced to satisfy the specified "
<< "quality criteria." << nl
<< "The quality and the surface conformation controls "
<< "can be altered and the internalDelaunayVertices read in "
<< "to try again, or more cell size resolution and motion "
<< "iterations can be applied in areas where problems are "
<< "occurring."
<< "can be altered and the " << nl
<< "internalDelaunayVertices read in to try again, or more "
<< "cell size resolution " << nl
<< "and motion iterations can be applied in areas where "
<< "problems are occurring."
<< endl;
}

View File

@ -632,11 +632,9 @@ void Foam::conformalVoronoiMesh::buildEdgeLocationTree
const pointField& existingEdgeLocations
) const
{
Random rndGen(72953);
treeBoundBox overallBb
(
treeBoundBox(geometryToConformTo_.bounds()).extend(rndGen, 1E-4)
treeBoundBox(geometryToConformTo_.bounds()).extend(rndGen_, 1E-4)
);
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
@ -658,11 +656,9 @@ void Foam::conformalVoronoiMesh::buildEdgeLocationTree
void Foam::conformalVoronoiMesh::buildSizeAndAlignmentTree() const
{
Random rndGen(627391);
treeBoundBox overallBb
(
treeBoundBox(geometryToConformTo_.bounds()).extend(rndGen, 1E-4)
treeBoundBox(geometryToConformTo_.bounds()).extend(rndGen_, 1E-4)
);
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);

View File

@ -444,6 +444,12 @@ inline const Foam::Time& Foam::conformalVoronoiMesh::time() const
}
inline Foam::Random& Foam::conformalVoronoiMesh::rndGen() const
{
return rndGen_;
}
inline const Foam::conformationSurfaces&
Foam::conformalVoronoiMesh::geometryToConformTo() const
{

View File

@ -76,7 +76,8 @@ std::vector<Vb::Point> bodyCentredCubic::initialPoints() const
delta *= pow((1.0/2.0),-(1.0/3.0));
Random rndGen(1735621);
Random& rndGen = cvMesh_.rndGen();
scalar pert = randomPerturbationCoeff_*cmptMin(delta);
std::vector<Vb::Point> initialPoints;

View File

@ -36,8 +36,6 @@ SourceFiles
#ifndef bodyCentredCubic_H
#define bodyCentredCubic_H
#include "Switch.H"
#include "Random.H"
#include "initialPointsMethod.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -68,7 +68,7 @@ std::vector<Vb::Point> densityWeightedStochastic::initialPoints() const
{
const boundBox& bb = cvMesh_.geometryToConformTo().bounds();
Random rndGen(5234986);
Random& rndGen = cvMesh_.rndGen();
std::vector<Vb::Point> initialPoints;

View File

@ -36,8 +36,6 @@ SourceFiles
#ifndef densityWeightedStochastic_H
#define densityWeightedStochastic_H
#include "Switch.H"
#include "Random.H"
#include "initialPointsMethod.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -76,7 +76,8 @@ std::vector<Vb::Point> faceCentredCubic::initialPoints() const
delta *= pow((1.0/4.0),-(1.0/3.0));
Random rndGen(1735621);
Random& rndGen = cvMesh_.rndGen();
scalar pert = randomPerturbationCoeff_*cmptMin(delta);
std::vector<Vb::Point> initialPoints;

View File

@ -36,8 +36,6 @@ SourceFiles
#ifndef faceCentredCubic_H
#define faceCentredCubic_H
#include "Switch.H"
#include "Random.H"
#include "initialPointsMethod.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -38,6 +38,8 @@ SourceFiles
#include "point.H"
#include "conformalVoronoiMesh.H"
#include "dictionary.H"
#include "Random.H"
#include "Switch.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"

View File

@ -76,7 +76,8 @@ std::vector<Vb::Point> uniformGrid::initialPoints() const
delta *= pow((1.0),-(1.0/3.0));
Random rndGen(1735621);
Random& rndGen = cvMesh_.rndGen();
scalar pert = randomPerturbationCoeff_*cmptMin(delta);
std::vector<Vb::Point> initialPoints;

View File

@ -36,8 +36,6 @@ SourceFiles
#ifndef uniformGrid_H
#define uniformGrid_H
#include "Switch.H"
#include "Random.H"
#include "initialPointsMethod.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //