initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / autoMesh / autoHexMesh / refinementSurfaces / refinementSurfaces.H
blobcee48bbe1f5effc3ed9cc0f6ad59193c87dce62e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 "triSurfaceGeoMesh.H"
42 #include "triSurfaceFields.H"
43 #include "vectorList.H"
44 #include "pointIndexHit.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 class searchableSurfaces;
52 class shellSurfaces;
53 class triSurfaceMesh;
55 /*---------------------------------------------------------------------------*\
56                            Class refinementSurfaces Declaration
57 \*---------------------------------------------------------------------------*/
59 class refinementSurfaces
61     // Private data
63         //- Reference to all geometry.
64         const searchableSurfaces& allGeometry_;
66         //- Indices of surfaces that are refinement ones
67         labelList surfaces_;
69         //- Surface name (word)
70         wordList names_;
72         //- Per 'interface' surface : name of faceZone to put faces into
73         wordList faceZoneNames_;
75         //- Per 'interface' surface : name of cellZone to put cells into
76         wordList cellZoneNames_;
78         //- Per 'interface' surface : (only used if surface is closed)
79         //  whether to zone cells inside or outside surface.
80         boolList zoneInside_;
83         //- From local region number to global region number
84         labelList regionOffset_;
86         //- From global region number to refinement level
87         labelList minLevel_;
89         //- From global region number to refinement level
90         labelList maxLevel_;
92         //- From global region number to perpendicular angle
93         scalarField perpendicularAngle_;
96     // Private Member Functions
98         //- Disallow default bitwise copy construct
99         refinementSurfaces(const refinementSurfaces&);
101         //- Disallow default bitwise assignment
102         void operator=(const refinementSurfaces&);
105 public:
107     // Constructors
109         //- Construct from surfaces and dictionaries
110         refinementSurfaces
111         (
112             const searchableSurfaces& allGeometry,
113             const PtrList<dictionary>&
114         );
116         //- Construct from surfaces and dictionary
117         refinementSurfaces
118         (
119             const searchableSurfaces& allGeometry,
120             const dictionary&
121         );
124     // Member Functions
126         // Access
128             const searchableSurfaces& geometry() const
129             {
130                 return allGeometry_;
131             }
133             const labelList& surfaces() const
134             {
135                 return surfaces_;
136             }
138             //- Names of surfaces
139             const wordList& names() const
140             {
141                 return names_;
142             }
144             //- Per 'interface' surface : name of faceZone to put faces into
145             const wordList& faceZoneNames() const
146             {
147                 return faceZoneNames_;
148             }
150             //- Per 'interface' surface : name of cellZone to put cells into
151             const wordList& cellZoneNames() const
152             {
153                 return cellZoneNames_;
154             }
156             //- Get indices of unnamed surfaces (surfaces without faceZoneName)
157             labelList getUnnamedSurfaces() const;
159             //- Get indices of named surfaces (surfaces with faceZoneName)
160             labelList getNamedSurfaces() const;
162             //- Get indices of closed named surfaces
163             labelList getClosedNamedSurfaces() const;
165             //- From local region number to global region number
166             const labelList& regionOffset() const
167             {
168                 return regionOffset_;
169             }
171             //- From global region number to refinement level
172             const labelList& minLevel() const
173             {
174                 return minLevel_;
175             }
177             //- From global region number to refinement level
178             const labelList& maxLevel() const
179             {
180                 return maxLevel_;
181             }
183             //- From global region number to perpendicular angle
184             const scalarField& perpendicularAngle() const
185             {
186                 return perpendicularAngle_;
187             }
190         // Helper
192             //- From surface and region on surface to global region
193             label globalRegion(const label surfI, const label regionI) const
194             {
195                 return regionOffset_[surfI]+regionI;
196             }
198             //- Min level for surface and region on surface
199             label minLevel(const label surfI, const label regionI) const
200             {
201                 return minLevel_[globalRegion(surfI, regionI)];
202             }
204             //- Max level for surface and region on surface
205             label maxLevel(const label surfI, const label regionI) const
206             {
207                 return maxLevel_[globalRegion(surfI, regionI)];
208             }
210             label nRegions() const
211             {
212                 return minLevel_.size();
213             }
215             //- Calculate minLevelFields
216             void setMinLevelFields
217             (
218                 const shellSurfaces& shells
219             );
221             //- Helper: count number of triangles per region
222             static labelList countRegions(const triSurface&);
225         // Searching
227             //- Find intersection of edge. Return -1 or first surface
228             //  with higher (than currentLevel) minlevel.
229             //  Return surface number and level.
230             void findHigherIntersection
231             (
232                 const pointField& start,
233                 const pointField& end,
234                 const labelList& currentLevel,  // current cell refinement level
236                 labelList& surfaces,
237                 labelList& surfaceLevel
238             ) const;
240             //- Find all intersections of edge. Unsorted order.
241             void findAllHigherIntersections
242             (
243                 const pointField& start,
244                 const pointField& end,
245                 const labelList& currentLevel,  // current cell refinement level
247                 List<vectorList>& surfaceNormal,
248                 labelListList& surfaceLevel
249             ) const;
251             //- Find intersection nearest to the endpoints. surface1,2 are
252             //  not indices into surfacesToTest but refinement surface indices.
253             //  Returns surface, region on surface (so not global surface)
254             //  and position on surface.
255             void findNearestIntersection
256             (
257                 const labelList& surfacesToTest,
258                 const pointField& start,
259                 const pointField& end,
261                 labelList& surface1,
262                 List<pointIndexHit>& hit1,
263                 labelList& region1,
264                 labelList& surface2,
265                 List<pointIndexHit>& hit2,
266                 labelList& region2
267             ) const;
269             //- Used for debugging only: find intersection of edge.
270             void findAnyIntersection
271             (
272                 const pointField& start,
273                 const pointField& end,
274                 labelList& surfaces,
275                 List<pointIndexHit>&
276             ) const;
278             //- Find nearest point on surfaces.
279             void findNearest
280             (
281                 const labelList& surfacesToTest,
282                 const pointField& samples,
283                 const scalarField& nearestDistSqr,
284                 labelList& surfaces,
285                 List<pointIndexHit>&
286             ) const;
288             //- Find nearest point on surfaces. Return surface and region on
289             //  surface (so not global surface)
290             void findNearestRegion
291             (
292                 const labelList& surfacesToTest,
293                 const pointField& samples,
294                 const  scalarField& nearestDistSqr,
295                 labelList& hitSurface,
296                 labelList& hitRegion
297             ) const;
299             //- Detect if a point is 'inside' (closed) surfaces.
300             //  Returns -1 if not, returns first surface it is.
301             void findInside
302             (
303                 const labelList& surfacesToTest,
304                 const pointField& pt,
305                 labelList& insideSurfaces
306             ) const;
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 } // End namespace Foam
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316 #endif
318 // ************************************************************************* //