diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify.C b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify.C index adc46f762378c75dafefa76bac50f125a5793b12..c3518ef1a0365e5359f9d402068a6914053049b9 100644 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify.C +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify.C @@ -173,6 +173,8 @@ int main(int argc, char *argv[]) surfaces, points, scalarField(points.size(), sqr(GREAT)), + searchableSurface::OUTSIDE, // for non-closed surfaces treat as + // outside nearestSurfaces, signedDist ); diff --git a/src/meshTools/searchableSurface/searchableSurfacesQueries.C b/src/meshTools/searchableSurface/searchableSurfacesQueries.C index 4db8f9acf37f58a13c9e874c657ab6aa9b7202a9..26f0a4532438786515bd73d60cb312907b79ed98 100644 --- a/src/meshTools/searchableSurface/searchableSurfacesQueries.C +++ b/src/meshTools/searchableSurface/searchableSurfacesQueries.C @@ -693,6 +693,7 @@ void Foam::searchableSurfacesQueries::signedDistance const labelList& surfacesToTest, const pointField& samples, const scalarField& nearestDistSqr, + const searchableSurface::volumeType illegalHandling, labelList& nearestSurfaces, scalarField& distance ) @@ -753,9 +754,32 @@ void Foam::searchableSurfacesQueries::signedDistance } else { - FatalErrorIn("signedDistance()") - << "getVolumeType failure, neither INSIDE or OUTSIDE" - << exit(FatalError); + switch (illegalHandling) + { + case searchableSurface::OUTSIDE: + { + distance[pointI] = dist; + break; + } + case searchableSurface::INSIDE: + { + distance[pointI] = -dist; + break; + } + default: + { + FatalErrorIn("signedDistance()") + << "getVolumeType failure," + << " neither INSIDE or OUTSIDE." + << " point:" << surfPoints[i] + << " surface:" + << allSurfaces[surfacesToTest[testI]].name() + << " volType:" + << searchableSurface::volumeTypeNames[vT] + << exit(FatalError); + break; + } + } } } } diff --git a/src/meshTools/searchableSurface/searchableSurfacesQueries.H b/src/meshTools/searchableSurface/searchableSurfacesQueries.H index a2dba23cb5d295a7b80338275a57d697ed670454..9f2ebfbadb6c575aaf0c5fb9a431acf6079df455 100644 --- a/src/meshTools/searchableSurface/searchableSurfacesQueries.H +++ b/src/meshTools/searchableSurface/searchableSurfacesQueries.H @@ -184,13 +184,18 @@ public: List<pointIndexHit>& ); - //- Find signed distance to nearest surface + //- Find signed distance to nearest surface. Outside is positive. + // illegalHandling: how to handle non-inside or outside + // OUTSIDE : treat as outside + // INSIDE : treat as inside + // UNKNOWN : throw fatal error static void signedDistance ( const PtrList<searchableSurface>& allSurfaces, const labelList& surfacesToTest, const pointField& samples, const scalarField& nearestDistSqr, + const searchableSurface::volumeType illegalHandling, labelList& nearestSurfaces, scalarField& distance );