diff --git a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 729ecd4835..94054bf4d7 100644 --- a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -204,6 +204,60 @@ void Foam::conformalVoronoiMesh::insertInitialPoints() void Foam::conformalVoronoiMesh::conformToSurface() { startOfSurfacePointPairs_ = number_of_vertices(); + + const dictionary& cvMeshDict( cvMeshControls_.cvMeshDict()); + + scalar defaultCellSize + ( + cvMeshDict.subDict("motionControl").lookup("defaultCellSize") + ); + + scalar surfDepthCoeff + ( + cvMeshDict.subDict("surfaceConformation").lookup + ( + "surfacePointSearchDepthCoeff" + ) + ); + + DynamicList surfacePoints; + DynamicList surfaceNormals; + + for + ( + Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + vit++ + ) + { + if (vit->internalPoint()) + { + point vert(topoint(vit->point())); + + // TODO Need to have a function to recover the local cell size, use + // the defaultCellSize for the moment + + scalar searchDistanceSqr = sqr(defaultCellSize*surfDepthCoeff); + + pointIndexHit pHit = geometryToConformTo_.findNearest + ( + vert, + searchDistanceSqr + ); + + if (pHit.hit()) + { + vit->setNearBoundary(); + + if (dualCellSurfaceIntersection(vit)) + { + allNearSurfacePoints.append(vert); + allSurfacePoints.append(pHit.hitPoint()); + allSurfaceTris.append(pHit.index()); + } + } + } + } } diff --git a/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index 497471b2cc..759810229e 100644 --- a/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/src/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -253,7 +253,6 @@ bool Foam::conformationSurfaces::findAnyIntersection ); return hitInfo[0].hit(); - } diff --git a/src/meshTools/searchableSurface/searchableSurfaces.C b/src/meshTools/searchableSurface/searchableSurfaces.C index cec34bd7e7..316eb9f503 100644 --- a/src/meshTools/searchableSurface/searchableSurfaces.C +++ b/src/meshTools/searchableSurface/searchableSurfaces.C @@ -285,7 +285,8 @@ void Foam::searchableSurfaces::findAnyIntersection } -// Find intersections of edge nearest to both endpoints. +//- Find all intersections in order from start to end. Returns for +// every hit the surface and the hit info. void Foam::searchableSurfaces::findAllIntersections ( const pointField& start, @@ -306,6 +307,31 @@ void Foam::searchableSurfaces::findAllIntersections } +//Find intersections of edge nearest to both endpoints. +void Foam::searchableSurfaces::findNearestIntersection +( + const pointField& start, + const pointField& end, + labelList& surface1, + List& hit1, + labelList& surface2, + List& hit2 +) const +{ + searchableSurfacesQueries::findNearestIntersection + ( + *this, + allSurfaces_, + start, + end, + surface1, + hit1, + surface2, + hit2 + ); +} + + // Find nearest. Return -1 or nearest point void Foam::searchableSurfaces::findNearest ( @@ -315,7 +341,7 @@ void Foam::searchableSurfaces::findNearest List& nearestInfo ) const { - return searchableSurfacesQueries::findNearest + searchableSurfacesQueries::findNearest ( *this, allSurfaces_, @@ -327,6 +353,17 @@ void Foam::searchableSurfaces::findNearest } +//- Calculate bounding box +Foam::boundBox Foam::searchableSurfaces::bounds() const +{ + return searchableSurfacesQueries::bounds + ( + *this, + allSurfaces_ + ); +} + + //- Calculate point which is on a set of surfaces. Foam::pointIndexHit Foam::searchableSurfaces::facesIntersection ( diff --git a/src/meshTools/searchableSurface/searchableSurfaces.H b/src/meshTools/searchableSurface/searchableSurfaces.H index af02ae1883..a60ae19d89 100644 --- a/src/meshTools/searchableSurface/searchableSurfaces.H +++ b/src/meshTools/searchableSurface/searchableSurfaces.H @@ -154,6 +154,17 @@ public: List >& ) const; + //Find intersections of edge nearest to both endpoints. + void findNearestIntersection + ( + const pointField& start, + const pointField& end, + labelList& surface1, + List& hit1, + labelList& surface2, + List& hit2 + ) const; + //- Find nearest. Return -1 (and a miss()) or surface and nearest // point. void findNearest @@ -164,6 +175,9 @@ public: List& ) const; + //- Calculate bounding box + boundBox bounds() const; + // Single point queries