Loading...
Searching...
No Matches
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
57class shellSurfaces;
58class triSurfaceMesh;
60/*---------------------------------------------------------------------------*\
61 Class refinementSurfaces Declaration
62\*---------------------------------------------------------------------------*/
63
64class refinementSurfaces
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 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 //- From global region number to whether to add buffer layers
123 boolList addBufferLayers_;
124
125 //- Are we operating in test mode?
126 const bool dryRun_;
127
128
129 // Private Member Functions
130
131 //- Given intersection results with geom detect local shell refinement
132 // level (possibly cached on triangles of geom)
133 labelList findHigherLevel
134 (
135 const searchableSurface& geom,
136 const shellSurfaces& shells,
137 const List<pointIndexHit>& intersectionInfo,
138 const labelList& surfaceLevel
139 ) const;
140
141 //- Calculate global region to surface
142 static labelList calcSurfaceIndex
143 (
144 const searchableSurfaces& allGeometry,
145 const labelList& surfaces
146 );
147
148 //- No copy construct
149 refinementSurfaces(const refinementSurfaces&) = delete;
150
151 //- No copy assignment
152 void operator=(const refinementSurfaces&) = delete;
153
154
155public:
156
157 // Constructors
158
159 //- Construct from surfaces and dictionary
160 refinementSurfaces
161 (
162 const searchableSurfaces& allGeometry,
163 const dictionary&,
164 const label gapLevelIncrement,
165 const bool dryRun
166 );
167
168 //- Construct from components
169 refinementSurfaces
170 (
171 const searchableSurfaces& allGeometry,
172 const labelList& surfaces,
173 const wordList& names,
175 const labelList& regionOffset,
176 const labelList& minLevel,
177 const labelList& maxLevel,
178 const labelList& gapLevel,
181 const bool dryRun
182 );
183
184
185 // Member Functions
186
187 // Access
188
189 const searchableSurfaces& geometry() const
190 {
191 return allGeometry_;
192 }
193
194 const labelList& surfaces() const
195 {
196 return surfaces_;
197 }
198
199 //- Names of surfaces
200 const wordList& names() const
201 {
202 return names_;
203 }
204
206 {
207 return surfZones_;
208 }
209
210 //- From surface to starting global region
211 const labelList& regionOffset() const
212 {
213 return regionOffset_;
214 }
215
216 //- From global region number to refinement level
217 const labelList& minLevel() const
218 {
219 return minLevel_;
220 }
221
222 //- From global region number to refinement level
223 const labelList& maxLevel() const
224 {
225 return maxLevel_;
226 }
227
228 //- From global region number to small gap refinement level
229 const labelList& gapLevel() const
230 {
231 return gapLevel_;
232 }
233
234 //- From global region number to cell level at which blockage
235 //- detection is applied
236 const labelList& blockLevel() const
237 {
238 return blockLevel_;
239 }
240
241 //- From global region number to cell level at which leakage
242 //- detection is applied. labelMax if not set.
243 const labelList& leakLevel() const
244 {
245 return leakLevel_;
246 }
247
248 //- From global region number to specification of gap and its
249 // refinement: 3 labels specifying
250 // - minimum wanted number of cells in the gap
251 // - minimum cell level when to start trying to detect gaps
252 // - maximum cell level to refine to (so do not detect gaps if
253 // cell >= maximum level)
255 {
256 return extendedGapLevel_;
257 }
258
259 //- From global region number to side of surface to detect
260 const List<volumeType>& extendedGapMode() const
261 {
262 return extendedGapMode_;
263 }
265 //- From global region number to whether to detect gaps to same
266 // surface (in gap refinement)
267 const boolList& gapSelf() const
268 {
269 return selfProximity_;
270 }
271
272 //- From global region number to specification of curvature
273 // refinement: 4 labels specifying
274 // - minimum wanted number of cells in the curvature radius
275 // - ?minimum cell level when to start trying to detect gaps
276 // - maximum cell level to refine to (so do not detect curvature if
277 // celllevel >= maximum level)
278 // - minimum radius to ignore (expressed as refinement level).
279 // This can be used to ignore feature-edges. Set to -1 to ignore.
281 {
282 return extendedCurvatureLevel_;
283 }
284
285 //- From global region number to perpendicular angle
286 const scalarField& perpendicularAngle() const
287 {
288 return perpendicularAngle_;
289 }
290
291 //- From global region number to patch type
292 const PtrList<dictionary>& patchInfo() const
293 {
294 return patchInfo_;
295 }
296
297 //- From global region number to whether to add buffer layers
298 // when snapping
299 const boolList& addBufferLayers() const
300 {
301 return addBufferLayers_;
302 }
303
304
305 // Helper
307 //- From surface and region on surface to global region
308 label globalRegion(const label surfI, const label regionI) const
309 {
310 return regionOffset_[surfI]+regionI;
311 }
312
313 //- From global region to surface + region
314 labelPair whichSurface(const label globalRegionI) const;
315
316 //- Min level for surface and region on surface
317 label minLevel(const label surfI, const label regionI) const
318 {
319 return minLevel_[globalRegion(surfI, regionI)];
321
322 //- Max level for surface and region on surface
323 label maxLevel(const label surfI, const label regionI) const
324 {
325 return maxLevel_[globalRegion(surfI, regionI)];
326 }
327
328 label nRegions() const
329 {
330 return minLevel_.size();
331 }
332
333 //- Per surface the maximum extendedGapLevel over all its regions
334 labelList maxGapLevel() const;
335
336 //- Per surface the maximum curvatureLevel over all its regions
339 //- Calculate minLevelFields according to both surface- and
340 // shell-based levels
342 (
343 const shellSurfaces& shells
344 );
345
346 //- Update minLevelFields according to (triSurface-only) curvature
348 (
349 const scalar cosAngle,
350 const scalar level0EdgeLength
351 );
352
354 //static labelList countRegions(const triSurface&);
355
356
357 // Searching
358
359 //- Find intersection of edge. Return -1 or first surface
360 // with higher (than currentLevel) minlevel.
361 // Return surface number and level.
363 (
364 const shellSurfaces& shells,
365
366 const pointField& start,
367 const pointField& end,
368 const labelList& currentLevel, // current cell refinement level
369
371 labelList& surfaceLevel
372 ) const;
373
374 //- Find all intersections of edge with any surface with applicable
375 // min/max refinement level. Unsorted order.
377 (
378 const pointField& start,
379 const pointField& end,
380 const labelList& currentLevel, // current cell refinement level
381
382 const labelList& globalMinLevel, // level per surfregion
383 const labelList& globalMaxLevel, // level per surfregion
384
385 List<vectorList>& surfaceNormal,
386 labelListList& surfaceLevel
387 ) const;
388
389 //- Find all intersections of edge with any surface with applicable
390 // min/max refinement level. Unsorted order.
392 (
393 const pointField& start,
394 const pointField& end,
395 const labelList& currentLevel, // current cell refinement level
396
397 const labelList& globalMinLevel, // level per surfregion
398 const labelList& globalMaxLevel, // level per surfregion
399
401 List<vectorList>& surfaceNormal,
402 labelListList& surfaceLevel
403 ) const;
405 //- Find intersection nearest to the endpoints. surface1,2 are
406 // not indices into surfacesToTest but refinement surface indices.
407 // Returns surface, region on surface (so not global surface)
408 // and position on surface.
410 (
411 const labelList& surfacesToTest,
412 const pointField& start,
413 const pointField& end,
414
415 labelList& surface1,
417 labelList& region1,
418 labelList& surface2,
420 labelList& region2
421 ) const;
422
423 //- findNearestIntersection but also get normals
425 (
426 const labelList& surfacesToTest,
427 const pointField& start,
428 const pointField& end,
429
430 labelList& surface1,
432 labelList& region1,
433 vectorField& normal1,
434
435 labelList& surface2,
437 labelList& region2,
438 vectorField& normal2
439 ) const;
440
441 //- Find nearest (to start only) intersection of edge
443 (
444 const pointField& start,
445 const pointField& end,
447 vectorField& normal
448 ) const;
449
450 //- Find nearest (to start only) intersection of edge
452 (
453 const pointField& start,
454 const pointField& end,
456 labelList& regions,
458 vectorField& normal
459 ) const;
460
461 //- Find nearest (to start only) intersection of edge
463 (
464 const pointField& start,
465 const pointField& end,
468 vectorField& normal
469 ) const;
470
471 //- Used for debugging only: find intersection of edge.
473 (
474 const pointField& start,
475 const pointField& end,
478 ) const;
479
480 //- Find nearest point on surfaces.
481 void findNearest
482 (
483 const labelList& surfacesToTest,
484 const pointField& samples,
485 const scalarField& nearestDistSqr,
488 ) const;
489
490 //- Find nearest point on surfaces. Return surface and region on
491 // surface (so not global surface)
493 (
494 const labelList& surfacesToTest,
495 const pointField& samples,
496 const scalarField& nearestDistSqr,
497 labelList& hitSurface,
498 labelList& hitRegion
499 ) const;
500
501 //- Find nearest point on surfaces. Return surface, region and
502 // normal on surface (so not global surface)
504 (
505 const labelList& surfacesToTest,
506 const pointField& samples,
507 const scalarField& nearestDistSqr,
508 labelList& hitSurface,
509 List<pointIndexHit>& hitInfo,
510 labelList& hitRegion,
511 vectorField& hitNormal
512 ) const;
513
514 //- Detect if a point is 'inside' (closed) surfaces.
515 // Returns -1 if not, returns first surface it is.
516 void findInside
517 (
518 const labelList& surfacesToTest,
519 const pointField& pt,
520 labelList& insideSurfaces
521 ) const;
522
523 // Region wise searching
524
525 //- Find nearest point on selected regions of surfaces.
526 void findNearest
527 (
528 const labelList& surfacesToTest,
529 const labelListList& regions,
530
531 const pointField& samples,
532 const scalarField& nearestDistSqr,
533
534 labelList& hitSurface,
535 List<pointIndexHit>& hitInfo
536 ) const;
537
538 //- Find nearest point on selected regions of surfaces.
540 (
541 const labelList& surfacesToTest,
542 const labelListList& regions,
543
544 const pointField& samples,
545 const scalarField& nearestDistSqr,
546
547 labelList& hitSurface,
548 List<pointIndexHit>& hitInfo,
549 labelList& hitRegion,
550 vectorField& hitNormal
551 ) const;
552
553};
554
555
556// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
557
558} // End namespace Foam
559
560// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
561
562#endif
563
564// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
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 List< FixedList< label, 4 > > & extendedCurvatureLevel() const
From global region number to specification of curvature.
const labelList & leakLevel() const
From global region number to cell level at which leakage detection is applied. labelMax if not set.
const searchableSurfaces & geometry() const
labelPair whichSurface(const label globalRegionI) const
From global region to surface + region.
const boolList & addBufferLayers() const
From global region number to whether to add buffer layers.
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
labelList maxCurvatureLevel() const
Per surface the maximum curvatureLevel over all its regions.
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
From global region number to cell level at which blockage detection is applied.
const List< FixedList< label, 3 > > & extendedGapLevel() const
From global region number to specification of gap and its.
void setCurvatureMinLevelFields(const scalar cosAngle, const scalar level0EdgeLength)
Update minLevelFields according to (triSurface-only) curvature.
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 according to both surface- and.
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').
Contains information about location on a triSurface.
IOoject and searching on triSurface.
Namespace for OpenFOAM.
Pair< label > labelPair
A pair of labels.
Definition Pair.H:54
List< word > wordList
List of word.
Definition fileName.H:60
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< bool > boolList
A List of bools.
Definition List.H:60
vectorField pointField
pointField is a vectorField.
Fields for triSurface.
scalarField samples(nIntervals, Zero)