Loading...
Searching...
No Matches
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
56class snapParameters;
57
60class fvMesh;
62/*---------------------------------------------------------------------------*\
63 Class snappyRefineDriver Declaration
64\*---------------------------------------------------------------------------*/
65
66class snappyRefineDriver
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 //- How to write surfaces. Used e.g. when writing leak closure faces
89 refPtr<surfaceWriter>& surfFormatter_;
90
91 //- Are we operating in test mode?
92 const bool dryRun_;
93
94
95 // Private Member Functions
96
97 void addNeighbours
98 (
99 const labelVector& n,
100 const labelList& cellLevel,
101 const labelVector& voxel,
102 const label voxeli,
104 ) const;
105
106 //- Rough estimate of cell size and cell count
107 void estimateCellSizeAndCount
108 (
109 const refinementParameters& refineParams
110 ) const;
111
112 //- Refine all cells pierced by explicit feature edges
113 label featureEdgeRefine
114 (
115 const refinementParameters& refineParams,
116 const label maxIter,
117 const label minRefine
118 );
119
120 //- Refine all cells containing small surface features
121 label smallFeatureRefine
122 (
123 const refinementParameters& refineParams,
124 const label maxIter
125 );
126
127 //- Refine all cells interacting with the surface
128 label surfaceOnlyRefine
129 (
130 const refinementParameters& refineParams,
131 const label maxIter,
132 const label leakBlockageIter // when to start leak closing
133 );
134
135 //- Refine all cells in small gaps
136 label gapOnlyRefine
137 (
138 const refinementParameters& refineParams,
139 const label maxIter
140 );
141
142 //- Block all cells in small gaps
143 label surfaceProximityBlock
144 (
145 const refinementParameters& refineParams,
146 const label maxIter
147 );
148
149 //- Refine all cells in large gaps
150 label bigGapOnlyRefine
151 (
152 const refinementParameters& refineParams,
153 const bool spreadGapSize,
154 const label maxIter
155 );
156
157 //- Refine cells with almost all sides refined
158 label danglingCellRefine
159 (
160 const refinementParameters& refineParams,
161 const label nFaces,
162 const label maxIter
163 );
164
165 //- Refine cells with opposite faces with differing refinement level
166 label refinementInterfaceRefine
167 (
168 const refinementParameters& refineParams,
169 const label maxIter
170 );
171
172 //- Helper: see if any element in f has higher level than cLevel
173 bool usesHigherLevel
174 (
175 const labelUList& boundaryPointLevel,
176 const labelUList& f,
177 const label cLevel
178 ) const;
179
180 //- Refine cells with a point/edge but not face on the boundary
181 label boundaryRefinementInterfaceRefine
182 (
183 const refinementParameters& refineParams,
184 const label maxIter
185 );
186
187 //- Remove all cells within intersected region
188 void removeInsideCells
189 (
190 const refinementParameters& refineParams,
191 const label nBufferLayers
192 );
193
194 //- Refine all cells inside/outside shell
195 label shellRefine
196 (
197 const refinementParameters& refineParams,
198 const label maxIter
199 );
200
201 // Directional refinement and smoothing
202
203 //- Refine (directional) all cells inside/outside shell
204 label directionalShellRefine
205 (
206 const refinementParameters& refineParams,
207 const label maxIter
208 );
209
210 //- Calculate local edge length from cell volumes
211 void mergeAndSmoothRatio
212 (
213 const scalarList& allSeedPointDist,
214 const label nSmoothExpansion,
215 List<Tuple2<scalar, scalar>>& keyAndValue
216 );
217
218 //- Smooth the directional expansion ratio
219 label directionalSmooth(const refinementParameters& refineParams);
220
221
222 //- Add baffles and remove unreachable cells
223 void baffleAndSplitMesh
224 (
225 const refinementParameters& refineParams,
226 const snapParameters& snapParams,
227 const bool handleSnapProblems,
228 const dictionary& motionDict
229 );
230
231 //- Add zones
232 void zonify
233 (
234 const refinementParameters& refineParams,
235 wordPairHashTable& zonesToFaceZone
236 );
237
238 void splitAndMergeBaffles
239 (
240 const refinementParameters& refineParams,
241 const snapParameters& snapParams,
242 const bool handleSnapProblems,
243 const dictionary& motionDict
244 );
245
246 //- Erode sticking-out zone faces. Bit heuristic.
247 void erodeNonManifoldZoneFaces
248 (
249 const refinementParameters& refineParams
250 );
251
252 //- Merge refined boundary faces (from exposing coarser cell)
253 void mergePatchFaces
254 (
255 const meshRefinement::FaceMergeType mergeType,
256 const refinementParameters& refineParams,
257 const dictionary& motionDict
258 );
259
260 //- Optionally delete some small regions
261 void deleteSmallRegions(const refinementParameters&);
262
263
264 //- No copy construct
265 snappyRefineDriver(const snappyRefineDriver&) = delete;
266
267 //- No copy assignment
268 void operator=(const snappyRefineDriver&) = delete;
269
270
271public:
272
273 //- Runtime type information
274 ClassName("snappyRefineDriver");
275
276
277 // Constructors
278
279 //- Construct from components
280 snappyRefineDriver
281 (
282 meshRefinement& meshRefiner,
283 decompositionMethod& decomposer,
284 fvMeshDistribute& distributor,
285 const labelUList& globalToMasterPatch,
286 const labelUList& globalToSlavePatch,
287 coordSetWriter& setFormatter,
288 refPtr<surfaceWriter>& surfFormatter,
289 const bool dryRun = false
290 );
291
292
293 // Member Functions
294
295 //- Do all the refinement
296 void doRefine
297 (
298 const dictionary& refineDict,
299 const refinementParameters& refineParams,
300 const snapParameters& snapParams,
301 const bool prepareForSnapping,
302 const meshRefinement::FaceMergeType mergeType,
303 const dictionary& motionDict
304 );
305
306 //- Helper: add faceZones and patches
307 static void addFaceZones
308 (
309 meshRefinement& meshRefiner,
310 const refinementParameters& refineParams,
311 const HashTable<Pair<word>>& faceZoneToPatches
312 );
313};
314
315
316// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317
318} // End namespace Foam
319
320// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
321
322#endif
323
324// ************************************************************************* //
label n
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
A HashTable similar to std::unordered_map.
Definition HashTable.H:124
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
An ordered pair of two objects of type <T> with first() and second() elements.
Definition Pair.H:66
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition Tuple2.H:51
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:133
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
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.
A class for managing references or pointers (no reference counting).
Definition refPtr.H:54
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:74
Namespace for OpenFOAM.
HashTable< word, wordPair, Foam::Hash< wordPair > > wordPairHashTable
HashTable of wordPair.
List< label > labelList
A List of labels.
Definition List.H:62
Vector< label > labelVector
Vector of labels.
Definition labelVector.H:47
UList< label > labelUList
A UList of labels.
Definition UList.H:75
List< scalar > scalarList
List of scalar.
Definition scalarList.H:32
labelList f(nPoints)