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