mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Parallelise initial points methods except hierarchicalDensityWeightedStochastic.
Rename hierarchicalDensityWeightedStochastic to autoDensity. Remove densityWeightedStochastic, superceded and difficult to parallelise.
This commit is contained in:
@ -27,8 +27,7 @@ initialPointsMethod/uniformGrid/uniformGrid.C
|
||||
initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C
|
||||
initialPointsMethod/faceCentredCubic/faceCentredCubic.C
|
||||
initialPointsMethod/pointFile/pointFile.C
|
||||
initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.C
|
||||
initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.C
|
||||
initialPointsMethod/autoDensity/autoDensity.C
|
||||
|
||||
relaxationModel/relaxationModel/relaxationModel.C
|
||||
relaxationModel/adaptiveLinear/adaptiveLinear.C
|
||||
|
||||
@ -989,11 +989,11 @@ Foam::backgroundMeshDecomposition::distribute
|
||||
|
||||
if (newCellI == -1)
|
||||
{
|
||||
Pout<< "findCell backgroundMeshDecomposition "
|
||||
<< v << " "
|
||||
<< oldCellI
|
||||
<< newCellI
|
||||
<< " find nearest cellI ";
|
||||
// Pout<< "findCell backgroundMeshDecomposition "
|
||||
// << v << " "
|
||||
// << oldCellI
|
||||
// << newCellI
|
||||
// << " find nearest cellI ";
|
||||
|
||||
newCellI = cellSearch.findNearestCell(v);
|
||||
|
||||
|
||||
@ -1331,12 +1331,13 @@ bool Foam::conformalVoronoiMesh::distributeBackground()
|
||||
|
||||
if (cellI == -1)
|
||||
{
|
||||
Pout<< "findCell conformalVoronoiMesh::distribute findCell "
|
||||
<< vit->type() << " "
|
||||
<< vit->index() << " "
|
||||
<< v << " "
|
||||
<< cellI
|
||||
<< " find nearest cellI ";
|
||||
// Pout<< "findCell conformalVoronoiMesh::distribute "
|
||||
// << "findCell "
|
||||
// << vit->type() << " "
|
||||
// << vit->index() << " "
|
||||
// << v << " "
|
||||
// << cellI
|
||||
// << " find nearest cellI ";
|
||||
|
||||
cellI = cellSearch.findNearestCell(v);
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "hierarchicalDensityWeightedStochastic.H"
|
||||
#include "autoDensity.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -33,17 +33,17 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(hierarchicalDensityWeightedStochastic, 0);
|
||||
defineTypeNameAndDebug(autoDensity, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
initialPointsMethod,
|
||||
hierarchicalDensityWeightedStochastic,
|
||||
autoDensity,
|
||||
dictionary
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::hierarchicalDensityWeightedStochastic::writeOBJ
|
||||
void Foam::autoDensity::writeOBJ
|
||||
(
|
||||
const treeBoundBox& bb,
|
||||
fileName name
|
||||
@ -68,8 +68,23 @@ void Foam::hierarchicalDensityWeightedStochastic::writeOBJ
|
||||
}
|
||||
}
|
||||
|
||||
bool Foam::autoDensity::combinedOverlaps(const treeBoundBox& box) const
|
||||
{
|
||||
const conformationSurfaces& geometry = cvMesh_.geometryToConformTo();
|
||||
|
||||
void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill
|
||||
return geometry.overlaps(box);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::autoDensity::combinedInside(const point& p) const
|
||||
{
|
||||
const conformationSurfaces& geometry = cvMesh_.geometryToConformTo();
|
||||
|
||||
return geometry.inside(p);
|
||||
}
|
||||
|
||||
|
||||
void Foam::autoDensity::recurseAndFill
|
||||
(
|
||||
std::list<Vb::Point>& initialPoints,
|
||||
const treeBoundBox& bb,
|
||||
@ -77,8 +92,6 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill
|
||||
word recursionName
|
||||
) const
|
||||
{
|
||||
const conformationSurfaces& geometry = cvMesh_.geometryToConformTo();
|
||||
|
||||
for (direction i = 0; i < 8; i++)
|
||||
{
|
||||
treeBoundBox subBB = bb.subBbox(i);
|
||||
@ -90,7 +103,7 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill
|
||||
cvMesh_.timeCheck(newName);
|
||||
}
|
||||
|
||||
if (geometry.overlaps(subBB))
|
||||
if (combinedOverlaps(subBB))
|
||||
{
|
||||
if (levelLimit > 0)
|
||||
{
|
||||
@ -127,7 +140,7 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (geometry.inside(subBB.midpoint()))
|
||||
else if (combinedInside(subBB.midpoint()))
|
||||
{
|
||||
// writeOBJ
|
||||
// (
|
||||
@ -163,7 +176,7 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill
|
||||
}
|
||||
|
||||
|
||||
bool Foam::hierarchicalDensityWeightedStochastic::fillBox
|
||||
bool Foam::autoDensity::fillBox
|
||||
(
|
||||
std::list<Vb::Point>& initialPoints,
|
||||
const treeBoundBox& bb,
|
||||
@ -711,7 +724,7 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
hierarchicalDensityWeightedStochastic::hierarchicalDensityWeightedStochastic
|
||||
autoDensity::autoDensity
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const conformalVoronoiMesh& cvMesh
|
||||
@ -737,8 +750,7 @@ hierarchicalDensityWeightedStochastic::hierarchicalDensityWeightedStochastic
|
||||
|
||||
WarningIn
|
||||
(
|
||||
"hierarchicalDensityWeightedStochastic::"
|
||||
"hierarchicalDensityWeightedStochastic"
|
||||
"autoDensity::autoDensity"
|
||||
"("
|
||||
"const dictionary& initialPointsDict,"
|
||||
"const conformalVoronoiMesh& cvMesh"
|
||||
@ -753,15 +765,25 @@ hierarchicalDensityWeightedStochastic::hierarchicalDensityWeightedStochastic
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
std::list<Vb::Point>
|
||||
hierarchicalDensityWeightedStochastic::initialPoints() const
|
||||
std::list<Vb::Point> autoDensity::initialPoints() const
|
||||
{
|
||||
const conformationSurfaces& geometry = cvMesh_.geometryToConformTo();
|
||||
treeBoundBox hierBB;
|
||||
|
||||
treeBoundBox hierBB = geometry.globalBounds().extend
|
||||
(
|
||||
cvMesh_.rndGen(), 1e-6
|
||||
);
|
||||
// Pick up the bounds of this processor, or the whole geometry, depending
|
||||
// on whether this is a parallel run.
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
hierBB = cvMesh_.decomposition().procBounds();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Extend the global box to move it off large plane surfaces
|
||||
hierBB = cvMesh_.geometryToConformTo().globalBounds().extend
|
||||
(
|
||||
cvMesh_.rndGen(),
|
||||
1e-6
|
||||
);
|
||||
}
|
||||
|
||||
std::list<Vb::Point> initialPoints;
|
||||
|
||||
@ -22,19 +22,19 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::hierarchicalDensityWeightedStochastic
|
||||
Foam::autoDensity
|
||||
|
||||
Description
|
||||
Choose random points inside the domain and place them with a probability
|
||||
proportional to the target density of points.
|
||||
|
||||
SourceFiles
|
||||
hierarchicalDensityWeightedStochastic.C
|
||||
autoDensity.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef hierarchicalDensityWeightedStochastic_H
|
||||
#define hierarchicalDensityWeightedStochastic_H
|
||||
#ifndef autoDensity_H
|
||||
#define autoDensity_H
|
||||
|
||||
#include "initialPointsMethod.H"
|
||||
#include "treeBoundBox.H"
|
||||
@ -45,10 +45,10 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class hierarchicalDensityWeightedStochastic Declaration
|
||||
Class autoDensity Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class hierarchicalDensityWeightedStochastic
|
||||
class autoDensity
|
||||
:
|
||||
public initialPointsMethod
|
||||
{
|
||||
@ -82,6 +82,14 @@ private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Check if the given box overlaps the geometry or, in parallel, the
|
||||
// backgroundMeshDecomposition
|
||||
bool combinedOverlaps(const treeBoundBox& box) const;
|
||||
|
||||
//- Check if the given point is inside the geometry and, in parallel,
|
||||
// the backgroundMeshDecomposition
|
||||
bool combinedInside(const point& p) const;
|
||||
|
||||
//- Write boundBox as obj
|
||||
void writeOBJ
|
||||
(
|
||||
@ -112,12 +120,12 @@ private:
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("hierarchicalDensityWeightedStochastic");
|
||||
TypeName("autoDensity");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
hierarchicalDensityWeightedStochastic
|
||||
autoDensity
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const conformalVoronoiMesh& cvMesh
|
||||
@ -125,7 +133,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~hierarchicalDensityWeightedStochastic()
|
||||
virtual ~autoDensity()
|
||||
{}
|
||||
|
||||
|
||||
@ -58,19 +58,30 @@ bodyCentredCubic::bodyCentredCubic
|
||||
|
||||
std::list<Vb::Point> bodyCentredCubic::initialPoints() const
|
||||
{
|
||||
const boundBox& bb = cvMesh_.geometryToConformTo().globalBounds();
|
||||
boundBox bb;
|
||||
|
||||
// Pick up the bounds of this processor, or the whole geometry, depending
|
||||
// on whether this is a parallel run.
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
bb = cvMesh_.decomposition().procBounds();
|
||||
}
|
||||
else
|
||||
{
|
||||
bb = cvMesh_.geometryToConformTo().globalBounds();
|
||||
}
|
||||
|
||||
scalar x0 = bb.min().x();
|
||||
scalar xR = bb.max().x() - x0;
|
||||
label ni = label(xR/initialCellSize_) + 1;
|
||||
label ni = label(xR/initialCellSize_);
|
||||
|
||||
scalar y0 = bb.min().y();
|
||||
scalar yR = bb.max().y() - y0;
|
||||
label nj = label(yR/initialCellSize_) + 1;
|
||||
label nj = label(yR/initialCellSize_);
|
||||
|
||||
scalar z0 = bb.min().z();
|
||||
scalar zR = bb.max().z() - z0;
|
||||
label nk = label(zR/initialCellSize_) + 1;
|
||||
label nk = label(zR/initialCellSize_);
|
||||
|
||||
vector delta(xR/ni, yR/nj, zR/nk);
|
||||
|
||||
@ -82,8 +93,6 @@ std::list<Vb::Point> bodyCentredCubic::initialPoints() const
|
||||
|
||||
std::list<Vb::Point> initialPoints;
|
||||
|
||||
List<bool> isSurfacePoint(2*nk, false);
|
||||
|
||||
for (label i = 0; i < ni; i++)
|
||||
{
|
||||
for (label j = 0; j < nj; j++)
|
||||
@ -114,7 +123,19 @@ std::list<Vb::Point> bodyCentredCubic::initialPoints() const
|
||||
pA.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = pA;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
if (cvMesh_.decomposition().positionOnThisProcessor(pA))
|
||||
{
|
||||
// Add this point in parallel only if this position is
|
||||
// on this processor.
|
||||
points[pI++] = pA;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points[pI++] = pA;
|
||||
}
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
@ -123,14 +144,35 @@ std::list<Vb::Point> bodyCentredCubic::initialPoints() const
|
||||
pB.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = pB;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
if (cvMesh_.decomposition().positionOnThisProcessor(pB))
|
||||
{
|
||||
// Add this point in parallel only if this position is
|
||||
// on this processor.
|
||||
points[pI++] = pB;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points[pI++] = pB;
|
||||
}
|
||||
}
|
||||
|
||||
points.setSize(pI);
|
||||
|
||||
Field<bool> insidePoints = cvMesh_.geometryToConformTo().wellInside
|
||||
(
|
||||
points,
|
||||
minimumSurfaceDistanceCoeffSqr_
|
||||
*sqr(cvMesh_.cellSizeControl().cellSize(points, isSurfacePoint))
|
||||
*sqr
|
||||
(
|
||||
cvMesh_.cellSizeControl().cellSize
|
||||
(
|
||||
points,
|
||||
List<bool>(points.size(), false)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
forAll(insidePoints, i)
|
||||
|
||||
@ -1,147 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
|
||||
\\/ 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 "densityWeightedStochastic.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(densityWeightedStochastic, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
initialPointsMethod,
|
||||
densityWeightedStochastic,
|
||||
dictionary
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
densityWeightedStochastic::densityWeightedStochastic
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const conformalVoronoiMesh& cvMesh
|
||||
)
|
||||
:
|
||||
initialPointsMethod(typeName, initialPointsDict, cvMesh),
|
||||
totalVolume_(readScalar(detailsDict().lookup("totalVolume"))),
|
||||
minCellSize_
|
||||
(
|
||||
detailsDict().lookupOrDefault<scalar>("minCellSize", GREAT)
|
||||
),
|
||||
minCellSizeLimit_
|
||||
(
|
||||
detailsDict().lookupOrDefault<scalar>("minCellSizeLimit", 0.0)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
std::list<Vb::Point> densityWeightedStochastic::initialPoints() const
|
||||
{
|
||||
const boundBox& bb = cvMesh_.geometryToConformTo().globalBounds();
|
||||
|
||||
Random& rndGen = cvMesh_.rndGen();
|
||||
|
||||
std::list<Vb::Point> initialPoints;
|
||||
|
||||
scalar volumeAdded = 0.0;
|
||||
|
||||
const point& min = bb.min();
|
||||
|
||||
vector span = bb.span();
|
||||
|
||||
label trialPoints = 0;
|
||||
|
||||
scalar maxDensity = 1/pow3(max(minCellSize_, SMALL));
|
||||
|
||||
while (volumeAdded < totalVolume_)
|
||||
{
|
||||
trialPoints++;
|
||||
|
||||
point p =
|
||||
min
|
||||
+ vector
|
||||
(
|
||||
span.x()*rndGen.scalar01(),
|
||||
span.y()*rndGen.scalar01(),
|
||||
span.z()*rndGen.scalar01()
|
||||
);
|
||||
|
||||
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())
|
||||
{
|
||||
// Determine if the point is "wellInside" the domain
|
||||
if
|
||||
(
|
||||
cvMesh_.geometryToConformTo().wellInside
|
||||
(
|
||||
p,
|
||||
minimumSurfaceDistanceCoeffSqr_*sqr(localSize)
|
||||
)
|
||||
)
|
||||
{
|
||||
initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z()));
|
||||
|
||||
volumeAdded += 1/localDensity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Info<< nl << " " << typeName << nl
|
||||
<< " " << initialPoints.size() << " points placed" << nl
|
||||
<< " " << trialPoints << " locations queried" << nl
|
||||
<< " " << scalar(initialPoints.size())/scalar(trialPoints)
|
||||
<< " success rate" << nl
|
||||
<< " minCellSize " << minCellSize_
|
||||
<< endl;
|
||||
|
||||
return initialPoints;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,106 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
|
||||
\\/ 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::densityWeightedStochastic
|
||||
|
||||
Description
|
||||
Choose random points inside the domain and place them with a probability
|
||||
proportional to the target density of points.
|
||||
|
||||
SourceFiles
|
||||
densityWeightedStochastic.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef densityWeightedStochastic_H
|
||||
#define densityWeightedStochastic_H
|
||||
|
||||
#include "initialPointsMethod.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class densityWeightedStochastic Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class densityWeightedStochastic
|
||||
:
|
||||
public initialPointsMethod
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- The total volume to be filled
|
||||
scalar totalVolume_;
|
||||
|
||||
//- 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:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("densityWeightedStochastic");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
densityWeightedStochastic
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const conformalVoronoiMesh& cvMesh
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~densityWeightedStochastic()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the initial points for the conformalVoronoiMesh
|
||||
virtual std::list<Vb::Point> initialPoints() const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -58,19 +58,30 @@ faceCentredCubic::faceCentredCubic
|
||||
|
||||
std::list<Vb::Point> faceCentredCubic::initialPoints() const
|
||||
{
|
||||
const boundBox& bb = cvMesh_.geometryToConformTo().globalBounds();
|
||||
boundBox bb;
|
||||
|
||||
// Pick up the bounds of this processor, or the whole geometry, depending
|
||||
// on whether this is a parallel run.
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
bb = cvMesh_.decomposition().procBounds();
|
||||
}
|
||||
else
|
||||
{
|
||||
bb = cvMesh_.geometryToConformTo().globalBounds();
|
||||
}
|
||||
|
||||
scalar x0 = bb.min().x();
|
||||
scalar xR = bb.max().x() - x0;
|
||||
label ni = label(xR/initialCellSize_) + 1;
|
||||
label ni = label(xR/initialCellSize_);
|
||||
|
||||
scalar y0 = bb.min().y();
|
||||
scalar yR = bb.max().y() - y0;
|
||||
label nj = label(yR/initialCellSize_) + 1;
|
||||
label nj = label(yR/initialCellSize_);
|
||||
|
||||
scalar z0 = bb.min().z();
|
||||
scalar zR = bb.max().z() - z0;
|
||||
label nk = label(zR/initialCellSize_) + 1;
|
||||
label nk = label(zR/initialCellSize_);
|
||||
|
||||
vector delta(xR/ni, yR/nj, zR/nk);
|
||||
|
||||
@ -82,8 +93,6 @@ std::list<Vb::Point> faceCentredCubic::initialPoints() const
|
||||
|
||||
std::list<Vb::Point> initialPoints;
|
||||
|
||||
List<bool> isSurfacePoint(4*nk, false);
|
||||
|
||||
for (label i = 0; i < ni; i++)
|
||||
{
|
||||
for (label j = 0; j < nj; j++)
|
||||
@ -112,7 +121,19 @@ std::list<Vb::Point> faceCentredCubic::initialPoints() const
|
||||
p.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = p;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
if (cvMesh_.decomposition().positionOnThisProcessor(p))
|
||||
{
|
||||
// Add this point in parallel only if this position is
|
||||
// on this processor.
|
||||
points[pI++] = p;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points[pI++] = p;
|
||||
}
|
||||
|
||||
p = point
|
||||
(
|
||||
@ -128,7 +149,19 @@ std::list<Vb::Point> faceCentredCubic::initialPoints() const
|
||||
p.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = p;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
if (cvMesh_.decomposition().positionOnThisProcessor(p))
|
||||
{
|
||||
// Add this point in parallel only if this position is
|
||||
// on this processor.
|
||||
points[pI++] = p;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points[pI++] = p;
|
||||
}
|
||||
|
||||
p = point
|
||||
(
|
||||
@ -144,7 +177,19 @@ std::list<Vb::Point> faceCentredCubic::initialPoints() const
|
||||
p.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = p;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
if (cvMesh_.decomposition().positionOnThisProcessor(p))
|
||||
{
|
||||
// Add this point in parallel only if this position is
|
||||
// on this processor.
|
||||
points[pI++] = p;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points[pI++] = p;
|
||||
}
|
||||
|
||||
p = point
|
||||
(
|
||||
@ -160,14 +205,35 @@ std::list<Vb::Point> faceCentredCubic::initialPoints() const
|
||||
p.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = p;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
if (cvMesh_.decomposition().positionOnThisProcessor(p))
|
||||
{
|
||||
// Add this point in parallel only if this position is
|
||||
// on this processor.
|
||||
points[pI++] = p;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points[pI++] = p;
|
||||
}
|
||||
}
|
||||
|
||||
points.setSize(pI);
|
||||
|
||||
Field<bool> insidePoints = cvMesh_.geometryToConformTo().wellInside
|
||||
(
|
||||
points,
|
||||
minimumSurfaceDistanceCoeffSqr_
|
||||
*sqr(cvMesh_.cellSizeControl().cellSize(points, isSurfacePoint))
|
||||
*sqr
|
||||
(
|
||||
cvMesh_.cellSizeControl().cellSize
|
||||
(
|
||||
points,
|
||||
List<bool>(points.size(), false)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
forAll(insidePoints, i)
|
||||
|
||||
@ -146,7 +146,7 @@ std::list<Vb::Point> uniformGrid::initialPoints() const
|
||||
cvMesh_.cellSizeControl().cellSize
|
||||
(
|
||||
points,
|
||||
List<bool>(pI, false)
|
||||
List<bool>(points.size(), false)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user