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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::isoSurfaceTopo
29 
30 Description
31  Marching tet iso surface algorithm with optional filtering to keep only
32  points originating from mesh edges.
33 
34 SourceFiles
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 
49 namespace Foam
50 {
51 
52 // Forward Declarations
53 class cellShape;
54 class polyMesh;
55 
56 /*---------------------------------------------------------------------------*\
57  Class isoSurfaceTopo Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class isoSurfaceTopo
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 
196 protected:
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 
216 public:
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,
235  const scalarField& pointValues,
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
258 
264 };
265 
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 } // End namespace Foam
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 #ifdef NoRepository
274  #include "isoSurfaceTopoTemplates.C"
275 #endif
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 #endif
280 
281 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::SymmTensor< scalar >
Foam::isoSurfaceBase
Low-level components common to various iso-surface algorithms.
Definition: isoSurfaceBase.H:66
s
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))
Definition: gmvOutputSpray.H:25
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::DynamicList< label >
Foam::isoSurfaceTopo::~isoSurfaceTopo
virtual ~isoSurfaceTopo()=default
Destructor.
Foam::isoSurfaceTopo::pointToVerts
const edgeList & pointToVerts() const noexcept
Per point: originating mesh vertex/cell centre combination.
Definition: isoSurfaceTopo.H:250
Foam::isoSurfaceTopo::inplaceSubsetMesh
void inplaceSubsetMesh(const bitSet &include)
Subset the surface using the selected faces.
Definition: isoSurfaceTopo.C:1618
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
declareIsoSurfaceInterpolateMethod
#define declareIsoSurfaceInterpolateMethod(Type)
Definition: isoSurfaceBase.H:271
Foam::Map< label >
isoSurfaceTopoTemplates.C
bitSet.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
isoSurfaceBase.H
Foam::isoSurfaceBase::mesh
const polyMesh & mesh() const noexcept
The mesh for which the iso-surface is associated.
Definition: isoSurfaceBase.H:194
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::isoSurfaceParams::isoSurfaceParams
isoSurfaceParams(const algorithmType algo=algorithmType::ALGO_DEFAULT, const filterType filter=filterType::DIAGCELL) noexcept
Default construct, or with specified algorithm.
Definition: isoSurfaceParams.C:135
Foam::isoSurfaceTopo::interpolateTemplate
tmp< Field< Type > > interpolateTemplate(const Field< Type > &cellData, const Field< Type > &pointData) const
Interpolates cellData and pointData fields.
edgeList.H
Foam::isoSurfaceParams
Preferences for controlling iso-surface algorithms.
Definition: isoSurfaceParams.H:107
Foam::vertices
pointField vertices(const blockVertexList &bvl)
Definition: blockVertexList.H:49
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SphericalTensor< scalar >
Foam::isoSurfaceBase::cellValues
const scalarField & cellValues() const noexcept
The mesh cell values used for creating the iso-surface.
Definition: isoSurfaceBase.H:200
Foam::EdgeMap< label >
Foam::Vector< scalar >
Foam::List< edge >
Foam::FixedList
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:104
Foam::pointToFace
A topoSetFaceSource to select faces with any point or any edge within a given pointSet(s).
Definition: pointToFace.H:176
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::tetCell
A tetrahedral cell primitive.
Definition: tetCell.H:64
Foam::isoSurfaceTopo::isoSurfaceTopo
isoSurfaceTopo(const polyMesh &mesh, const scalarField &cellValues, const scalarField &pointValues, const scalar iso, const isoSurfaceParams &params=isoSurfaceParams(), const bitSet &ignoreCells=bitSet())
Construct from cell and point values.
Definition: isoSurfaceTopo.C:909
Foam::isoSurfaceTopo
Marching tet iso surface algorithm with optional filtering to keep only points originating from mesh ...
Definition: isoSurfaceTopo.H:59
Foam::MeshedSurface< face >
Foam::isoSurfaceTopo::TypeName
TypeName("isoSurfaceTopo")
Runtime type information.
Foam::isoSurfaceBase::pointValues
const scalarField & pointValues() const noexcept
The mesh point values used for creating the iso-surface.
Definition: isoSurfaceBase.H:206
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79