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 surface to starting global region
81  labelList regionOffset_;
82 
83  //- From global region number to surface
84  labelList regionToSurface_;
85 
86  //- From global region number to refinement level
87  labelList minLevel_;
88 
89  //- From global region number to refinement level
90  labelList maxLevel_;
91 
92  //- From global region number to small-gap level
93  labelList gapLevel_;
94 
95  //- From global region number to cell level at which blockage detection
96  // needs to apply
97  labelList blockLevel_;
98 
99  //- From global region number to small-gap level specification
100  List<FixedList<label, 3>> extendedGapLevel_;
101 
102  //- From global region number to side of surface to detect
103  List<volumeType> extendedGapMode_;
104 
105  //- From global region number to whether to allow selfProximity
106  // (in gap refinement)
107  boolList selfProximity_;
108 
109  //- From global region number to perpendicular angle
110  scalarField perpendicularAngle_;
111 
112  //- From global region number to patchType
113  PtrList<dictionary> patchInfo_;
114 
115  //- Are we operating in test mode?
116  const bool dryRun_;
117 
118 
119  // Private Member Functions
120 
121  //- Given intersection results with geom detect local shell refinement
122  // level (possibly cached on triangles of geom)
123  labelList findHigherLevel
124  (
125  const searchableSurface& geom,
126  const shellSurfaces& shells,
127  const List<pointIndexHit>& intersectionInfo,
128  const labelList& surfaceLevel
129  ) const;
130 
131  //- Calculate global region to surface
132  static labelList calcSurfaceIndex
133  (
134  const searchableSurfaces& allGeometry,
135  const labelList& surfaces
136  );
137 
138  //- No copy construct
139  refinementSurfaces(const refinementSurfaces&) = delete;
140 
141  //- No copy assignment
142  void operator=(const refinementSurfaces&) = delete;
143 
144 
145 public:
146 
147  // Constructors
148 
149  //- Construct from surfaces and dictionary
151  (
152  const searchableSurfaces& allGeometry,
153  const dictionary&,
154  const label gapLevelIncrement,
155  const bool dryRun
156  );
157 
158  //- Construct from components
160  (
161  const searchableSurfaces& allGeometry,
162  const labelList& surfaces,
163  const wordList& names,
165  const labelList& regionOffset,
166  const labelList& minLevel,
167  const labelList& maxLevel,
168  const labelList& gapLevel,
171  const bool dryRun
172  );
173 
174 
175  // Member Functions
176 
177  // Access
178 
179  const searchableSurfaces& geometry() const
180  {
181  return allGeometry_;
182  }
183 
184  const labelList& surfaces() const
185  {
186  return surfaces_;
187  }
188 
189  //- Names of surfaces
190  const wordList& names() const
191  {
192  return names_;
193  }
194 
195  const PtrList<surfaceZonesInfo>& surfZones() const
196  {
197  return surfZones_;
198  }
199 
200  //- From surface to starting global region
201  const labelList& regionOffset() const
202  {
203  return regionOffset_;
204  }
205 
206  //- From global region number to refinement level
207  const labelList& minLevel() const
208  {
209  return minLevel_;
210  }
211 
212  //- From global region number to refinement level
213  const labelList& maxLevel() const
214  {
215  return maxLevel_;
216  }
217 
218  //- From global region number to small gap refinement level
219  const labelList& gapLevel() const
220  {
221  return gapLevel_;
222  }
223 
224  //- From global region number to cell level at which blockage
225  //- detection is applied
226  const labelList& blockLevel() const
227  {
228  return blockLevel_;
229  }
230 
231  //- From global region number to specification of gap and its
232  // refinement: 3 labels specifying
233  // - minimum wanted number of cells in the gap
234  // - minimum cell level when to start trying to detect gaps
235  // - maximum cell level to refine to (so do not detect gaps if
236  // cell >= maximum level)
238  {
239  return extendedGapLevel_;
240  }
241 
242  //- From global region number to side of surface to detect
243  const List<volumeType>& extendedGapMode() const
244  {
245  return extendedGapMode_;
246  }
247 
248  //- From global region number to whether to detect gaps to same
249  // surface (in gap refinement)
250  const boolList& gapSelf() const
251  {
252  return selfProximity_;
253  }
254 
255  //- From global region number to perpendicular angle
256  const scalarField& perpendicularAngle() const
257  {
258  return perpendicularAngle_;
259  }
260 
261  //- From global region number to patch type
262  const PtrList<dictionary>& patchInfo() const
263  {
264  return patchInfo_;
265  }
266 
267 
268  // Helper
269 
270  //- From surface and region on surface to global region
271  label globalRegion(const label surfI, const label regionI) const
272  {
273  return regionOffset_[surfI]+regionI;
274  }
275 
276  //- From global region to surface + region
277  labelPair whichSurface(const label globalRegionI) const;
278 
279  //- Min level for surface and region on surface
280  label minLevel(const label surfI, const label regionI) const
281  {
282  return minLevel_[globalRegion(surfI, regionI)];
283  }
284 
285  //- Max level for surface and region on surface
286  label maxLevel(const label surfI, const label regionI) const
287  {
288  return maxLevel_[globalRegion(surfI, regionI)];
289  }
290 
291  label nRegions() const
292  {
293  return minLevel_.size();
294  }
295 
296  //- Per surface the maximum extendedGapLevel over all its regions
297  labelList maxGapLevel() const;
298 
299  //- Calculate minLevelFields
300  void setMinLevelFields
301  (
302  const shellSurfaces& shells
303  );
304 
306  //static labelList countRegions(const triSurface&);
307 
308 
309  // Searching
310 
311  //- Find intersection of edge. Return -1 or first surface
312  // with higher (than currentLevel) minlevel.
313  // Return surface number and level.
315  (
316  const shellSurfaces& shells,
317 
318  const pointField& start,
319  const pointField& end,
320  const labelList& currentLevel, // current cell refinement level
321 
323  labelList& surfaceLevel
324  ) const;
325 
326  //- Find all intersections of edge with any surface with applicable
327  // min/max refinement level. Unsorted order.
329  (
330  const pointField& start,
331  const pointField& end,
332  const labelList& currentLevel, // current cell refinement level
333 
334  const labelList& globalMinLevel, // level per surfregion
335  const labelList& globalMaxLevel, // level per surfregion
336 
337  List<vectorList>& surfaceNormal,
338  labelListList& surfaceLevel
339  ) const;
340 
341  //- Find all intersections of edge with any surface with applicable
342  // min/max refinement level. Unsorted order.
344  (
345  const pointField& start,
346  const pointField& end,
347  const labelList& currentLevel, // current cell refinement level
348 
349  const labelList& globalMinLevel, // level per surfregion
350  const labelList& globalMaxLevel, // level per surfregion
351 
353  List<vectorList>& surfaceNormal,
354  labelListList& surfaceLevel
355  ) const;
356 
357  //- Find intersection nearest to the endpoints. surface1,2 are
358  // not indices into surfacesToTest but refinement surface indices.
359  // Returns surface, region on surface (so not global surface)
360  // and position on surface.
362  (
363  const labelList& surfacesToTest,
364  const pointField& start,
365  const pointField& end,
366 
367  labelList& surface1,
368  List<pointIndexHit>& hit1,
369  labelList& region1,
370  labelList& surface2,
371  List<pointIndexHit>& hit2,
372  labelList& region2
373  ) const;
374 
375  //- findNearestIntersection but also get normals
377  (
378  const labelList& surfacesToTest,
379  const pointField& start,
380  const pointField& end,
381 
382  labelList& surface1,
383  List<pointIndexHit>& hit1,
384  labelList& region1,
385  vectorField& normal1,
386 
387  labelList& surface2,
388  List<pointIndexHit>& hit2,
389  labelList& region2,
390  vectorField& normal2
391  ) const;
392 
393  //- Find nearest (to start only) intersection of edge
395  (
396  const pointField& start,
397  const pointField& end,
399  vectorField& normal
400  ) const;
401 
402  //- Find nearest (to start only) intersection of edge
404  (
405  const pointField& start,
406  const pointField& end,
409  vectorField& normal
410  ) const;
411 
412  //- Used for debugging only: find intersection of edge.
414  (
415  const pointField& start,
416  const pointField& end,
419  ) const;
420 
421  //- Find nearest point on surfaces.
422  void findNearest
423  (
424  const labelList& surfacesToTest,
425  const pointField& samples,
426  const scalarField& nearestDistSqr,
429  ) const;
430 
431  //- Find nearest point on surfaces. Return surface and region on
432  // surface (so not global surface)
433  void findNearestRegion
434  (
435  const labelList& surfacesToTest,
436  const pointField& samples,
437  const scalarField& nearestDistSqr,
438  labelList& hitSurface,
439  labelList& hitRegion
440  ) const;
441 
442  //- Find nearest point on surfaces. Return surface, region and
443  // normal on surface (so not global surface)
444  void findNearestRegion
445  (
446  const labelList& surfacesToTest,
447  const pointField& samples,
448  const scalarField& nearestDistSqr,
449  labelList& hitSurface,
450  List<pointIndexHit>& hitInfo,
451  labelList& hitRegion,
452  vectorField& hitNormal
453  ) const;
454 
455  //- Detect if a point is 'inside' (closed) surfaces.
456  // Returns -1 if not, returns first surface it is.
457  void findInside
458  (
459  const labelList& surfacesToTest,
460  const pointField& pt,
461  labelList& insideSurfaces
462  ) const;
463 
464  // Region wise searching
465 
466  //- Find nearest point on selected regions of surfaces.
467  void findNearest
468  (
469  const labelList& surfacesToTest,
470  const labelListList& regions,
471 
472  const pointField& samples,
473  const scalarField& nearestDistSqr,
474 
475  labelList& hitSurface,
476  List<pointIndexHit>& hitInfo
477  ) const;
478 
479  //- Find nearest point on selected regions of surfaces.
480  void findNearestRegion
481  (
482  const labelList& surfacesToTest,
483  const labelListList& regions,
484 
485  const pointField& samples,
486  const scalarField& nearestDistSqr,
487 
488  labelList& hitSurface,
489  List<pointIndexHit>& hitInfo,
490  labelList& hitRegion,
491  vectorField& hitNormal
492  ) const;
493 
494 };
495 
496 
497 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
498 
499 } // End namespace Foam
500 
501 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
502 
503 #endif
504 
505 // ************************************************************************* //
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:1538
Foam::refinementSurfaces::maxLevel
const labelList & maxLevel() const
From global region number to refinement level.
Definition: refinementSurfaces.H:212
vectorList.H
Foam::refinementSurfaces::maxGapLevel
labelList maxGapLevel() const
Per surface the maximum extendedGapLevel over all its regions.
Definition: refinementSurfaces.C:686
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:1559
Foam::refinementSurfaces::maxLevel
label maxLevel(const label surfI, const label regionI) const
Max level for surface and region on surface.
Definition: refinementSurfaces.H:285
Foam::refinementSurfaces::surfaces
const labelList & surfaces() const
Definition: refinementSurfaces.H:183
Foam::refinementSurfaces::gapSelf
const boolList & gapSelf() const
From global region number to whether to detect gaps to same.
Definition: refinementSurfaces.H:249
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:840
triSurfaceFields.H
Fields for triSurface.
triSurfaceGeoMesh.H
Foam::refinementSurfaces::geometry
const searchableSurfaces & geometry() const
Definition: refinementSurfaces.H:178
Foam::refinementSurfaces::gapLevel
const labelList & gapLevel() const
From global region number to small gap refinement level.
Definition: refinementSurfaces.H:218
Foam::refinementSurfaces::surfZones
const PtrList< surfaceZonesInfo > & surfZones() const
Definition: refinementSurfaces.H:194
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:189
Foam::refinementSurfaces::whichSurface
labelPair whichSurface(const label globalRegionI) const
From global region to surface + region.
Definition: refinementSurfaces.C:621
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:206
Foam::refinementSurfaces::blockLevel
const labelList & blockLevel() const
Definition: refinementSurfaces.H:225
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:62
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:236
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:270
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
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:261
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:1592
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:1776
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:1192
Foam::Pair< label >
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:1002
Foam::refinementSurfaces::minLevel
label minLevel(const label surfI, const label regionI) const
Min level for surface and region on surface.
Definition: refinementSurfaces.H:279
Foam::List< label >
Foam::refinementSurfaces::perpendicularAngle
const scalarField & perpendicularAngle() const
From global region number to perpendicular angle.
Definition: refinementSurfaces.H:255
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:242
Foam::refinementSurfaces::nRegions
label nRegions() const
Definition: refinementSurfaces.H:290
Foam::refinementSurfaces::regionOffset
const labelList & regionOffset() const
From surface to starting global region.
Definition: refinementSurfaces.H:200
Foam::refinementSurfaces::setMinLevelFields
void setMinLevelFields(const shellSurfaces &shells)
Calculate minLevelFields.
Definition: refinementSurfaces.C:707
Foam::refinementSurfaces
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
Definition: refinementSurfaces.H:63