shellSurfaces.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-2015 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::shellSurfaces
29 
30 Description
31  Encapsulates queries for volume refinement ('refine all cells within
32  shell').
33 
34 SourceFiles
35  shellSurfaces.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef shellSurfaces_H
40 #define shellSurfaces_H
41 
42 #include "searchableSurface.H"
43 #include "Enum.H"
44 #include "Tuple2.H"
45 #include "labelVector.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 class searchableSurfaces;
53 
54 /*---------------------------------------------------------------------------*\
55  Class shellSurfaces Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class shellSurfaces
59 {
60 public:
61 
62  // Public data types
63 
64  //- Volume refinement controls
65  enum refineMode
66  {
67  INSIDE, // Refine all inside shell
68  OUTSIDE, // ,, outside
69  DISTANCE // Refine based on distance to shell
70  };
71 
72 
73 private:
74 
75  // Private data
76 
77  //- Reference to all geometry.
78  const searchableSurfaces& allGeometry_;
79 
80  //- Dry-run mode?
81  const bool dryRun_;
82 
83  //- Indices of surfaces that are shells
84  labelList shells_;
85 
86  //- Per shell whether to refine inside or outside
87  List<refineMode> modes_;
88 
89  //- Per shell the list of ranges
90  List<scalarField> distances_;
91 
92  //- Per shell per distance the refinement level
93  labelListList levels_;
94 
95 
96  // Directional
97 
98  //- Per shell any additional directional refinement
100 
101  //- Per shell the smoothing direction
102  vectorField smoothDirection_;
103 
104  //- Per shell the directional smoothing iterations
105  labelList nSmoothExpansion_;
106 
107  //- Per shell the positional smoothing iterations
108  labelList nSmoothPosition_;
109 
110 
111  // Gap level refinement
112 
113  //- Per shell, per region the small-gap level specification
114  List<List<FixedList<label, 3>>> extendedGapLevel_;
115 
116  //- Per shell, per region the small-gap level specification
117  List<List<volumeType>> extendedGapMode_;
118 
119 
120  // Private data
121 
122  //- refineMode names
123  static const Enum<refineMode> refineModeNames_;
124 
125 
126  // Private Member Functions
127 
128  //- Helper function for initialisation of levels
129  void setAndCheckLevels
130  (
131  const label shellI,
133  );
134 
135  //- Helper function for checking of gap information
136  void checkGapLevels
137  (
138  const dictionary&,
139  const label shellI,
140  const List<FixedList<label, 3>>& levels
141  );
142 
143  void orient();
144 
145  //- Find first shell with a level higher than maxLevel
146  void findHigherLevel
147  (
148  const pointField& pt,
149  const label shellI,
151  ) const;
152 
153  //- Update highest min gap level
154  void findHigherGapLevel
155  (
156  const pointField& pt,
157  const labelList& ptLevel,
158  const label shellI,
159  labelList& gapShell,
160  List<FixedList<label, 3>>& gapInfo,
161  List<volumeType>& gapMode
162  ) const;
163 
164  //- Find first shell with a level lower or equal to minLevel. Update
165  // minLevel and shell.
166  void findLevel
167  (
168  const pointField& pt,
169  const label shellI,
170  labelList& minLevel,
171  labelList& shell
172  ) const;
173 
174 public:
175 
176  // Constructors
177 
178  //- Construct from geometry and dictionary
180  (
181  const searchableSurfaces& allGeometry,
182  const dictionary& shellsDict,
183  const bool dryRun = false
184  );
185 
186 
187  // Member Functions
188 
189  // Access
190 
191  //- Indices of surfaces that are shells
192  const labelList& shells() const
193  {
194  return shells_;
195  }
196 
197  //- Per shell, per region the small-gap level specification
199  {
200  return extendedGapLevel_;
201  }
202 
203  //- Per shell, per region the small-gap level specification
204  const List<List<volumeType>>& extendedGapMode() const
205  {
206  return extendedGapMode_;
207  }
208 
209  // Query
210 
211  //- Highest shell level
212  label maxLevel() const;
213 
214  //- Highest shell gap level
215  labelList maxGapLevel() const;
216 
217  //- Min and max cell level for directional refinement
219 
220  //- Find shell level higher than ptLevel
221  void findHigherLevel
222  (
223  const pointField& pt,
224  const labelList& ptLevel,
226  ) const;
227 
228  //- Find a shell whose minimum gap level is >= ptLevel
229  void findHigherGapLevel
230  (
231  const pointField& pt,
232  const labelList& ptLevel,
233  labelList& gapShell,
234  List<FixedList<label, 3>>& gapInfo,
235  List<volumeType>& gapMode
236  ) const;
237 
238  //- Find a shell whose minimum gap level is >= ptLevel. gapInfo
239  // is (0 0 0) if no shell found
240  void findHigherGapLevel
241  (
242  const pointField& pt,
243  const labelList& ptLevel,
244  List<FixedList<label, 3>>& gapInfo,
245  List<volumeType>& gapMode
246  ) const;
247 
248  //- Find first shell (or -1) with level equal or lower than ptLevel.
249  void findLevel
250  (
251  const pointField& pt,
252  const labelList& ptLevel,
253  labelList& shell
254  ) const;
255 
256  //- Find any shell (or -1) with higher wanted directional level
258  (
259  const pointField& pt,
260  const labelList& ptLevel, // omnidirectional level
261  const labelList& dirLevel, // directional level
262  const direction dir,
263  labelList& shell
264  ) const;
265 
266  //- Per shell the smoothing direction
267  const vectorField& smoothDirection() const;
268 
269  //- Per shell the directional smoothing iterations
270  const labelList& nSmoothExpansion() const;
271 
272  //- Per shell the positional smoothing iterations
273  const labelList& nSmoothPosition() const;
274 };
275 
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 } // End namespace Foam
280 
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 
283 #endif
284 
285 // ************************************************************************* //
Foam::shellSurfaces::refineMode
refineMode
Volume refinement controls.
Definition: shellSurfaces.H:64
Foam::shellSurfaces::shells
const labelList & shells() const
Indices of surfaces that are shells.
Definition: shellSurfaces.H:191
Foam::Enum< refineMode >
Foam::shellSurfaces::smoothDirection
const vectorField & smoothDirection() const
Per shell the smoothing direction.
Definition: shellSurfaces.C:832
searchableSurface.H
Tuple2.H
labelVector.H
Foam::shellSurfaces::DISTANCE
Definition: shellSurfaces.H:68
Foam::shellSurfaces::extendedGapLevel
const List< List< FixedList< label, 3 > > > & extendedGapLevel() const
Per shell, per region the small-gap level specification.
Definition: shellSurfaces.H:197
Foam::shellSurfaces::maxGapLevel
labelList maxGapLevel() const
Highest shell gap level.
Definition: shellSurfaces.C:799
Foam::shellSurfaces::OUTSIDE
Definition: shellSurfaces.H:67
Foam::shellSurfaces
Encapsulates queries for volume refinement ('refine all cells within shell').
Definition: shellSurfaces.H:57
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:62
Foam::Field< vector >
Foam::shellSurfaces::directionalSelectLevel
labelPairList directionalSelectLevel() const
Min and max cell level for directional refinement.
Definition: shellSurfaces.C:815
Foam::shellSurfaces::shellSurfaces
shellSurfaces(const searchableSurfaces &allGeometry, const dictionary &shellsDict, const bool dryRun=false)
Construct from geometry and dictionary.
Definition: shellSurfaces.C:579
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::shellSurfaces::findDirectionalLevel
void findDirectionalLevel(const pointField &pt, const labelList &ptLevel, const labelList &dirLevel, const direction dir, labelList &shell) const
Find any shell (or -1) with higher wanted directional level.
Definition: shellSurfaces.C:924
Foam::List< label >
Foam::searchableSurfaces
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Definition: searchableSurfaces.H:92
Foam::FixedList< label, 3 >
Foam::shellSurfaces::extendedGapMode
const List< List< volumeType > > & extendedGapMode() const
Per shell, per region the small-gap level specification.
Definition: shellSurfaces.H:203
Foam::direction
uint8_t direction
Definition: direction.H:47
Foam::shellSurfaces::nSmoothPosition
const labelList & nSmoothPosition() const
Per shell the positional smoothing iterations.
Definition: shellSurfaces.C:838
Foam::shellSurfaces::nSmoothExpansion
const labelList & nSmoothExpansion() const
Per shell the directional smoothing iterations.
Definition: shellSurfaces.C:826
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:57
Foam::shellSurfaces::INSIDE
Definition: shellSurfaces.H:66
Foam::shellSurfaces::maxLevel
label maxLevel() const
Highest shell level.
Definition: shellSurfaces.C:788
Enum.H