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 cell level at which leakage detection
100  // needs to apply
101  labelList leakLevel_;
102 
103  //- From global region number to small-gap level specification
104  List<FixedList<label, 3>> extendedGapLevel_;
105 
106  //- From global region number to side of surface to detect
107  List<volumeType> extendedGapMode_;
108 
109  //- From global region number to whether to allow selfProximity
110  // (in gap refinement)
111  boolList selfProximity_;
112 
113  //- From global region number to curvature specification
114  List<FixedList<label, 4>> extendedCurvatureLevel_;
115 
116  //- From global region number to perpendicular angle
117  scalarField perpendicularAngle_;
118 
119  //- From global region number to patchType
120  PtrList<dictionary> patchInfo_;
121 
122  //- Are we operating in test mode?
123  const bool dryRun_;
124 
125 
126  // Private Member Functions
127 
128  //- Given intersection results with geom detect local shell refinement
129  // level (possibly cached on triangles of geom)
130  labelList findHigherLevel
131  (
132  const searchableSurface& geom,
133  const shellSurfaces& shells,
134  const List<pointIndexHit>& intersectionInfo,
135  const labelList& surfaceLevel
136  ) const;
137 
138  //- Calculate global region to surface
139  static labelList calcSurfaceIndex
140  (
141  const searchableSurfaces& allGeometry,
142  const labelList& surfaces
143  );
144 
145  //- No copy construct
146  refinementSurfaces(const refinementSurfaces&) = delete;
147 
148  //- No copy assignment
149  void operator=(const refinementSurfaces&) = delete;
150 
151 
152 public:
153 
154  // Constructors
155 
156  //- Construct from surfaces and dictionary
158  (
159  const searchableSurfaces& allGeometry,
160  const dictionary&,
161  const label gapLevelIncrement,
162  const bool dryRun
163  );
164 
165  //- Construct from components
167  (
168  const searchableSurfaces& allGeometry,
169  const labelList& surfaces,
170  const wordList& names,
172  const labelList& regionOffset,
173  const labelList& minLevel,
174  const labelList& maxLevel,
175  const labelList& gapLevel,
178  const bool dryRun
179  );
180 
181 
182  // Member Functions
183 
184  // Access
185 
186  const searchableSurfaces& geometry() const
187  {
188  return allGeometry_;
189  }
190 
191  const labelList& surfaces() const
192  {
193  return surfaces_;
194  }
195 
196  //- Names of surfaces
197  const wordList& names() const
198  {
199  return names_;
200  }
201 
202  const PtrList<surfaceZonesInfo>& surfZones() const
203  {
204  return surfZones_;
205  }
206 
207  //- From surface to starting global region
208  const labelList& regionOffset() const
209  {
210  return regionOffset_;
211  }
212 
213  //- From global region number to refinement level
214  const labelList& minLevel() const
215  {
216  return minLevel_;
217  }
218 
219  //- From global region number to refinement level
220  const labelList& maxLevel() const
221  {
222  return maxLevel_;
223  }
224 
225  //- From global region number to small gap refinement level
226  const labelList& gapLevel() const
227  {
228  return gapLevel_;
229  }
230 
231  //- From global region number to cell level at which blockage
232  //- detection is applied
233  const labelList& blockLevel() const
234  {
235  return blockLevel_;
236  }
237 
238  //- From global region number to cell level at which leakage
239  //- detection is applied. labelMax if not set.
240  const labelList& leakLevel() const
241  {
242  return leakLevel_;
243  }
244 
245  //- From global region number to specification of gap and its
246  // refinement: 3 labels specifying
247  // - minimum wanted number of cells in the gap
248  // - minimum cell level when to start trying to detect gaps
249  // - maximum cell level to refine to (so do not detect gaps if
250  // cell >= maximum level)
252  {
253  return extendedGapLevel_;
254  }
255 
256  //- From global region number to side of surface to detect
257  const List<volumeType>& extendedGapMode() const
258  {
259  return extendedGapMode_;
260  }
261 
262  //- From global region number to whether to detect gaps to same
263  // surface (in gap refinement)
264  const boolList& gapSelf() const
265  {
266  return selfProximity_;
267  }
268 
269  //- From global region number to specification of curvature
270  // refinement: 4 labels specifying
271  // - minimum wanted number of cells in the curvature radius
272  // - ?minimum cell level when to start trying to detect gaps
273  // - maximum cell level to refine to (so do not detect curvature if
274  // celllevel >= maximum level)
275  // - minimum radius to ignore (expressed as refinement level).
276  // This can be used to ignore feature-edges. Set to -1 to ignore.
278  {
279  return extendedCurvatureLevel_;
280  }
281 
282  //- From global region number to perpendicular angle
284  {
285  return perpendicularAngle_;
286  }
287 
288  //- From global region number to patch type
289  const PtrList<dictionary>& patchInfo() const
290  {
291  return patchInfo_;
292  }
293 
294 
295  // Helper
296 
297  //- From surface and region on surface to global region
298  label globalRegion(const label surfI, const label regionI) const
299  {
300  return regionOffset_[surfI]+regionI;
301  }
302 
303  //- From global region to surface + region
304  labelPair whichSurface(const label globalRegionI) const;
305 
306  //- Min level for surface and region on surface
307  label minLevel(const label surfI, const label regionI) const
308  {
309  return minLevel_[globalRegion(surfI, regionI)];
310  }
311 
312  //- Max level for surface and region on surface
313  label maxLevel(const label surfI, const label regionI) const
314  {
315  return maxLevel_[globalRegion(surfI, regionI)];
316  }
317 
318  label nRegions() const
319  {
320  return minLevel_.size();
321  }
322 
323  //- Per surface the maximum extendedGapLevel over all its regions
324  labelList maxGapLevel() const;
325 
326  //- Per surface the maximum curvatureLevel over all its regions
328 
329  //- Calculate minLevelFields according to both surface- and
330  // shell-based levels
331  void setMinLevelFields
332  (
333  const shellSurfaces& shells
334  );
335 
336  //- Update minLevelFields according to (triSurface-only) curvature
338  (
339  const scalar cosAngle,
340  const scalar level0EdgeLength
341  );
342 
344  //static labelList countRegions(const triSurface&);
345 
346 
347  // Searching
348 
349  //- Find intersection of edge. Return -1 or first surface
350  // with higher (than currentLevel) minlevel.
351  // Return surface number and level.
353  (
354  const shellSurfaces& shells,
355 
356  const pointField& start,
357  const pointField& end,
358  const labelList& currentLevel, // current cell refinement level
359 
361  labelList& surfaceLevel
362  ) const;
363 
364  //- Find all intersections of edge with any surface with applicable
365  // min/max refinement level. Unsorted order.
367  (
368  const pointField& start,
369  const pointField& end,
370  const labelList& currentLevel, // current cell refinement level
371 
372  const labelList& globalMinLevel, // level per surfregion
373  const labelList& globalMaxLevel, // level per surfregion
374 
375  List<vectorList>& surfaceNormal,
376  labelListList& surfaceLevel
377  ) const;
378 
379  //- Find all intersections of edge with any surface with applicable
380  // min/max refinement level. Unsorted order.
382  (
383  const pointField& start,
384  const pointField& end,
385  const labelList& currentLevel, // current cell refinement level
386 
387  const labelList& globalMinLevel, // level per surfregion
388  const labelList& globalMaxLevel, // level per surfregion
391  List<vectorList>& surfaceNormal,
392  labelListList& surfaceLevel
393  ) const;
394 
395  //- Find intersection nearest to the endpoints. surface1,2 are
396  // not indices into surfacesToTest but refinement surface indices.
397  // Returns surface, region on surface (so not global surface)
398  // and position on surface.
400  (
401  const labelList& surfacesToTest,
402  const pointField& start,
403  const pointField& end,
404 
405  labelList& surface1,
406  List<pointIndexHit>& hit1,
407  labelList& region1,
408  labelList& surface2,
409  List<pointIndexHit>& hit2,
410  labelList& region2
411  ) const;
412 
413  //- findNearestIntersection but also get normals
415  (
416  const labelList& surfacesToTest,
417  const pointField& start,
418  const pointField& end,
419 
420  labelList& surface1,
421  List<pointIndexHit>& hit1,
422  labelList& region1,
423  vectorField& normal1,
424 
425  labelList& surface2,
426  List<pointIndexHit>& hit2,
427  labelList& region2,
428  vectorField& normal2
429  ) const;
430 
431  //- Find nearest (to start only) intersection of edge
433  (
434  const pointField& start,
435  const pointField& end,
437  vectorField& normal
438  ) const;
439 
440  //- Find nearest (to start only) intersection of edge
442  (
443  const pointField& start,
444  const pointField& end,
447  vectorField& normal
448  ) const;
449 
450  //- Used for debugging only: find intersection of edge.
452  (
453  const pointField& start,
454  const pointField& end,
457  ) const;
458 
459  //- Find nearest point on surfaces.
460  void findNearest
461  (
462  const labelList& surfacesToTest,
463  const pointField& samples,
464  const scalarField& nearestDistSqr,
467  ) const;
468 
469  //- Find nearest point on surfaces. Return surface and region on
470  // surface (so not global surface)
471  void findNearestRegion
472  (
473  const labelList& surfacesToTest,
474  const pointField& samples,
475  const scalarField& nearestDistSqr,
476  labelList& hitSurface,
477  labelList& hitRegion
478  ) const;
479 
480  //- Find nearest point on surfaces. Return surface, region and
481  // normal on surface (so not global surface)
482  void findNearestRegion
483  (
484  const labelList& surfacesToTest,
485  const pointField& samples,
486  const scalarField& nearestDistSqr,
487  labelList& hitSurface,
488  List<pointIndexHit>& hitInfo,
489  labelList& hitRegion,
490  vectorField& hitNormal
491  ) const;
492 
493  //- Detect if a point is 'inside' (closed) surfaces.
494  // Returns -1 if not, returns first surface it is.
495  void findInside
496  (
497  const labelList& surfacesToTest,
498  const pointField& pt,
499  labelList& insideSurfaces
500  ) const;
501 
502  // Region wise searching
503 
504  //- Find nearest point on selected regions of surfaces.
505  void findNearest
506  (
507  const labelList& surfacesToTest,
508  const labelListList& regions,
509 
510  const pointField& samples,
511  const scalarField& nearestDistSqr,
512 
513  labelList& hitSurface,
514  List<pointIndexHit>& hitInfo
515  ) const;
516 
517  //- Find nearest point on selected regions of surfaces.
518  void findNearestRegion
519  (
520  const labelList& surfacesToTest,
521  const labelListList& regions,
522 
523  const pointField& samples,
524  const scalarField& nearestDistSqr,
525 
526  labelList& hitSurface,
527  List<pointIndexHit>& hitInfo,
528  labelList& hitRegion,
529  vectorField& hitNormal
530  ) const;
531 
532 };
533 
534 
535 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
536 
537 } // End namespace Foam
538 
539 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
540 
541 #endif
542 
543 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
labelList maxCurvatureLevel() const
Per surface the maximum curvatureLevel over all its regions.
const labelList & surfaces() const
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Fields for triSurface.
scalarField samples(nIntervals, Zero)
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Used for debugging only: find intersection of edge.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
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.
const labelList & leakLevel() const
From global region number to cell level at which leakage detection is applied. labelMax if not set...
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
const boolList & gapSelf() const
From global region number to whether to detect gaps to same.
const searchableSurfaces & geometry() const
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.
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 surface to starting global region.
labelPair whichSurface(const label globalRegionI) const
From global region to surface + region.
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.
Container for searchableSurfaces. The collection is specified as a dictionary. For example...
Encapsulates queries for volume refinement (&#39;refine all cells within shell&#39;).
Definition: shellSurfaces.H:53
const List< volumeType > & extendedGapMode() const
From global region number to side of surface to detect.
const PtrList< surfaceZonesInfo > & surfZones() const
const scalarField & perpendicularAngle() const
From global region number to perpendicular angle.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:201
void setCurvatureMinLevelFields(const scalar cosAngle, const scalar level0EdgeLength)
Update minLevelFields according to (triSurface-only) curvature.
const labelList & blockLevel() const
From global region number to cell level at which blockage detection is applied.
const wordList & names() const
Names of surfaces.
const List< FixedList< label, 3 > > & extendedGapLevel() const
From global region number to specification of gap and its.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
labelList maxGapLevel() const
Per surface the maximum extendedGapLevel over all its regions.
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.
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 according to both surface- and.
Namespace for OpenFOAM.
const labelList & maxLevel() const
From global region number to refinement level.
const List< FixedList< label, 4 > > & extendedCurvatureLevel() const
From global region number to specification of curvature.
void findInside(const labelList &surfacesToTest, const pointField &pt, labelList &insideSurfaces) const
Detect if a point is &#39;inside&#39; (closed) surfaces.