isoSurfaceCell.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::isoSurfaceCell
29
30Description
31 A surface formed by the iso value.
32 After "Polygonising A Scalar Field Using Tetrahedrons", Paul Bourke
33 (http://paulbourke.net/geometry/polygonise) and
34 "Regularised Marching Tetrahedra: improved iso-surface extraction",
35 G.M. Treece, R.W. Prager and A.H. Gee.
36
37 See isoSurface. This is a variant which does tetrahedrisation from
38 triangulation of face to cell centre instead of edge of face to two
39 neighbouring cell centres. This gives much lower quality triangles
40 but they are local to a cell.
41
42SourceFiles
43 isoSurfaceCell.C
44 isoSurfaceCellTemplates.C
45
46\*---------------------------------------------------------------------------*/
47
48#ifndef isoSurfaceCell_H
49#define isoSurfaceCell_H
50
51#include "labelPair.H"
52#include "pointIndexHit.H"
53#include "isoSurfaceBase.H"
54
55// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56
57namespace Foam
58{
59
60// Forward Declarations
61class triSurface;
62
63/*---------------------------------------------------------------------------*\
64 Class isoSurfaceCell Declaration
65\*---------------------------------------------------------------------------*/
68:
69 public isoSurfaceBase
70{
71 // Private Data
72
73 //- When to merge points
74 const scalar mergeDistance_;
75
76 //- The cell cut type
77 List<cutType> cellCutType_;
78
79 //- Estimated number of cut cells
80 label nCutCells_;
81
82 //- For every unmerged triangle point the point in the triSurface
83 labelList triPointMergeMap_;
84
85 //- triSurface points that have weighted interpolation
86 DynamicList<label> interpolatedPoints_;
87
88 //- corresponding original, unmerged points
89 DynamicList<FixedList<label, 3>> interpolatedOldPoints_;
90
91 //- corresponding weights
92 DynamicList<FixedList<scalar, 3>> interpolationWeights_;
93
94
95 // Private Member Functions
96
97 //- Get location of iso value as fraction inbetween s0,s1
98 scalar isoFraction(const scalar s0, const scalar s1) const;
99
100 //- Return the two common points between two triangles
101 static labelPair findCommonPoints
102 (
103 const labelledTri&,
104 const labelledTri&
105 );
106
107 //- Calculate centre of surface.
108 static point calcCentre(const triSurface&);
109
110 //- Replace surface (localPoints, localTris) with single point.
111 // Returns point. Destroys arguments.
112 pointIndexHit collapseSurface
113 (
114 const label celli,
117 ) const;
118
119 //- Determine per cc whether all near cuts can be snapped to single
120 //- point.
121 void calcSnappedCc
122 (
123 const bitSet& isTet,
124 const scalarField& cVals,
125 const scalarField& pVals,
127 labelList& snappedCc
128 ) const;
129
130 //- Generate triangles for face connected to pointi
131 void genPointTris
132 (
133 const scalarField& cellValues,
135 const label pointi,
136 const label facei,
137 const label celli,
138 DynamicList<point, 64>& localTriPoints
139 ) const;
140
141 //- Generate triangles for tet connected to pointi
142 void genPointTris
143 (
145 const label pointi,
146 const label facei,
147 const label celli,
148 DynamicList<point, 64>& localTriPoints
149 ) const;
150
151 //- Determine per point whether all near cuts can be snapped to single
152 // point.
153 void calcSnappedPoint
154 (
155 const bitSet& isTet,
156 const scalarField& cVals,
157 const scalarField& pVals,
159 labelList& snappedPoint
160 ) const;
161
162 //- Generate single point by interpolation or snapping
163 template<class Type>
164 Type generatePoint
165 (
166 const DynamicList<Type>& snappedPoints,
167 const scalar s0,
168 const Type& p0,
169 const label p0Index,
170 const scalar s1,
171 const Type& p1,
172 const label p1Index
173 ) const;
174
175 template<class Type>
176 void generateTriPoints
177 (
178 const DynamicList<Type>& snapped,
179 const scalar s0,
180 const Type& p0,
181 const label p0Index,
182 const scalar s1,
183 const Type& p1,
184 const label p1Index,
185 const scalar s2,
186 const Type& p2,
187 const label p2Index,
188 const scalar s3,
189 const Type& p3,
190 const label p3Index,
192 ) const;
193
194 template<class Type>
195 void generateTriPoints
196 (
197 const scalarField& cVals,
198 const scalarField& pVals,
199
200 const Field<Type>& cCoords,
201 const Field<Type>& pCoords,
202
203 const DynamicList<Type>& snappedPoints,
204 const labelList& snappedCc,
205 const labelList& snappedPoint,
206
208 DynamicList<label>& triMeshCells
209 ) const;
210
211 triSurface stitchTriPoints
212 (
213 const bool checkDuplicates,
214 const List<point>& triPoints,
215 labelList& triPointReverseMap, // unmerged to merged point
216 labelList& triMap // merged to unmerged triangle
217 ) const;
218
219 //- Determine edge-face addressing
220 void calcAddressing
221 (
222 const triSurface& surf,
224 labelList& edgeFace0,
225 labelList& edgeFace1,
226 Map<labelList>& edgeFacesRest
227 ) const;
228
229 //- Is triangle (given by 3 edges) not fully connected?
230 static bool danglingTriangle
231 (
232 const FixedList<label, 3>& fEdges,
233 const labelList& edgeFace1
234 );
235
236 //- Mark all non-fully connected triangles
237 static label markDanglingTriangles
238 (
240 const labelList& edgeFace0,
241 const labelList& edgeFace1,
242 const Map<labelList>& edgeFacesRest,
243 boolList& keepTriangles
244 );
245
246 static triSurface subsetMesh
247 (
248 const triSurface&,
249 const labelList& newToOldFaces,
250 labelList& oldToNewPoints,
251 labelList& newToOldPoints
252 );
253
254
255 // Sampling
256
257 //- Interpolates cCoords, pCoords.
258 template<class Type>
259 tmp<Field<Type>> interpolateTemplate
260 (
261 const Field<Type>& cCoords,
262 const Field<Type>& pCoords
263 ) const;
264
265public:
266
267 //- Runtime type information
268 TypeName("isoSurfaceCell");
269
270
271 // Constructors
272
273 //- Construct from cell and point values
274 //
275 // \param ignoreCells cells to ignore in the cellValues
276 //
277 // Control parameters include
278 // - bounds optional bounding box for trimming
279 // - mergeTol fraction of mesh bounding box for merging points
281 (
282 const polyMesh& mesh,
283 const scalarField& cellValues,
285 const scalar iso,
286 const isoSurfaceParams& params = isoSurfaceParams(),
287 const bitSet& ignoreCells = bitSet()
288 );
289
290
291 //- Destructor
292 virtual ~isoSurfaceCell() = default;
293
294
295 // Sampling
302};
303
304
305// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306
307} // End namespace Foam
308
309// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310
311#ifdef NoRepository
313#endif
314
315// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316
317#endif
318
319// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:66
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const Field< point_type > & points() const noexcept
Return reference to global points.
const labelListList & faceEdges() const
Return face-edge addressing.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
Low-level components common to various iso-surface algorithms.
const scalarField & cellValues() const noexcept
The mesh cell values used for creating the iso-surface.
const polyMesh & mesh() const noexcept
The mesh for which the iso-surface is associated.
const scalarField & pointValues() const noexcept
The mesh point values used for creating the iso-surface.
A surface formed by the iso value. After "Polygonising A Scalar Field Using Tetrahedrons",...
TypeName("isoSurfaceCell")
Runtime type information.
virtual ~isoSurfaceCell()=default
Destructor.
Preferences for controlling iso-surface algorithms.
A triFace with additional (region) index.
Definition: labelledTri.H:60
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A class for managing temporary objects.
Definition: tmp.H:65
Triangle storage. Null constructable (unfortunately triangle<point, point> is not)
Definition: triPoints.H:55
Triangulated surface description with patch information.
Definition: triSurface.H:79
const volScalarField & p0
Definition: EEqn.H:36
#define declareIsoSurfaceInterpolateMethod(Type)
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73