All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
polyMeshAdder.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::polyMeshAdder
26 
27 Description
28  Adds two meshes without using any polyMesh morphing.
29 
30  Gets faces to couple as faceCoupleInfo which is list of faces on both
31  meshes. Returns map from last mesh addition.
32 
33 SourceFiles
34  polyMeshAdder.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef polyMeshAdder_H
39 #define polyMeshAdder_H
40 
41 #include "autoPtr.H"
42 #include "polyMesh.H"
43 #include "mapAddedPolyMesh.H"
44 #include "faceCoupleInfo.H"
45 #include "SortableList.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward declaration of classes
53 class IOobject;
54 class polyTopoChange;
55 
56 /*---------------------------------------------------------------------------*\
57  Class polyMeshAdder Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class polyMeshAdder
61 {
62 
63 private:
64 
65  // Private Member Functions
66 
67  //- Index of patch in allPatches. Add if nonexisting.
68  static label patchIndex
69  (
70  const polyPatch&,
71  DynamicList<word>& allPatchNames,
72  DynamicList<word>& allPatchTypes
73  );
74 
75  //- Index of zone in all zones
76  static label zoneIndex(const word&, DynamicList<word>&);
77 
78  static void mergePatchNames
79  (
80  const polyBoundaryMesh& patches0,
81  const polyBoundaryMesh& patches1,
82 
83  DynamicList<word>& allPatchNames,
84  DynamicList<word>& allPatchTypes,
85 
86  labelList& from1ToAllPatches,
87  labelList& fromAllTo1Patches
88  );
89 
90  //- Get starts of patches
91  static labelList getPatchStarts(const polyBoundaryMesh&);
92  //- Get sizes of patches
93  static labelList getPatchSizes(const polyBoundaryMesh&);
94 
95  static List<polyPatch*> combinePatches
96  (
97  const polyMesh& mesh0,
98  const polyMesh& mesh1,
99  const polyBoundaryMesh& allBoundaryMesh,
100  const label nAllPatches,
101  const labelList& fromAllTo1Patches,
102 
103  const label nInternalFaces,
104  const labelList& nFaces,
105 
106  labelList& from0ToAllPatches,
107  labelList& from1ToAllPatches
108  );
109 
110  //- Determine order for internalFaces to be upper-triangular.
111  // Does not change order of external faces.
112  static labelList getFaceOrder
113  (
114  const cellList& cells,
115  const label nInternalFaces,
116  const labelList& owner,
117  const labelList& neighbour
118  );
119 
120  //- Extends face f with split points. cutEdgeToPoints gives for every
121  // edge the points introduced in between the endpoints.
122  static void insertVertices
123  (
124  const edgeLookup& cutEdgeToPoints,
125  const Map<label>& meshToMaster,
126  const labelList& masterToCutPoints,
127  const face& masterFace,
128 
129  DynamicList<label>& workFace,
130  face& f
131  );
132 
133  //- Merges primitives of two meshes.
134  static void mergePrimitives
135  (
136  const polyMesh& mesh0,
137  const polyMesh& mesh1,
138  const faceCoupleInfo& coupleInfo,
139 
140  const label nAllPatches,
141  const labelList& fromAllTo1Patches,
142  const labelList& from1ToAllPatches,
143 
145  labelList& from0ToAllPoints,
146  labelList& from1ToAllPoints,
147 
148  faceList& allFaces,
149  labelList& allOwner,
150  labelList& allNeighbour,
151  label& nInternalFaces,
152  labelList& nFacesPerPatch,
153  label& nCells,
154 
155  labelList& from0ToAllFaces,
156  labelList& from1ToAllFaces,
157  labelList& from1ToAllCells
158  );
159 
160  //- Merge point zones
161  static void mergePointZones
162  (
163  const label nAllPoints,
164 
165  const pointZoneMesh& pz0,
166  const pointZoneMesh& pz1,
167  const labelList& from0ToAllPoints,
168  const labelList& from1ToAllPoints,
169 
170  DynamicList<word>& zoneNames,
171  labelList& from1ToAll,
172  List<DynamicList<label>>& pzPoints
173  );
174 
175  //- Merge face zones
176  static void mergeFaceZones
177  (
178  const labelList& allOwner,
179 
180  const polyMesh& mesh0,
181  const polyMesh& mesh1,
182  const labelList& from0ToAllFaces,
183  const labelList& from1ToAllFaces,
184  const labelList& from1ToAllCells,
185 
186  DynamicList<word>& zoneNames,
187  labelList& from1ToAll,
188  List<DynamicList<label>>& fzFaces,
189  List<DynamicList<bool>>& fzFlips
190  );
191 
192  //- Merge cell zones
193  static void mergeCellZones
194  (
195  const label nAllCells,
196 
197  const cellZoneMesh& cz0,
198  const cellZoneMesh& cz1,
199  const labelList& from1ToAllCells,
200 
201  DynamicList<word>& zoneNames,
202  labelList& from1ToAll,
203  List<DynamicList<label>>& czCells
204  );
205 
206  //- Merge point/face/cell zone information
207  static void mergeZones
208  (
209  const label nAllPoints,
210  const labelList& allOwner,
211  const label nAllCells,
212 
213  const polyMesh& mesh0,
214  const polyMesh& mesh1,
215  const labelList& from0ToAllPoints,
216  const labelList& from0ToAllFaces,
217  const labelList& from1ToAllPoints,
218  const labelList& from1ToAllFaces,
219  const labelList& from1ToAllCells,
220 
221  DynamicList<word>& pointZoneNames,
222  List<DynamicList<label>>& pzPoints,
223 
224  DynamicList<word>& faceZoneNames,
225  List<DynamicList<label>>& fzFaces,
226  List<DynamicList<bool>>& fzFlips,
227 
228  DynamicList<word>& cellZoneNames,
229  List<DynamicList<label>>& czCells
230  );
231 
232  //- Create new zones and add to new mesh.
233  static void addZones
234  (
235  const DynamicList<word>& pointZoneNames,
236  const List<DynamicList<label>>& pzPoints,
237 
238  const DynamicList<word>& faceZoneNames,
239  const List<DynamicList<label>>& fzFaces,
240  const List<DynamicList<bool>>& fzFlips,
241 
242  const DynamicList<word>& cellZoneNames,
243  const List<DynamicList<label>>& czCells,
244 
245  polyMesh& mesh
246  );
247 
248 public:
249 
250 
251  // Member Functions
252 
253 
254  //- Add two polyMeshes. Returns new polyMesh and map construct.
255  static autoPtr<polyMesh> add
256  (
257  const IOobject& io,
258  const polyMesh& mesh0,
259  const polyMesh& mesh1,
260  const faceCoupleInfo& coupleInfo,
262  );
263 
264  //- Inplace add mesh to polyMesh. Returns map construct.
266  (
267  polyMesh& mesh0,
268  const polyMesh& mesh1,
269  const faceCoupleInfo& coupleInfo,
270  const bool validBoundary = true
271  );
272 
273  // Point merging
274 
275  //- Find topologically and geometrically shared points.
276  //
277  // - should only be called for parallel correct mesh
278  // (since uses mesh.globalData)
279  // - returns Map from point to master point (all in mesh point
280  // labels) for any sets of points that need to be merged.
282  (
283  const polyMesh&,
284  const scalar mergeTol
285  );
286 
287  //- Helper: Merge points.
288  //
289  // - Gets map from point to destination point
290  // - Removes all points that don't map to themselves
291  // - Modifies all faces that use the points to be removed.
292  static void mergePoints
293  (
294  const polyMesh&,
295  const Map<label>& pointToMaster,
296  polyTopoChange& meshMod
297  );
298 };
299 
300 
301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 
303 } // End namespace Foam
304 
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 
307 #endif
308 
309 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Adds two meshes without using any polyMesh morphing.
Definition: polyMeshAdder.H:59
Container for information needed to couple to meshes. When constructed from two meshes and a geometri...
dynamicFvMesh & mesh
const cellShapeList & cells
static void mergePoints(const polyMesh &, const Map< label > &pointToMaster, polyTopoChange &meshMod)
Helper: Merge points.
A class for handling words, derived from string.
Definition: word.H:59
Foam::polyBoundaryMesh.
labelList f(nPoints)
Direct mesh changes based on v1.3 polyTopoChange syntax.
tmp< pointField > allPoints(const Triangulation &t)
Extract all points in vertex-index order.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
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.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
static Map< label > findSharedPoints(const polyMesh &, const scalar mergeTol)
Find topologically and geometrically shared points.
Namespace for OpenFOAM.