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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::refinementSurfaces
29
30Description
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
35SourceFiles
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
53namespace Foam
54{
55
56class searchableSurfaces;
57class shellSurfaces;
58class triSurfaceMesh;
59
60/*---------------------------------------------------------------------------*\
61 Class refinementSurfaces Declaration
62\*---------------------------------------------------------------------------*/
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
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 perpendicular angle
114 scalarField perpendicularAngle_;
115
116 //- From global region number to patchType
117 PtrList<dictionary> patchInfo_;
118
119 //- Are we operating in test mode?
120 const bool dryRun_;
121
122
123 // Private Member Functions
124
125 //- Given intersection results with geom detect local shell refinement
126 // level (possibly cached on triangles of geom)
127 labelList findHigherLevel
128 (
129 const searchableSurface& geom,
130 const shellSurfaces& shells,
131 const List<pointIndexHit>& intersectionInfo,
132 const labelList& surfaceLevel
133 ) const;
134
135 //- Calculate global region to surface
136 static labelList calcSurfaceIndex
137 (
138 const searchableSurfaces& allGeometry,
139 const labelList& surfaces
140 );
141
142 //- No copy construct
143 refinementSurfaces(const refinementSurfaces&) = delete;
144
145 //- No copy assignment
146 void operator=(const refinementSurfaces&) = delete;
147
148
149public:
150
151 // Constructors
152
153 //- Construct from surfaces and dictionary
155 (
156 const searchableSurfaces& allGeometry,
157 const dictionary&,
158 const label gapLevelIncrement,
159 const bool dryRun
160 );
161
162 //- Construct from components
164 (
165 const searchableSurfaces& allGeometry,
166 const labelList& surfaces,
167 const wordList& names,
169 const labelList& regionOffset,
170 const labelList& minLevel,
171 const labelList& maxLevel,
172 const labelList& gapLevel,
175 const bool dryRun
176 );
177
178
179 // Member Functions
180
181 // Access
183 const searchableSurfaces& geometry() const
184 {
185 return allGeometry_;
186 }
188 const labelList& surfaces() const
189 {
190 return surfaces_;
191 }
192
193 //- Names of surfaces
194 const wordList& names() const
195 {
196 return names_;
197 }
200 {
201 return surfZones_;
202 }
203
204 //- From surface to starting global region
205 const labelList& regionOffset() const
206 {
207 return regionOffset_;
208 }
209
210 //- From global region number to refinement level
211 const labelList& minLevel() const
212 {
213 return minLevel_;
214 }
215
216 //- From global region number to refinement level
217 const labelList& maxLevel() const
218 {
219 return maxLevel_;
220 }
221
222 //- From global region number to small gap refinement level
223 const labelList& gapLevel() const
224 {
225 return gapLevel_;
226 }
227
228 //- From global region number to cell level at which blockage
229 //- detection is applied
230 const labelList& blockLevel() const
231 {
232 return blockLevel_;
233 }
234
235 //- From global region number to cell level at which leakage
236 //- detection is applied. labelMax if not set.
237 const labelList& leakLevel() const
238 {
239 return leakLevel_;
240 }
241
242 //- From global region number to specification of gap and its
243 // refinement: 3 labels specifying
244 // - minimum wanted number of cells in the gap
245 // - minimum cell level when to start trying to detect gaps
246 // - maximum cell level to refine to (so do not detect gaps if
247 // cell >= maximum level)
249 {
250 return extendedGapLevel_;
251 }
252
253 //- From global region number to side of surface to detect
254 const List<volumeType>& extendedGapMode() const
255 {
256 return extendedGapMode_;
257 }
258
259 //- From global region number to whether to detect gaps to same
260 // surface (in gap refinement)
261 const boolList& gapSelf() const
262 {
263 return selfProximity_;
264 }
265
266 //- From global region number to perpendicular angle
267 const scalarField& perpendicularAngle() const
268 {
269 return perpendicularAngle_;
270 }
271
272 //- From global region number to patch type
273 const PtrList<dictionary>& patchInfo() const
274 {
275 return patchInfo_;
276 }
277
278
279 // Helper
280
281 //- From surface and region on surface to global region
282 label globalRegion(const label surfI, const label regionI) const
283 {
284 return regionOffset_[surfI]+regionI;
285 }
286
287 //- From global region to surface + region
288 labelPair whichSurface(const label globalRegionI) const;
289
290 //- Min level for surface and region on surface
291 label minLevel(const label surfI, const label regionI) const
292 {
293 return minLevel_[globalRegion(surfI, regionI)];
294 }
295
296 //- Max level for surface and region on surface
297 label maxLevel(const label surfI, const label regionI) const
298 {
299 return maxLevel_[globalRegion(surfI, regionI)];
300 }
302 label nRegions() const
303 {
304 return minLevel_.size();
305 }
306
307 //- Per surface the maximum extendedGapLevel over all its regions
308 labelList maxGapLevel() const;
309
310 //- Calculate minLevelFields
312 (
313 const shellSurfaces& shells
314 );
315
317 //static labelList countRegions(const triSurface&);
318
319
320 // Searching
321
322 //- Find intersection of edge. Return -1 or first surface
323 // with higher (than currentLevel) minlevel.
324 // Return surface number and level.
326 (
327 const shellSurfaces& shells,
328
329 const pointField& start,
330 const pointField& end,
331 const labelList& currentLevel, // current cell refinement level
332
334 labelList& surfaceLevel
335 ) const;
336
337 //- Find all intersections of edge with any surface with applicable
338 // min/max refinement level. Unsorted order.
340 (
341 const pointField& start,
342 const pointField& end,
343 const labelList& currentLevel, // current cell refinement level
344
345 const labelList& globalMinLevel, // level per surfregion
346 const labelList& globalMaxLevel, // level per surfregion
347
348 List<vectorList>& surfaceNormal,
349 labelListList& surfaceLevel
350 ) const;
351
352 //- Find all intersections of edge with any surface with applicable
353 // min/max refinement level. Unsorted order.
355 (
356 const pointField& start,
357 const pointField& end,
358 const labelList& currentLevel, // current cell refinement level
359
360 const labelList& globalMinLevel, // level per surfregion
361 const labelList& globalMaxLevel, // level per surfregion
362
364 List<vectorList>& surfaceNormal,
365 labelListList& surfaceLevel
366 ) const;
367
368 //- Find intersection nearest to the endpoints. surface1,2 are
369 // not indices into surfacesToTest but refinement surface indices.
370 // Returns surface, region on surface (so not global surface)
371 // and position on surface.
373 (
374 const labelList& surfacesToTest,
375 const pointField& start,
376 const pointField& end,
377
378 labelList& surface1,
380 labelList& region1,
381 labelList& surface2,
383 labelList& region2
384 ) const;
385
386 //- findNearestIntersection but also get normals
388 (
389 const labelList& surfacesToTest,
390 const pointField& start,
391 const pointField& end,
392
393 labelList& surface1,
395 labelList& region1,
396 vectorField& normal1,
397
398 labelList& surface2,
400 labelList& region2,
401 vectorField& normal2
402 ) const;
403
404 //- Find nearest (to start only) intersection of edge
406 (
407 const pointField& start,
408 const pointField& end,
410 vectorField& normal
411 ) const;
412
413 //- Find nearest (to start only) intersection of edge
415 (
416 const pointField& start,
417 const pointField& end,
420 vectorField& normal
421 ) const;
422
423 //- Used for debugging only: find intersection of edge.
425 (
426 const pointField& start,
427 const pointField& end,
430 ) const;
431
432 //- Find nearest point on surfaces.
433 void findNearest
434 (
435 const labelList& surfacesToTest,
436 const pointField& samples,
437 const scalarField& nearestDistSqr,
440 ) const;
441
442 //- Find nearest point on surfaces. Return surface and region on
443 // surface (so not global surface)
445 (
446 const labelList& surfacesToTest,
447 const pointField& samples,
448 const scalarField& nearestDistSqr,
449 labelList& hitSurface,
450 labelList& hitRegion
451 ) const;
452
453 //- Find nearest point on surfaces. Return surface, region and
454 // normal on surface (so not global surface)
456 (
457 const labelList& surfacesToTest,
458 const pointField& samples,
459 const scalarField& nearestDistSqr,
460 labelList& hitSurface,
461 List<pointIndexHit>& hitInfo,
462 labelList& hitRegion,
463 vectorField& hitNormal
464 ) const;
465
466 //- Detect if a point is 'inside' (closed) surfaces.
467 // Returns -1 if not, returns first surface it is.
468 void findInside
469 (
470 const labelList& surfacesToTest,
471 const pointField& pt,
472 labelList& insideSurfaces
473 ) const;
474
475 // Region wise searching
476
477 //- Find nearest point on selected regions of surfaces.
478 void findNearest
479 (
480 const labelList& surfacesToTest,
481 const labelListList& regions,
482
483 const pointField& samples,
484 const scalarField& nearestDistSqr,
485
486 labelList& hitSurface,
487 List<pointIndexHit>& hitInfo
488 ) const;
489
490 //- Find nearest point on selected regions of surfaces.
492 (
493 const labelList& surfacesToTest,
494 const labelListList& regions,
495
496 const pointField& samples,
497 const scalarField& nearestDistSqr,
498
499 labelList& hitSurface,
500 List<pointIndexHit>& hitInfo,
501 labelList& hitRegion,
502 vectorField& hitNormal
503 ) const;
504
505};
506
507
508// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
509
510} // End namespace Foam
511
512// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
513
514#endif
515
516// ************************************************************************* //
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
labelList maxGapLevel() const
Per surface the maximum extendedGapLevel over all its regions.
const labelList & gapLevel() const
From global region number to small gap refinement level.
label minLevel(const label surfI, const label regionI) const
Min level for surface and region on surface.
const List< volumeType > & extendedGapMode() const
From global region number to side of surface to detect.
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.
const PtrList< dictionary > & patchInfo() const
From global region number to patch type.
const labelList & leakLevel() const
const searchableSurfaces & geometry() const
labelPair whichSurface(const label globalRegionI) const
From global region to surface + region.
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
const wordList & names() const
Names of surfaces.
label globalRegion(const label surfI, const label regionI) const
From surface and region on surface to global region.
label maxLevel(const label surfI, const label regionI) const
Max level for surface and region on surface.
const boolList & gapSelf() const
From global region number to whether to detect gaps to same.
const labelList & surfaces() const
void findInside(const labelList &surfacesToTest, const pointField &pt, labelList &insideSurfaces) const
Detect if a point is 'inside' (closed) surfaces.
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 & blockLevel() const
const List< FixedList< label, 3 > > & extendedGapLevel() const
From global region number to specification of gap and its.
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.
const labelList & maxLevel() const
From global region number to refinement level.
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 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.
const scalarField & perpendicularAngle() const
From global region number to perpendicular angle.
const PtrList< surfaceZonesInfo > & surfZones() const
const labelList & regionOffset() const
From surface to starting global region.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Encapsulates queries for volume refinement ('refine all cells within shell').
Definition: shellSurfaces.H:58
Contains information about location on a triSurface.
Namespace for OpenFOAM.
Fields for triSurface.
scalarField samples(nIntervals, Zero)