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 polyMeshAdder_H
42#define 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;
57
58/*---------------------------------------------------------------------------*\
59 Class polyMeshAdder Declaration
60\*---------------------------------------------------------------------------*/
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 //- Get starts of patches
90 static labelList getPatchStarts(const polyBoundaryMesh&);
91 //- Get sizes of patches
92 static labelList getPatchSizes(const polyBoundaryMesh&);
93
94 static List<polyPatch*> combinePatches
95 (
96 const polyMesh& mesh0,
97 const polyMesh& mesh1,
98 const polyBoundaryMesh& allBoundaryMesh,
99 const label nAllPatches,
100 const labelList& fromAllTo1Patches,
101
102 const label nInternalFaces,
103 const labelList& nFaces,
104
105 labelList& from0ToAllPatches,
106 labelList& from1ToAllPatches
107 );
108
109 //- Determine order for internalFaces to be upper-triangular.
110 // Does not change order of external faces.
111 static labelList getFaceOrder
112 (
113 const cellList& cells,
114 const label nInternalFaces,
115 const labelList& owner,
116 const labelList& neighbour
117 );
118
119 //- Extends face f with split points. cutEdgeToPoints gives for every
120 // edge the points introduced inbetween the endpoints.
121 static void insertVertices
122 (
123 const edgeLookup& cutEdgeToPoints,
124 const Map<label>& meshToMaster,
125 const labelList& masterToCutPoints,
126 const face& masterFace,
127
128 DynamicList<label>& workFace,
129 face& f
130 );
131
132 //- Merges primitives of two meshes.
133 static void mergePrimitives
134 (
135 const polyMesh& mesh0,
136 const polyMesh& mesh1,
137 const faceCoupleInfo& coupleInfo,
138
139 const label nAllPatches,
140 const labelList& fromAllTo1Patches,
141 const labelList& from1ToAllPatches,
142
143 pointField& allPoints,
144 labelList& from0ToAllPoints,
145 labelList& from1ToAllPoints,
146
147 faceList& allFaces,
148 labelList& allOwner,
149 labelList& allNeighbour,
150 label& nInternalFaces,
151 labelList& nFacesPerPatch,
152 label& nCells,
153
154 labelList& from0ToAllFaces,
155 labelList& from1ToAllFaces,
156 labelList& from1ToAllCells
157 );
158
159 //- Merge point zones
160 static void mergePointZones
161 (
162 const label nAllPoints,
163
164 const pointZoneMesh& pz0,
165 const pointZoneMesh& pz1,
166 const labelList& from0ToAllPoints,
167 const labelList& from1ToAllPoints,
168
169 DynamicList<word>& zoneNames,
170 labelList& from1ToAll,
171 List<DynamicList<label>>& pzPoints
172 );
173
174 //- Merge face zones
175 static void mergeFaceZones
176 (
177 const labelList& allOwner,
178
179 const polyMesh& mesh0,
180 const polyMesh& mesh1,
181 const labelList& from0ToAllFaces,
182 const labelList& from1ToAllFaces,
183 const labelList& from1ToAllCells,
184
185 DynamicList<word>& zoneNames,
186 labelList& from1ToAll,
187 List<DynamicList<label>>& fzFaces,
188 List<DynamicList<bool>>& fzFlips
189 );
190
191 //- Merge cell zones
192 static void mergeCellZones
193 (
194 const label nAllCells,
195
196 const cellZoneMesh& cz0,
197 const cellZoneMesh& cz1,
198 const labelList& from1ToAllCells,
199
200 DynamicList<word>& zoneNames,
201 labelList& from1ToAll,
202 List<DynamicList<label>>& czCells
203 );
204
205 //- Merge point/face/cell zone information
206 static void mergeZones
207 (
208 const label nAllPoints,
209 const labelList& allOwner,
210 const label nAllCells,
211
212 const polyMesh& mesh0,
213 const polyMesh& mesh1,
214 const labelList& from0ToAllPoints,
215 const labelList& from0ToAllFaces,
216 const labelList& from1ToAllPoints,
217 const labelList& from1ToAllFaces,
218 const labelList& from1ToAllCells,
219
220 DynamicList<word>& pointZoneNames,
221 List<DynamicList<label>>& pzPoints,
222
223 DynamicList<word>& faceZoneNames,
224 List<DynamicList<label>>& fzFaces,
225 List<DynamicList<bool>>& fzFlips,
226
227 DynamicList<word>& cellZoneNames,
228 List<DynamicList<label>>& czCells
229 );
230
231 //- Create new zones and add to new mesh.
232 static void addZones
233 (
234 const DynamicList<word>& pointZoneNames,
235 const List<DynamicList<label>>& pzPoints,
236
237 const DynamicList<word>& faceZoneNames,
238 const List<DynamicList<label>>& fzFaces,
239 const List<DynamicList<bool>>& fzFlips,
240
241 const DynamicList<word>& cellZoneNames,
242 const List<DynamicList<label>>& czCells,
243
245 );
246
247
248 //- Multi-mesh addition
249
250 //- Find n'th processor patch going to nbrProci. Usually n=0 except
251 //- for e.g. processorCyclic
252 static label procPatchIndex
253 (
254 const polyBoundaryMesh& pbm,
255 const label nbrProci,
256 const label n
257 );
258
259 //- Determine shared points. Takes pairs of one-to-one patches
260 //0 that are converted into internal faces
261 static void compactPoints
262 (
264 const labelListList& localBoundaryFace,
265 const labelListList& remoteFaceProc,
266 const labelListList& remoteBoundaryFace,
267 const labelListList& remoteFaceStart,
269
270 labelListList& pointProcAddressing,
271 labelListList& localPoints
272 );
273
274
275public:
276
277 // Member Functions
278
279
280 //- Add two polyMeshes. Returns new polyMesh and map construct.
282 (
283 const IOobject& io,
284 const polyMesh& mesh0,
285 const polyMesh& mesh1,
286 const faceCoupleInfo& coupleInfo,
288 );
289
290 //- Inplace add mesh to polyMesh. Returns map construct.
292 (
293 polyMesh& mesh0,
294 const polyMesh& mesh1,
295 const faceCoupleInfo& coupleInfo,
296 const bool validBoundary = true
297 );
298
299 // Point merging
300
301 //- Find topologically and geometrically shared points.
302 //
303 // - should only be called for parallel correct mesh
304 // (since uses mesh.globalData)
305 // - returns Map from point to master point (all in mesh point
306 // labels) for any sets of points that need to be merged.
308 (
309 const polyMesh&,
310 const scalar mergeTol
311 );
312
313 //- Helper: Merge points.
314 //
315 // - Gets map from point to destination point
316 // - Removes all points that don't map to themselves
317 // - Modifies all faces that use the points to be removed.
318 static void mergePoints
319 (
320 const polyMesh&,
321 const Map<label>& pointToMaster,
322 polyTopoChange& meshMod
323 );
324
325
326 // Multi-mesh merging. Expects same patches (apart from processor
327 // patches)
328
329 //- Helper: find pairs of processor patches. Return number of
330 //- non-processor patches
331 static label procPatchPairs
332 (
334 List<DynamicList<label>>& localPatch,
335 List<DynamicList<label>>& remoteMesh,
336 List<DynamicList<label>>& remotePatch
337 );
338
339 //- Helper: expand list of coupled patches into pairs of coupled
340 //- faces
341 static void patchFacePairs
342 (
344 const List<DynamicList<label>>& localPatch,
345 const List<DynamicList<label>>& remoteMesh,
346 const List<DynamicList<label>>& remotePatch,
347 labelListList& localBoundaryFace,
348 labelListList& remoteFaceMesh,
349 labelListList& remoteBoundaryFace
350 );
351
352 //- Add multiple meshes
353 static void add
354 (
356 const UList<labelList>& patchMap,
357
358 const labelListList& localBoundaryFace,
359 const labelListList& remoteFaceMesh,
360 const labelListList& remoteBoundaryFace,
361 const labelListList& remoteFaceStart,
362
363 const UList<labelList>& pointZoneMap,
364 const UList<labelList>& faceZoneMap,
365 const UList<labelList>& cellZoneMap,
366
367 polyTopoChange& meshMod,
368 labelListList& cellProcAddressing,
369 labelListList& faceProcAddressing,
370 labelListList& pointProcAddressing
371 );
372};
373
374
375// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
376
377} // End namespace Foam
378
379// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
380
381#endif
382
383// ************************************************************************* //
label n
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
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:94
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
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:75
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
Calculates points shared by more than two processor patches or cyclic patches.
Definition: globalPoints.H:103
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Adds two meshes without using any polyMesh morphing.
Definition: polyMeshAdder.H:62
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)
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)
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
Direct mesh changes based on v1.3 polyTopoChange syntax.
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
const cellShapeList & cells
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
labelList f(nPoints)