refinementParameters.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-2020,2023 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::refinementParameters
29 
30 Description
31  Simple container to keep together refinement specific information.
32 
33 SourceFiles
34  refinementParameters.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef refinementParameters_H
39 #define refinementParameters_H
40 
41 #include "dictionary.H"
42 #include "pointField.H"
43 #include "Switch.H"
44 #include "wordPairHashes.H"
45 #include "surfaceZonesInfo.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward Declarations
53 class polyMesh;
54 
55 /*---------------------------------------------------------------------------*\
56  Class refinementParameters Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 {
61  // Private Data
62 
63  //- Total number of cells
64  const label maxGlobalCells_;
65 
66  //- Per processor max number of cells
67  const label maxLocalCells_;
68 
69  //- When to stop refining
70  const label minRefineCells_;
71 
72  //- Curvature
73  scalar curvature_;
74 
75  //- Planarity criterion
76  const scalar planarAngle_;
77 
78  //- Number of layers between different refinement levels
79  const label nBufferLayers_;
80 
81 
82  // Selection of areas
83 
84  //- Areas not to keep
85  const pointField locationsOutsideMesh_;
86 
87  //- Areas to keep
88  pointField locationsInMesh_;
89 
90  //- How to handle connections between inside and outside points
91  const bool useLeakClosure_;
92 
93  //- Region for location
94  wordList zonesInMesh_;
95 
96  //- Information on how to handle faces on faceZones
97  const dictionary faceZoneControls_;
98 
99 
100  //- FaceZone faces allowed which have owner and neighbour in same
101  // cellZone?
102  const Switch allowFreeStandingZoneFaces_;
103 
104  //- Use old topology based problem-cell removal (cells with 8 points
105  // on surface)
106  const Switch useTopologicalSnapDetection_;
107 
108  //- Allowed load unbalance
109  const scalar maxLoadUnbalance_;
110 
111  //- Trigger cell count to start balancing
112  const label maxCellUnbalance_;
113 
114  const Switch handleSnapProblems_;
115 
116  const Switch interfaceRefine_;
117 
118  const label nErodeCellZone_;
119 
120  const label nFilterIter_;
121 
122  const scalar minCellFraction_;
123 
124  const label nMinCells_;
125 
126  //- Force final balancing after castellation
127  const bool balanceAtEnd_;
128 
129  const bool dryRun_;
130 
131 
132  // Private Member Functions
133 
134  //- No copy construct
136 
137  //- No copy assignment
138  void operator=(const refinementParameters&) = delete;
139 
140 
141 public:
142 
143  // Constructors
144 
145  //- Construct from dictionary - new syntax
146  refinementParameters(const dictionary& dict, const bool dryRun = false);
147 
148 
149  // Member Functions
150 
151  // Access
152 
153  //- Total number of cells
154  label maxGlobalCells() const
155  {
156  return maxGlobalCells_;
157  }
158 
159  //- Per processor max number of cells
160  label maxLocalCells() const
161  {
162  return maxLocalCells_;
163  }
164 
165  //- When to stop refining
166  label minRefineCells() const
167  {
168  return minRefineCells_;
169  }
170 
171  //- Curvature
172  scalar curvature() const
173  {
174  return curvature_;
175  }
176 
177  //- Angle when two intersections are considered to be planar
178  scalar planarAngle() const
179  {
180  return planarAngle_;
181  }
182 
183  //- Number of layers between different refinement levels
184  label nBufferLayers() const
185  {
186  return nBufferLayers_;
187  }
188 
189  //- Areas to keep
190  const pointField& locationsInMesh() const
191  {
192  return locationsInMesh_;
193  }
194 
195  //- Per area the zone name
196  const wordList& zonesInMesh() const
197  {
198  return zonesInMesh_;
199  }
200 
201  //- Optional points which are checked to be outside the mesh
202  const pointField& locationsOutsideMesh() const
203  {
204  return locationsOutsideMesh_;
205  }
206 
207  //- Whether to attempt to close any 'leak' between
208  // locationsInsideMesh and locationsOutsideMesh. Default is
209  // false (dump path and exit with error)
210  // (see also refinementSurfaces::leakLevel to force surfaces to
211  // be checked for leaks early-on in the refinement)
212  bool useLeakClosure() const
213  {
214  return useLeakClosure_;
215  }
216 
217  //- Are zone faces allowed only inbetween different cell zones
218  // or also just free standing?
219  bool allowFreeStandingZoneFaces() const
220  {
221  return allowFreeStandingZoneFaces_;
222  }
224  //- Use old topology based problem-cell removal
225  // (cells with 8 points on surface)
226  bool useTopologicalSnapDetection() const
227  {
228  return useTopologicalSnapDetection_;
229  }
230 
231  //- Allowed load unbalance
232  scalar maxLoadUnbalance() const
233  {
234  return maxLoadUnbalance_;
235  }
236 
237  //- Trigger cell count to start balancing
238  label maxCellUnbalance() const
239  {
240  return maxCellUnbalance_;
241  }
242 
243  bool handleSnapProblems() const
244  {
245  return handleSnapProblems_;
246  }
248  //- Refine cell with opposite faces with different refinement level
249  bool interfaceRefine() const
250  {
251  return interfaceRefine_;
252  }
253 
254  //- Number of iterations of erosion to get a consistent cellZone
255  label nErodeCellZone() const
256  {
257  return nErodeCellZone_;
258  }
259 
260  //- Number of iterations of infill/erosion to get a smoother
261  // blockage
262  label nFilterIter() const
263  {
264  return nFilterIter_;
265  }
266 
267  //- When are disconnected regions small. Fraction of overall size
268  // of a zone or background. Default 0.
269  scalar minCellFraction() const
270  {
271  return minCellFraction_;
272  }
273 
274  //- When are disconnected regions small. Absolute number of cells
275  // in a zone or background. Default 0.
276  label nMinCells() const
277  {
278  return nMinCells_;
279  }
280 
281  //- Force final balancing after castallation
282  bool balanceAtEnd() const
283  {
284  return balanceAtEnd_;
285  }
286 
287 
288  // Other
289 
290  //- Get patchInfo and faceType for faceZone
292  (
293  const word& fzName,
295  ) const;
297  //- Add cellZones to mesh. Return indices of cellZones (or -1)
299 
300  //- Checks that cells are in mesh. Returns cells (or -1) they
301  // are in.
302  static labelList findCells
303  (
304  const bool checkInsideMesh,
305  const polyMesh&,
306  const pointField& locations
307  );
308 
309  //- Extract indices of named locations (so excludes 'keepPoints')
311 
312  //- Extract indices of unnamed locations ('keepPoints')
314 
315  //- Helper: per zone (entry in zonesInMesh) the locations with
316  // additionally locationsOutsideMesh as last. Used in
317  // hole filling
319  (
321  const wordList& zonesInMesh,
323  );
324 };
326 
327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 
329 } // End namespace Foam
330 
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 
333 #endif
334 
335 // ************************************************************************* //
dictionary dict
const pointField & locationsOutsideMesh() const
Optional points which are checked to be outside the mesh.
bool useLeakClosure() const
Whether to attempt to close any &#39;leak&#39; between.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
bool interfaceRefine() const
Refine cell with opposite faces with different refinement level.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:77
Simple container to keep together refinement specific information.
dictionary getZoneInfo(const word &fzName, surfaceZonesInfo::faceZoneType &faceType) const
Get patchInfo and faceType for faceZone.
scalar minCellFraction() const
When are disconnected regions small. Fraction of overall size.
labelList addCellZonesToMesh(polyMesh &) const
Add cellZones to mesh. Return indices of cellZones (or -1)
label nErodeCellZone() const
Number of iterations of erosion to get a consistent cellZone.
const pointField & locationsInMesh() const
Areas to keep.
label minRefineCells() const
When to stop refining.
bool allowFreeStandingZoneFaces() const
Are zone faces allowed only inbetween different cell zones.
static labelList zonedLocations(const wordList &zonesInMesh)
Extract indices of named locations (so excludes &#39;keepPoints&#39;)
A class for handling words, derived from Foam::string.
Definition: word.H:63
label maxCellUnbalance() const
Trigger cell count to start balancing.
bool useTopologicalSnapDetection() const
Use old topology based problem-cell removal.
label maxGlobalCells() const
Total number of cells.
scalar maxLoadUnbalance() const
Allowed load unbalance.
const wordList & zonesInMesh() const
Per area the zone name.
label nMinCells() const
When are disconnected regions small. Absolute number of cells.
label nFilterIter() const
Number of iterations of infill/erosion to get a smoother.
scalar planarAngle() const
Angle when two intersections are considered to be planar.
static labelList findCells(const bool checkInsideMesh, const polyMesh &, const pointField &locations)
Checks that cells are in mesh. Returns cells (or -1) they.
static List< pointField > zonePoints(const pointField &locationsInMesh, const wordList &zonesInMesh, const pointField &locationsOutsideMesh)
Helper: per zone (entry in zonesInMesh) the locations with.
faceZoneType
What to do with faceZone faces.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
static labelList unzonedLocations(const wordList &zonesInMesh)
Extract indices of unnamed locations (&#39;keepPoints&#39;)
bool balanceAtEnd() const
Force final balancing after castallation.
scalar curvature() const
Curvature.
Namespace for OpenFOAM.
label maxLocalCells() const
Per processor max number of cells.
label nBufferLayers() const
Number of layers between different refinement levels.