diff --git a/src/sampling/surface/isoSurface/isoSurfaceBase.H b/src/sampling/surface/isoSurface/isoSurfaceBase.H
index 3e29657bd1..a856f06f26 100644
--- a/src/sampling/surface/isoSurface/isoSurfaceBase.H
+++ b/src/sampling/surface/isoSurface/isoSurfaceBase.H
@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
- Copyright (C) 2019-2020 OpenCFD Ltd.
+ Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -127,26 +127,6 @@ protected:
// Protected Member Functions
- //- Check for tet values above/below given (iso) value
- // Result encoded as a single integer
- inline static constexpr int getTetCutIndex
- (
- const scalar a,
- const scalar b,
- const scalar c,
- const scalar d,
- const scalar isoval
- ) noexcept
- {
- return
- (
- (a < isoval ? 1 : 0)
- | (b < isoval ? 2 : 0)
- | (c < isoval ? 4 : 0)
- | (d < isoval ? 8 : 0)
- );
- }
-
//- Count the number of cuts matching the mask type
// Checks as bitmask or as zero.
static label countCutType
diff --git a/src/sampling/surface/isoSurface/isoSurfaceParams.C b/src/sampling/surface/isoSurface/isoSurfaceParams.C
index cf9494ed5d..60b003dcb4 100644
--- a/src/sampling/surface/isoSurface/isoSurfaceParams.C
+++ b/src/sampling/surface/isoSurface/isoSurfaceParams.C
@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
- Copyright (C) 2020 OpenCFD Ltd.
+ Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -52,10 +52,12 @@ const Foam::Enum
Foam::isoSurfaceParams::filterNames
({
{ filterType::NONE, "none" },
- { filterType::CELL, "cell" },
- { filterType::DIAGCELL, "diagcell" },
{ filterType::PARTIAL, "partial" },
{ filterType::FULL, "full" },
+ { filterType::CLEAN, "clean" },
+
+ { filterType::CELL, "cell" },
+ { filterType::DIAGCELL, "diagcell" },
});
@@ -137,6 +139,7 @@ Foam::isoSurfaceParams::isoSurfaceParams
:
algo_(algo),
filter_(filter),
+ snap_(true),
mergeTol_(1e-6),
clipBounds_(boundBox::invertedBox)
{}
@@ -152,6 +155,7 @@ Foam::isoSurfaceParams::isoSurfaceParams
{
algo_ = getAlgorithmType(dict, algo_);
filter_ = getFilterType(dict, filter_);
+ snap_ = dict.getOrDefault("snap", true);
dict.readIfPresent("mergeTol", mergeTol_);
dict.readIfPresent("bounds", clipBounds_);
}
diff --git a/src/sampling/surface/isoSurface/isoSurfaceParams.H b/src/sampling/surface/isoSurface/isoSurfaceParams.H
index 1b794f7059..d73da00c27 100644
--- a/src/sampling/surface/isoSurface/isoSurfaceParams.H
+++ b/src/sampling/surface/isoSurface/isoSurfaceParams.H
@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
- Copyright (C) 2020 OpenCFD Ltd.
+ Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -35,12 +35,22 @@ Description
isoMethod | Algorithm (cell/topo/point/default) | no | default
regularise | Face simplification (enum or bool) | no | true
mergeTol | Point merge tolerance (cell/point) | no | 1e-6
+ snap | Point snapping (topo) | no | true
bounds | Optional clip bounds | no | inverted
\endtable
The default algorithm denotes the use of the current \em standard
algorithm.
+Filtering types (for topological iso-surface)
+ - \c none : leave tet cuts untouched
+ - \c partial , \c cell : Combine intra-cell faces
+ - \c full , \c diagcell : Perform \c partial and remove face-diagonal
+ points
+ - \c clean : Perform \c full and eliminate open edges as well.
+ (May cause excessive erosion!)
+ .
+
SourceFiles
isoSurfaceParams.C
@@ -85,8 +95,12 @@ public:
NONE = 0, //!< No filtering
CELL, //!< Remove pyramid edge points
DIAGCELL, //!< Remove pyramid edge points, face-diagonals
+ NONMANIFOLD, //!< Remove pyramid edge points, face-diagonals
+ //!< and non-manifold faces
+
PARTIAL = CELL, //!< Same as CELL
FULL = DIAGCELL, //!< Same as DIAGCELL
+ CLEAN = NONMANIFOLD //!< Same as NONMANIFOLD
};
@@ -100,6 +114,9 @@ private:
//- Filtering for iso-surface faces/points
filterType filter_;
+ //- Point snapping enabled
+ bool snap_;
+
//- Merge tolerance for cell/point (default: 1e-6)
scalar mergeTol_;
@@ -186,6 +203,18 @@ public:
filter_ = fltr;
}
+ //- Get point snapping flag
+ bool snap() const noexcept
+ {
+ return snap_;
+ }
+
+ //- Set point snapping flag
+ void snap(bool on) noexcept
+ {
+ snap_ = on;
+ }
+
//- Get current merge tolerance
scalar mergeTol() const noexcept
{
diff --git a/src/sampling/surface/isoSurface/isoSurfaceTopo.C b/src/sampling/surface/isoSurface/isoSurfaceTopo.C
index e8ff86266f..c0fe1a8077 100644
--- a/src/sampling/surface/isoSurface/isoSurfaceTopo.C
+++ b/src/sampling/surface/isoSurface/isoSurfaceTopo.C
@@ -29,13 +29,16 @@ License
#include "isoSurfaceTopo.H"
#include "polyMesh.H"
#include "volFields.H"
+#include "edgeHashes.H"
#include "tetCell.H"
-#include "tetMatcher.H"
#include "tetPointRef.H"
#include "DynamicField.H"
#include "syncTools.H"
#include "uindirectPrimitivePatch.H"
#include "polyMeshTetDecomposition.H"
+#include "foamVtkInternalMeshWriter.H"
+#include "foamVtkLineWriter.H"
+#include "foamVtkSurfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -51,452 +54,624 @@ namespace Foam
}
-// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+// Get/set snapIndex (0, 1 or 2) at given position
+// 0 = no snap
+// 1 = snap to first edge end
+// 2 = snap to second edge end
+// NB: 4 lower bits left free for regular tet-cut information
-Foam::label Foam::isoSurfaceTopo::generatePoint
+#undef SNAP_END_VALUE
+#undef SNAP_END_ENCODE
+#define SNAP_END_ENCODE(pos, val) (((val) << (4 + 2 * pos)))
+#define SNAP_END_VALUE(pos, val) (((val) >> (4 + 2 * pos)) & 0x3)
+
+
+// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Check for tet values above/below given (iso) value
+// Result encoded as an integer, with possible snapping information too
+inline static int getTetCutIndex
(
- const label facei,
- const bool edgeIsDiag,
- const edge& vertices,
+ scalar p0,
+ scalar p1,
+ scalar p2,
+ scalar p3,
+ const scalar val,
+ const bool doSnap
+) noexcept
+{
+ int cutIndex
+ (
+ (p0 < val ? 1 : 0) // point 0
+ | (p1 < val ? 2 : 0) // point 1
+ | (p2 < val ? 4 : 0) // point 2
+ | (p3 < val ? 8 : 0) // point 3
+ );
- DynamicList& pointToVerts,
- DynamicList