From e4e4d85286b454eddb31a38a1b7eb41af6594421 Mon Sep 17 00:00:00 2001 From: graham Date: Tue, 28 Sep 2010 13:34:47 +0100 Subject: [PATCH] ENH: Stored size and alignment rebuilds at specified interval. --- .../conformalVoronoiMesh.C | 41 ++++++++++++++----- .../conformalVoronoiMesh.H | 13 +++--- .../conformalVoronoiMeshConformToSurface.C | 2 +- .../cvControls/cvControls.C | 6 +++ .../cvControls/cvControls.H | 6 +++ .../cvControls/cvControlsI.H | 6 +++ 6 files changed, 57 insertions(+), 17 deletions(-) diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 2066b09d0f..1357d8a9a6 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -68,11 +68,11 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh startOfSurfacePointPairs_(0), featureVertices_(), featurePointLocations_(), - featurePointTree_(), + featurePointTreePtr_(), sizeAndAlignmentLocations_(), storedSizes_(), storedAlignments_(), - sizeAndAlignmentTree_(), + sizeAndAlignmentTreePtr_(), surfaceConformationVertices_(), initialPointsMethod_ ( @@ -800,7 +800,7 @@ void Foam::conformalVoronoiMesh::reinsertFeaturePoints() const Foam::indexedOctree& Foam::conformalVoronoiMesh::featurePointTree() const { - if (featurePointTree_.empty()) + if (featurePointTreePtr_.empty()) { Random rndGen(92561); @@ -812,7 +812,7 @@ Foam::conformalVoronoiMesh::featurePointTree() const overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - featurePointTree_.reset + featurePointTreePtr_.reset ( new indexedOctree ( @@ -825,7 +825,7 @@ Foam::conformalVoronoiMesh::featurePointTree() const ); } - return featurePointTree_(); + return featurePointTreePtr_(); } @@ -862,14 +862,14 @@ void Foam::conformalVoronoiMesh::insertInitialPoints() void Foam::conformalVoronoiMesh::storeSizesAndAlignments ( - const std::vector& initPts + const std::vector& storePts ) { 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()); @@ -877,7 +877,7 @@ void Foam::conformalVoronoiMesh::storeSizesAndAlignments forAll(sizeAndAlignmentLocations_, i) { - sizeAndAlignmentLocations_[i] = topoint(initPts[i]); + sizeAndAlignmentLocations_[i] = topoint(storePts[i]); storedSizes_[i] = cellSizeControl().cellSize ( @@ -896,17 +896,34 @@ void Foam::conformalVoronoiMesh::storeSizesAndAlignments } +void Foam::conformalVoronoiMesh::updateSizesAndAlignments +( + const std::vector& storePts +) +{ + if + ( + runTime_.timeIndex() + % cvMeshControls().sizeAndAlignmentRebuildFrequency() == 0 + ) + { + storeSizesAndAlignments(storePts); + } +} + + const Foam::indexedOctree& Foam::conformalVoronoiMesh::sizeAndAlignmentTree() const { - if (sizeAndAlignmentTree_.empty()) + if (sizeAndAlignmentTreePtr_.empty()) { buildSizeAndAlignmentTree(); } - return sizeAndAlignmentTree_(); + return sizeAndAlignmentTreePtr_(); } + void Foam::conformalVoronoiMesh::setVertexSizeAndAlignment() { Info<< nl << "Looking up target cell alignment and size" << endl; @@ -1515,6 +1532,8 @@ void Foam::conformalVoronoiMesh::move() conformToSurface(); + updateSizesAndAlignments(pointsToInsert); + timeCheck(); Info<< nl diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index dbbbca2f1d..873fd10267 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -134,11 +134,11 @@ private: List featureVertices_; //- 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_; //- Search tree for feature point locations - mutable autoPtr > featurePointTree_; + mutable autoPtr > featurePointTreePtr_; //- Store locations where the cell size and alignments will be // pre-calculated and looked up @@ -151,7 +151,7 @@ private: tensorField storedAlignments_; //- Search tree for size and alignment lookup points - mutable autoPtr > sizeAndAlignmentTree_; + mutable autoPtr > sizeAndAlignmentTreePtr_; //- Store the surface and feature edge conformation locations to be // reinserted @@ -341,8 +341,11 @@ private: void insertInitialPoints(); //- Store data for sizeAndAlignmentLocations_, storedSizes_ and - // storedAlignments_ and initialise the sizeAndAlignmentTree_ - void storeSizesAndAlignments(const std::vector& initPts); + // storedAlignments_ and initialise the sizeAndAlignmentTreePtr_ + void storeSizesAndAlignments(const std::vector& storePts); + + //- Restore the sizes and alignments if required + void updateSizesAndAlignments(const std::vector& storePts); //- Demand driven construction of octree for and alignment points const indexedOctree& sizeAndAlignmentTree() const; diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index 1673fdbf9b..98fdc3d251 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -668,7 +668,7 @@ void Foam::conformalVoronoiMesh::buildSizeAndAlignmentTree() const overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - sizeAndAlignmentTree_.reset + sizeAndAlignmentTreePtr_.reset ( new indexedOctree ( diff --git a/src/mesh/conformalVoronoiMesh/cvControls/cvControls.C b/src/mesh/conformalVoronoiMesh/cvControls/cvControls.C index 2b1c8ea8e2..ae53f4214a 100644 --- a/src/mesh/conformalVoronoiMesh/cvControls/cvControls.C +++ b/src/mesh/conformalVoronoiMesh/cvControls/cvControls.C @@ -229,6 +229,12 @@ Foam::cvControls::cvControls degToRad(readScalar(motionDict.lookup("alignmentAcceptanceAngle"))) ); + sizeAndAlignmentRebuildFrequency_ = max + ( + 1, + readLabel(motionDict.lookup("sizeAndAlignmentRebuildFrequency")) + ); + // Point removal criteria const dictionary& insertionDict diff --git a/src/mesh/conformalVoronoiMesh/cvControls/cvControls.H b/src/mesh/conformalVoronoiMesh/cvControls/cvControls.H index c57445ed3b..1b194fd5ba 100644 --- a/src/mesh/conformalVoronoiMesh/cvControls/cvControls.H +++ b/src/mesh/conformalVoronoiMesh/cvControls/cvControls.H @@ -196,6 +196,9 @@ class cvControls // face will be accepted for rotation scalar cosAlignmentAcceptanceAngle_; + //- Now often to re-store the size and alignment data + label sizeAndAlignmentRebuildFrequency_; + // Point insertion criteria //- Length between Delaunay vertices above which a new Dv should be @@ -365,6 +368,9 @@ public: //- Return the cosAlignmentAcceptanceAngle inline scalar cosAlignmentAcceptanceAngle() const; + //- Return the sizeAndAlignmentRebuildFrequency + inline label sizeAndAlignmentRebuildFrequency() const; + //- Return the insertionDistCoeff inline scalar insertionDistCoeff() const; diff --git a/src/mesh/conformalVoronoiMesh/cvControls/cvControlsI.H b/src/mesh/conformalVoronoiMesh/cvControls/cvControlsI.H index fd7a9bede6..4184e17df3 100644 --- a/src/mesh/conformalVoronoiMesh/cvControls/cvControlsI.H +++ b/src/mesh/conformalVoronoiMesh/cvControls/cvControlsI.H @@ -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 { return insertionDistCoeff_;