diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index fb27c2250c..ac75fda7ad 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -34,7 +34,6 @@ License #include "controlMeshRefinement.H" #include "smoothAlignmentSolver.H" - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam @@ -93,317 +92,6 @@ void Foam::conformalVoronoiMesh::cellSizeMeshOverlapsBackground() const } -Foam::scalar Foam::conformalVoronoiMesh::requiredSize -( - const Foam::point& pt -) const -{ - pointIndexHit surfHit; - label hitSurface; - - DynamicList cellSizeHits; - - geometryToConformTo_.findSurfaceNearest - ( - pt, - sqr(GREAT), - surfHit, - hitSurface - ); - - if (!surfHit.hit()) - { - FatalErrorIn - ( - "Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment" - ) - << "findSurfaceNearest did not find a hit across the surfaces." - << exit(FatalError) << endl; - } - - cellSizeHits.append(cellShapeControls().cellSize(pt)); - - // Primary alignment - - vectorField norm(1); - - allGeometry_[hitSurface].getNormal - ( - List(1, surfHit), - norm - ); - - const vector np = norm[0]; - - // Generate equally spaced 'spokes' in a circle normal to the - // direction from the vertex to the closest point on the surface - // and look for a secondary intersection. - - const vector d = surfHit.hitPoint() - pt; - - const tensor Rp = rotationTensor(vector(0,0,1), np); - - const label s = cvMeshControls().alignmentSearchSpokes(); - - const scalar spanMag = geometryToConformTo_.globalBounds().mag(); - - scalar totalDist = 0; - - for (label i = 0; i < s; i++) - { - vector spoke - ( - Foam::cos(i*constant::mathematical::twoPi/s), - Foam::sin(i*constant::mathematical::twoPi/s), - 0 - ); - - spoke *= spanMag; - - spoke = Rp & spoke; - - pointIndexHit spokeHit; - - label spokeSurface = -1; - - // internal spoke - - geometryToConformTo_.findSurfaceNearestIntersection - ( - pt, - pt + spoke, - spokeHit, - spokeSurface - ); - - if (spokeHit.hit()) - { - const Foam::point& hitPt = spokeHit.hitPoint(); - - scalar spokeHitDistance = mag(hitPt - pt); - - cellSizeHits.append - ( - cellShapeControls().cellSize(hitPt) - ); - - totalDist += spokeHitDistance; - } - - //external spoke - - Foam::point mirrorPt = pt + 2*d; - - geometryToConformTo_.findSurfaceNearestIntersection - ( - mirrorPt, - mirrorPt + spoke, - spokeHit, - spokeSurface - ); - - if (spokeHit.hit()) - { - const Foam::point& hitPt = spokeHit.hitPoint(); - - scalar spokeHitDistance = mag(hitPt - mirrorPt); - - cellSizeHits.append - ( - cellShapeControls().cellSize(hitPt) - ); - - totalDist += spokeHitDistance; - } - } - - scalar cellSize = 0; - - forAll(cellSizeHits, hitI) - { - cellSize += cellSizeHits[hitI]; - } - - return cellSize/cellSizeHits.size(); - //return cellShapeControls().cellSize(pt); -} - - -Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment -( - const Foam::point& pt -) const -{ - pointIndexHit surfHit; - label hitSurface; - - geometryToConformTo_.findSurfaceNearest - ( - pt, - sqr(GREAT), - surfHit, - hitSurface - ); - - if (!surfHit.hit()) - { - FatalErrorIn - ( - "Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment" - ) - << "findSurfaceNearest did not find a hit across the surfaces." - << exit(FatalError) << endl; - } - - // Primary alignment - - vectorField norm(1); - - allGeometry_[hitSurface].getNormal - ( - List(1, surfHit), - norm - ); - - const vector np = norm[0]; - - // Generate equally spaced 'spokes' in a circle normal to the - // direction from the vertex to the closest point on the surface - // and look for a secondary intersection. - - const vector d = surfHit.hitPoint() - pt; - - const tensor Rp = rotationTensor(vector(0,0,1), np); - - const label s = cvMeshControls().alignmentSearchSpokes(); - - scalar closestSpokeHitDistance = GREAT; - - pointIndexHit closestSpokeHit; - - label closestSpokeSurface = -1; - - const scalar spanMag = geometryToConformTo_.globalBounds().mag(); - - for (label i = 0; i < s; i++) - { - vector spoke - ( - Foam::cos(i*constant::mathematical::twoPi/s), - Foam::sin(i*constant::mathematical::twoPi/s), - 0 - ); - - spoke *= spanMag; - - spoke = Rp & spoke; - - pointIndexHit spokeHit; - - label spokeSurface = -1; - - // internal spoke - - geometryToConformTo_.findSurfaceNearestIntersection - ( - pt, - pt + spoke, - spokeHit, - spokeSurface - ); - - if (spokeHit.hit()) - { - scalar spokeHitDistance = mag - ( - spokeHit.hitPoint() - pt - ); - - if (spokeHitDistance < closestSpokeHitDistance) - { - closestSpokeHit = spokeHit; - closestSpokeSurface = spokeSurface; - closestSpokeHitDistance = spokeHitDistance; - } - } - - //external spoke - - Foam::point mirrorPt = pt + 2*d; - - geometryToConformTo_.findSurfaceNearestIntersection - ( - mirrorPt, - mirrorPt + spoke, - spokeHit, - spokeSurface - ); - - if (spokeHit.hit()) - { - scalar spokeHitDistance = mag - ( - spokeHit.hitPoint() - mirrorPt - ); - - if (spokeHitDistance < closestSpokeHitDistance) - { - closestSpokeHit = spokeHit; - closestSpokeSurface = spokeSurface; - closestSpokeHitDistance = spokeHitDistance; - } - } - } - - if (closestSpokeSurface == -1) - { - WarningIn - ( - "conformalVoronoiMesh::requiredAlignment" - "(" - "const Foam::point& pt" - ") const" - ) << "No secondary surface hit found in spoke search " - << "using " << s - << " spokes, try increasing alignmentSearchSpokes." - << endl; - - return I; - } - - // Auxiliary alignment generated by spoke intersection normal. - - allGeometry_[closestSpokeSurface].getNormal - ( - List(1, closestSpokeHit), - norm - ); - - const vector& na = norm[0]; - - // Secondary alignment - vector ns = np ^ na; - - if (mag(ns) < SMALL) - { - FatalErrorIn("conformalVoronoiMesh::requiredAlignment") - << "Parallel normals detected in spoke search." << nl - << "point: " << pt << nl - << "closest surface point: " << surfHit.hitPoint() << nl - << "closest spoke hit: " << closestSpokeHit.hitPoint() << nl - << "np: " << surfHit.hitPoint() + np << nl - << "ns: " << closestSpokeHit.hitPoint() + na << nl - << exit(FatalError); - } - - ns /= mag(ns); - - tensor Rs = rotationTensor((Rp & vector(0,1,0)), ns); - - return (Rs & Rp); -} - - void Foam::conformalVoronoiMesh::insertInternalPoints ( List& points, diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index 1659c1da3a..18ab434869 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -269,12 +269,6 @@ private: //- Return the local maximum surface protrusion distance inline scalar maxSurfaceProtrusion(const Foam::point& pt) const; - //- Return the required cell size at the given location - scalar requiredSize(const Foam::point& pt) const; - - //- Return the required alignment directions at the given location - tensor requiredAlignment(const Foam::point& pt) const; - //- Insert Point and return its auto-generated index inline bool insertPoint ( diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.C index 85657ae25d..f4ed8b66bd 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.C @@ -151,21 +151,11 @@ Foam::cvControls::cvControls maxLoadUnbalance_ = -1; } - alignmentSearchSpokes_ = readLabel - ( - motionDict.lookup("alignmentSearchSpokes") - ); - cosAlignmentAcceptanceAngle_ = cos ( degToRad(readScalar(motionDict.lookup("alignmentAcceptanceAngle"))) ); - sizeAndAlignmentRebuildFrequency_ = max - ( - 1, - readLabel(motionDict.lookup("sizeAndAlignmentRebuildFrequency")) - ); // Point removal criteria diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.H index 12348599b5..3deb133ba1 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.H @@ -148,17 +148,10 @@ class cvControls //- Allowed relative load unbalance scalar maxLoadUnbalance_; - //- Number of "spokes" to use to search for secondary alignment - // direction - label alignmentSearchSpokes_; - //- cosine of angle of alignment with required direction within which a // face will be accepted for rotation scalar cosAlignmentAcceptanceAngle_; - //- Now often to re-store the size and alignment data - label sizeAndAlignmentRebuildFrequency_; - // Point insertion criteria @@ -286,15 +279,9 @@ public: //- Return the maxLoadUnbalance inline scalar maxLoadUnbalance() const; - //- Return the number of alignmentSearchSpokes to use - inline label alignmentSearchSpokes() const; - //- Return the cosAlignmentAcceptanceAngle inline scalar cosAlignmentAcceptanceAngle() const; - //- Return the sizeAndAlignmentRebuildFrequency - inline label sizeAndAlignmentRebuildFrequency() const; - //- Return the aspectRatio inline scalar aspectRatio() const; diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControlsI.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControlsI.H index 889e58ee47..97995349f7 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControlsI.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControlsI.H @@ -148,24 +148,12 @@ inline Foam::scalar Foam::cvControls::maxLoadUnbalance() const } -inline Foam::label Foam::cvControls::alignmentSearchSpokes() const -{ - return alignmentSearchSpokes_; -} - - inline Foam::scalar Foam::cvControls::cosAlignmentAcceptanceAngle() const { return cosAlignmentAcceptanceAngle_; } -inline Foam::label Foam::cvControls::sizeAndAlignmentRebuildFrequency() const -{ - return sizeAndAlignmentRebuildFrequency_; -} - - inline Foam::scalar Foam::cvControls::insertionDistCoeff() const { return insertionDistCoeff_; diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshDict b/applications/utilities/mesh/generation/cvMesh/cvMeshDict index 9947bce7f2..29a1321144 100644 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshDict +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshDict @@ -308,6 +308,12 @@ motionControl // Timing and memory usage. timeChecks no; + // For each delaunay edge (between two vertices, becomes + // the Voronoi face normal) snap to the alignment direction if within + // alignmentAcceptanceAngle. Slightly > 45 is a good choice - prevents + // flipping. + alignmentAcceptanceAngle 48; + // When to insert points. Not advisable change to // these settings. pointInsertionCriteria