mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Auto and limited min cell size for densityWeightedStochastic.
This commit is contained in:
@ -51,9 +51,13 @@ densityWeightedStochastic::densityWeightedStochastic
|
|||||||
:
|
:
|
||||||
initialPointsMethod(typeName, initialPointsDict, cvMesh),
|
initialPointsMethod(typeName, initialPointsDict, cvMesh),
|
||||||
totalVolume_(readScalar(detailsDict().lookup("totalVolume"))),
|
totalVolume_(readScalar(detailsDict().lookup("totalVolume"))),
|
||||||
maxDensity_
|
minCellSize_
|
||||||
(
|
(
|
||||||
1.0/pow3(readScalar(detailsDict().lookup("minCellSize")))
|
detailsDict().lookupOrDefault<scalar>("minCellSize", GREAT)
|
||||||
|
),
|
||||||
|
minCellSizeLimit_
|
||||||
|
(
|
||||||
|
detailsDict().lookupOrDefault<scalar>("minCellSizeLimit", 0.0)
|
||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -76,6 +80,8 @@ std::vector<Vb::Point> densityWeightedStochastic::initialPoints() const
|
|||||||
|
|
||||||
label trialPoints = 0;
|
label trialPoints = 0;
|
||||||
|
|
||||||
|
scalar maxDensity = 1/pow3(max(minCellSize_, SMALL));
|
||||||
|
|
||||||
while (volumeAdded < totalVolume_)
|
while (volumeAdded < totalVolume_)
|
||||||
{
|
{
|
||||||
trialPoints++;
|
trialPoints++;
|
||||||
@ -91,10 +97,19 @@ std::vector<Vb::Point> densityWeightedStochastic::initialPoints() const
|
|||||||
|
|
||||||
scalar localSize = cvMesh_.cellSizeControl().cellSize(p);
|
scalar localSize = cvMesh_.cellSizeControl().cellSize(p);
|
||||||
|
|
||||||
|
if (localSize < minCellSize_)
|
||||||
|
{
|
||||||
|
minCellSize_ = max(localSize, minCellSizeLimit_);
|
||||||
|
|
||||||
|
// 1/(minimum cell size)^3, gives the maximum permissible point
|
||||||
|
// density
|
||||||
|
maxDensity = 1/pow3(max(minCellSize_, SMALL));
|
||||||
|
}
|
||||||
|
|
||||||
scalar localDensity = 1/pow3(max(localSize, SMALL));
|
scalar localDensity = 1/pow3(max(localSize, SMALL));
|
||||||
|
|
||||||
// Accept possible placements proportional to the relative local density
|
// Accept possible placements proportional to the relative local density
|
||||||
if (localDensity/maxDensity_ > rndGen.scalar01())
|
if (localDensity/maxDensity > rndGen.scalar01())
|
||||||
{
|
{
|
||||||
// Determine if the point is "wellInside" the domain
|
// Determine if the point is "wellInside" the domain
|
||||||
if
|
if
|
||||||
@ -116,7 +131,8 @@ std::vector<Vb::Point> densityWeightedStochastic::initialPoints() const
|
|||||||
Info<< nl << " " << typeName << " - "
|
Info<< nl << " " << typeName << " - "
|
||||||
<< trialPoints << " locations queried ("
|
<< trialPoints << " locations queried ("
|
||||||
<< scalar(initialPoints.size())/scalar(trialPoints)
|
<< scalar(initialPoints.size())/scalar(trialPoints)
|
||||||
<< " success rate)" << endl;
|
<< " success rate). minCellSize " << minCellSize_
|
||||||
|
<< endl;
|
||||||
|
|
||||||
return initialPoints;
|
return initialPoints;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,8 @@ Class
|
|||||||
Foam::densityWeightedStochastic
|
Foam::densityWeightedStochastic
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
Choose random points inside the domain and place them with a probability
|
||||||
|
proportional to the target density of points.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
densityWeightedStochastic.C
|
densityWeightedStochastic.C
|
||||||
@ -44,7 +46,7 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class densityWeightedStochastic Declaration
|
Class densityWeightedStochastic Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class densityWeightedStochastic
|
class densityWeightedStochastic
|
||||||
@ -59,9 +61,13 @@ private:
|
|||||||
//- The total volume to be filled
|
//- The total volume to be filled
|
||||||
scalar totalVolume_;
|
scalar totalVolume_;
|
||||||
|
|
||||||
//- 1/(minimum cell size)^3, gives the maximum permissible point
|
//- Working variable for minimum cell size, a starting value may be
|
||||||
// density
|
// specified in the dictionary
|
||||||
scalar maxDensity_;
|
mutable scalar minCellSize_;
|
||||||
|
|
||||||
|
//- Smallest minimum cell size allowed, i.e. to avoid high initial
|
||||||
|
// population of areas of small size
|
||||||
|
scalar minCellSizeLimit_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user