All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
refinementSurfaces.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
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 
40 #include "triSurfaceGeoMesh.H"
41 #include "triSurfaceFields.H"
42 #include "vectorList.H"
43 #include "pointIndexHit.H"
44 #include "surfaceZonesInfo.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 class searchableSurfaces;
53 class triSurfaceMesh;
54 
55 typedef List<point> pointList;
56 
57 /*---------------------------------------------------------------------------*\
58  Class refinementSurfaces Declaration
59 \*---------------------------------------------------------------------------*/
60 
62 {
63  // Private Data
64 
65  //- Reference to all geometry.
66  const searchableSurfaces& allGeometry_;
67 
68  //- Indices of surfaces that are refinement ones
69  labelList surfaces_;
70 
71  //- Surface name (word)
72  wordList names_;
73 
74  //- List of surface zone (face and cell zone) information
75  PtrList<surfaceZonesInfo> surfZones_;
76 
77  //- From local region number to global region number
78  labelList regionOffset_;
79 
80  //- From global region number to refinement level
81  labelList minLevel_;
82 
83  //- From global region number to refinement level
84  labelList maxLevel_;
85 
86  //- From global region number to small-gap level
87  labelList gapLevel_;
88 
89  //- From global region number to perpendicular angle
90  scalarField perpendicularAngle_;
91 
92  //- From global region number to patchType
93  PtrList<dictionary> patchInfo_;
94 
95 
96 public:
97 
98  // Constructors
99 
100  //- Construct from surfaces and dictionary
102  (
103  const searchableSurfaces& allGeometry,
104  const dictionary&,
105  const label gapLevelIncrement
106  );
107 
108  //- Construct from components
110  (
111  const searchableSurfaces& allGeometry,
112  const labelList& surfaces,
113  const wordList& names,
115  const labelList& regionOffset,
116  const labelList& minLevel,
117  const labelList& maxLevel,
118  const labelList& gapLevel,
121  );
122 
123  //- Disallow default bitwise copy construction
124  refinementSurfaces(const refinementSurfaces&) = delete;
125 
126 
127  // Member Functions
128 
129  // Access
131  const searchableSurfaces& geometry() const
132  {
133  return allGeometry_;
134  }
136  const labelList& surfaces() const
137  {
138  return surfaces_;
139  }
140 
141  //- Names of surfaces
142  const wordList& names() const
143  {
144  return names_;
145  }
147  const PtrList<surfaceZonesInfo>& surfZones() const
148  {
149  return surfZones_;
150  }
151 
152  //- From local region number to global region number
153  const labelList& regionOffset() const
154  {
155  return regionOffset_;
156  }
157 
158  //- From global region number to refinement level
159  const labelList& minLevel() const
160  {
161  return minLevel_;
162  }
163 
164  //- From global region number to refinement level
165  const labelList& maxLevel() const
166  {
167  return maxLevel_;
168  }
169 
170  //- From global region number to small gap refinement level
171  const labelList& gapLevel() const
172  {
173  return gapLevel_;
174  }
175 
176  //- From global region number to perpendicular angle
177  const scalarField& perpendicularAngle() const
178  {
179  return perpendicularAngle_;
180  }
181 
182  //- From global region number to patch type
183  const PtrList<dictionary>& patchInfo() const
184  {
185  return patchInfo_;
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  }
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 
235  labelList& surfaces,
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  const labelList& globalRegionLevel, // level per surfregion
246 
247  List<vectorList>& surfaceNormal,
248  labelListList& surfaceLevel
249  ) const;
250 
251  //- Find all intersections of edge. Unsorted order.
253  (
254  const pointField& start,
255  const pointField& end,
256  const labelList& currentLevel, // current cell refinement level
257  const labelList& globalRegionLevel, // level per surfregion
258 
260  List<vectorList>& surfaceNormal,
261  labelListList& surfaceLevel
262  ) const;
263 
264  //- Find intersection nearest to the endpoints. surface1,2 are
265  // not indices into surfacesToTest but refinement surface indices.
266  // Returns surface, region on surface (so not global surface)
267  // and position on surface.
269  (
270  const labelList& surfacesToTest,
271  const pointField& start,
272  const pointField& end,
273 
274  labelList& surface1,
275  List<pointIndexHit>& hit1,
276  labelList& region1,
277  labelList& surface2,
278  List<pointIndexHit>& hit2,
279  labelList& region2
280  ) const;
281 
282  //- findNearestIntersection but also get normals
284  (
285  const labelList& surfacesToTest,
286  const pointField& start,
287  const pointField& end,
288 
289  labelList& surface1,
290  List<pointIndexHit>& hit1,
291  labelList& region1,
292  vectorField& normal1,
293 
294  labelList& surface2,
295  List<pointIndexHit>& hit2,
296  labelList& region2,
297  vectorField& normal2
298  ) const;
299 
300  //- Used for debugging only: find intersection of edge.
302  (
303  const pointField& start,
304  const pointField& end,
305  labelList& surfaces,
307  ) const;
308 
309  //- Find nearest point on surfaces.
310  void findNearest
311  (
312  const labelList& surfacesToTest,
313  const pointField& samples,
314  const scalarField& nearestDistSqr,
315  labelList& surfaces,
317  ) const;
318 
319  //- Find nearest point on surfaces. Return surface and region on
320  // surface (so not global surface)
321  void findNearestRegion
322  (
323  const labelList& surfacesToTest,
324  const pointField& samples,
325  const scalarField& nearestDistSqr,
326  labelList& hitSurface,
327  labelList& hitRegion
328  ) const;
329 
330  //- Find nearest point on surfaces. Return surface, region and
331  // normal on surface (so not global surface)
332  void findNearestRegion
333  (
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
341  ) const;
342 
343  //- Detect if a point is 'inside' (closed) surfaces.
344  // Returns -1 if not, returns first surface it is.
345  void findInside
346  (
347  const labelList& surfacesToTest,
348  const pointField& pt,
349  labelList& insideSurfaces
350  ) const;
351 
352 
353  // Member Operators
354 
355  //- Disallow default bitwise assignment
356  void operator=(const refinementSurfaces&) = delete;
357 };
358 
359 
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361 
362 } // End namespace Foam
363 
364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
365 
366 #endif
367 
368 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const labelList & surfaces() const
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
void findAllHigherIntersections(const pointField &start, const pointField &end, const labelList &currentLevel, const labelList &globalRegionLevel, List< vectorList > &surfaceNormal, labelListList &surfaceLevel) const
Find all intersections of edge. Unsorted order.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Fields for triSurface.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Used for debugging only: find intersection of edge.
const labelList & minLevel() const
From global region number to refinement level.
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
IOoject and searching on triSurface.
const searchableSurfaces & geometry() const
scalarField samples(nIntervals, 0)
void findNearestRegion(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &hitSurface, labelList &hitRegion) const
Find nearest point on surfaces. Return surface and region on.
const labelList & gapLevel() const
From global region number to small gap refinement level.
const labelList & regionOffset() const
From local region number to global region number.
Container for searchableSurfaces.
Encapsulates queries for volume refinement (&#39;refine all cells within shell&#39;).
Definition: shellSurfaces.H:53
const PtrList< surfaceZonesInfo > & surfZones() const
const scalarField & perpendicularAngle() const
From global region number to perpendicular angle.
void operator=(const refinementSurfaces &)=delete
Disallow default bitwise assignment.
refinementSurfaces(const searchableSurfaces &allGeometry, const dictionary &, const label gapLevelIncrement)
Construct from surfaces and dictionary.
const wordList & names() const
Names of surfaces.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
label globalRegion(const label surfI, const label regionI) const
From surface and region on surface to global region.
const PtrList< dictionary > & patchInfo() const
From global region number to patch type.
Contains information about location on a triSurface.
List< point > pointList
void findHigherIntersection(const pointField &start, const pointField &end, const labelList &currentLevel, labelList &surfaces, labelList &surfaceLevel) const
Find intersection of edge. Return -1 or first surface.
void findNearestIntersection(const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &region1, labelList &surface2, List< pointIndexHit > &hit2, labelList &region2) const
Find intersection nearest to the endpoints. surface1,2 are.
void setMinLevelFields(const shellSurfaces &shells)
Calculate minLevelFields.
Namespace for OpenFOAM.
const labelList & maxLevel() const
From global region number to refinement level.
void findInside(const labelList &surfacesToTest, const pointField &pt, labelList &insideSurfaces) const
Detect if a point is &#39;inside&#39; (closed) surfaces.