All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2019 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 optional filtering to keep only
29  points originating from mesh edges.
30 
31 SourceFiles
32  isoSurface.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef isoSurface_H
37 #define isoSurface_H
38 
39 #include "labelPair.H"
40 #include "pointIndexHit.H"
41 #include "PackedBoolList.H"
42 #include "MeshedSurface.H"
43 #include "edgeList.H"
44 #include "NamedEnum.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 class polyMesh;
52 class tetMatcher;
53 
54 /*---------------------------------------------------------------------------*\
55  Class isoSurface Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class isoSurface
59 :
60  public MeshedSurface<face>
61 {
62 public:
63 
64  enum class filterType
65  {
66  none, // No filtering
67  partial, // Remove points from vertex to cell-centre edges and
68  // merge triangles that form a contiguous cut through a
69  // single cell
70  full // Also remove points from face-diagonals and merge
71  // edges that originate from the same face
72  };
73 
75 
76 
77 private:
78 
79  // Private Data
80 
81  enum class cellCutType
82  {
83  notCut, // Not cut
84  sphere, // All edges to cell centre cut
85  cut // Normal cut
86  };
87 
88 
89  //- Reference to mesh
90  const polyMesh& mesh_;
91 
92  const scalarField& cVals_;
93 
94  const scalarField& pVals_;
95 
96  //- Iso value
97  const scalar iso_;
98 
99  //- Corrected version of tetBasePtIs
100  labelList tetBasePtIs_;
101 
102  //- Per point: originating mesh vertex/cc. See encoding above
103  edgeList pointToVerts_;
104 
105  //- For every face the original cell in mesh
106  labelList meshCells_;
107 
108  //- For every point the originating face in mesh
109  labelList pointToFace_;
110 
111 
112  // Private Member Functions
113 
114  scalar minTetQ
115  (
116  const label facei,
117  const label faceBasePtI
118  ) const;
119 
120  void fixTetBasePtIs();
121 
122  //- Does any edge of triangle cross iso value?
123  bool isTriCut
124  (
125  const triFace& tri,
126  const scalarField& pointValues
127  ) const;
128 
129  //- Determine whether cell is cut
130  cellCutType calcCutType
131  (
132  const bool isTet,
133  const label
134  ) const;
135 
136  //- Determine for all mesh whether cell is cut
137  label calcCutTypes
138  (
139  tetMatcher& tet,
140  List<cellCutType>& cellCutTypes
141  );
142 
143  //- Generate single point on edge
144  label generatePoint
145  (
146  const label facei,
147  const bool edgeIsDiag,
148  const edge& vertices,
149 
152  DynamicList<bool>& pointFromDiag,
153  EdgeMap<label>& vertsToPoint
154  ) const;
155 
156  //- Generate triangles from tet
157  void generateTriPoints
158  (
159  const label facei,
160  const FixedList<scalar, 4>& s,
161  const FixedList<point, 4>& p,
162  const FixedList<label, 4>& pIndex,
163  const FixedList<bool, 6>& edgeIsDiag,
164 
165  DynamicList<edge>& pointToVerts,
166  DynamicList<label>& pointToFace,
167  DynamicList<bool>& pointFromDiag,
168 
169  EdgeMap<label>& vertsToPoint,
170  DynamicList<label>& verts
171  ) const;
172 
173  //- Generate triangles from cell
174  void generateTriPoints
175  (
176  const label celli,
177  const bool isTet,
178 
179  DynamicList<edge>& pointToVerts,
180  DynamicList<label>& pointToFace,
181  DynamicList<bool>& pointFromDiag,
182 
183  EdgeMap<label>& vertsToPoint,
184  DynamicList<label>& verts,
185  DynamicList<label>& faceLabels
186  ) const;
187 
188 
189  // Simplification
190 
191  void triangulateOutside
192  (
193  const bool filterDiag,
194  const PrimitivePatch<SubList<face>, const pointField&>& pp,
195  const boolList& pointFromDiag,
196  const labelList& pointToFace,
197  const label cellID,
198 
199  DynamicList<face>& compactFaces,
200  DynamicList<label>& compactCellIDs
201  ) const;
202 
203  MeshedSurface<face> removeInsidePoints
204  (
205  const bool filterDiag,
206  const MeshedSurface<face>& s,
207  const boolList& pointFromDiag,
208  const labelList& pointToFace,
209  const labelList& start, // Per cell:starting tri
210  DynamicList<label>& pointCompactMap, // Per point the original
211  DynamicList<label>& compactCellIDs // Per face the cellID
212  ) const;
213 
214 
215 public:
216 
217  //- Runtime type information
218  TypeName("isoSurface");
219 
220 
221  // Constructors
222 
223  //- Construct from dictionary
224  isoSurface
225  (
226  const polyMesh& mesh,
227  const scalarField& cellValues,
228  const scalarField& pointValues,
229  const scalar iso,
230  const filterType filter
231  );
232 
233 
234  // Member Functions
235 
236  //- For every face original cell in mesh
237  const labelList& meshCells() const
238  {
239  return meshCells_;
240  }
241 
242  //- For every point originating face (pyramid) in mesh
243  const labelList& pointToFace() const
244  {
245  return pointToFace_;
246  }
247 
248  //- Per point: originating mesh vertex/cc. See encoding above
249  const edgeList& pointToVerts() const
250  {
251  return pointToVerts_;
252  }
253 
254  //- Interpolates cCoords,pCoords.
255  template<class Type>
257  (
258  const Field<Type>& cCoords,
259  const Field<Type>& pCoords
260  ) const;
261 };
262 
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 } // End namespace Foam
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
270 #ifdef NoRepository
271  #include "isoSurfaceTemplates.C"
272 #endif
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 #endif
277 
278 // ************************************************************************* //
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
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:236
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
static const NamedEnum< filterType, 3 > filterTypeNames_
Definition: isoSurface.H:73
const edgeList & pointToVerts() const
Per point: originating mesh vertex/cc. See encoding above.
Definition: isoSurface.H:248
TypeName("isoSurface")
Runtime type information.
const labelList & pointToFace() const
For every point originating face (pyramid) in mesh.
Definition: isoSurface.H:242
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Marching tet iso surface algorithm with optional filtering to keep only points originating from mesh ...
Definition: isoSurface.H:57
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.