All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cellClassification.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-2020 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::cellClassification
26 
27 Description
28  'Cuts' a mesh with a surface.
29 
30  Divides cells into three types
31  - cut, i.e. any of the edges of the cell is split or any edge of the
32  surface pierces any of the faces of the cell.
33  - outside: cell can be reached by Meshwave from any of the supplied
34  outside points (without crossing any cut cell)
35  - inside: all other.
36 
37  Used in various meshing programs.
38 
39  Has various utility functions to deal with 'features' on this level
40  where the mesh still has all inside and outside cells.
41 
42  \par Concepts
43 
44  - point classification:
45  - point used by meshType cells only
46  - point used by non-meshType cells only
47  - point used by both types ('mixed')
48 
49  - hanging cells: meshType cells using mixed points only.
50  These cells would have all their vertices on the surface when
51  extracting the meshType cells.
52 
53  - regionEdges: edges where the cells using it are of mixed type.
54  Or more precise when walking around the edge and looking at the
55  different types of the cells there are more than two regions with
56  same type.
57 
58  Seen from above:
59  \verbatim
60  Ok:
61  A | A
62  |
63  --+---
64  |
65  B | B
66 
67  Not ok:
68  A | B
69  |
70  ---+---
71  |
72  B | A
73  \endverbatim
74 
75  because this latter situation would cause the surface after subsetting
76  type A or B to be multiply connected across this edge. And also when
77  snapping the edge end points to the surface it might cause some twisted
78  faces if the surface is normal to the edge (and smoothing the surface
79  would not help since the points on the edge would be 'pulled' from two
80  different sides)
81 
82  - regionPoints: like regionEdges but now for points.
83  Points where subsetting the mesh would cause a multiply connected
84  outside surface (connected across point, not edge)
85 
86 
87 SourceFiles
88  cellClassification.C
89 
90 \*---------------------------------------------------------------------------*/
91 
92 #ifndef cellClassification_H
93 #define cellClassification_H
94 
95 #include "pointField.H"
96 #include "Map.H"
97 #include "boolList.H"
98 #include "labelList.H"
99 #include "faceList.H"
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 namespace Foam
104 {
105 
106 // Forward declaration of classes
107 class triSurfaceSearch;
108 class meshSearch;
109 class polyMesh;
110 class primitiveMesh;
111 
112 /*---------------------------------------------------------------------------*\
113  Class cellClassification Declaration
114 \*---------------------------------------------------------------------------*/
116 class cellClassification
117 :
118  public labelList
119 {
120 
121 public:
122 
123  // Public data types
124 
125  //- Type of cell.
126  enum cType
127  {
129  INSIDE, // Inside of surface
130  OUTSIDE, // Outside ,,
131  CUT // cut by surface
132  };
133 
134 
135  //- Enumeration defining the whether points are use by cells of
136  // a certain type.
137  enum pointStatus
138  {
140  MESH, // points used by meshType cells
141  NONMESH, // ,, non-mesh type cells
142  MIXED // ,, both types of cell
143  };
144 
145 private:
146 
147  // Private Data
148 
149  //- Reference to mesh
150  const polyMesh& mesh_;
151 
152 
153  // Private Static Functions
154 
155  //- Count number of occurrences of elem in list
156  static label count(const labelList& elems, const label elem);
157 
158  // Private Member Functions
159 
160  //- Mark all faces intersected by or intersecting surface
161  boolList markFaces(const triSurfaceSearch&) const;
162 
163  //- Divide cells into cut/inside/outside by using MeshWave from cut
164  // faces. No check is done on whether outsidePts are in different
165  // domains.
166  void markCells
167  (
168  const meshSearch& queryMesh,
169  const boolList& piercedFace,
170  const pointField& outsidePts
171  );
172 
173  //- Use cell status to classify points as being internal to meshType,
174  // internal to non-meshType or on border of both.
175  void classifyPoints
176  (
177  const label meshType,
178  const labelList& cellType,
179  List<pointStatus>& pointSide
180  ) const;
181 
182  //- Return true if cell uses only points with status=mixed
183  bool usesMixedPointsOnly
184  (
185  const List<pointStatus>&,
186  const label celli
187  ) const;
188 
189  //- Get faces (and its 'owner') in between cells of differing type
190  // (meshType and non-meshType).
191  void getMeshOutside(const label meshType, faceList&, labelList&) const;
192 
193 public:
194 
195  // Static Data Members
196  ClassName("cellClassification");
197 
198  // Constructors
199 
200  //- Construct from mesh and surface and point(s) on outside
202  (
203  const polyMesh& mesh,
204  const meshSearch& meshQuery,
205  const triSurfaceSearch& surfQuery,
206  const pointField& outsidePoints
207  );
208 
209  //- Construct from mesh and type for every cell.
210  // Used to be able to reuse filling routines below.
211  cellClassification(const polyMesh& mesh, const labelList& cellType);
212 
213  //- Copy constructor
215 
216 
217  // Member Functions
219  const polyMesh& mesh() const
220  {
221  return mesh_;
222  }
223 
225  (
226  const label nLayers,
227  const label meshType,
228  const label fillType
229  );
230 
231  //- Sets vertex neighbours of meshType cells to fillType
232  label growSurface(const label meshType, const label fillType);
233 
234  //- Find hanging cells (cells with all points on outside) and set their
235  // type to fillType.
236  // Iterate until nothing changed. Returns total number of cells
237  // changed (in all iterations)
239  (
240  const label meshType,
241  const label fillType,
242  const label maxIter
243  );
244 
245  //- Find regionEdges and fill one neighbour. Iterate until nothing
246  // changes. Returns total number of cells changed.
248  (
249  const label meshType,
250  const label fillType,
251  const label maxIter
252  );
253 
254  //- Find regionPoints and fill all neighbours. Iterate until nothing
255  // changes. Returns total number of cells changed.
257  (
258  const label meshType,
259  const label fillType,
260  const label maxIter
261  );
262 
263  //- Write statistics on cell types to Ostream
264  void writeStats(Ostream& os) const;
265 
266 
267  // Member Operators
268 
269  void operator=(const cellClassification&);
270 
271 };
272 
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 } // End namespace Foam
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 #endif
281 
282 // ************************************************************************* //
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
Definition: meshSearch.H:57
label trimCutCells(const label nLayers, const label meshType, const label fillType)
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
ClassName("cellClassification")
const polyMesh & mesh() const
void operator=(const cellClassification &)
cellClassification(const polyMesh &mesh, const meshSearch &meshQuery, const triSurfaceSearch &surfQuery, const pointField &outsidePoints)
Construct from mesh and surface and point(s) on outside.
Helper class to search on triSurface.
&#39;Cuts&#39; a mesh with a surface.
label fillRegionPoints(const label meshType, const label fillType, const label maxIter)
Find regionPoints and fill all neighbours. Iterate until nothing.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
pointStatus
Enumeration defining the whether points are use by cells of.
label growSurface(const label meshType, const label fillType)
Sets vertex neighbours of meshType cells to fillType.
label fillRegionEdges(const label meshType, const label fillType, const label maxIter)
Find regionEdges and fill one neighbour. Iterate until nothing.
void writeStats(Ostream &os) const
Write statistics on cell types to Ostream.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
label fillHangingCells(const label meshType, const label fillType, const label maxIter)
Find hanging cells (cells with all points on outside) and set their.
Namespace for OpenFOAM.