isoSurfaceTopo.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-2019 OpenFOAM Foundation
9 Copyright (C) 2019-2021 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::isoSurfaceTopo
29
30Description
31 Marching tet iso surface algorithm with optional filtering to keep only
32 points originating from mesh edges.
33
34SourceFiles
35 isoSurfaceTopo.C
36 isoSurfaceTopoTemplates.C
37
38\*---------------------------------------------------------------------------*/
39
40#ifndef isoSurfaceTopo_H
41#define isoSurfaceTopo_H
42
43#include "bitSet.H"
44#include "edgeList.H"
45#include "isoSurfaceBase.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52// Forward Declarations
53class cellShape;
54class polyMesh;
55
56/*---------------------------------------------------------------------------*\
57 Class isoSurfaceTopo Declaration
58\*---------------------------------------------------------------------------*/
61:
62 public isoSurfaceBase
63{
64 // Private Data
65
66 //- Per point: originating mesh vertex/cell centre combination.
67 // Vertices less than nPoints are mesh vertices,
68 // duplicate vertices indicate a snapped point
69 edgeList pointToVerts_;
70
71
72 // Private Classes
73
74 //- Handling, bookkeeping for tet cuts
75 class tetCutAddressing
76 {
77 // Bookkeeping hashes used during construction
78 EdgeMap<label> vertsToPointLookup_;
79 Map<label> snapVertsLookup_;
80
81 // Filter information for face diagonals
82 DynamicList<label> pointToFace_;
83 DynamicList<bool> pointFromDiag_;
84
85 // Final output
86 DynamicList<edge> pointToVerts_;
87 DynamicList<label> cutPoints_;
88
89 //- List of cut (decomposed) cell tets. Debug use only.
90 DynamicList<cellShape> debugCutTets_;
91
92 bool debugCutTetsOn_;
93
94
95 public:
96
97 // Constructors
98
99 //- Construct with reserved sizes
100 tetCutAddressing
101 (
102 const label nCutCells,
103 const bool useSnap,
104 const bool useDebugCuts = false
105 );
106
107
108 // Member Functions
109
110 //- Effective number of faces
111 label nFaces() const { return cutPoints_.size()/3; }
112
113 DynamicList<label>& pointToFace() { return pointToFace_; }
114 DynamicList<bool>& pointFromDiag() { return pointFromDiag_; }
115
116 DynamicList<edge>& pointToVerts() { return pointToVerts_; }
117 DynamicList<label>& cutPoints() { return cutPoints_; }
118 DynamicList<cellShape>& debugCutTets() { return debugCutTets_; }
119
120 //- Number of debug cut tets
121 label nDebugTets() const { return debugCutTets_.size(); }
122
123 //- Debugging cut tets active
124 bool debugCutTetsOn() const { return debugCutTetsOn_; }
125
126 void clearDebug();
127 void clearDiagonal();
128 void clearHashes();
129
130 //- Generate single point on edge
131 label generatePoint
132 (
133 label facei,
134 bool edgeIsDiagonal,
135
136 // 0: no snap, 1: snap first, 2: snap second
137 const int snapEnd,
138
139 const edge& vertices
140 );
141
142 //- Generate triangles from tet cut
143 bool generatePoints
144 (
145 const label facei,
146 const int tetCutIndex,
147 const tetCell& tetLabels,
148 const FixedList<bool, 6>& edgeIsDiagonal
149 );
150 };
151
152
153 // Private Member Functions
154
155 //- Generate triangle points from cell
156 void generateTriPoints
157 (
158 const label celli,
159 const bool isTet,
160 const labelList& tetBasePtIs,
161
162 tetCutAddressing& tetCutAddr
163 ) const;
164
165
166 // Simplification
167
168 static void triangulateOutside
169 (
170 const bool filterDiag,
171 const primitivePatch& pp,
172
173 const boolUList& pointFromDiag,
174 const labelUList& pointToFace,
175 const label cellID,
176
177 DynamicList<face>& compactFaces,
178 DynamicList<label>& compactCellIDs
179 );
180
181 static void removeInsidePoints
182 (
183 Mesh& s, // Modify inplace
184 const bool filterDiag,
185
186 // Inputs
187 const boolUList& pointFromDiag,
188 const labelUList& pointToFace,
189 const labelUList& start, // Per cell:starting tri
190
191 // Outputs
192 DynamicList<label>& compactCellIDs // Per face the cellID
193 );
194
195
196protected:
197
198 // Editing
199
200 //- Subset the surface using the selected faces.
201 //
202 // \param[in] include the faces to select
203 void inplaceSubsetMesh(const bitSet& include);
204
205
206 // Sampling
207
208 //- Interpolates cellData and pointData fields
209 template<class Type>
211 (
212 const Field<Type>& cellData,
213 const Field<Type>& pointData
214 ) const;
215
216public:
217
218 //- Runtime type information
219 TypeName("isoSurfaceTopo");
220
221
222 // Constructors
223
224 //- Construct from cell and point values
225 //
226 // \param ignoreCells cells to ignore in the cellValues
227 //
228 // Control parameters include
229 // - bounds optional bounding box for trimming
230 // - mergeTol fraction of mesh bounding box for merging points
232 (
233 const polyMesh& mesh,
234 const scalarField& cellValues,
236 const scalar iso,
237 const isoSurfaceParams& params = isoSurfaceParams(),
238 const bitSet& ignoreCells = bitSet()
239 );
240
241
242 //- Destructor
243 virtual ~isoSurfaceTopo() = default;
244
245
246 // Member Functions
247
248 //- Per point: originating mesh vertex/cell centre combination.
249 // Vertices less than nPoints are mesh vertices (encoding above),
250 // duplicate vertices indicate a snapped point
251 const edgeList& pointToVerts() const noexcept
252 {
253 return pointToVerts_;
254 }
255
256
257 // Sampling
264};
265
266
267// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268
269} // End namespace Foam
270
271// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272
273#ifdef NoRepository
275#endif
276
277// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278
279#endif
280
281// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
Definition: EdgeMap.H:54
Generic templated field type.
Definition: Field.H:82
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
A list of faces which address into the list of points.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.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.
Preferences for controlling iso-surface algorithms.
Marching tet iso surface algorithm with optional filtering to keep only points originating from mesh ...
const edgeList & pointToVerts() const noexcept
Per point: originating mesh vertex/cell centre combination.
virtual ~isoSurfaceTopo()=default
Destructor.
void inplaceSubsetMesh(const bitSet &include)
Subset the surface using the selected faces.
TypeName("isoSurfaceTopo")
Runtime type information.
tmp< Field< Type > > interpolateTemplate(const Field< Type > &cellData, const Field< Type > &pointData) const
Interpolates cellData and pointData fields.
A topoSetFaceSource to select faces with any point or any edge within a given pointSet(s).
Definition: pointToFace.H:179
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A tetrahedral cell primitive.
Definition: tetCell.H:67
A class for managing temporary objects.
Definition: tmp.H:65
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define declareIsoSurfaceInterpolateMethod(Type)
Namespace for OpenFOAM.
pointField vertices(const blockVertexList &bvl)
const direction noexcept
Definition: Scalar.H:223
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73