snappyRefineDriver.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-2021 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::snappyRefineDriver
29
30Description
31
32SourceFiles
33 snappyRefineDriver.C
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef snappyRefineDriver_H
38#define snappyRefineDriver_H
39
40#include "wordPairHashes.H"
41#include "labelList.H"
42#include "scalarField.H"
43#include "Tuple2.H"
44#include "coordSetWriter.H"
45#include "DynamicList.H"
46#include "labelVector.H"
47#include "meshRefinement.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53
54// Forward Declarations
55class refinementParameters;
56class snapParameters;
57
58class decompositionMethod;
59class fvMeshDistribute;
60class fvMesh;
61
62/*---------------------------------------------------------------------------*\
63 Class snappyRefineDriver Declaration
64\*---------------------------------------------------------------------------*/
67{
68 // Private data
69
70 //- Mesh+surface
71 meshRefinement& meshRefiner_;
72
73 //- Reference to decomposition method
74 decompositionMethod& decomposer_;
75
76 //- Reference to mesh distribution engine
77 fvMeshDistribute& distributor_;
78
79 //- From surface region to patch
80 const labelList globalToMasterPatch_;
81
82 //- From surface region to patch
83 const labelList globalToSlavePatch_;
84
85 //- How to write lines. Used e.g. when writing leak-paths
86 coordSetWriter& setFormatter_;
87
88 //- Are we operating in test mode?
89 const bool dryRun_;
90
91
92 // Private Member Functions
93
94 void addNeighbours
95 (
96 const labelVector& n,
97 const labelList& cellLevel,
98 const labelVector& voxel,
99 const label voxeli,
101 ) const;
102
103 //- Rough estimate of cell size and cell count
104 void estimateCellSizeAndCount
105 (
106 const refinementParameters& refineParams
107 ) const;
108
109 //- Refine all cells pierced by explicit feature edges
110 label featureEdgeRefine
111 (
112 const refinementParameters& refineParams,
113 const label maxIter,
114 const label minRefine
115 );
116
117 //- Refine all cells containing small surface features
118 label smallFeatureRefine
119 (
120 const refinementParameters& refineParams,
121 const label maxIter
122 );
123
124 //- Refine all cells interacting with the surface
125 label surfaceOnlyRefine
126 (
127 const refinementParameters& refineParams,
128 const label maxIter,
129 const label leakBlockageIter // when to start leak closing
130 );
131
132 //- Refine all cells in small gaps
133 label gapOnlyRefine
134 (
135 const refinementParameters& refineParams,
136 const label maxIter
137 );
138
139 //- Block all cells in small gaps
140 label surfaceProximityBlock
141 (
142 const refinementParameters& refineParams,
143 const label maxIter
144 );
145
146 //- Refine all cells in large gaps
147 label bigGapOnlyRefine
148 (
149 const refinementParameters& refineParams,
150 const bool spreadGapSize,
151 const label maxIter
152 );
153
154 //- Refine cells with almost all sides refined
155 label danglingCellRefine
156 (
157 const refinementParameters& refineParams,
158 const label nFaces,
159 const label maxIter
160 );
161
162 //- Refine cells with opposite faces with differing refinement level
163 label refinementInterfaceRefine
164 (
165 const refinementParameters& refineParams,
166 const label maxIter
167 );
168
169 //- Helper: see if any element in f has higher level than cLevel
170 bool usesHigherLevel
171 (
172 const labelUList& boundaryPointLevel,
173 const labelUList& f,
174 const label cLevel
175 ) const;
176
177 //- Refine cells with a point/edge but not face on the boundary
178 label boundaryRefinementInterfaceRefine
179 (
180 const refinementParameters& refineParams,
181 const label maxIter
182 );
183
184 //- Remove all cells within intersected region
185 void removeInsideCells
186 (
187 const refinementParameters& refineParams,
188 const label nBufferLayers
189 );
190
191 //- Refine all cells inside/outside shell
192 label shellRefine
193 (
194 const refinementParameters& refineParams,
195 const label maxIter
196 );
197
198 // Directional refinement and smoothing
199
200 //- Refine (directional) all cells inside/outside shell
201 label directionalShellRefine
202 (
203 const refinementParameters& refineParams,
204 const label maxIter
205 );
206
207 //- Calculate local edge length from cell volumes
208 void mergeAndSmoothRatio
209 (
210 const scalarList& allSeedPointDist,
211 const label nSmoothExpansion,
212 List<Tuple2<scalar, scalar>>& keyAndValue
213 );
214
215 //- Smooth the directional expansion ratio
216 label directionalSmooth(const refinementParameters& refineParams);
217
218
219 //- Add baffles and remove unreachable cells
220 void baffleAndSplitMesh
221 (
222 const refinementParameters& refineParams,
223 const snapParameters& snapParams,
224 const bool handleSnapProblems,
225 const dictionary& motionDict
226 );
227
228 //- Add zones
229 void zonify
230 (
231 const refinementParameters& refineParams,
232 wordPairHashTable& zonesToFaceZone
233 );
234
235 void splitAndMergeBaffles
236 (
237 const refinementParameters& refineParams,
238 const snapParameters& snapParams,
239 const bool handleSnapProblems,
240 const dictionary& motionDict
241 );
242
243 //- Merge refined boundary faces (from exposing coarser cell)
244 void mergePatchFaces
245 (
246 const meshRefinement::FaceMergeType mergeType,
247 const refinementParameters& refineParams,
248 const dictionary& motionDict
249 );
250
251 //- Optionally delete some small regions
252 void deleteSmallRegions(const refinementParameters&);
253
254
255 //- No copy construct
256 snappyRefineDriver(const snappyRefineDriver&) = delete;
257
258 //- No copy assignment
259 void operator=(const snappyRefineDriver&) = delete;
260
261
262public:
263
264 //- Runtime type information
265 ClassName("snappyRefineDriver");
266
267
268 // Constructors
269
270 //- Construct from components
272 (
273 meshRefinement& meshRefiner,
274 decompositionMethod& decomposer,
275 fvMeshDistribute& distributor,
276 const labelUList& globalToMasterPatch,
277 const labelUList& globalToSlavePatch,
278 coordSetWriter& setFormatter,
279 const bool dryRun = false
280 );
281
282
283 // Member Functions
284
285 //- Do all the refinement
286 void doRefine
287 (
288 const dictionary& refineDict,
289 const refinementParameters& refineParams,
290 const snapParameters& snapParams,
291 const bool prepareForSnapping,
292 const meshRefinement::FaceMergeType mergeType,
293 const dictionary& motionDict
294 );
295
296 //- Helper: add faceZones and patches
297 static void addFaceZones
298 (
299 meshRefinement& meshRefiner,
300 const refinementParameters& refineParams,
301 const HashTable<Pair<word>>& faceZoneToPatches
302 );
303};
304
305
306// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307
308} // End namespace Foam
309
310// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311
312#endif
313
314// ************************************************************************* //
label n
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
A HashTable similar to std::unordered_map.
Definition: HashTable.H:123
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: Pair.H:69
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:58
Base class for writing coordSet(s) and tracks with fields.
Abstract base class for domain decomposition.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
FaceMergeType
Enumeration for what to do with co-planar patch faces on a single.
Simple container to keep together refinement specific information.
Simple container to keep together snap specific information.
ClassName("snappyRefineDriver")
Runtime type information.
static void addFaceZones(meshRefinement &meshRefiner, const refinementParameters &refineParams, const HashTable< Pair< word > > &faceZoneToPatches)
Helper: add faceZones and patches.
void doRefine(const dictionary &refineDict, const refinementParameters &refineParams, const snapParameters &snapParams, const bool prepareForSnapping, const meshRefinement::FaceMergeType mergeType, const dictionary &motionDict)
Do all the refinement.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
Namespace for OpenFOAM.
labelList f(nPoints)