diff --git a/src/sampling/surface/distanceSurface/distanceSurface.C b/src/sampling/surface/distanceSurface/distanceSurface.C index 734a6b48cc..7b5f5474c5 100644 --- a/src/sampling/surface/distanceSurface/distanceSurface.C +++ b/src/sampling/surface/distanceSurface/distanceSurface.C @@ -68,8 +68,7 @@ Foam::distanceSurface::distanceSurface distance_(dict.get("distance")), signed_ ( - // Always signed when distance = 0. - dict.get("signed") || equal(distance_, Zero) + distance_ < 0 || equal(distance_, Zero) || dict.get("signed") ), cell_(dict.lookupOrDefault("cell", true)), regularise_(dict.lookupOrDefault("regularise", true)), @@ -113,8 +112,7 @@ Foam::distanceSurface::distanceSurface distance_(distance), signed_ ( - // Always signed when distance = 0. - signedDistance || equal(distance_, Zero) + signedDistance || distance_ < 0 || equal(distance_, Zero) ), cell_(cell), regularise_(regularise), @@ -148,7 +146,7 @@ void Foam::distanceSurface::createGeometry() ( IOobject ( - "cellDistance", + "distanceSurface.cellDistance", fvm.time().timeName(), fvm.time(), IOobject::NO_READ, @@ -164,7 +162,8 @@ void Foam::distanceSurface::createGeometry() // For distance = 0 (and isoSurfaceCell) we apply additional filtering // to limit the extent of open edges. - const bool filterCells = (cell_ && signed_ && equal(distance_, Zero)); + const bool isZeroDist = equal(distance_, Zero); + const bool filterCells = (cell_ && isZeroDist); bitSet ignoreCells; if (filterCells) @@ -185,7 +184,7 @@ void Foam::distanceSurface::createGeometry() nearest ); - if (signed_) + if (signed_ || isZeroDist) { vectorField norms; surfPtr_().getNormal(nearest, norms); @@ -196,7 +195,12 @@ void Foam::distanceSurface::createGeometry() { const point diff(cc[i] - nearest[i].hitPoint()); - fld[i] = sign(diff & norms[i]) * Foam::mag(diff); + fld[i] = + ( + isZeroDist // Use normal distance + ? (diff & norms[i]) + : Foam::sign(diff & norms[i]) * Foam::mag(diff) + ); // Since cellPoints() is used in isoSurfaceCell too, // no additional overhead caused here @@ -250,7 +254,12 @@ void Foam::distanceSurface::createGeometry() { const point diff(cc[i] - nearest[i].hitPoint()); - fld[i] = sign(diff & norms[i]) * Foam::mag(diff); + fld[i] = + ( + isZeroDist // Use normal distance + ? (diff & norms[i]) + : Foam::sign(diff & norms[i]) * Foam::mag(diff) + ); } } else @@ -290,7 +299,12 @@ void Foam::distanceSurface::createGeometry() { const point diff(pts[i] - nearest[i].hitPoint()); - pointDistance_[i] = sign(diff & norms[i]) * Foam::mag(diff); + pointDistance_[i] = + ( + isZeroDist // Use normal distance + ? (diff & norms[i]) + : Foam::sign(diff & norms[i]) * Foam::mag(diff) + ); } } else @@ -311,7 +325,7 @@ void Foam::distanceSurface::createGeometry() ( IOobject ( - "pointDistance", + "distanceSurface.pointDistance", fvm.time().timeName(), fvm.time(), IOobject::NO_READ, diff --git a/src/sampling/surface/distanceSurface/distanceSurface.H b/src/sampling/surface/distanceSurface/distanceSurface.H index f988ba5223..7f01f97b88 100644 --- a/src/sampling/surface/distanceSurface/distanceSurface.H +++ b/src/sampling/surface/distanceSurface/distanceSurface.H @@ -25,27 +25,28 @@ Class Foam::distanceSurface Description - A surface defined by distance to an input surface - using either - an isoSurfaceCell or an isoSurface. + A surface defined by a distance from an input searchable surface. + Uses an isoSurfaceCell or an isoSurface algorithm for constructing the + distance surface. Usage Dictionary controls: \table Property | Description | Required | Default distance | distance from surface | yes | - signed | apply sign for +ve/-ve distance | yes | + signed | Use sign when distance is positive | partly | cell | use isoSurfaceCell algorithm | no | true - regularise | point snapping | yes | - bounds | limit with bounding box | no | - surfaceType | type of surface | yes | - surfaceName | name of surface in \c triSurface/ | no | dict name + regularise | Point snapping for iso-surface | yes | + bounds | Limit with bounding box | no | + surfaceType | Type of surface | yes | + surfaceName | Name of surface in \c triSurface/ | no | dict name \endtable Note - Some special adjustments are undertaken for distance = 0. - - Always treated as signed (ignoring the input value), since it is - nearly impossible to generate any surface otherwise. - - With the isoSurfaceCell algorithm is used, additional checks for open + For distance = 0, some special adjustments. + - Always signed (ignoring the input value). + - Use normal distance from surface (for better treatment of open edges). + - When the isoSurfaceCell algorithm is used, additional checks for open surfaces edges are used to limit the extend of resulting distance surface. The resulting surface elements will not, however, contain partial cell coverage. @@ -88,13 +89,13 @@ class distanceSurface //- Signed distance const bool signed_; - //- Whether to use isoSurfaceCell or isoSurface + //- Use isoSurfaceCell (true) or isoSurface (false) algorithm const bool cell_; - //- Whether to coarsen + //- Whether to coarsen iso-surface triangles const bool regularise_; - //- Optional bounding box to trim triangles against + //- Optional bounding box to trim against const boundBox bounds_; //- Distance to cell centres diff --git a/src/sampling/surface/isoSurface/isoSurface.C b/src/sampling/surface/isoSurface/isoSurface.C index 90d185090b..bc2a3b3c4c 100644 --- a/src/sampling/surface/isoSurface/isoSurface.C +++ b/src/sampling/surface/isoSurface/isoSurface.C @@ -1481,7 +1481,7 @@ Foam::isoSurface::isoSurface ( IOobject ( - "cutType", + "isoSurface.cutType", fvm.time().timeName(), fvm.time(), IOobject::NO_READ, diff --git a/src/sampling/surface/isoSurface/isoSurfaceCell.C b/src/sampling/surface/isoSurface/isoSurfaceCell.C index 6cecc030c2..73ce0804bd 100644 --- a/src/sampling/surface/isoSurface/isoSurfaceCell.C +++ b/src/sampling/surface/isoSurface/isoSurfaceCell.C @@ -1342,7 +1342,7 @@ Foam::isoSurfaceCell::isoSurfaceCell ( IOobject ( - "cutType", + "isoSurfaceCell.cutType", fvm.time().timeName(), fvm.time(), IOobject::NO_READ, diff --git a/tutorials/compressible/rhoSimpleFoam/squareBend/system/samplingDebug b/tutorials/compressible/rhoSimpleFoam/squareBend/system/samplingDebug index 88683dfc3f..bc86fdcfb4 100644 --- a/tutorials/compressible/rhoSimpleFoam/squareBend/system/samplingDebug +++ b/tutorials/compressible/rhoSimpleFoam/squareBend/system/samplingDebug @@ -42,6 +42,13 @@ debug } } + _disk1 + { + surfaceType disk; + origin (-0.1 -0.05 0); + normal (1 1 1); + radius 0.015; + } surfaces ( @@ -55,6 +62,16 @@ debug surfaceName angledPlane.obj; } + disk1 + { + ${_disk1} + type distanceSurface; + distance 0; + cell false; + signed true; + triangulate false; + } + iso { type isoSurface;