ENH: Stored size and alignment rebuilds at specified interval.

This commit is contained in:
graham
2010-09-28 13:34:47 +01:00
parent a4a593d645
commit e4e4d85286
6 changed files with 57 additions and 17 deletions

View File

@ -68,11 +68,11 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh
startOfSurfacePointPairs_(0), startOfSurfacePointPairs_(0),
featureVertices_(), featureVertices_(),
featurePointLocations_(), featurePointLocations_(),
featurePointTree_(), featurePointTreePtr_(),
sizeAndAlignmentLocations_(), sizeAndAlignmentLocations_(),
storedSizes_(), storedSizes_(),
storedAlignments_(), storedAlignments_(),
sizeAndAlignmentTree_(), sizeAndAlignmentTreePtr_(),
surfaceConformationVertices_(), surfaceConformationVertices_(),
initialPointsMethod_ initialPointsMethod_
( (
@ -800,7 +800,7 @@ void Foam::conformalVoronoiMesh::reinsertFeaturePoints()
const Foam::indexedOctree<Foam::treeDataPoint>& const Foam::indexedOctree<Foam::treeDataPoint>&
Foam::conformalVoronoiMesh::featurePointTree() const Foam::conformalVoronoiMesh::featurePointTree() const
{ {
if (featurePointTree_.empty()) if (featurePointTreePtr_.empty())
{ {
Random rndGen(92561); Random rndGen(92561);
@ -812,7 +812,7 @@ Foam::conformalVoronoiMesh::featurePointTree() const
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
featurePointTree_.reset featurePointTreePtr_.reset
( (
new indexedOctree<treeDataPoint> new indexedOctree<treeDataPoint>
( (
@ -825,7 +825,7 @@ Foam::conformalVoronoiMesh::featurePointTree() const
); );
} }
return featurePointTree_(); return featurePointTreePtr_();
} }
@ -862,14 +862,14 @@ void Foam::conformalVoronoiMesh::insertInitialPoints()
void Foam::conformalVoronoiMesh::storeSizesAndAlignments void Foam::conformalVoronoiMesh::storeSizesAndAlignments
( (
const std::vector<Point>& initPts const std::vector<Point>& storePts
) )
{ {
timeCheck(); timeCheck();
Info << nl << "Initialise stored size and alignment data" << endl; Info << nl << "Store size and alignment" << endl;
sizeAndAlignmentLocations_.setSize(initPts.size()); sizeAndAlignmentLocations_.setSize(storePts.size());
storedSizes_.setSize(sizeAndAlignmentLocations_.size()); storedSizes_.setSize(sizeAndAlignmentLocations_.size());
@ -877,7 +877,7 @@ void Foam::conformalVoronoiMesh::storeSizesAndAlignments
forAll(sizeAndAlignmentLocations_, i) forAll(sizeAndAlignmentLocations_, i)
{ {
sizeAndAlignmentLocations_[i] = topoint(initPts[i]); sizeAndAlignmentLocations_[i] = topoint(storePts[i]);
storedSizes_[i] = cellSizeControl().cellSize storedSizes_[i] = cellSizeControl().cellSize
( (
@ -896,17 +896,34 @@ void Foam::conformalVoronoiMesh::storeSizesAndAlignments
} }
void Foam::conformalVoronoiMesh::updateSizesAndAlignments
(
const std::vector<Point>& storePts
)
{
if
(
runTime_.timeIndex()
% cvMeshControls().sizeAndAlignmentRebuildFrequency() == 0
)
{
storeSizesAndAlignments(storePts);
}
}
const Foam::indexedOctree<Foam::treeDataPoint>& const Foam::indexedOctree<Foam::treeDataPoint>&
Foam::conformalVoronoiMesh::sizeAndAlignmentTree() const Foam::conformalVoronoiMesh::sizeAndAlignmentTree() const
{ {
if (sizeAndAlignmentTree_.empty()) if (sizeAndAlignmentTreePtr_.empty())
{ {
buildSizeAndAlignmentTree(); buildSizeAndAlignmentTree();
} }
return sizeAndAlignmentTree_(); return sizeAndAlignmentTreePtr_();
} }
void Foam::conformalVoronoiMesh::setVertexSizeAndAlignment() void Foam::conformalVoronoiMesh::setVertexSizeAndAlignment()
{ {
Info<< nl << "Looking up target cell alignment and size" << endl; Info<< nl << "Looking up target cell alignment and size" << endl;
@ -1515,6 +1532,8 @@ void Foam::conformalVoronoiMesh::move()
conformToSurface(); conformToSurface();
updateSizesAndAlignments(pointsToInsert);
timeCheck(); timeCheck();
Info<< nl Info<< nl

View File

@ -134,11 +134,11 @@ private:
List<Vb> featureVertices_; List<Vb> featureVertices_;
//- Storing the locations of all of the features to be conformed to. //- Storing the locations of all of the features to be conformed to.
// Single pointField required by the featurePointTree_. // Single pointField required by the featurePointTree.
pointField featurePointLocations_; pointField featurePointLocations_;
//- Search tree for feature point locations //- Search tree for feature point locations
mutable autoPtr<indexedOctree<treeDataPoint> > featurePointTree_; mutable autoPtr<indexedOctree<treeDataPoint> > featurePointTreePtr_;
//- Store locations where the cell size and alignments will be //- Store locations where the cell size and alignments will be
// pre-calculated and looked up // pre-calculated and looked up
@ -151,7 +151,7 @@ private:
tensorField storedAlignments_; tensorField storedAlignments_;
//- Search tree for size and alignment lookup points //- Search tree for size and alignment lookup points
mutable autoPtr<indexedOctree<treeDataPoint> > sizeAndAlignmentTree_; mutable autoPtr<indexedOctree<treeDataPoint> > sizeAndAlignmentTreePtr_;
//- Store the surface and feature edge conformation locations to be //- Store the surface and feature edge conformation locations to be
// reinserted // reinserted
@ -341,8 +341,11 @@ private:
void insertInitialPoints(); void insertInitialPoints();
//- Store data for sizeAndAlignmentLocations_, storedSizes_ and //- Store data for sizeAndAlignmentLocations_, storedSizes_ and
// storedAlignments_ and initialise the sizeAndAlignmentTree_ // storedAlignments_ and initialise the sizeAndAlignmentTreePtr_
void storeSizesAndAlignments(const std::vector<Point>& initPts); void storeSizesAndAlignments(const std::vector<Point>& storePts);
//- Restore the sizes and alignments if required
void updateSizesAndAlignments(const std::vector<Point>& storePts);
//- Demand driven construction of octree for and alignment points //- Demand driven construction of octree for and alignment points
const indexedOctree<treeDataPoint>& sizeAndAlignmentTree() const; const indexedOctree<treeDataPoint>& sizeAndAlignmentTree() const;

View File

@ -668,7 +668,7 @@ void Foam::conformalVoronoiMesh::buildSizeAndAlignmentTree() const
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
sizeAndAlignmentTree_.reset sizeAndAlignmentTreePtr_.reset
( (
new indexedOctree<treeDataPoint> new indexedOctree<treeDataPoint>
( (

View File

@ -229,6 +229,12 @@ Foam::cvControls::cvControls
degToRad(readScalar(motionDict.lookup("alignmentAcceptanceAngle"))) degToRad(readScalar(motionDict.lookup("alignmentAcceptanceAngle")))
); );
sizeAndAlignmentRebuildFrequency_ = max
(
1,
readLabel(motionDict.lookup("sizeAndAlignmentRebuildFrequency"))
);
// Point removal criteria // Point removal criteria
const dictionary& insertionDict const dictionary& insertionDict

View File

@ -196,6 +196,9 @@ class cvControls
// face will be accepted for rotation // face will be accepted for rotation
scalar cosAlignmentAcceptanceAngle_; scalar cosAlignmentAcceptanceAngle_;
//- Now often to re-store the size and alignment data
label sizeAndAlignmentRebuildFrequency_;
// Point insertion criteria // Point insertion criteria
//- Length between Delaunay vertices above which a new Dv should be //- Length between Delaunay vertices above which a new Dv should be
@ -365,6 +368,9 @@ public:
//- Return the cosAlignmentAcceptanceAngle //- Return the cosAlignmentAcceptanceAngle
inline scalar cosAlignmentAcceptanceAngle() const; inline scalar cosAlignmentAcceptanceAngle() const;
//- Return the sizeAndAlignmentRebuildFrequency
inline label sizeAndAlignmentRebuildFrequency() const;
//- Return the insertionDistCoeff //- Return the insertionDistCoeff
inline scalar insertionDistCoeff() const; inline scalar insertionDistCoeff() const;

View File

@ -115,6 +115,12 @@ inline Foam::scalar Foam::cvControls::cosAlignmentAcceptanceAngle() const
} }
inline Foam::label Foam::cvControls::sizeAndAlignmentRebuildFrequency() const
{
return sizeAndAlignmentRebuildFrequency_;
}
inline Foam::scalar Foam::cvControls::insertionDistCoeff() const inline Foam::scalar Foam::cvControls::insertionDistCoeff() const
{ {
return insertionDistCoeff_; return insertionDistCoeff_;