1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::cellClassification
29 'Cuts' a mesh with a surface.
31 Divides cells into three types
32 - cut, i.e. any of the edges of the cell is split or any edge of the
33 surface pierces any of the faces of the cell.
34 - outside: cell can be reached by Meshwave from any of the supplied
35 outside points (without crossing any cut cell)
38 Used in various meshing programs.
40 Has various utility functions to deal with 'features' on this level
41 where the mesh still has all inside and outside cells.
45 - point classification:
46 - point used by meshType cells only
47 - point used by non-meshType cells only
48 - point used by both types ('mixed')
50 - hanging cells: meshType cells using mixed points only.
51 These cells would have all their vertices on the surface when
52 extracting the meshType cells.
54 - regionEdges: edges where the cells using it are of mixed type.
55 Or more precise when walking around the edge and looking at the
56 different types of the cells there are more than two regions with
76 because this latter situation would cause the surface after subsetting
77 type A or B to be multiply connected across this edge. And also when
78 snapping the edge end points to the surface it might cause some twisted
79 faces if the surface is normal to the edge (and smoothing the surface
80 would not help since the points on the edge would be 'pulled' from two
83 - regionPoints: like regionEdges but now for points.
84 Points where subsetting the mesh would cause a multiply connected
85 outside surface (connected across point, not edge)
91 \*---------------------------------------------------------------------------*/
93 #ifndef cellClassification_H
94 #define cellClassification_H
96 #include "pointField.H"
99 #include "labelList.H"
100 #include "faceList.H"
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 // Forward declaration of classes
108 class triSurfaceSearch;
115 /*---------------------------------------------------------------------------*\
116 Class cellClassification Declaration
117 \*---------------------------------------------------------------------------*/
119 class cellClassification
132 INSIDE, // Inside of surface
133 OUTSIDE, // Outside ,,
134 CUT // cut by surface
138 //- Enumeration defining the whether points are use by cells of
143 MESH, // points used by meshType cells
144 NONMESH, // ,, non-mesh type cells
145 MIXED // ,, both types of cell
152 //- Reference to mesh
153 const polyMesh& mesh_;
156 // Private Static Functions
158 //- Count number of occurrences of elem in list
159 static label count(const labelList& elems, const label elem);
161 // Private Member Functions
163 //- Mark all faces intersected by or intersecting surface
164 boolList markFaces(const triSurfaceSearch&) const;
166 //- Divide cells into cut/inside/outside by using MeshWave from cut
167 // faces. No check is done on whether outsidePts are in different
171 const meshSearch& queryMesh,
172 const boolList& piercedFace,
173 const pointField& outsidePts
176 //- Use cell status to classify points as being internal to meshType,
177 // internal to non-meshType or on border of both.
180 const label meshType,
181 const labelList& cellType,
182 List<pointStatus>& pointSide
185 //- Return true if cell uses only points with status=mixed
186 bool usesMixedPointsOnly
188 const List<pointStatus>&,
192 //- Get faces (and its 'owner') inbetween cells of differing type
193 // (meshType and non-meshType).
194 void getMeshOutside(const label meshType, faceList&, labelList&) const;
198 // Static data members
199 ClassName("cellClassification");
203 //- Construct from mesh and surface and point(s) on outside
206 const polyMesh& mesh,
207 const meshSearch& meshQuery,
208 const triSurfaceSearch& surfQuery,
209 const pointField& outsidePoints
212 //- Construct from mesh and type for every cell.
213 // Used to be able to reuse filling routines below.
214 cellClassification(const polyMesh& mesh, const labelList& cellType);
216 //- Construct as copy
217 cellClassification(const cellClassification&);
222 const polyMesh& mesh() const
230 const label meshType,
234 //- Sets vertex neighbours of meshType cells to fillType
235 label growSurface(const label meshType, const label fillType);
237 //- Find hanging cells (cells with all points on outside) and set their
239 // Iterate until nothing changed. Returns total number of cells
240 // changed (in all iterations)
241 label fillHangingCells
243 const label meshType,
244 const label fillType,
248 //- Find regionEdges and fill one neighbour. Iterate until nothing
249 // changes. Returns total number of cells changed.
250 label fillRegionEdges
252 const label meshType,
253 const label fillType,
257 //- Find regionPoints and fill all neighbours. Iterate until nothing
258 // changes. Returns total number of cells changed.
259 label fillRegionPoints
261 const label meshType,
262 const label fillType,
266 //- Write statistics on cell types to Ostream
267 void writeStats(Ostream& os) const;
272 void operator=(const cellClassification&);
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 } // End namespace Foam
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 // ************************************************************************* //