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-2024 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 "Map.H"
96 #include "boolList.H"
97 #include "labelList.H"
98 #include "faceList.H"
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 namespace Foam
103 {
104 
105 // Forward declaration of classes
106 class triSurfaceSearch;
107 class meshSearch;
108 class polyMesh;
109 class primitiveMesh;
110 
111 /*---------------------------------------------------------------------------*\
112  Class cellClassification Declaration
113 \*---------------------------------------------------------------------------*/
114 
115 class cellClassification
116 :
117  public labelList
118 {
119 
120 public:
121 
122  // Public data types
123 
124  //- Type of cell.
125  enum cType
126  {
128  INSIDE, // Inside of surface
129  OUTSIDE, // Outside ,,
130  CUT // cut by surface
131  };
132 
133 
134  //- Enumeration defining the whether points are use by cells of
135  // a certain type.
136  enum pointStatus
137  {
139  MESH, // points used by meshType cells
140  NONMESH, // ,, non-mesh type cells
141  MIXED // ,, both types of cell
142  };
143 
144 private:
145 
146  // Private Data
147 
148  //- Reference to mesh
149  const polyMesh& mesh_;
150 
151 
152  // Private Static Functions
153 
154  //- Count number of occurrences of elem in list
155  static label count(const labelList& elems, const label elem);
156 
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 FaceCellWave 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 List<point>& 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 
194 public:
195 
196  // Static Data Members
197  ClassName("cellClassification");
198 
199  // Constructors
200 
201  //- Construct from mesh and surface and point(s) on outside
203  (
204  const polyMesh& mesh,
205  const meshSearch& meshQuery,
206  const triSurfaceSearch& surfQuery,
207  const List<point>& outsidePoints
208  );
209 
210  //- Construct from mesh and type for every cell.
211  // Used to be able to reuse filling routines below.
212  cellClassification(const polyMesh& mesh, const labelList& cellType);
213 
214  //- Copy constructor
216 
217 
218  // Member Functions
219 
220  const polyMesh& mesh() const
221  {
222  return mesh_;
223  }
224 
226  (
227  const label nLayers,
228  const label meshType,
229  const label fillType
230  );
231 
232  //- Sets vertex neighbours of meshType cells to fillType
233  label growSurface(const label meshType, const label fillType);
234 
235  //- Find hanging cells (cells with all points on outside) and set their
236  // type to fillType.
237  // Iterate until nothing changed. Returns total number of cells
238  // changed (in all iterations)
240  (
241  const label meshType,
242  const label fillType,
243  const label maxIter
244  );
245 
246  //- Find regionEdges and fill one neighbour. Iterate until nothing
247  // changes. Returns total number of cells changed.
249  (
250  const label meshType,
251  const label fillType,
252  const label maxIter
253  );
254 
255  //- Find regionPoints and fill all neighbours. Iterate until nothing
256  // changes. Returns total number of cells changed.
258  (
259  const label meshType,
260  const label fillType,
261  const label maxIter
262  );
263 
264  //- Write statistics on cell types to Ostream
265  void writeStats(Ostream& os) const;
266 
267 
268  // Member Operators
269 
270  void operator=(const cellClassification&);
271 
272 };
273 
274 
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 
277 } // End namespace Foam
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
281 #endif
282 
283 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
'Cuts' 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.
label fillHangingCells(const label meshType, const label fillType, const label maxIter)
Find hanging cells (cells with all points on outside) and set their.
cellClassification(const polyMesh &mesh, const meshSearch &meshQuery, const triSurfaceSearch &surfQuery, const List< point > &outsidePoints)
Construct from mesh and surface and point(s) on outside.
label growSurface(const label meshType, const label fillType)
Sets vertex neighbours of meshType cells to fillType.
void operator=(const cellClassification &)
label trimCutCells(const label nLayers, const label meshType, const label fillType)
pointStatus
Enumeration defining the whether points are use by cells of.
ClassName("cellClassification")
void writeStats(Ostream &os) const
Write statistics on cell types to Ostream.
const polyMesh & mesh() const
label fillRegionEdges(const label meshType, const label fillType, const label maxIter)
Find regionEdges and fill one neighbour. Iterate until nothing.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition: meshSearch.H:58
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Helper class to search on triSurface.
Namespace for OpenFOAM.
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