From f2dbdd66bf9bb80bb043f26989f6601c4b0c08a8 Mon Sep 17 00:00:00 2001 From: laurence Date: Wed, 14 Aug 2013 12:40:52 +0100 Subject: [PATCH] ENH: foamyHexMesh: surface conformation and initial point insertion autoDensity: Change to reference and correct typo surfaceConformation: Include Delaunay cells that are entirely made up of boundary points. Also increase the length of the line to intersect. --- .../conformalVoronoiMeshConformToSurface.C | 37 ++++++++++++++----- .../autoDensity/autoDensity.C | 4 +- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index ba7d0b5782..db77f62f5f 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -1286,14 +1286,24 @@ void Foam::conformalVoronoiMesh::dualCellLargestSurfaceProtrusion if ( is_infinite(c1) || is_infinite(c2) - || !c1->hasInternalPoint() || !c2->hasInternalPoint() + || (!c1->hasInternalPoint() && !c2->hasInternalPoint()) || !c1->real() || !c2->real() ) { continue; } - Foam::point edgeMid = 0.5*(c1->dual() + c2->dual()); +// Foam::point endPt = 0.5*(c1->dual() + c2->dual()); + Foam::point endPt = c1->dual(); + + if + ( + magSqr(vert - c1->dual()) + < magSqr(vert - c2->dual()) + ) + { + endPt = c2->dual(); + } pointIndexHit surfHit; label hitSurface; @@ -1301,7 +1311,7 @@ void Foam::conformalVoronoiMesh::dualCellLargestSurfaceProtrusion geometryToConformTo_.findSurfaceAnyIntersection ( vert, - edgeMid, + endPt, surfHit, hitSurface ); @@ -1319,7 +1329,7 @@ void Foam::conformalVoronoiMesh::dualCellLargestSurfaceProtrusion const vector& n = norm[0]; const scalar normalProtrusionDistance = - (edgeMid - surfHit.hitPoint()) & n; + (endPt - surfHit.hitPoint()) & n; if (normalProtrusionDistance > maxProtrusionDistance) { @@ -1382,14 +1392,24 @@ void Foam::conformalVoronoiMesh::dualCellLargestSurfaceIncursion if ( is_infinite(c1) || is_infinite(c2) - || !c1->hasInternalPoint() || !c2->hasInternalPoint() + || (!c1->hasInternalPoint() && !c2->hasInternalPoint()) || !c1->real() || !c2->real() ) { continue; } - Foam::point edgeMid = 0.5*(c1->dual() + c2->dual()); +// Foam::point endPt = 0.5*(c1->dual() + c2->dual()); + Foam::point endPt = c1->dual(); + + if + ( + magSqr(vert - c1->dual()) + < magSqr(vert - c2->dual()) + ) + { + endPt = c2->dual(); + } pointIndexHit surfHit; label hitSurface; @@ -1397,7 +1417,7 @@ void Foam::conformalVoronoiMesh::dualCellLargestSurfaceIncursion geometryToConformTo_.findSurfaceAnyIntersection ( vert, - edgeMid, + endPt, surfHit, hitSurface ); @@ -1414,8 +1434,7 @@ void Foam::conformalVoronoiMesh::dualCellLargestSurfaceIncursion const vector& n = norm[0]; - scalar normalIncursionDistance = - (edgeMid - surfHit.hitPoint()) & n; + scalar normalIncursionDistance = (endPt - surfHit.hitPoint()) & n; if (normalIncursionDistance < minIncursionDistance) { diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C index fd7600017d..8234fd8b36 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C @@ -350,7 +350,7 @@ bool Foam::autoDensity::fillBox if (!overlapping && !wellInside) { - // If this is an inside box then then it is possible to fill points very + // If this is an inside box then it is possible to fill points very // close to the boundary, to prevent this, check the corners and sides // of the box so ensure that they are "wellInside". If not, set as an // overlapping box. @@ -644,7 +644,7 @@ bool Foam::autoDensity::fillBox { trialPoints++; - point p = samplePoints[i]; + const point& p = samplePoints[i]; scalar localSize = sampleSizes[i];