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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2014 OpenFOAM Foundation
9  Copyright (C) 2015 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::refinementSurfaces
29 
30 Description
31  Container for data on surfaces used for surface-driven refinement.
32  Contains all the data about the level of refinement needed per
33  surface.
34 
35 SourceFiles
36  refinementSurfaces.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef refinementSurfaces_H
41 #define refinementSurfaces_H
42 
43 #include "triSurfaceGeoMesh.H"
44 #include "triSurfaceFields.H"
45 #include "vectorList.H"
46 #include "pointIndexHit.H"
47 #include "surfaceZonesInfo.H"
48 #include "volumeType.H"
49 #include "pointList.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 class searchableSurfaces;
57 class shellSurfaces;
58 class triSurfaceMesh;
59 
60 /*---------------------------------------------------------------------------*\
61  Class refinementSurfaces Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 {
66  // Private data
67 
68  //- Reference to all geometry.
69  const searchableSurfaces& allGeometry_;
70 
71  //- Indices of surfaces that are refinement ones
72  labelList surfaces_;
73 
74  //- Surface name (word)
75  wordList names_;
76 
77  //- List of surface zone (face and cell zone) information
78  PtrList<surfaceZonesInfo> surfZones_;
79 
80  //- From local region number to global region number
81  labelList regionOffset_;
82 
83  //- From global region number to refinement level
84  labelList minLevel_;
85 
86  //- From global region number to refinement level
87  labelList maxLevel_;
88 
89  //- From global region number to small-gap level
90  labelList gapLevel_;
91 
92  //- From global region number to cell level at which blockage detection
93  // needs to apply
94  labelList blockLevel_;
95 
96  //- From global region number to small-gap level specification
97  List<FixedList<label, 3>> extendedGapLevel_;
98 
99  //- From global region number to side of surface to detect
100  List<volumeType> extendedGapMode_;
101 
102  //- From global region number to perpendicular angle
103  scalarField perpendicularAngle_;
104 
105  //- From global region number to patchType
106  PtrList<dictionary> patchInfo_;
107 
108  //- Are we operating in test mode?
109  const bool dryRun_;
110 
111 
112  // Private Member Functions
113 
114  //- Given intersection results with geom detect local shell refinement
115  // level (possibly cached on triangles of geom)
116  labelList findHigherLevel
117  (
118  const searchableSurface& geom,
119  const shellSurfaces& shells,
120  const List<pointIndexHit>& intersectionInfo,
121  const labelList& surfaceLevel
122  ) const;
123 
124  //- No copy construct
125  refinementSurfaces(const refinementSurfaces&) = delete;
126 
127  //- No copy assignment
128  void operator=(const refinementSurfaces&) = delete;
129 
130 
131 public:
132 
133  // Constructors
134 
135  //- Construct from surfaces and dictionary
137  (
138  const searchableSurfaces& allGeometry,
139  const dictionary&,
140  const label gapLevelIncrement,
141  const bool dryRun
142  );
143 
144  //- Construct from components
146  (
147  const searchableSurfaces& allGeometry,
148  const labelList& surfaces,
149  const wordList& names,
151  const labelList& regionOffset,
152  const labelList& minLevel,
153  const labelList& maxLevel,
154  const labelList& gapLevel,
157  const bool dryRun
158  );
159 
160 
161  // Member Functions
162 
163  // Access
164 
165  const searchableSurfaces& geometry() const
166  {
167  return allGeometry_;
168  }
169 
170  const labelList& surfaces() const
171  {
172  return surfaces_;
173  }
174 
175  //- Names of surfaces
176  const wordList& names() const
177  {
178  return names_;
179  }
180 
181  const PtrList<surfaceZonesInfo>& surfZones() const
182  {
183  return surfZones_;
184  }
185 
186  //- From local region number to global region number
187  const labelList& regionOffset() const
188  {
189  return regionOffset_;
190  }
191 
192  //- From global region number to refinement level
193  const labelList& minLevel() const
194  {
195  return minLevel_;
196  }
197 
198  //- From global region number to refinement level
199  const labelList& maxLevel() const
200  {
201  return maxLevel_;
202  }
203 
204  //- From global region number to small gap refinement level
205  const labelList& gapLevel() const
206  {
207  return gapLevel_;
208  }
209 
210  //- From global region number to cell level at which blockage
211  //- detection is applied
212  const labelList& blockLevel() const
213  {
214  return blockLevel_;
215  }
216 
217  //- From global region number to specification of gap and its
218  // refinement: 3 labels specifying
219  // - minimum wanted number of cells in the gap
220  // - minimum cell level when to start trying to detect gaps
221  // - maximum cell level to refine to (so do not detect gaps if
222  // cell >= maximum level)
224  {
225  return extendedGapLevel_;
226  }
227 
228  //- From global region number to side of surface to detect
229  const List<volumeType>& extendedGapMode() const
230  {
231  return extendedGapMode_;
232  }
233 
234  //- From global region number to perpendicular angle
235  const scalarField& perpendicularAngle() const
236  {
237  return perpendicularAngle_;
238  }
239 
240  //- From global region number to patch type
241  const PtrList<dictionary>& patchInfo() const
242  {
243  return patchInfo_;
244  }
245 
246 
247  // Helper
248 
249  //- From surface and region on surface to global region
250  label globalRegion(const label surfI, const label regionI) const
251  {
252  return regionOffset_[surfI]+regionI;
253  }
254 
255  //- Min level for surface and region on surface
256  label minLevel(const label surfI, const label regionI) const
257  {
258  return minLevel_[globalRegion(surfI, regionI)];
259  }
260 
261  //- Max level for surface and region on surface
262  label maxLevel(const label surfI, const label regionI) const
263  {
264  return maxLevel_[globalRegion(surfI, regionI)];
265  }
266 
267  label nRegions() const
268  {
269  return minLevel_.size();
270  }
271 
272  //- Per surface the maximum extendedGapLevel over all its regions
273  labelList maxGapLevel() const;
274 
275  //- Calculate minLevelFields
276  void setMinLevelFields
277  (
278  const shellSurfaces& shells
279  );
280 
282  //static labelList countRegions(const triSurface&);
283 
284 
285  // Searching
286 
287  //- Find intersection of edge. Return -1 or first surface
288  // with higher (than currentLevel) minlevel.
289  // Return surface number and level.
291  (
292  const shellSurfaces& shells,
293 
294  const pointField& start,
295  const pointField& end,
296  const labelList& currentLevel, // current cell refinement level
297 
299  labelList& surfaceLevel
300  ) const;
301 
302  //- Find all intersections of edge with any surface with applicable
303  // min/max refinement level. Unsorted order.
305  (
306  const pointField& start,
307  const pointField& end,
308  const labelList& currentLevel, // current cell refinement level
309 
310  const labelList& globalMinLevel, // level per surfregion
311  const labelList& globalMaxLevel, // level per surfregion
312 
313  List<vectorList>& surfaceNormal,
314  labelListList& surfaceLevel
315  ) const;
316 
317  //- Find all intersections of edge with any surface with applicable
318  // min/max refinement level. Unsorted order.
320  (
321  const pointField& start,
322  const pointField& end,
323  const labelList& currentLevel, // current cell refinement level
324 
325  const labelList& globalMinLevel, // level per surfregion
326  const labelList& globalMaxLevel, // level per surfregion
327 
329  List<vectorList>& surfaceNormal,
330  labelListList& surfaceLevel
331  ) const;
332 
333  //- Find intersection nearest to the endpoints. surface1,2 are
334  // not indices into surfacesToTest but refinement surface indices.
335  // Returns surface, region on surface (so not global surface)
336  // and position on surface.
338  (
339  const labelList& surfacesToTest,
340  const pointField& start,
341  const pointField& end,
342 
343  labelList& surface1,
344  List<pointIndexHit>& hit1,
345  labelList& region1,
346  labelList& surface2,
347  List<pointIndexHit>& hit2,
348  labelList& region2
349  ) const;
350 
351  //- findNearestIntersection but also get normals
353  (
354  const labelList& surfacesToTest,
355  const pointField& start,
356  const pointField& end,
357 
358  labelList& surface1,
359  List<pointIndexHit>& hit1,
360  labelList& region1,
361  vectorField& normal1,
362 
363  labelList& surface2,
364  List<pointIndexHit>& hit2,
365  labelList& region2,
366  vectorField& normal2
367  ) const;
368 
369  //- Find nearest (to start only) intersection of edge
371  (
372  const pointField& start,
373  const pointField& end,
375  vectorField& normal
376  ) const;
377 
378  //- Find nearest (to start only) intersection of edge
380  (
381  const pointField& start,
382  const pointField& end,
385  vectorField& normal
386  ) const;
387 
388  //- Used for debugging only: find intersection of edge.
390  (
391  const pointField& start,
392  const pointField& end,
395  ) const;
396 
397  //- Find nearest point on surfaces.
398  void findNearest
399  (
400  const labelList& surfacesToTest,
401  const pointField& samples,
402  const scalarField& nearestDistSqr,
405  ) const;
406 
407  //- Find nearest point on surfaces. Return surface and region on
408  // surface (so not global surface)
409  void findNearestRegion
410  (
411  const labelList& surfacesToTest,
412  const pointField& samples,
413  const scalarField& nearestDistSqr,
414  labelList& hitSurface,
415  labelList& hitRegion
416  ) const;
417 
418  //- Find nearest point on surfaces. Return surface, region and
419  // normal on surface (so not global surface)
420  void findNearestRegion
421  (
422  const labelList& surfacesToTest,
423  const pointField& samples,
424  const scalarField& nearestDistSqr,
425  labelList& hitSurface,
426  List<pointIndexHit>& hitInfo,
427  labelList& hitRegion,
428  vectorField& hitNormal
429  ) const;
430 
431  //- Detect if a point is 'inside' (closed) surfaces.
432  // Returns -1 if not, returns first surface it is.
433  void findInside
434  (
435  const labelList& surfacesToTest,
436  const pointField& pt,
437  labelList& insideSurfaces
438  ) const;
439 
440  // Region wise searching
441 
442  //- Find nearest point on selected regions of surfaces.
443  void findNearest
444  (
445  const labelList& surfacesToTest,
446  const labelListList& regions,
447 
448  const pointField& samples,
449  const scalarField& nearestDistSqr,
450 
451  labelList& hitSurface,
452  List<pointIndexHit>& hitInfo
453  ) const;
454 
455  //- Find nearest point on selected regions of surfaces.
456  void findNearestRegion
457  (
458  const labelList& surfacesToTest,
459  const labelListList& regions,
460 
461  const pointField& samples,
462  const scalarField& nearestDistSqr,
463 
464  labelList& hitSurface,
465  List<pointIndexHit>& hitInfo,
466  labelList& hitRegion,
467  vectorField& hitNormal
468  ) const;
469 
470 };
471 
472 
473 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
474 
475 } // End namespace Foam
476 
477 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
478 
479 #endif
480 
481 // ************************************************************************* //
pointIndexHit.H
Foam::refinementSurfaces::findAnyIntersection
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Used for debugging only: find intersection of edge.
Definition: refinementSurfaces.C:1468
Foam::refinementSurfaces::maxLevel
const labelList & maxLevel() const
From global region number to refinement level.
Definition: refinementSurfaces.H:198
vectorList.H
Foam::refinementSurfaces::maxGapLevel
labelList maxGapLevel() const
Per surface the maximum extendedGapLevel over all its regions.
Definition: refinementSurfaces.C:616
Foam::refinementSurfaces::findNearest
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
Definition: refinementSurfaces.C:1489
Foam::refinementSurfaces::maxLevel
label maxLevel(const label surfI, const label regionI) const
Max level for surface and region on surface.
Definition: refinementSurfaces.H:261
Foam::refinementSurfaces::surfaces
const labelList & surfaces() const
Definition: refinementSurfaces.H:169
Foam::surfaceLocation
Contains information about location on a triSurface.
Definition: surfaceLocation.H:75
Foam::refinementSurfaces::findHigherIntersection
void findHigherIntersection(const shellSurfaces &shells, const pointField &start, const pointField &end, const labelList &currentLevel, labelList &surfaces, labelList &surfaceLevel) const
Find intersection of edge. Return -1 or first surface.
Definition: refinementSurfaces.C:770
triSurfaceFields.H
Fields for triSurface.
triSurfaceGeoMesh.H
Foam::refinementSurfaces::geometry
const searchableSurfaces & geometry() const
Definition: refinementSurfaces.H:164
Foam::refinementSurfaces::gapLevel
const labelList & gapLevel() const
From global region number to small gap refinement level.
Definition: refinementSurfaces.H:204
Foam::refinementSurfaces::surfZones
const PtrList< surfaceZonesInfo > & surfZones() const
Definition: refinementSurfaces.H:180
Foam::shellSurfaces
Encapsulates queries for volume refinement ('refine all cells within shell').
Definition: shellSurfaces.H:57
volumeType.H
Foam::refinementSurfaces::names
const wordList & names() const
Names of surfaces.
Definition: refinementSurfaces.H:175
Foam::label
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:62
Foam::Field< scalar >
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:69
pointList.H
Foam::refinementSurfaces::minLevel
const labelList & minLevel() const
From global region number to refinement level.
Definition: refinementSurfaces.H:192
Foam::refinementSurfaces::blockLevel
const labelList & blockLevel() const
Definition: refinementSurfaces.H:211
samples
scalarField samples(nIntervals, Zero)
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:65
surfaceZonesInfo.H
Foam::refinementSurfaces::extendedGapLevel
const List< FixedList< label, 3 > > & extendedGapLevel() const
From global region number to specification of gap and its.
Definition: refinementSurfaces.H:222
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::refinementSurfaces::globalRegion
label globalRegion(const label surfI, const label regionI) const
From surface and region on surface to global region.
Definition: refinementSurfaces.H:249
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:115
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::refinementSurfaces::patchInfo
const PtrList< dictionary > & patchInfo() const
From global region number to patch type.
Definition: refinementSurfaces.H:240
Foam::refinementSurfaces::findNearestRegion
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.
Definition: refinementSurfaces.C:1522
Foam::refinementSurfaces::findInside
void findInside(const labelList &surfacesToTest, const pointField &pt, labelList &insideSurfaces) const
Detect if a point is 'inside' (closed) surfaces.
Definition: refinementSurfaces.C:1706
Foam::refinementSurfaces::findNearestIntersection
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.
Definition: refinementSurfaces.C:1122
Foam::refinementSurfaces::findAllIntersections
void findAllIntersections(const pointField &start, const pointField &end, const labelList &currentLevel, const labelList &globalMinLevel, const labelList &globalMaxLevel, List< vectorList > &surfaceNormal, labelListList &surfaceLevel) const
Find all intersections of edge with any surface with applicable.
Definition: refinementSurfaces.C:932
Foam::refinementSurfaces::minLevel
label minLevel(const label surfI, const label regionI) const
Min level for surface and region on surface.
Definition: refinementSurfaces.H:255
Foam::List< label >
Foam::refinementSurfaces::perpendicularAngle
const scalarField & perpendicularAngle() const
From global region number to perpendicular angle.
Definition: refinementSurfaces.H:234
Foam::searchableSurfaces
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Definition: searchableSurfaces.H:92
Foam::refinementSurfaces::extendedGapMode
const List< volumeType > & extendedGapMode() const
From global region number to side of surface to detect.
Definition: refinementSurfaces.H:228
Foam::start
label ListType::const_reference const label start
Definition: ListOps.H:408
Foam::refinementSurfaces::nRegions
label nRegions() const
Definition: refinementSurfaces.H:266
Foam::refinementSurfaces::regionOffset
const labelList & regionOffset() const
From local region number to global region number.
Definition: refinementSurfaces.H:186
Foam::refinementSurfaces::setMinLevelFields
void setMinLevelFields(const shellSurfaces &shells)
Calculate minLevelFields.
Definition: refinementSurfaces.C:637
Foam::refinementSurfaces
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
Definition: refinementSurfaces.H:63