diff --git a/applications/utilities/mesh/generation/cvMesh/cvMesh.C b/applications/utilities/mesh/generation/cvMesh/cvMesh.C index f3a3273e5b..6fad72474c 100644 --- a/applications/utilities/mesh/generation/cvMesh/cvMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/cvMesh.C @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) mesh.move(); - mesh.conformToSurface(); + // mesh.conformToSurface(); } mesh.writeMesh(); diff --git a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index f3084adbd3..f2b04c14eb 100644 --- a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -74,6 +74,7 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh storedSizes_(), storedAlignments_(), sizeAndAlignmentTree_(), + surfaceConformationVertices_(), initialPointsMethod_ ( initialPointsMethod::New @@ -105,6 +106,8 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh conformToSurface(); + storeSurfaceConformation(); + if(cvMeshControls().objOutput()) { writePoints("allInitialPoints.obj", false); @@ -1314,6 +1317,61 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits } +void Foam::conformalVoronoiMesh::storeSurfaceConformation() +{ + Info<< nl << " Storing surface conformation." << endl; + + surfaceConformationVertices_.setSize + ( + number_of_vertices() - startOfSurfacePointPairs_ + ); + + label surfPtI = 0; + + for + ( + Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + vit++ + ) + { + if (vit->index() >= startOfSurfacePointPairs_) + { + if (!vit->pairPoint()) + { + FatalErrorIn("storeSurfaceConformation()") + << "Trying to store a vertex that is not a surface point" + << exit(FatalError); + } + + surfaceConformationVertices_[surfPtI] = Vb(vit->point()); + + surfaceConformationVertices_[surfPtI].index() = + vit->index() - startOfSurfacePointPairs_; + + surfaceConformationVertices_[surfPtI].type() = + vit->type() - startOfSurfacePointPairs_; + + surfPtI++; + } + } + + Info<< " Stored " << surfaceConformationVertices_.size() + << " vertices" << endl; +} + + +void Foam::conformalVoronoiMesh::reinsertSurfaceConformation() +{ + Info<< nl << " Reinserting stored surface conformation" << endl; + + forAll(surfaceConformationVertices_, v) + { + insertVb(surfaceConformationVertices_[v], startOfSurfacePointPairs_); + } +} + + void Foam::conformalVoronoiMesh::calcDualMesh ( pointField& points, @@ -2559,8 +2617,28 @@ void Foam::conformalVoronoiMesh::move() reinsertFeaturePoints(); startOfInternalPoints_ = number_of_vertices(); + timeCheck(); + Info<< nl << " Reinserting entire tessellation" << endl; insertPoints(pointsToInsert); + + timeCheck(); + + if (runTime_.timeIndex() % 10 == 0) + { + Info<< nl << " Rebuilding surface conformation " + << "HARD CODED TO EVERY 10 STEPS" << endl; + + conformToSurface(); + storeSurfaceConformation(); + } + else + { + startOfSurfacePointPairs_ = number_of_vertices(); + reinsertSurfaceConformation(); + } + + timeCheck(); } diff --git a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index 41b5453479..34a12549f4 100644 --- a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -132,6 +132,10 @@ class conformalVoronoiMesh //- Search tree for size and alignment lookup points mutable autoPtr > sizeAndAlignmentTree_; + //- Store the surface and feature edge conformation locations to be + // reinserted + List surfaceConformationVertices_; + //- Method for inserting initial points. Runtime selectable. autoPtr initialPointsMethod_; @@ -200,8 +204,9 @@ class conformalVoronoiMesh const vector& n ); - //- Insert a Vb (a typedef of CGAL::indexedVertex) - inline void insertVb(const Vb& v); + //- Insert a Vb (a typedef of CGAL::indexedVertex) with the + // possibility of an offset for the index and the type + inline void insertVb(const Vb& v, label offset = 0); //- Insert pairs of points on the surface with the given normals, at the // specified spacing @@ -362,6 +367,14 @@ class conformalVoronoiMesh autoPtr >& edgeLocationTree ) const; + //- Store the surface conformation with the indices offset to be + // relative to zero + void storeSurfaceConformation(); + + //- Reinsert the surface conformation re-offsetting indices to be + // relative to new number of internal vertices + void reinsertSurfaceConformation(); + //- Dual calculation void calcDualMesh ( diff --git a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H index 9bcc167ae6..880b0bcfdc 100644 --- a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H +++ b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H @@ -202,7 +202,7 @@ inline void Foam::conformalVoronoiMesh::insertPointPair } -inline void Foam::conformalVoronoiMesh::insertVb(const Vb& v) +inline void Foam::conformalVoronoiMesh::insertVb(const Vb& v, label offset) { const Point& Pt(v.point()); @@ -218,8 +218,16 @@ inline void Foam::conformalVoronoiMesh::insertVb(const Vb& v) } else { - vh->index() = v.index(); - vh->type() = v.type(); + vh->index() = v.index() + offset; + + if (v.pairPoint()) + { + vh->type() = v.type() + offset; + } + else + { + vh->type() = v.type(); + } } }