Loading...
Searching...
No Matches
polyMeshAdder.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-2016 OpenFOAM Foundation
9 Copyright (C) 2020-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::polyMeshAdder
29
30Description
31 Adds two meshes without using any polyMesh morphing.
32
33 Gets faces to couple as faceCoupleInfo which is list of faces on both
34 meshes. Returns map from last mesh addition.
35
36SourceFiles
37 polyMeshAdder.C
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef Foam_polyMeshAdder_H
42#define Foam_polyMeshAdder_H
43
44#include "autoPtr.H"
45#include "polyMesh.H"
46#include "mapAddedPolyMesh.H"
47#include "faceCoupleInfo.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53
54// Forward Declarations
55class IOobject;
56class polyTopoChange;
58/*---------------------------------------------------------------------------*\
59 Class polyMeshAdder Declaration
60\*---------------------------------------------------------------------------*/
61
62class polyMeshAdder
63{
64 // Private Member Functions
65
66 //- Index of patch in allPatches. Add if nonexisting.
67 static label patchIndex
68 (
69 const polyPatch&,
70 DynamicList<word>& allPatchNames,
71 DynamicList<word>& allPatchTypes
72 );
73
74 //- Index of zone in all zones
75 static label zoneIndex(const word&, DynamicList<word>&);
76
77 static void mergePatchNames
78 (
79 const polyBoundaryMesh& patches0,
80 const polyBoundaryMesh& patches1,
81
82 DynamicList<word>& allPatchNames,
83 DynamicList<word>& allPatchTypes,
84
85 labelList& from1ToAllPatches,
86 labelList& fromAllTo1Patches
87 );
88
89 static List<polyPatch*> combinePatches
90 (
91 const polyMesh& mesh0,
92 const polyMesh& mesh1,
93 const polyBoundaryMesh& allBoundaryMesh,
94 const label nAllPatches,
95 const labelList& fromAllTo1Patches,
96
97 const label nInternalFaces,
98 const labelList& nFaces,
99
100 labelList& from0ToAllPatches,
101 labelList& from1ToAllPatches
102 );
103
104 //- Determine order for internalFaces to be upper-triangular.
105 // Does not change order of external faces.
106 static labelList getFaceOrder
107 (
108 const cellList& cells,
109 const label nInternalFaces,
110 const labelList& owner,
111 const labelList& neighbour
112 );
113
114 //- Extends face f with split points. cutEdgeToPoints gives for every
115 // edge the points introduced inbetween the endpoints.
116 static void insertVertices
117 (
118 const EdgeMap<labelList>& cutEdgeToPoints,
119 const Map<label>& meshToMaster,
120 const labelList& masterToCutPoints,
121 const face& masterFace,
122
123 DynamicList<label>& workFace,
124 face& f
125 );
126
127 //- Merges primitives of two meshes.
128 static void mergePrimitives
129 (
130 const polyMesh& mesh0,
131 const polyMesh& mesh1,
132 const faceCoupleInfo& coupleInfo,
133
134 const label nAllPatches,
135 const labelList& fromAllTo1Patches,
136 const labelList& from1ToAllPatches,
137
138 pointField& allPoints,
139 labelList& from0ToAllPoints,
140 labelList& from1ToAllPoints,
141
142 faceList& allFaces,
143 labelList& allOwner,
144 labelList& allNeighbour,
145 label& nInternalFaces,
146 labelList& nFacesPerPatch,
147 label& nCells,
148
149 labelList& from0ToAllFaces,
150 labelList& from1ToAllFaces,
151 labelList& from1ToAllCells
152 );
153
154 //- Merge point zones
155 static void mergePointZones
156 (
157 const label nAllPoints,
158
159 const pointZoneMesh& pz0,
160 const pointZoneMesh& pz1,
161 const labelList& from0ToAllPoints,
162 const labelList& from1ToAllPoints,
163
164 DynamicList<word>& zoneNames,
165 labelList& from1ToAll,
166 List<DynamicList<label>>& pzPoints
167 );
168
169 //- Merge face zones
170 static void mergeFaceZones
171 (
172 const labelList& allOwner,
173
174 const polyMesh& mesh0,
175 const polyMesh& mesh1,
176 const labelList& from0ToAllFaces,
177 const labelList& from1ToAllFaces,
178 const labelList& from1ToAllCells,
179
180 DynamicList<word>& zoneNames,
181 labelList& from1ToAll,
182 List<DynamicList<label>>& fzFaces,
183 List<DynamicList<bool>>& fzFlips
184 );
185
186 //- Merge cell zones
187 static void mergeCellZones
188 (
189 const label nAllCells,
190
191 const cellZoneMesh& cz0,
192 const cellZoneMesh& cz1,
193 const labelList& from1ToAllCells,
194
195 DynamicList<word>& zoneNames,
196 labelList& from1ToAll,
197 List<DynamicList<label>>& czCells
198 );
199
200 //- Merge point/face/cell zone information
201 static void mergeZones
202 (
203 const label nAllPoints,
204 const labelList& allOwner,
205 const label nAllCells,
206
207 const polyMesh& mesh0,
208 const polyMesh& mesh1,
209 const labelList& from0ToAllPoints,
210 const labelList& from0ToAllFaces,
211 const labelList& from1ToAllPoints,
212 const labelList& from1ToAllFaces,
213 const labelList& from1ToAllCells,
214
215 DynamicList<word>& pointZoneNames,
216 List<DynamicList<label>>& pzPoints,
217
218 DynamicList<word>& faceZoneNames,
219 List<DynamicList<label>>& fzFaces,
220 List<DynamicList<bool>>& fzFlips,
221
222 DynamicList<word>& cellZoneNames,
223 List<DynamicList<label>>& czCells
224 );
225
226 //- Create new zones and add to new mesh.
227 static void addZones
228 (
229 const UList<word>& pointZoneNames,
230 const List<DynamicList<label>>& pzPoints,
231
232 const UList<word>& faceZoneNames,
233 const List<DynamicList<label>>& fzFaces,
234 const List<DynamicList<bool>>& fzFlips,
235
236 const UList<word>& cellZoneNames,
237 const List<DynamicList<label>>& czCells,
238
240 );
241
242
243 //- Multi-mesh addition
244
245 //- Find n'th processor patch going to nbrProci. Usually n=0 except
246 //- for e.g. processorCyclic
247 static label procPatchIndex
248 (
249 const polyBoundaryMesh& pbm,
250 const label nbrProci,
251 const label n
252 );
253
254 //- Determine shared points. Takes pairs of one-to-one patches
255 //0 that are converted into internal faces
256 static void compactPoints
257 (
259 const labelListList& localBoundaryFace,
260 const labelListList& remoteFaceProc,
261 const labelListList& remoteBoundaryFace,
262 const labelListList& remoteFaceStart,
264
265 labelListList& pointProcAddressing,
266 labelListList& localPoints
267 );
268
269
270public:
271
272 // Member Functions
273
274
275 //- Add two polyMeshes. Returns new polyMesh and map construct.
277 (
278 const IOobject& io,
279 const polyMesh& mesh0,
280 const polyMesh& mesh1,
281 const faceCoupleInfo& coupleInfo,
283 );
284
285 //- Inplace add mesh to polyMesh. Returns map construct.
287 (
288 polyMesh& mesh0,
289 const polyMesh& mesh1,
290 const faceCoupleInfo& coupleInfo,
291 const bool validBoundary = true
292 );
293
294 // Point merging
295
296 //- Find topologically and geometrically shared points.
297 //
298 // - should only be called for parallel correct mesh
299 // (since uses mesh.globalData)
300 // - returns Map from point to master point (all in mesh point
301 // labels) for any sets of points that need to be merged.
303 (
304 const polyMesh&,
305 const scalar mergeTol
306 );
307
308 //- Helper: Merge points.
309 //
310 // - Gets map from point to destination point
311 // - Removes all points that don't map to themselves
312 // - Modifies all faces that use the points to be removed.
313 static void mergePoints
314 (
315 const polyMesh&,
316 const Map<label>& pointToMaster,
317 polyTopoChange& meshMod
318 );
319
320
321 // Multi-mesh merging. Expects same patches (apart from processor
322 // patches)
323
324 //- Helper: find pairs of processor patches. Return number of
325 //- non-processor patches
326 static label procPatchPairs
327 (
329 List<DynamicList<label>>& localPatch,
330 List<DynamicList<label>>& remoteMesh,
331 List<DynamicList<label>>& remotePatch
332 );
333
334 //- Helper: expand list of coupled patches into pairs of coupled
335 //- faces
336 static void patchFacePairs
337 (
339 const List<DynamicList<label>>& localPatch,
340 const List<DynamicList<label>>& remoteMesh,
341 const List<DynamicList<label>>& remotePatch,
342 labelListList& localBoundaryFace,
343 labelListList& remoteFaceMesh,
344 labelListList& remoteBoundaryFace
345 );
346
347 //- Add multiple meshes
348 static void add
349 (
351 const UList<labelList>& patchMap,
352
353 const labelListList& localBoundaryFace,
354 const labelListList& remoteFaceMesh,
355 const labelListList& remoteBoundaryFace,
356 const labelListList& remoteFaceStart,
357
358 const UList<labelList>& pointZoneMap,
359 const UList<labelList>& faceZoneMap,
360 const UList<labelList>& cellZoneMap,
361
362 polyTopoChange& meshMod,
363 labelListList& cellProcAddressing,
364 labelListList& faceProcAddressing,
365 labelListList& pointProcAddressing
366 );
367};
368
369
370// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
371
372} // End namespace Foam
373
374// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
375
376#endif
377
378// ************************************************************************* //
label n
const polyBoundaryMesh & pbm
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
Map from edge (expressed as its endpoints) to value. Hashing (and ==) on an edge is symmetric.
Definition edgeHashes.H:59
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
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 HashTable to objects of type <T> with a label key.
Definition Map.H:54
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition UPtrList.H:101
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Container for information needed to couple to meshes. When constructed from two meshes and a geometri...
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
Definition globalIndex.H:77
Calculates points shared by more than two processor patches or cyclic patches.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Adds two meshes without using any polyMesh morphing.
static autoPtr< polyMesh > add(const IOobject &io, const polyMesh &mesh0, const polyMesh &mesh1, const faceCoupleInfo &coupleInfo, autoPtr< mapAddedPolyMesh > &mapPtr)
Add two polyMeshes. Returns new polyMesh and map construct.
static void mergePoints(const polyMesh &, const Map< label > &pointToMaster, polyTopoChange &meshMod)
Helper: Merge points.
static void patchFacePairs(const UPtrList< polyMesh > &meshes, const List< DynamicList< label > > &localPatch, const List< DynamicList< label > > &remoteMesh, const List< DynamicList< label > > &remotePatch, labelListList &localBoundaryFace, labelListList &remoteFaceMesh, labelListList &remoteBoundaryFace)
Helper: expand list of coupled patches into pairs of coupled faces.
static Map< label > findSharedPoints(const polyMesh &, const scalar mergeTol)
Find topologically and geometrically shared points.
static label procPatchPairs(const UPtrList< polyMesh > &meshes, List< DynamicList< label > > &localPatch, List< DynamicList< label > > &remoteMesh, List< DynamicList< label > > &remotePatch)
Helper: find pairs of processor patches. Return number of non-processor patches.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
Direct mesh changes based on v1.3 polyTopoChange syntax.
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
const auto & io
const cellShapeList & cells
Namespace for OpenFOAM.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with pointZone content on a polyMesh.
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
List< face > faceList
List of faces.
Definition faceListFwd.H:41
List< cell > cellList
List of cell.
Definition cellListFwd.H:41
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with cellZone content on a polyMesh.
vectorField pointField
pointField is a vectorField.
labelList f(nPoints)