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-2018 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  // Private Member Functions
97 
98  //- Disallow default bitwise copy construct
100 
101  //- Disallow default bitwise assignment
102  void operator=(const refinementSurfaces&);
103 
104 
105 public:
106 
107  // Constructors
108 
109  //- Construct from surfaces and dictionary
111  (
112  const searchableSurfaces& allGeometry,
113  const dictionary&,
114  const label gapLevelIncrement
115  );
116 
117  //- Construct from components
119  (
120  const searchableSurfaces& allGeometry,
121  const labelList& surfaces,
122  const wordList& names,
124  const labelList& regionOffset,
125  const labelList& minLevel,
126  const labelList& maxLevel,
127  const labelList& gapLevel,
130  );
131 
132 
133  // Member Functions
134 
135  // Access
137  const searchableSurfaces& geometry() const
138  {
139  return allGeometry_;
140  }
142  const labelList& surfaces() const
143  {
144  return surfaces_;
145  }
146 
147  //- Names of surfaces
148  const wordList& names() const
149  {
150  return names_;
151  }
153  const PtrList<surfaceZonesInfo>& surfZones() const
154  {
155  return surfZones_;
156  }
157 
158  //- From local region number to global region number
159  const labelList& regionOffset() const
160  {
161  return regionOffset_;
162  }
163 
164  //- From global region number to refinement level
165  const labelList& minLevel() const
166  {
167  return minLevel_;
168  }
169 
170  //- From global region number to refinement level
171  const labelList& maxLevel() const
172  {
173  return maxLevel_;
174  }
175 
176  //- From global region number to small gap refinement level
177  const labelList& gapLevel() const
178  {
179  return gapLevel_;
180  }
181 
182  //- From global region number to perpendicular angle
183  const scalarField& perpendicularAngle() const
184  {
185  return perpendicularAngle_;
186  }
187 
188  //- From global region number to patch type
189  const PtrList<dictionary>& patchInfo() const
190  {
191  return patchInfo_;
192  }
193 
194 
195  // Helper
196 
197  //- From surface and region on surface to global region
198  label globalRegion(const label surfI, const label regionI) const
199  {
200  return regionOffset_[surfI]+regionI;
201  }
202 
203  //- Min level for surface and region on surface
204  label minLevel(const label surfI, const label regionI) const
205  {
206  return minLevel_[globalRegion(surfI, regionI)];
207  }
208 
209  //- Max level for surface and region on surface
210  label maxLevel(const label surfI, const label regionI) const
211  {
212  return maxLevel_[globalRegion(surfI, regionI)];
213  }
215  label nRegions() const
216  {
217  return minLevel_.size();
218  }
219 
220  //- Calculate minLevelFields
221  void setMinLevelFields
222  (
223  const shellSurfaces& shells
224  );
225 
227  // static labelList countRegions(const triSurface&);
228 
229 
230  // Searching
231 
232  //- Find intersection of edge. Return -1 or first surface
233  // with higher (than currentLevel) minlevel.
234  // Return surface number and level.
236  (
237  const pointField& start,
238  const pointField& end,
239  const labelList& currentLevel, // current cell refinement level
240 
241  labelList& surfaces,
242  labelList& surfaceLevel
243  ) const;
244 
245  //- Find all intersections of edge. Unsorted order.
247  (
248  const pointField& start,
249  const pointField& end,
250  const labelList& currentLevel, // current cell refinement level
251  const labelList& globalRegionLevel, // level per surfregion
252 
253  List<vectorList>& surfaceNormal,
254  labelListList& surfaceLevel
255  ) const;
256 
257  //- Find all intersections of edge. Unsorted order.
259  (
260  const pointField& start,
261  const pointField& end,
262  const labelList& currentLevel, // current cell refinement level
263  const labelList& globalRegionLevel, // level per surfregion
264 
266  List<vectorList>& surfaceNormal,
267  labelListList& surfaceLevel
268  ) const;
269 
270  //- Find intersection nearest to the endpoints. surface1,2 are
271  // not indices into surfacesToTest but refinement surface indices.
272  // Returns surface, region on surface (so not global surface)
273  // and position on surface.
275  (
276  const labelList& surfacesToTest,
277  const pointField& start,
278  const pointField& end,
279 
280  labelList& surface1,
281  List<pointIndexHit>& hit1,
282  labelList& region1,
283  labelList& surface2,
284  List<pointIndexHit>& hit2,
285  labelList& region2
286  ) const;
287 
288  //- findNearestIntersection but also get normals
290  (
291  const labelList& surfacesToTest,
292  const pointField& start,
293  const pointField& end,
294 
295  labelList& surface1,
296  List<pointIndexHit>& hit1,
297  labelList& region1,
298  vectorField& normal1,
299 
300  labelList& surface2,
301  List<pointIndexHit>& hit2,
302  labelList& region2,
303  vectorField& normal2
304  ) const;
305 
306  //- Used for debugging only: find intersection of edge.
308  (
309  const pointField& start,
310  const pointField& end,
311  labelList& surfaces,
313  ) const;
314 
315  //- Find nearest point on surfaces.
316  void findNearest
317  (
318  const labelList& surfacesToTest,
319  const pointField& samples,
320  const scalarField& nearestDistSqr,
321  labelList& surfaces,
323  ) const;
324 
325  //- Find nearest point on surfaces. Return surface and region on
326  // surface (so not global surface)
327  void findNearestRegion
328  (
329  const labelList& surfacesToTest,
330  const pointField& samples,
331  const scalarField& nearestDistSqr,
332  labelList& hitSurface,
333  labelList& hitRegion
334  ) const;
335 
336  //- Find nearest point on surfaces. Return surface, region and
337  // normal on surface (so not global surface)
338  void findNearestRegion
339  (
340  const labelList& surfacesToTest,
341  const pointField& samples,
342  const scalarField& nearestDistSqr,
343  labelList& hitSurface,
344  List<pointIndexHit>& hitInfo,
345  labelList& hitRegion,
346  vectorField& hitNormal
347  ) const;
348 
349  //- Detect if a point is 'inside' (closed) surfaces.
350  // Returns -1 if not, returns first surface it is.
351  void findInside
352  (
353  const labelList& surfacesToTest,
354  const pointField& pt,
355  labelList& insideSurfaces
356  ) const;
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:137
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:60
Fields for triSurface.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
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:52
const PtrList< surfaceZonesInfo > & surfZones() const
const scalarField & perpendicularAngle() const
From global region number to perpendicular angle.
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:63
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.