initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / autoMesh / autoHexMesh / refinementSurfaces / refinementSurfaces.H
blobedb613d966f11b8b62ab55de4c83765b9ab55bd9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::refinementSurfaces
28 Description
29     Container for data on surfaces used for surface-driven refinement.
30     Contains all the data about the level of refinement needed per
31     surface.
33 SourceFiles
34     refinementSurfaces.C
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 class searchableSurfaces;
53 class shellSurfaces;
54 class triSurfaceMesh;
56 /*---------------------------------------------------------------------------*\
57                            Class refinementSurfaces Declaration
58 \*---------------------------------------------------------------------------*/
60 class refinementSurfaces
62     // Private data
64         //- Reference to all geometry.
65         const searchableSurfaces& allGeometry_;
67         //- Indices of surfaces that are refinement ones
68         labelList surfaces_;
70         //- Surface name (word)
71         wordList names_;
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.
81         boolList zoneInside_;
84         //- From local region number to global region number
85         labelList regionOffset_;
87         //- From global region number to refinement level
88         labelList minLevel_;
90         //- From global region number to refinement level
91         labelList maxLevel_;
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&);
106 public:
108     // Constructors
110         //- Construct from surfaces and dictionaries
111         refinementSurfaces
112         (
113             const searchableSurfaces& allGeometry,
114             const PtrList<dictionary>&
115         );
117         //- Construct from surfaces and dictionary
118         refinementSurfaces
119         (
120             const searchableSurfaces& allGeometry,
121             const dictionary&
122         );
125     // Member Functions
127         // Access
129             const searchableSurfaces& geometry() const
130             {
131                 return allGeometry_;
132             }
134             const labelList& surfaces() const
135             {
136                 return surfaces_;
137             }
139             //- Names of surfaces
140             const wordList& names() const
141             {
142                 return names_;
143             }
145             //- Per 'interface' surface : name of faceZone to put faces into
146             const wordList& faceZoneNames() const
147             {
148                 return faceZoneNames_;
149             }
151             //- Per 'interface' surface : name of cellZone to put cells into
152             const wordList& cellZoneNames() const
153             {
154                 return cellZoneNames_;
155             }
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
165             {
166                 return regionOffset_;
167             }
169             //- From global region number to refinement level
170             const labelList& minLevel() const
171             {
172                 return minLevel_;
173             }
175             //- From global region number to refinement level
176             const labelList& maxLevel() const
177             {
178                 return maxLevel_;
179             }
182         // Helper
184             //- From surface and region on surface to global region
185             label globalRegion(const label surfI, const label regionI) const
186             {
187                 return regionOffset_[surfI]+regionI;
188             }
190             //- Min level for surface and region on surface
191             label minLevel(const label surfI, const label regionI) const
192             {
193                 return minLevel_[globalRegion(surfI, regionI)];
194             }
196             //- Max level for surface and region on surface
197             label maxLevel(const label surfI, const label regionI) const
198             {
199                 return maxLevel_[globalRegion(surfI, regionI)];
200             }
202             label nRegions() const
203             {
204                 return minLevel_.size();
205             }
207             //- Calculate minLevelFields
208             void setMinLevelFields
209             (
210                 const shellSurfaces& shells
211             );
213             //- Helper: orient (closed only) surfaces so keepPoint is outside.
214             static void orientSurface
215             (
216                 const point& keepPoint,
217                 triSurfaceMesh& surface
218             );
220             //- Helper: count number of triangles per region
221             static labelList countRegions(const triSurface&);
224         // Searching
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
230             (
231                 const pointField& start,
232                 const pointField& end,
233                 const labelList& currentLevel,  // current cell refinement level
235                 labelList& surfaces,
236                 labelList& surfaceLevel
237             ) const;
239             //- Find all intersections of edge. Unsorted order.
240             void findAllHigherIntersections
241             (
242                 const pointField& start,
243                 const pointField& end,
244                 const labelList& currentLevel,  // current cell refinement level
246                 List<vectorList>& surfaceNormal,
247                 labelListList& surfaceLevel
248             ) const;
250             //- Find intersection nearest to the endpoints. surface1,2 are
251             //  not indices into surfacesToTest but refinement surface indices.
252             void findNearestIntersection
253             (
254                 const labelList& surfacesToTest,
255                 const pointField& start,
256                 const pointField& end,
258                 labelList& surface1,
259                 List<pointIndexHit>& hit1,
260                 labelList& region1,
261                 labelList& surface2,
262                 List<pointIndexHit>& hit2,
263                 labelList& region2
264             ) const;
266             //- Used for debugging only: find intersection of edge.
267             void findAnyIntersection
268             (
269                 const pointField& start,
270                 const pointField& end,
271                 labelList& surfaces,
272                 List<pointIndexHit>&
273             ) const;
275             //- Find nearest point on surfaces.
276             void findNearest
277             (
278                 const labelList& surfacesToTest,
279                 const pointField& samples,
280                 const scalarField& nearestDistSqr,
281                 labelList& surfaces,
282                 List<pointIndexHit>&
283             ) const;
285             //- Detect if a point is 'inside' (closed) surfaces.
286             //  Returns -1 if not, returns first surface it is.
287             void findInside
288             (
289                 const labelList& surfacesToTest,
290                 const pointField& pt,
291                 labelList& insideSurfaces
292             ) const;
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 } // End namespace Foam
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 #endif
304 // ************************************************************************* //