1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
25 Foam::cellClassification
28 'Cuts' a mesh with a surface.
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)
37 Used in various meshing programs.
39 Has various utility functions to deal with 'features' on this level
40 where the mesh still has all inside and outside cells.
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')
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.
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
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
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)
90 \*---------------------------------------------------------------------------*/
92 #ifndef cellClassification_H
93 #define cellClassification_H
95 #include "pointField.H"
98 #include "labelList.H"
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 // Forward declaration of classes
107 class triSurfaceSearch;
114 /*---------------------------------------------------------------------------*\
115 Class cellClassification Declaration
116 \*---------------------------------------------------------------------------*/
118 class cellClassification
131 INSIDE, // Inside of surface
132 OUTSIDE, // Outside ,,
133 CUT // cut by surface
137 //- Enumeration defining the whether points are use by cells of
142 MESH, // points used by meshType cells
143 NONMESH, // ,, non-mesh type cells
144 MIXED // ,, both types of cell
151 //- Reference to mesh
152 const polyMesh& mesh_;
155 // Private Static Functions
157 //- Count number of occurrences of elem in list
158 static label count(const labelList& elems, const label elem);
160 // Private Member Functions
162 //- Mark all faces intersected by or intersecting surface
163 boolList markFaces(const triSurfaceSearch&) const;
165 //- Divide cells into cut/inside/outside by using MeshWave from cut
166 // faces. No check is done on whether outsidePts are in different
170 const meshSearch& queryMesh,
171 const boolList& piercedFace,
172 const pointField& outsidePts
175 //- Use cell status to classify points as being internal to meshType,
176 // internal to non-meshType or on border of both.
179 const label meshType,
180 const labelList& cellType,
181 List<pointStatus>& pointSide
184 //- Return true if cell uses only points with status=mixed
185 bool usesMixedPointsOnly
187 const List<pointStatus>&,
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;
197 // Static data members
198 ClassName("cellClassification");
202 //- Construct from mesh and surface and point(s) on outside
205 const polyMesh& mesh,
206 const meshSearch& meshQuery,
207 const triSurfaceSearch& surfQuery,
208 const pointField& outsidePoints
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);
215 //- Construct as copy
216 cellClassification(const cellClassification&);
221 const polyMesh& mesh() const
229 const label meshType,
233 //- Sets vertex neighbours of meshType cells to fillType
234 label growSurface(const label meshType, const label fillType);
236 //- Find hanging cells (cells with all points on outside) and set their
238 // Iterate until nothing changed. Returns total number of cells
239 // changed (in all iterations)
240 label fillHangingCells
242 const label meshType,
243 const label fillType,
247 //- Find regionEdges and fill one neighbour. Iterate until nothing
248 // changes. Returns total number of cells changed.
249 label fillRegionEdges
251 const label meshType,
252 const label fillType,
256 //- Find regionPoints and fill all neighbours. Iterate until nothing
257 // changes. Returns total number of cells changed.
258 label fillRegionPoints
260 const label meshType,
261 const label fillType,
265 //- Write statistics on cell types to Ostream
266 void writeStats(Ostream& os) const;
271 void operator=(const cellClassification&);
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 } // End namespace Foam
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 // ************************************************************************* //