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::refinementSurfaces
29 Container for data on surfaces used for surface-driven refinement.
30 Contains all the data about the level of refinement needed per
36 \*---------------------------------------------------------------------------*/
38 #ifndef refinementSurfaces_H
39 #define refinementSurfaces_H
41 #include "PackedList.H"
42 #include "triSurfaceGeoMesh.H"
43 #include "triSurfaceFields.H"
44 #include "vectorList.H"
45 #include "pointIndexHit.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 class searchableSurfaces;
56 /*---------------------------------------------------------------------------*\
57 Class refinementSurfaces Declaration
58 \*---------------------------------------------------------------------------*/
60 class refinementSurfaces
64 //- Reference to all geometry.
65 const searchableSurfaces& allGeometry_;
67 //- Indices of surfaces that are refinement ones
70 //- Surface name (word)
73 //- Per 'interface' surface : name of faceZone to put faces into
74 wordList faceZoneNames_;
76 //- Per 'interface' surface : name of cellZone to put cells into
77 wordList cellZoneNames_;
79 //- Per 'interface' surface : (only used if surface is closed)
80 // whether to zone cells inside or outside surface.
84 //- From local region number to global region number
85 labelList regionOffset_;
87 //- From global region number to refinement level
90 //- From global region number to refinement level
93 //- Per surface refinement level adapted for shells.
94 PtrList<triSurfaceLabelField> minLevelFields_;
97 // Private Member Functions
99 //- Disallow default bitwise copy construct
100 refinementSurfaces(const refinementSurfaces&);
102 //- Disallow default bitwise assignment
103 void operator=(const refinementSurfaces&);
110 //- Construct from surfaces and dictionaries
113 const searchableSurfaces& allGeometry,
114 const PtrList<dictionary>&
117 //- Construct from surfaces and dictionary
120 const searchableSurfaces& allGeometry,
129 const searchableSurfaces& geometry() const
134 const labelList& surfaces() const
139 //- Names of surfaces
140 const wordList& names() const
145 //- Per 'interface' surface : name of faceZone to put faces into
146 const wordList& faceZoneNames() const
148 return faceZoneNames_;
151 //- Per 'interface' surface : name of cellZone to put cells into
152 const wordList& cellZoneNames() const
154 return cellZoneNames_;
157 //- Get indices of named surfaces (surfaces with cellZoneName)
158 labelList getNamedSurfaces() const;
160 //- Get indices of closed named surfaces
161 labelList getClosedNamedSurfaces() const;
163 //- From local region number to global region number
164 const labelList& regionOffset() const
166 return regionOffset_;
169 //- From global region number to refinement level
170 const labelList& minLevel() const
175 //- From global region number to refinement level
176 const labelList& maxLevel() const
184 //- From surface and region on surface to global region
185 label globalRegion(const label surfI, const label regionI) const
187 return regionOffset_[surfI]+regionI;
190 //- Min level for surface and region on surface
191 label minLevel(const label surfI, const label regionI) const
193 return minLevel_[globalRegion(surfI, regionI)];
196 //- Max level for surface and region on surface
197 label maxLevel(const label surfI, const label regionI) const
199 return maxLevel_[globalRegion(surfI, regionI)];
202 label nRegions() const
204 return minLevel_.size();
207 //- Calculate minLevelFields
208 void setMinLevelFields
210 const shellSurfaces& shells
213 //- Helper: orient (closed only) surfaces so keepPoint is outside.
214 static void orientSurface
216 const point& keepPoint,
217 triSurfaceMesh& surface
220 //- Helper: count number of triangles per region
221 static labelList countRegions(const triSurface&);
226 //- Find intersection of edge. Return -1 or first surface
227 // with higher (than currentLevel) minlevel.
228 // Return surface number and level.
229 void findHigherIntersection
231 const pointField& start,
232 const pointField& end,
233 const labelList& currentLevel, // current cell refinement level
236 labelList& surfaceLevel
239 //- Find all intersections of edge. Unsorted order.
240 void findAllHigherIntersections
242 const pointField& start,
243 const pointField& end,
244 const labelList& currentLevel, // current cell refinement level
246 List<vectorList>& surfaceNormal,
247 labelListList& surfaceLevel
250 //- Find intersection nearest to the endpoints. surface1,2 are
251 // not indices into surfacesToTest but refinement surface indices.
252 void findNearestIntersection
254 const labelList& surfacesToTest,
255 const pointField& start,
256 const pointField& end,
259 List<pointIndexHit>& hit1,
262 List<pointIndexHit>& hit2,
266 //- Used for debugging only: find intersection of edge.
267 void findAnyIntersection
269 const pointField& start,
270 const pointField& end,
275 //- Find nearest point on surfaces.
278 const labelList& surfacesToTest,
279 const pointField& samples,
280 const scalarField& nearestDistSqr,
285 //- Detect if a point is 'inside' (closed) surfaces.
286 // Returns -1 if not, returns first surface it is.
289 const labelList& surfacesToTest,
290 const pointField& pt,
291 labelList& insideSurfaces
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 } // End namespace Foam
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 // ************************************************************************* //