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 | Copyright (C) 2011-2014 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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 #include "volumeType.H"
46 #include "pointList.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 class searchableSurfaces;
54 class shellSurfaces;
55 class triSurfaceMesh;
56 
57 /*---------------------------------------------------------------------------*\
58  Class refinementSurfaces Declaration
59 \*---------------------------------------------------------------------------*/
60 
62 {
63  // Private data
64 
65  //- Reference to all geometry.
67 
68  //- Indices of surfaces that are refinement ones
70 
71  //- Surface name (word)
73 
74  //- List of surface zone (face and cell zone) information
76 
77  //- From local region number to global region number
79 
80  //- From global region number to refinement level
82 
83  //- From global region number to refinement level
85 
86  //- From global region number to small-gap level
88 
89  //- From global region number to small-gap level specification
91 
92  //- From global region number to side of surface to detect
94 
95  //- From global region number to perpendicular angle
97 
98  //- From global region number to patchType
100 
101 
102  // Private Member Functions
103 
104  //- Given intersection results with geom detect local shell refinement
105  // level (possibly cached on triangles of geom)
107  (
108  const searchableSurface& geom,
109  const shellSurfaces& shells,
110  const List<pointIndexHit>& intersectionInfo,
111  const labelList& surfaceLevel
112  ) const;
113 
114  //- Disallow default bitwise copy construct
116 
117  //- Disallow default bitwise assignment
118  void operator=(const refinementSurfaces&);
119 
120 
121 public:
122 
123  // Constructors
124 
125  //- Construct from surfaces and dictionary
127  (
128  const searchableSurfaces& allGeometry,
129  const dictionary&,
130  const label gapLevelIncrement
131  );
132 
133  //- Construct from components
135  (
136  const searchableSurfaces& allGeometry,
137  const labelList& surfaces,
138  const wordList& names,
140  const labelList& regionOffset,
141  const labelList& minLevel,
142  const labelList& maxLevel,
143  const labelList& gapLevel,
146  );
147 
148 
149  // Member Functions
150 
151  // Access
152 
153  const searchableSurfaces& geometry() const
154  {
155  return allGeometry_;
156  }
157 
158  const labelList& surfaces() const
159  {
160  return surfaces_;
161  }
162 
163  //- Names of surfaces
164  const wordList& names() const
165  {
166  return names_;
167  }
168 
169  const PtrList<surfaceZonesInfo>& surfZones() const
170  {
171  return surfZones_;
172  }
173 
174  //- From local region number to global region number
175  const labelList& regionOffset() const
176  {
177  return regionOffset_;
178  }
179 
180  //- From global region number to refinement level
181  const labelList& minLevel() const
182  {
183  return minLevel_;
184  }
185 
186  //- From global region number to refinement level
187  const labelList& maxLevel() const
188  {
189  return maxLevel_;
190  }
191 
192  //- From global region number to small gap refinement level
193  const labelList& gapLevel() const
194  {
195  return gapLevel_;
196  }
197 
198  //- From global region number to specification of gap and its
199  // refinement: 3 labels specifying
200  // - minimum wanted number of cells in the gap
201  // - minimum cell level when to start trying to detect gaps
202  // - maximum cell level to refine to (so do not detect gaps if
203  // cell >= maximum level)
205  {
206  return extendedGapLevel_;
207  }
208 
209  //- From global region number to side of surface to detect
210  const List<volumeType>& extendedGapMode() const
211  {
212  return extendedGapMode_;
213  }
214 
215  //- From global region number to perpendicular angle
216  const scalarField& perpendicularAngle() const
217  {
218  return perpendicularAngle_;
219  }
220 
221  //- From global region number to patch type
222  const PtrList<dictionary>& patchInfo() const
223  {
224  return patchInfo_;
225  }
226 
227 
228  // Helper
229 
230  //- From surface and region on surface to global region
231  label globalRegion(const label surfI, const label regionI) const
232  {
233  return regionOffset_[surfI]+regionI;
234  }
235 
236  //- Min level for surface and region on surface
237  label minLevel(const label surfI, const label regionI) const
238  {
239  return minLevel_[globalRegion(surfI, regionI)];
240  }
241 
242  //- Max level for surface and region on surface
243  label maxLevel(const label surfI, const label regionI) const
244  {
245  return maxLevel_[globalRegion(surfI, regionI)];
246  }
247 
248  label nRegions() const
249  {
250  return minLevel_.size();
251  }
252 
253  //- Per surface the maximum extendedGapLevel over all its regions
254  labelList maxGapLevel() const;
255 
256  //- Calculate minLevelFields
257  void setMinLevelFields
258  (
259  const shellSurfaces& shells
260  );
261 
263  //static labelList countRegions(const triSurface&);
264 
265 
266  // Searching
267 
268  //- Find intersection of edge. Return -1 or first surface
269  // with higher (than currentLevel) minlevel.
270  // Return surface number and level.
272  (
273  const shellSurfaces& shells,
274 
275  const pointField& start,
276  const pointField& end,
277  const labelList& currentLevel, // current cell refinement level
278 
280  labelList& surfaceLevel
281  ) const;
282 
283  //- Find all intersections of edge. Unsorted order.
285  (
286  const pointField& start,
287  const pointField& end,
288  const labelList& currentLevel, // current cell refinement level
289  const labelList& globalRegionLevel, // level per surfregion
290 
291  List<vectorList>& surfaceNormal,
292  labelListList& surfaceLevel
293  ) const;
294 
295  //- Find all intersections of edge. Unsorted order.
297  (
298  const pointField& start,
299  const pointField& end,
300  const labelList& currentLevel, // current cell refinement level
301  const labelList& globalRegionLevel, // level per surfregion
302 
304  List<vectorList>& surfaceNormal,
305  labelListList& surfaceLevel
306  ) const;
307 
308  //- Find intersection nearest to the endpoints. surface1,2 are
309  // not indices into surfacesToTest but refinement surface indices.
310  // Returns surface, region on surface (so not global surface)
311  // and position on surface.
313  (
314  const labelList& surfacesToTest,
315  const pointField& start,
316  const pointField& end,
317 
318  labelList& surface1,
319  List<pointIndexHit>& hit1,
320  labelList& region1,
321  labelList& surface2,
322  List<pointIndexHit>& hit2,
323  labelList& region2
324  ) const;
325 
326  //- findNearestIntersection but also get normals
328  (
329  const labelList& surfacesToTest,
330  const pointField& start,
331  const pointField& end,
332 
333  labelList& surface1,
334  List<pointIndexHit>& hit1,
335  labelList& region1,
336  vectorField& normal1,
337 
338  labelList& surface2,
339  List<pointIndexHit>& hit2,
340  labelList& region2,
341  vectorField& normal2
342  ) const;
343 
344  //- Find nearest (to start only) intersection of edge
346  (
347  const pointField& start,
348  const pointField& end,
351  ) const;
352 
353  //- Find nearest (to start only) intersection of edge
355  (
356  const pointField& start,
357  const pointField& end,
361  ) const;
362 
363  //- Used for debugging only: find intersection of edge.
365  (
366  const pointField& start,
367  const pointField& end,
370  ) const;
371 
372  //- Find nearest point on surfaces.
373  void findNearest
374  (
375  const labelList& surfacesToTest,
376  const pointField& samples,
377  const scalarField& nearestDistSqr,
380  ) const;
381 
382  //- Find nearest point on surfaces. Return surface and region on
383  // surface (so not global surface)
384  void findNearestRegion
385  (
386  const labelList& surfacesToTest,
387  const pointField& samples,
388  const scalarField& nearestDistSqr,
389  labelList& hitSurface,
390  labelList& hitRegion
391  ) const;
392 
393  //- Find nearest point on surfaces. Return surface, region and
394  // normal on surface (so not global surface)
395  void findNearestRegion
396  (
397  const labelList& surfacesToTest,
398  const pointField& samples,
399  const scalarField& nearestDistSqr,
400  labelList& hitSurface,
401  List<pointIndexHit>& hitInfo,
402  labelList& hitRegion,
403  vectorField& hitNormal
404  ) const;
405 
406  //- Detect if a point is 'inside' (closed) surfaces.
407  // Returns -1 if not, returns first surface it is.
408  void findInside
409  (
410  const labelList& surfacesToTest,
411  const pointField& pt,
412  labelList& insideSurfaces
413  ) const;
414 
415  // Region wise searching
416 
417  //- Find nearest point on selected regions of surfaces.
418  void findNearest
419  (
420  const labelList& surfacesToTest,
421  const labelListList& regions,
422 
423  const pointField& samples,
424  const scalarField& nearestDistSqr,
425 
426  labelList& hitSurface,
427  List<pointIndexHit>& hitInfo
428  ) const;
429 
430  //- Find nearest point on selected regions of surfaces.
431  void findNearestRegion
432  (
433  const labelList& surfacesToTest,
434  const labelListList& regions,
435 
436  const pointField& samples,
437  const scalarField& nearestDistSqr,
438 
439  labelList& hitSurface,
440  List<pointIndexHit>& hitInfo,
441  labelList& hitRegion,
442  vectorField& hitNormal
443  ) const;
444 
445 };
446 
447 
448 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
449 
450 } // End namespace Foam
451 
452 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
453 
454 #endif
455 
456 // ************************************************************************* //
Foam::refinementSurfaces::allGeometry_
const searchableSurfaces & allGeometry_
Reference to all geometry.
Definition: refinementSurfaces.H:65
pointIndexHit.H
Foam::refinementSurfaces::findAllHigherIntersections
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.
Definition: refinementSurfaces.C:885
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:1409
Foam::refinementSurfaces::maxLevel
const labelList & maxLevel() const
From global region number to refinement level.
Definition: refinementSurfaces.H:186
vectorList.H
Foam::refinementSurfaces::maxGapLevel
labelList maxGapLevel() const
Per surface the maximum extendedGapLevel over all its regions.
Definition: refinementSurfaces.C:573
Foam::refinementSurfaces::extendedGapMode_
List< volumeType > extendedGapMode_
From global region number to side of surface to detect.
Definition: refinementSurfaces.H:92
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:1430
Foam::refinementSurfaces::maxLevel
label maxLevel(const label surfI, const label regionI) const
Max level for surface and region on surface.
Definition: refinementSurfaces.H:242
Foam::refinementSurfaces::surfaces
const labelList & surfaces() const
Definition: refinementSurfaces.H:157
Foam::refinementSurfaces::names_
wordList names_
Surface name (word)
Definition: refinementSurfaces.H:71
Foam::refinementSurfaces::surfZones_
PtrList< surfaceZonesInfo > surfZones_
List of surface zone (face and cell zone) information.
Definition: refinementSurfaces.H:74
Foam::surfaceLocation
Contains information about location on a triSurface:
Definition: surfaceLocation.H:60
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:723
triSurfaceFields.H
Fields for triSurface.
Foam::refinementSurfaces::patchInfo_
PtrList< dictionary > patchInfo_
From global region number to patchType.
Definition: refinementSurfaces.H:98
Foam::refinementSurfaces::maxLevel_
labelList maxLevel_
From global region number to refinement level.
Definition: refinementSurfaces.H:83
Foam::refinementSurfaces::refinementSurfaces
refinementSurfaces(const refinementSurfaces &)
Disallow default bitwise copy construct.
triSurfaceGeoMesh.H
Foam::refinementSurfaces::geometry
const searchableSurfaces & geometry() const
Definition: refinementSurfaces.H:152
Foam::refinementSurfaces::gapLevel
const labelList & gapLevel() const
From global region number to small gap refinement level.
Definition: refinementSurfaces.H:192
Foam::refinementSurfaces::operator=
void operator=(const refinementSurfaces &)
Disallow default bitwise assignment.
samples
scalarField samples(nIntervals, 0)
Foam::refinementSurfaces::findHigherLevel
labelList findHigherLevel(const searchableSurface &geom, const shellSurfaces &shells, const List< pointIndexHit > &intersectionInfo, const labelList &surfaceLevel) const
Given intersection results with geom detect local shell refinement.
Definition: refinementSurfaces.C:39
Foam::refinementSurfaces::surfaces_
labelList surfaces_
Indices of surfaces that are refinement ones.
Definition: refinementSurfaces.H:68
Foam::refinementSurfaces::surfZones
const PtrList< surfaceZonesInfo > & surfZones() const
Definition: refinementSurfaces.H:168
Foam::shellSurfaces
Encapsulates queries for volume refinement ('refine all cells within shell').
Definition: shellSurfaces.H:52
volumeType.H
Foam::refinementSurfaces::names
const wordList & names() const
Names of surfaces.
Definition: refinementSurfaces.H:163
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:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::refinementSurfaces::perpendicularAngle_
scalarField perpendicularAngle_
From global region number to perpendicular angle.
Definition: refinementSurfaces.H:95
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:66
pointList.H
Foam::refinementSurfaces::minLevel
const labelList & minLevel() const
From global region number to refinement level.
Definition: refinementSurfaces.H:180
Foam::refinementSurfaces::minLevel_
labelList minLevel_
From global region number to refinement level.
Definition: refinementSurfaces.H:80
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
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:203
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::refinementSurfaces::globalRegion
label globalRegion(const label surfI, const label regionI) const
From surface and region on surface to global region.
Definition: refinementSurfaces.H:230
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::refinementSurfaces::patchInfo
const PtrList< dictionary > & patchInfo() const
From global region number to patch type.
Definition: refinementSurfaces.H:221
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:1463
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:1647
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:1063
Foam::refinementSurfaces::extendedGapLevel_
List< FixedList< label, 3 > > extendedGapLevel_
From global region number to small-gap level specification.
Definition: refinementSurfaces.H:89
Foam::refinementSurfaces::minLevel
label minLevel(const label surfI, const label regionI) const
Min level for surface and region on surface.
Definition: refinementSurfaces.H:236
Foam::List
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
Foam::refinementSurfaces::perpendicularAngle
const scalarField & perpendicularAngle() const
From global region number to perpendicular angle.
Definition: refinementSurfaces.H:215
Foam::searchableSurfaces
Container for searchableSurfaces.
Definition: searchableSurfaces.H:53
Foam::refinementSurfaces::extendedGapMode
const List< volumeType > & extendedGapMode() const
From global region number to side of surface to detect.
Definition: refinementSurfaces.H:209
Foam::refinementSurfaces::nRegions
label nRegions() const
Definition: refinementSurfaces.H:247
Foam::refinementSurfaces::regionOffset
const labelList & regionOffset() const
From local region number to global region number.
Definition: refinementSurfaces.H:174
Foam::refinementSurfaces::setMinLevelFields
void setMinLevelFields(const shellSurfaces &shells)
Calculate minLevelFields.
Definition: refinementSurfaces.C:594
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::refinementSurfaces
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
Definition: refinementSurfaces.H:60
Foam::refinementSurfaces::gapLevel_
labelList gapLevel_
From global region number to small-gap level.
Definition: refinementSurfaces.H:86
normal
A normal distribution model.
Foam::refinementSurfaces::regionOffset_
labelList regionOffset_
From local region number to global region number.
Definition: refinementSurfaces.H:77