FreeFOAM The Cross-Platform CFD Toolkit
refinementSurfaces.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::refinementSurfaces
26 
27 Description
28  Container for data on surfaces used for surface-driven refinement.
29  Contains all the data about the level of refinement needed per
30  surface.
31 
32 SourceFiles
33  refinementSurfaces.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef refinementSurfaces_H
38 #define refinementSurfaces_H
39 
42 #include <OpenFOAM/vectorList.H>
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 class searchableSurfaces;
51 class shellSurfaces;
52 class triSurfaceMesh;
53 
54 /*---------------------------------------------------------------------------*\
55  Class refinementSurfaces Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 {
60  // Private data
61 
62  //- Reference to all geometry.
63  const searchableSurfaces& allGeometry_;
64 
65  //- Indices of surfaces that are refinement ones
66  labelList surfaces_;
67 
68  //- Surface name (word)
69  wordList names_;
70 
71  //- Per 'interface' surface : name of faceZone to put faces into
72  wordList faceZoneNames_;
73 
74  //- Per 'interface' surface : name of cellZone to put cells into
75  wordList cellZoneNames_;
76 
77  //- Per 'interface' surface : (only used if surface is closed)
78  // whether to zone cells inside or outside surface.
79  boolList zoneInside_;
80 
81 
82  //- From local region number to global region number
83  labelList regionOffset_;
84 
85  //- From global region number to refinement level
86  labelList minLevel_;
87 
88  //- From global region number to refinement level
89  labelList maxLevel_;
90 
91  //- From global region number to perpendicular angle
92  scalarField perpendicularAngle_;
93 
94 
95  // Private Member Functions
96 
97  //- Disallow default bitwise copy construct
99 
100  //- Disallow default bitwise assignment
101  void operator=(const refinementSurfaces&);
102 
103 
104 public:
105 
106  // Constructors
107 
108  //- Construct from surfaces and dictionaries
110  (
111  const searchableSurfaces& allGeometry,
112  const PtrList<dictionary>&
113  );
114 
115  //- Construct from surfaces and dictionary
117  (
118  const searchableSurfaces& allGeometry,
119  const dictionary&
120  );
121 
122 
123  // Member Functions
124 
125  // Access
126 
128  {
129  return allGeometry_;
130  }
131 
132  const labelList& surfaces() const
133  {
134  return surfaces_;
135  }
136 
137  //- Names of surfaces
138  const wordList& names() const
139  {
140  return names_;
141  }
142 
143  //- Per 'interface' surface : name of faceZone to put faces into
144  const wordList& faceZoneNames() const
145  {
146  return faceZoneNames_;
147  }
148 
149  //- Per 'interface' surface : name of cellZone to put cells into
150  const wordList& cellZoneNames() const
151  {
152  return cellZoneNames_;
153  }
154 
155  //- Get indices of unnamed surfaces (surfaces without faceZoneName)
157 
158  //- Get indices of named surfaces (surfaces with faceZoneName)
159  labelList getNamedSurfaces() const;
160 
161  //- Get indices of closed named surfaces
163 
164  //- From local region number to global region number
165  const labelList& regionOffset() const
166  {
167  return regionOffset_;
168  }
169 
170  //- From global region number to refinement level
171  const labelList& minLevel() const
172  {
173  return minLevel_;
174  }
175 
176  //- From global region number to refinement level
177  const labelList& maxLevel() const
178  {
179  return maxLevel_;
180  }
181 
182  //- From global region number to perpendicular angle
184  {
185  return perpendicularAngle_;
186  }
187 
188 
189  // Helper
190 
191  //- From surface and region on surface to global region
192  label globalRegion(const label surfI, const label regionI) const
193  {
194  return regionOffset_[surfI]+regionI;
195  }
196 
197  //- Min level for surface and region on surface
198  label minLevel(const label surfI, const label regionI) const
199  {
200  return minLevel_[globalRegion(surfI, regionI)];
201  }
202 
203  //- Max level for surface and region on surface
204  label maxLevel(const label surfI, const label regionI) const
205  {
206  return maxLevel_[globalRegion(surfI, regionI)];
207  }
208 
209  label nRegions() const
210  {
211  return minLevel_.size();
212  }
213 
214  //- Calculate minLevelFields
215  void setMinLevelFields
216  (
217  const shellSurfaces& shells
218  );
219 
221  //static labelList countRegions(const triSurface&);
222 
223 
224  // Searching
225 
226  //- Find intersection of edge. Return -1 or first surface
227  // with higher (than currentLevel) minlevel.
228  // Return surface number and level.
230  (
231  const pointField& start,
232  const pointField& end,
233  const labelList& currentLevel, // current cell refinement level
234 
236  labelList& surfaceLevel
237  ) const;
238 
239  //- Find all intersections of edge. Unsorted order.
241  (
242  const pointField& start,
243  const pointField& end,
244  const labelList& currentLevel, // current cell refinement level
245 
246  List<vectorList>& surfaceNormal,
247  labelListList& surfaceLevel
248  ) const;
249 
250  //- Find intersection nearest to the endpoints. surface1,2 are
251  // not indices into surfacesToTest but refinement surface indices.
252  // Returns surface, region on surface (so not global surface)
253  // and position on surface.
255  (
256  const labelList& surfacesToTest,
257  const pointField& start,
258  const pointField& end,
259 
260  labelList& surface1,
261  List<pointIndexHit>& hit1,
262  labelList& region1,
263  labelList& surface2,
264  List<pointIndexHit>& hit2,
265  labelList& region2
266  ) const;
267 
268  //- Used for debugging only: find intersection of edge.
270  (
271  const pointField& start,
272  const pointField& end,
275  ) const;
276 
277  //- Find nearest point on surfaces.
278  void findNearest
279  (
280  const labelList& surfacesToTest,
281  const pointField& samples,
282  const scalarField& nearestDistSqr,
285  ) const;
286 
287  //- Find nearest point on surfaces. Return surface and region on
288  // surface (so not global surface)
289  void findNearestRegion
290  (
291  const labelList& surfacesToTest,
292  const pointField& samples,
293  const scalarField& nearestDistSqr,
294  labelList& hitSurface,
295  labelList& hitRegion
296  ) const;
297 
298  //- Detect if a point is 'inside' (closed) surfaces.
299  // Returns -1 if not, returns first surface it is.
300  void findInside
301  (
302  const labelList& surfacesToTest,
303  const pointField& pt,
304  labelList& insideSurfaces
305  ) const;
306 };
307 
308 
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 
311 } // End namespace Foam
312 
313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
314 
315 #endif
316 
317 // ************************ vim: set sw=4 sts=4 et: ************************ //