cellClassification.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::cellClassification
28
29Description
30 'Cuts' a mesh with a surface.
31
32 Divides cells into three types
33 - cut, i.e. any of the edges of the cell is split or any edge of the
34 surface pierces any of the faces of the cell.
35 - outside: cell can be reached by Meshwave from any of the supplied
36 outside points (without crossing any cut cell)
37 - inside: all other.
38
39 Used in various meshing programs.
40
41 Has various utility functions to deal with 'features' on this level
42 where the mesh still has all inside and outside cells.
43
44 \par Concepts
45
46 - point classification:
47 - point used by meshType cells only
48 - point used by non-meshType cells only
49 - point used by both types ('mixed')
50
51 - hanging cells: meshType cells using mixed points only.
52 These cells would have all their vertices on the surface when
53 extracting the meshType cells.
54
55 - regionEdges: edges where the cells using it are of mixed type.
56 Or more precise when walking around the edge and looking at the
57 different types of the cells there are more than two regions with
58 same type.
59
60 Seen from above:
61 \verbatim
62 Ok:
63 A | A
64 |
65 --+---
66 |
67 B | B
68
69 Not ok:
70 A | B
71 |
72 ---+---
73 |
74 B | A
75 \endverbatim
76
77 because this latter situation would cause the surface after subsetting
78 type A or B to be multiply connected across this edge. And also when
79 snapping the edge end points to the surface it might cause some twisted
80 faces if the surface is normal to the edge (and smoothing the surface
81 would not help since the points on the edge would be 'pulled' from two
82 different sides)
83
84 - regionPoints: like regionEdges but now for points.
85 Points where subsetting the mesh would cause a multiply connected
86 outside surface (connected across point, not edge)
87
88
89SourceFiles
90 cellClassification.C
91
92\*---------------------------------------------------------------------------*/
93
94#ifndef cellClassification_H
95#define cellClassification_H
96
97#include "pointField.H"
98#include "Map.H"
99#include "boolList.H"
100#include "labelList.H"
101#include "faceList.H"
102
103// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104
105namespace Foam
106{
107
108// Forward declaration of classes
109class triSurfaceSearch;
110class meshSearch;
111class polyMesh;
112class primitiveMesh;
113
114/*---------------------------------------------------------------------------*\
115 Class cellClassification Declaration
116\*---------------------------------------------------------------------------*/
119:
120 public labelList
121{
122
123public:
124
125 // Public data types
126
127 //- Type of cell.
128 enum cType
131 INSIDE, // Inside of surface
132 OUTSIDE, // Outside ,,
133 CUT // cut by surface
134 };
135
136
137 //- Enumeration defining the whether points are use by cells of
138 // a certain type.
139 enum pointStatus
142 MESH, // points used by meshType cells
143 NONMESH, // ,, non-mesh type cells
144 MIXED // ,, both types of cell
145 };
146
147private:
148
149 // Private data
150
151 //- Reference to mesh
152 const polyMesh& mesh_;
153
154
155 // Private Static Functions
156
157 //- Count number of occurrences of elem in list
158 static label count(const labelList& elems, const label elem);
159
160 // Private Member Functions
161
162 //- Mark all faces intersected by or intersecting surface
163 boolList markFaces(const triSurfaceSearch&) const;
164
165 //- Divide cells into cut/inside/outside by using MeshWave from cut
166 // faces. No check is done on whether outsidePts are in different
167 // domains.
168 void markCells
169 (
170 const meshSearch& queryMesh,
171 const boolList& piercedFace,
172 const pointField& outsidePts
173 );
174
175 //- Use cell status to classify points as being internal to meshType,
176 // internal to non-meshType or on border of both.
177 void classifyPoints
178 (
179 const label meshType,
180 const labelList& cellType,
181 List<pointStatus>& pointSide
182 ) const;
183
184 //- Return true if cell uses only points with status=mixed
185 bool usesMixedPointsOnly
186 (
187 const List<pointStatus>&,
188 const label celli
189 ) const;
190
191 //- Get faces (and its 'owner') inbetween cells of differing type
192 // (meshType and non-meshType).
193 void getMeshOutside(const label meshType, faceList&, labelList&) const;
194
195public:
196
197 // Static data members
198 ClassName("cellClassification");
199
200 // Constructors
201
202 //- Construct from mesh and surface and point(s) on outside
204 (
205 const polyMesh& mesh,
206 const meshSearch& meshQuery,
207 const triSurfaceSearch& surfQuery,
208 const pointField& outsidePoints
209 );
210
211 //- Construct from mesh and type for every cell.
212 // Used to be able to reuse filling routines below.
213 cellClassification(const polyMesh& mesh, const labelList& cellType);
214
215 //- Construct as copy
217
218
219 // Member Functions
221 const polyMesh& mesh() const
222 {
223 return mesh_;
224 }
225
226 label trimCutCells
227 (
228 const label nLayers,
229 const label meshType,
230 const label fillType
231 );
232
233 //- Sets vertex neighbours of meshType cells to fillType
234 label growSurface(const label meshType, const label fillType);
235
236 //- Find hanging cells (cells with all points on outside) and set their
237 // type to fillType.
238 // Iterate until nothing changed. Returns total number of cells
239 // changed (in all iterations)
240 label fillHangingCells
241 (
242 const label meshType,
243 const label fillType,
244 const label maxIter
245 );
246
247 //- Find regionEdges and fill one neighbour. Iterate until nothing
248 // changes. Returns total number of cells changed.
249 label fillRegionEdges
250 (
251 const label meshType,
252 const label fillType,
253 const label maxIter
254 );
255
256 //- Find regionPoints and fill all neighbours. Iterate until nothing
257 // changes. Returns total number of cells changed.
258 label fillRegionPoints
259 (
260 const label meshType,
261 const label fillType,
262 const label maxIter
263 );
264
265 //- Write statistics on cell types to Ostream
266 void writeStats(Ostream& os) const;
267
268
269 // Member Operators
270
271 void operator=(const cellClassification&);
272
273};
274
275
276// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277
278} // End namespace Foam
279
280// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281
282#endif
283
284// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
'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.
const polyMesh & mesh() const
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.
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:61
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
Helper class to search on triSurface.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.