1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Foam::refinementSurfaces
28 Container for data on surfaces used for surface-driven refinement.
29 Contains all the data about the level of refinement needed per
35 \*---------------------------------------------------------------------------*/
37 #ifndef refinementSurfaces_H
38 #define refinementSurfaces_H
40 #include "triSurfaceGeoMesh.H"
41 #include "triSurfaceFields.H"
42 #include "vectorList.H"
43 #include "pointIndexHit.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 class searchableSurfaces;
54 /*---------------------------------------------------------------------------*\
55 Class refinementSurfaces Declaration
56 \*---------------------------------------------------------------------------*/
58 class refinementSurfaces
62 //- Types of selection of area
63 enum areaSelectionAlgo
71 static const NamedEnum<areaSelectionAlgo, 4> areaSelectionAlgoNames;
77 //- Reference to all geometry.
78 const searchableSurfaces& allGeometry_;
80 //- Indices of surfaces that are refinement ones
83 //- Surface name (word)
86 //- Per 'interface' surface : name of faceZone to put faces into
87 wordList faceZoneNames_;
89 //- Per 'interface' surface : name of cellZone to put cells into
90 wordList cellZoneNames_;
92 //- Per 'interface' surface : (only used if surface is closed)
93 // How to select zone cells : surface inside or outside or given
95 List<areaSelectionAlgo> zoneInside_;
97 //- If zoneInside=location gives the corresponding inside point
98 pointField zoneInsidePoints_;
100 //- From local region number to global region number
101 labelList regionOffset_;
103 //- From global region number to refinement level
106 //- From global region number to refinement level
109 //- From global region number to perpendicular angle
110 scalarField perpendicularAngle_;
112 //- From global region number to patchType
113 PtrList<dictionary> patchInfo_;
116 // Private Member Functions
118 //- Disallow default bitwise copy construct
119 refinementSurfaces(const refinementSurfaces&);
121 //- Disallow default bitwise assignment
122 void operator=(const refinementSurfaces&);
129 //- Construct from surfaces and dictionary
132 const searchableSurfaces& allGeometry,
141 const searchableSurfaces& geometry() const
146 const labelList& surfaces() const
151 //- Names of surfaces
152 const wordList& names() const
157 //- Per 'interface' surface : name of faceZone to put faces into
158 const wordList& faceZoneNames() const
160 return faceZoneNames_;
163 //- Per 'interface' surface : empty or name of cellZone to put
165 const wordList& cellZoneNames() const
167 return cellZoneNames_;
170 //- Get indices of unnamed surfaces (surfaces without faceZoneName)
171 labelList getUnnamedSurfaces() const;
173 //- Get indices of named surfaces (surfaces with faceZoneName)
174 labelList getNamedSurfaces() const;
176 //- Get indices of surfaces with a cellZone that are closed and
177 // have 'inside' or 'outside' selection.
178 labelList getClosedNamedSurfaces() const;
180 //- Get indices of surfaces with a cellZone that have 'insidePoint'
182 labelList getInsidePointNamedSurfaces() const;
184 //- Get specified inside locations for surfaces with a cellZone
185 const pointField& zoneInsidePoints() const
187 return zoneInsidePoints_;
190 //- From local region number to global region number
191 const labelList& regionOffset() const
193 return regionOffset_;
196 //- From global region number to refinement level
197 const labelList& minLevel() const
202 //- From global region number to refinement level
203 const labelList& maxLevel() const
208 //- From global region number to perpendicular angle
209 const scalarField& perpendicularAngle() const
211 return perpendicularAngle_;
214 //- From global region number to patch type
215 const PtrList<dictionary>& patchInfo() const
223 //- From surface and region on surface to global region
224 label globalRegion(const label surfI, const label regionI) const
226 return regionOffset_[surfI]+regionI;
229 //- Min level for surface and region on surface
230 label minLevel(const label surfI, const label regionI) const
232 return minLevel_[globalRegion(surfI, regionI)];
235 //- Max level for surface and region on surface
236 label maxLevel(const label surfI, const label regionI) const
238 return maxLevel_[globalRegion(surfI, regionI)];
241 label nRegions() const
243 return minLevel_.size();
246 //- Calculate minLevelFields
247 void setMinLevelFields
249 const shellSurfaces& shells
252 ////- Helper: count number of triangles per region
253 //static labelList countRegions(const triSurface&);
258 //- Find intersection of edge. Return -1 or first surface
259 // with higher (than currentLevel) minlevel.
260 // Return surface number and level.
261 void findHigherIntersection
263 const pointField& start,
264 const pointField& end,
265 const labelList& currentLevel, // current cell refinement level
268 labelList& surfaceLevel
271 //- Find all intersections of edge. Unsorted order.
272 void findAllHigherIntersections
274 const pointField& start,
275 const pointField& end,
276 const labelList& currentLevel, // current cell refinement level
278 List<vectorList>& surfaceNormal,
279 labelListList& surfaceLevel
282 //- Find intersection nearest to the endpoints. surface1,2 are
283 // not indices into surfacesToTest but refinement surface indices.
284 // Returns surface, region on surface (so not global surface)
285 // and position on surface.
286 void findNearestIntersection
288 const labelList& surfacesToTest,
289 const pointField& start,
290 const pointField& end,
293 List<pointIndexHit>& hit1,
296 List<pointIndexHit>& hit2,
300 //- Used for debugging only: find intersection of edge.
301 void findAnyIntersection
303 const pointField& start,
304 const pointField& end,
309 //- Find nearest point on surfaces.
312 const labelList& surfacesToTest,
313 const pointField& samples,
314 const scalarField& nearestDistSqr,
319 //- Find nearest point on surfaces. Return surface and region on
320 // surface (so not global surface)
321 void findNearestRegion
323 const labelList& surfacesToTest,
324 const pointField& samples,
325 const scalarField& nearestDistSqr,
326 labelList& hitSurface,
330 //- Find nearest point on surfaces. Return surface, region and
331 // normal on surface (so not global surface)
332 void findNearestRegion
334 const labelList& surfacesToTest,
335 const pointField& samples,
336 const scalarField& nearestDistSqr,
337 labelList& hitSurface,
338 List<pointIndexHit>& hitInfo,
339 labelList& hitRegion,
340 vectorField& hitNormal
343 //- Detect if a point is 'inside' (closed) surfaces.
344 // Returns -1 if not, returns first surface it is.
347 const labelList& surfacesToTest,
348 const pointField& pt,
349 labelList& insideSurfaces
354 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
356 } // End namespace Foam
358 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362 // ************************************************************************* //