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),
|
||||
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;
|
||||
|
||||
scalar maxDensity = 1/pow3(max(minCellSize_, SMALL));
|
||||
|
||||
while (volumeAdded < totalVolume_)
|
||||
{
|
||||
trialPoints++;
|
||||
@ -91,10 +97,19 @@ std::vector<Vb::Point> densityWeightedStochastic::initialPoints() const
|
||||
|
||||
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));
|
||||
|
||||
// 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
|
||||
if
|
||||
@ -116,7 +131,8 @@ std::vector<Vb::Point> densityWeightedStochastic::initialPoints() const
|
||||
Info<< nl << " " << typeName << " - "
|
||||
<< trialPoints << " locations queried ("
|
||||
<< scalar(initialPoints.size())/scalar(trialPoints)
|
||||
<< " success rate)" << endl;
|
||||
<< " success rate). minCellSize " << minCellSize_
|
||||
<< endl;
|
||||
|
||||
return initialPoints;
|
||||
}
|
||||
|
||||
@ -25,6 +25,8 @@ Class
|
||||
Foam::densityWeightedStochastic
|
||||
|
||||
Description
|
||||
Choose random points inside the domain and place them with a probability
|
||||
proportional to the target density of points.
|
||||
|
||||
SourceFiles
|
||||
densityWeightedStochastic.C
|
||||
@ -44,7 +46,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class densityWeightedStochastic Declaration
|
||||
Class densityWeightedStochastic Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class densityWeightedStochastic
|
||||
@ -59,9 +61,13 @@ private:
|
||||
//- The total volume to be filled
|
||||
scalar totalVolume_;
|
||||
|
||||
//- 1/(minimum cell size)^3, gives the maximum permissible point
|
||||
// density
|
||||
scalar maxDensity_;
|
||||
//- Working variable for minimum cell size, a starting value may be
|
||||
// specified in the dictionary
|
||||
mutable scalar minCellSize_;
|
||||
|
||||
//- Smallest minimum cell size allowed, i.e. to avoid high initial
|
||||
// population of areas of small size
|
||||
scalar minCellSizeLimit_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user