isoSurface.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::isoSurface
26 
27 Description
28  Marching tet iso surface algorithm with filtering to remove unnecessary
29  topology.
30 
31  Three levels of filtering are possible:
32 
33  - none:
34  Don't filter; the full intersection between the iso surface and the
35  tetrahedral decomposition of the mesh is generated
36 
37  - partial:
38  Remove points from vertex to cell-centre edges and merge triangles that
39  form a contiguous cut through a single cell
40 
41  - full:
42  As partial, but also remove points from face-diagonals and merge edges
43  that originate from the same face
44 
45  - clean:
46  As full, but also remove faces that were made non-manifold by the point
47  filtering process. Note that this process is not entirely robust. The
48  removal process can result in entire contiguous sections of the surface
49  being removed. If small imperfections in the surface can be tolerated,
50  then it is advised to use "full" filtering instead.
51 
52 SourceFiles
53  isoSurface.C
54 
55 \*---------------------------------------------------------------------------*/
56 
57 #ifndef isoSurface_H
58 #define isoSurface_H
59 
60 #include "labelPair.H"
61 #include "pointIndexHit.H"
62 #include "PackedBoolList.H"
63 #include "MeshedSurface.H"
64 #include "edgeList.H"
65 #include "NamedEnum.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 class polyMesh;
73 class tetMatcher;
74 
75 /*---------------------------------------------------------------------------*\
76  Class isoSurface Declaration
77 \*---------------------------------------------------------------------------*/
78 
79 class isoSurface
80 :
81  public MeshedSurface<face>
82 {
83 public:
84 
85  enum class filterType
86  {
87  none,
88  partial,
89  full,
90  clean
91  };
92 
94 
95 
96 private:
97 
98  // Private Data
99 
100  enum class cellCutType
101  {
102  notCut, // Not cut
103  sphere, // All edges to cell centre cut
104  cut // Normal cut
105  };
106 
107 
108  //- Reference to mesh
109  const polyMesh& mesh_;
110 
111  const scalarField& cVals_;
112 
113  const scalarField& pVals_;
114 
115  //- Iso value
116  const scalar iso_;
117 
118  //- Corrected version of tetBasePtIs
119  labelList tetBasePtIs_;
120 
121  //- Per point: originating mesh vertex/cc. See encoding above
122  edgeList pointToVerts_;
123 
124  //- For every face the original cell in mesh
125  labelList meshCells_;
126 
127  //- For every point the originating face in mesh
128  labelList pointToFace_;
129 
130 
131  // Private Member Functions
132 
133  scalar minTetQ
134  (
135  const label facei,
136  const label faceBasePtI
137  ) const;
138 
139  void fixTetBasePtIs();
140 
141  //- Does any edge of triangle cross iso value?
142  bool isTriCut
143  (
144  const triFace& tri,
145  const scalarField& pointValues
146  ) const;
147 
148  //- Determine whether cell is cut
149  cellCutType calcCutType
150  (
151  const bool isTet,
152  const label
153  ) const;
154 
155  //- Determine for all mesh whether cell is cut
156  label calcCutTypes
157  (
158  tetMatcher& tet,
159  List<cellCutType>& cellCutTypes
160  );
161 
162  //- Generate single point on edge
163  label generatePoint
164  (
165  const label facei,
166  const bool edgeIsDiag,
167  const edge& vertices,
168 
171  DynamicList<bool>& pointFromDiag,
172  EdgeMap<label>& vertsToPoint
173  ) const;
174 
175  //- Generate triangles from tet
176  void generateTriPoints
177  (
178  const label facei,
179  const FixedList<scalar, 4>& s,
180  const FixedList<point, 4>& p,
181  const FixedList<label, 4>& pIndex,
182  const FixedList<bool, 6>& edgeIsDiag,
183 
184  DynamicList<edge>& pointToVerts,
185  DynamicList<label>& pointToFace,
186  DynamicList<bool>& pointFromDiag,
187 
188  EdgeMap<label>& vertsToPoint,
189  DynamicList<label>& verts
190  ) const;
191 
192  //- Generate triangles from cell
193  void generateTriPoints
194  (
195  const label celli,
196  const bool isTet,
197 
198  DynamicList<edge>& pointToVerts,
199  DynamicList<label>& pointToFace,
200  DynamicList<bool>& pointFromDiag,
201 
202  EdgeMap<label>& vertsToPoint,
203  DynamicList<label>& verts,
204  DynamicList<label>& faceLabels
205  ) const;
206 
207 
208  // Simplification
209 
210  void triangulateOutside
211  (
212  const bool filterDiag,
213  const PrimitivePatch<SubList<face>, const pointField&>& pp,
214  const boolList& pointFromDiag,
215  const labelList& pointToFace,
216  const label cellID,
217 
218  DynamicList<face>& compactFaces,
219  DynamicList<label>& compactCellIDs
220  ) const;
221 
222  MeshedSurface<face> removeInsidePoints
223  (
224  const bool filterDiag,
225  const MeshedSurface<face>& s,
226  const boolList& pointFromDiag,
227  const labelList& pointToFace,
228  const labelList& start, // Per cell:starting tri
229  DynamicList<label>& pointCompactMap, // Per point the original
230  DynamicList<label>& compactCellIDs // Per face the cellID
231  ) const;
232 
233 
234 public:
235 
236  //- Runtime type information
237  TypeName("isoSurface");
238 
239 
240  // Constructors
241 
242  //- Construct from dictionary
243  isoSurface
244  (
245  const polyMesh& mesh,
246  const scalarField& cellValues,
247  const scalarField& pointValues,
248  const scalar iso,
249  const filterType filter
250  );
251 
252 
253  // Member Functions
254 
255  //- For every face original cell in mesh
256  const labelList& meshCells() const
257  {
258  return meshCells_;
259  }
260 
261  //- For every point originating face (pyramid) in mesh
262  const labelList& pointToFace() const
263  {
264  return pointToFace_;
265  }
266 
267  //- Per point: originating mesh vertex/cc. See encoding above
268  const edgeList& pointToVerts() const
269  {
270  return pointToVerts_;
271  }
272 
273  //- Interpolates cCoords,pCoords.
274  template<class Type>
276  (
277  const Field<Type>& cCoords,
278  const Field<Type>& pCoords
279  ) const;
280 };
281 
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 } // End namespace Foam
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 #ifdef NoRepository
290  #include "isoSurfaceTemplates.C"
291 #endif
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 
295 #endif
296 
297 // ************************************************************************* //
A cellMatcher for tet cells.
Definition: tetMatcher.H:51
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:54
static const NamedEnum< filterType, 4 > filterTypeNames_
Definition: isoSurface.H:92
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:72
const labelList & meshCells() const
For every face original cell in mesh.
Definition: isoSurface.H:255
pointField vertices(const blockVertexList &bvl)
A list of faces which address into the list of points.
A List obtained as a section of another List.
Definition: SubList.H:53
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
tmp< Field< Type > > interpolate(const Field< Type > &cCoords, const Field< Type > &pCoords) const
Interpolates cCoords,pCoords.
dynamicFvMesh & mesh
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
A triangular face using a FixedList of labels corresponding to mesh vertices.
Definition: triFace.H:68
const edgeList & pointToVerts() const
Per point: originating mesh vertex/cc. See encoding above.
Definition: isoSurface.H:267
TypeName("isoSurface")
Runtime type information.
const labelList & pointToFace() const
For every point originating face (pyramid) in mesh.
Definition: isoSurface.H:261
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Marching tet iso surface algorithm with filtering to remove unnecessary topology. ...
Definition: isoSurface.H:78
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
A topoSetSource to select faces based on use of points.
Definition: pointToFace.H:49
isoSurface(const polyMesh &mesh, const scalarField &cellValues, const scalarField &pointValues, const scalar iso, const filterType filter)
Construct from dictionary.
Definition: isoSurface.C:1158
Namespace for OpenFOAM.