1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 "triSurfaceGeoMesh.H"
42 #include "triSurfaceFields.H"
43 #include "vectorList.H"
44 #include "pointIndexHit.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 class searchableSurfaces;
55 /*---------------------------------------------------------------------------*\
56 Class refinementSurfaces Declaration
57 \*---------------------------------------------------------------------------*/
59 class refinementSurfaces
63 //- Reference to all geometry.
64 const searchableSurfaces& allGeometry_;
66 //- Indices of surfaces that are refinement ones
69 //- Surface name (word)
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.
83 //- From local region number to global region number
84 labelList regionOffset_;
86 //- From global region number to refinement level
89 //- From global region number to refinement level
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&);
109 //- Construct from surfaces and dictionaries
112 const searchableSurfaces& allGeometry,
113 const PtrList<dictionary>&
116 //- Construct from surfaces and dictionary
119 const searchableSurfaces& allGeometry,
128 const searchableSurfaces& geometry() const
133 const labelList& surfaces() const
138 //- Names of surfaces
139 const wordList& names() const
144 //- Per 'interface' surface : name of faceZone to put faces into
145 const wordList& faceZoneNames() const
147 return faceZoneNames_;
150 //- Per 'interface' surface : name of cellZone to put cells into
151 const wordList& cellZoneNames() const
153 return cellZoneNames_;
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
168 return regionOffset_;
171 //- From global region number to refinement level
172 const labelList& minLevel() const
177 //- From global region number to refinement level
178 const labelList& maxLevel() const
183 //- From global region number to perpendicular angle
184 const scalarField& perpendicularAngle() const
186 return perpendicularAngle_;
192 //- From surface and region on surface to global region
193 label globalRegion(const label surfI, const label regionI) const
195 return regionOffset_[surfI]+regionI;
198 //- Min level for surface and region on surface
199 label minLevel(const label surfI, const label regionI) const
201 return minLevel_[globalRegion(surfI, regionI)];
204 //- Max level for surface and region on surface
205 label maxLevel(const label surfI, const label regionI) const
207 return maxLevel_[globalRegion(surfI, regionI)];
210 label nRegions() const
212 return minLevel_.size();
215 //- Calculate minLevelFields
216 void setMinLevelFields
218 const shellSurfaces& shells
221 //- Helper: count number of triangles per region
222 static labelList countRegions(const triSurface&);
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
232 const pointField& start,
233 const pointField& end,
234 const labelList& currentLevel, // current cell refinement level
237 labelList& surfaceLevel
240 //- Find all intersections of edge. Unsorted order.
241 void findAllHigherIntersections
243 const pointField& start,
244 const pointField& end,
245 const labelList& currentLevel, // current cell refinement level
247 List<vectorList>& surfaceNormal,
248 labelListList& surfaceLevel
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
257 const labelList& surfacesToTest,
258 const pointField& start,
259 const pointField& end,
262 List<pointIndexHit>& hit1,
265 List<pointIndexHit>& hit2,
269 //- Used for debugging only: find intersection of edge.
270 void findAnyIntersection
272 const pointField& start,
273 const pointField& end,
278 //- Find nearest point on surfaces.
281 const labelList& surfacesToTest,
282 const pointField& samples,
283 const scalarField& nearestDistSqr,
288 //- Find nearest point on surfaces. Return surface and region on
289 // surface (so not global surface)
290 void findNearestRegion
292 const labelList& surfacesToTest,
293 const pointField& samples,
294 const scalarField& nearestDistSqr,
295 labelList& hitSurface,
299 //- Detect if a point is 'inside' (closed) surfaces.
300 // Returns -1 if not, returns first surface it is.
303 const labelList& surfacesToTest,
304 const pointField& pt,
305 labelList& insideSurfaces
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 } // End namespace Foam
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 // ************************************************************************* //