From e61bc5c9feecc892912c3713ddfceb6d8b844c89 Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 15 Jul 2009 19:38:48 +0100 Subject: [PATCH] Adding patching information for all surfaces. Adding check when inseting a new vertex on a long Delaunay edge that the edge does not pierce the surface, causing a span between thin parts of the surface. Contains temporary checking code for internalPoints that are not inside the surface. Was passing points by copy rather than const reference to conformationSurfaces ...Intersection queries, rectified. --- .../conformalVoronoiMesh.C | 67 ++++++++++--------- .../conformationSurfaces.C | 55 +++++++++++++-- .../conformationSurfaces.H | 34 ++++++++-- .../conformationSurfacesI.H | 6 ++ 4 files changed, 120 insertions(+), 42 deletions(-) diff --git a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 2624d11688..b0df6aa47c 100644 --- a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -1479,24 +1479,9 @@ void Foam::conformalVoronoiMesh::calcDualMesh // ~~~~~~~~~~~~ dual face and owner neighbour construction ~~~~~~~~~~~~~~~~~ - //label nPatches = qSurf_.patches().size() + 1; + patchNames = geometryToConformTo_.patchNames(); - //label defaultPatchIndex = qSurf_.patches().size(); - - label nPatches = 1; - - label defaultPatchIndex = 0; - - patchNames.setSize(nPatches); - - //const geometricSurfacePatchList& surfacePatches = qSurf_.patches(); - - // forAll(surfacePatches, sP) - // { - // patchNames[sP] = surfacePatches[sP].name(); - // } - - patchNames[defaultPatchIndex] = "cvMesh_defaultPatch"; + label nPatches = patchNames.size(); patchSizes.setSize(nPatches); @@ -1622,20 +1607,13 @@ void Foam::conformalVoronoiMesh::calcDualMesh point ptB = topoint(vB->point()); - //pointIndexHit pHit = qSurf_.tree().findLineAny(ptA, ptB); - - //label patchIndex = qSurf_[pHit.index()].region(); - - label patchIndex = defaultPatchIndex; + label patchIndex = geometryToConformTo_.findPatch(ptA, ptB); if (patchIndex == -1) { - patchIndex = defaultPatchIndex; - WarningIn("Foam::conformalVoronoiMesh::calcDualMesh") << "Dual face found that is not on a surface " - << "patch. Adding to " - << patchNames[defaultPatchIndex] + << "patch. Adding to " << patchNames[0] << endl; } @@ -2253,12 +2231,25 @@ void Foam::conformalVoronoiMesh::move() ) { // Point insertion - pointsToInsert.push_back - ( - toPoint(0.5*(dVA + dVB)) - ); - pointsAdded++; + if + ( + !geometryToConformTo_.findSurfaceAnyIntersection + ( + dVA, + dVB + ) + ) + { + // Prevent insertions spanning surfaces + + pointsToInsert.push_back + ( + toPoint(0.5*(dVA + dVB)) + ); + + pointsAdded++; + } } else if ( @@ -2325,6 +2316,20 @@ void Foam::conformalVoronoiMesh::move() vit, displacementAccumulator[vit->index()] ); + + + // TEMPORARY: CHECK IF ALL INTERNAL POINTS ARE INSIDE + if + ( + geometryToConformTo_.inside + ( + pointField(1, topoint(vit->point())) + )[0] == false + ) + { + Info<< "INTERNAL POINT " << topoint(vit->point()) + << " NOT INSIDE" << endl; + } } } diff --git a/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index 3310e4ae1d..34535f3d06 100644 --- a/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -41,7 +41,10 @@ Foam::conformationSurfaces::conformationSurfaces features_(), locationInMesh_(surfaceConformationDict.lookup("locationInMesh")), surfaces_(), + allGeometryToSurfaces_(), baffleSurfaces_(), + patchNames_(0), + patchOffsets_(), bounds_() { const dictionary& surfacesDict @@ -53,10 +56,14 @@ Foam::conformationSurfaces::conformationSurfaces surfaces_.setSize(surfacesDict.size()); + allGeometryToSurfaces_.setSize(allGeometry_.size(), -1); + baffleSurfaces_.setSize(surfacesDict.size()); features_.setSize(surfacesDict.size()); + patchOffsets_.setSize(surfacesDict.size()); + label surfI = 0; forAllConstIter(dictionary, surfacesDict, iter) @@ -65,6 +72,8 @@ Foam::conformationSurfaces::conformationSurfaces surfaces_[surfI] = allGeometry_.findSurfaceID(surfaceName); + allGeometryToSurfaces_[surfaces_[surfI]] = surfI; + if (surfaces_[surfI] < 0) { FatalErrorIn("Foam::conformationSurfaces::conformationSurfaces") @@ -73,6 +82,10 @@ Foam::conformationSurfaces::conformationSurfaces << exit(FatalError); } + patchOffsets_[surfI] = patchNames_.size(); + + patchNames_.append(allGeometry.regionNames()[surfaces_[surfI]]); + const dictionary& surfaceSubDict(surfacesDict.subDict(surfaceName)); baffleSurfaces_[surfI] = Switch @@ -307,8 +320,8 @@ Foam::Field Foam::conformationSurfaces::wellOutside bool Foam::conformationSurfaces::findSurfaceAnyIntersection ( - point start, - point end + const point& start, + const point& end ) const { labelList hitSurfaces; @@ -330,8 +343,8 @@ bool Foam::conformationSurfaces::findSurfaceAnyIntersection void Foam::conformationSurfaces::findSurfaceAnyIntersection ( - point start, - point end, + const point& start, + const point& end, pointIndexHit& surfHit, label& hitSurface ) const @@ -364,8 +377,8 @@ void Foam::conformationSurfaces::findSurfaceAnyIntersection void Foam::conformationSurfaces::findSurfaceNearestIntersection ( - point start, - point end, + const point& start, + const point& end, pointIndexHit& surfHit, label& hitSurface ) const @@ -607,4 +620,34 @@ void Foam::conformationSurfaces::writeFeatureObj } +Foam::label Foam::conformationSurfaces::findPatch +( + const point& ptA, + const point& ptB +) const +{ + pointIndexHit surfHit; + label hitSurface; + + findSurfaceAnyIntersection(ptA, ptB, surfHit, hitSurface); + + if (!surfHit.hit()) + { + return -1; + } + + labelList surfLocalRegion; + + allGeometry_[hitSurface].getRegion + ( + List(1, surfHit), + surfLocalRegion + ); + + return + surfLocalRegion[0] + patchOffsets_[allGeometryToSurfaces_[hitSurface]]; + +} + + // ************************************************************************* // diff --git a/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H index ee6ad83cdf..ce3ff0c21f 100644 --- a/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H +++ b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H @@ -74,10 +74,23 @@ class conformationSurfaces //- Indices of surfaces in allGeometry that are to be conformed to labelList surfaces_; + //- Reverse mapping, which entry in surfaces corresponds to the surface + // in allGeometry specified by the list index. -1 for a surface that + // isn't used. + labelList allGeometryToSurfaces_; + //- A boolean value for each surface to be conformed to specifying if it // is to be treated as a baffle boolList baffleSurfaces_; + //- A flat list of all of the names of the patches from all of the + // surfaces to be reproduced in the meshed geometry + List patchNames_; + + //- The offset between the patch indices of the individual surface and + // the entry in the overall patch list + labelList patchOffsets_; + //- The overall boundBox of all of the surfaces to be conformed to boundBox bounds_; @@ -122,6 +135,9 @@ public: //- Return the surface indices inline const labelList& surfaces() const; + //- Return the patch names + inline const List& patchNames() const; + //- Return the boundBox inline const boundBox& bounds() const; @@ -151,14 +167,18 @@ public: ) const; // Finding if the line joining start and end intersects the surface - bool findSurfaceAnyIntersection(point start, point end) const; + bool findSurfaceAnyIntersection + ( + const point& start, + const point& end + ) const; //- Finding if the line joining start and end intersects the surface // and returning the hit and surface information void findSurfaceAnyIntersection ( - point start, - point end, + const point& start, + const point& end, pointIndexHit& surfHit, label& hitSurface ) const; @@ -166,8 +186,8 @@ public: //- Finding the nearestIntersection of the surface to start void findSurfaceNearestIntersection ( - point start, - point end, + const point& start, + const point& end, pointIndexHit& surfHit, label& hitSurface ) const; @@ -217,6 +237,10 @@ public: List