diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index e8cedc49c2..958fcf6763 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -240,9 +240,9 @@ void Foam::conformalVoronoiMesh::insertPoints { label preDistributionSize(points.size()); - DynamicList transferPoints(points.size()/2); + DynamicList transferPoints; - DynamicList pointsOnProcessor(points.size()/2); + DynamicList pointsOnProcessor; for ( @@ -277,12 +277,16 @@ void Foam::conformalVoronoiMesh::insertPoints decomposition_().distributePoints(transferPoints) ); + const label oldSize = points.size(); + + points.setSize(oldSize + transferPoints.size()); + forAll(transferPoints, tPI) { - points.append(toPoint(transferPoints[tPI])); + points[tPI + oldSize] = toPoint(transferPoints[tPI]); } - label sizeChange = preDistributionSize - label(points.size()); + label sizeChange = preDistributionSize - points.size(); // if (mag(sizeChange) > 0) // { @@ -417,7 +421,6 @@ void Foam::conformalVoronoiMesh::insertPoints // ); // } - rangeInsertWithInfo ( pts.begin(), @@ -1246,6 +1249,8 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh // better balance the surface conformation load. distributeBackground(); +// conformToSurface(); + buildSurfaceConformation(rmCoarse); // The introduction of the surface conformation may have distorted the @@ -1313,7 +1318,7 @@ void Foam::conformalVoronoiMesh::move() { cit->cellIndex() = dualVertI; - dualVertices[dualVertI] = topoint(dual(cit)); + dualVertices[dualVertI] = cit->dual(); dualVertI++; } @@ -1511,7 +1516,6 @@ void Foam::conformalVoronoiMesh::move() ( toPoint(0.5*(dVA + dVB)) ); - } } else if @@ -1671,9 +1675,57 @@ void Foam::conformalVoronoiMesh::move() insertPoints(pointsToInsert); + // Remove internal points that have been inserted outside the surface. + label internalPtIsOutside = 0; + + for + ( + Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + ++vit + ) + { + if (vit->internalPoint()) + { + bool inside + = geometryToConformTo_.inside(topoint(vit->point())); + + if (!inside) + { + remove(vit); + internalPtIsOutside++; + } + } + } + + Info<< " " << internalPtIsOutside + << " internal points were inserted outside the domain. " + << "They have been removed." << endl; + + // Fix points that have not been significantly displaced +// for +// ( +// Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); +// vit != finite_vertices_end(); +// ++vit +// ) +// { +// if (vit->internalPoint()) +// { +// if +// ( +// mag(displacementAccumulator[vit->index()]) +// < 0.1*targetCellSize(topoint(vit->point())) +// ) +// { +// vit->setVertexFixed(); +// } +// } +// } + if (cvMeshControls().objOutput() && runTime_.outputTime()) { - writePoints("points_" + runTime_.timeName() + ".obj", false); + writePoints("points_" + runTime_.timeName() + ".obj", true); } timeCheck("Internal points inserted"); diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index b590eb31cd..a514c660a1 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -48,7 +48,6 @@ SourceFiles #define CGAL_INEXACT #include "CGALTriangulation3Ddefs.H" -#include #include "uint.H" #include "ulong.H" #include "searchableSurfaces.H" @@ -595,6 +594,12 @@ private: Foam::point& b ) const; + label removeProcessorBoundarySeeds(bool reinsertBoundPts); + + void seedProcessorBoundarySurfaces(bool seedProcessors); + + label numberOfUnusedReferredPoints() const; + //- Build the parallelInterfaces of the mesh void buildParallelInterface ( @@ -1240,7 +1245,7 @@ public: Traits_for_spatial_sort() ); - typename Triangulation::Cell_handle hint; + typename Triangulation::Vertex_handle hint; for ( @@ -1250,16 +1255,9 @@ public: ++p ) { - typename Triangulation::Locate_type lt; - typename Triangulation::Cell_handle c; - label li, lj; - - c = T.locate(*(p->first), lt, li, lj, hint); - const size_t checkInsertion = T.number_of_vertices(); - typename Triangulation::Vertex_handle v - = T.insert(*(p->first), lt, c, li, lj); + hint = T.insert(*(p->first), hint); if (checkInsertion != T.number_of_vertices() - 1) { @@ -1278,12 +1276,11 @@ public: // type directly (note that this routine never gets // called for referredPoints so type will never be // -procI - type += T.number_of_vertices() - 1; + type += checkInsertion; } - v->index() = indices[oldIndex] - + T.number_of_vertices() - 1; - v->type() = type; + hint->index() = indices[oldIndex] + checkInsertion; + hint->type() = type; } } } diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index 04ef2af045..d103d3c0fc 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -1890,7 +1890,7 @@ void Foam::conformalVoronoiMesh::indexDualVertices { cit->cellIndex() = dualVertI; - pts[dualVertI] = topoint(dual(cit)); + pts[dualVertI] = cit->dual(); if ( diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index 847974a2f4..7f4c7abb6e 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -41,6 +41,11 @@ void Foam::conformalVoronoiMesh::conformToSurface() { reconformationMode reconfMode = reconformationControl(); + if (Pstream::parRun()) + { + seedProcessorBoundarySurfaces(true); + } + if (reconfMode == rmNone) { // Reinsert stored surface conformation @@ -69,6 +74,16 @@ void Foam::conformalVoronoiMesh::conformToSurface() storeSurfaceConformation(); } + if (Pstream::parRun()) + { + label nFarPoints = removeProcessorBoundarySeeds(true); + + reduce(nFarPoints, sumOp