FreeFOAM The Cross-Platform CFD Toolkit
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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/autoPtr.H>
42 #include <OpenFOAM/polyMesh.H>
44 #include "faceCoupleInfo.H"
45 #include <OpenFOAM/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 
61 {
62 
63 private:
64  // Private data
65 
66 
67  // Private Member Functions
68 
69  //- Append all elements of a list to a DynamicList
70  template<class T>
71  static void append(const List<T>&, DynamicList<T>&);
72 
73  //- Append all mapped elements of a list to a DynamicList
74  static void append
75  (
76  const labelList& map,
77  const labelList& lst,
79  );
80 
81  //- Append all mapped elements of a list to a DynamicList that are
82  // not already present in the sorted list.
83  static void append
84  (
85  const labelList& map,
86  const labelList& lst,
87  const SortableList<label>& sortedLst,
89  );
90 
91  //- Index of patch in allPatches. Add if nonexisting.
92  static label patchIndex
93  (
94  const polyPatch&,
95  DynamicList<word>& allPatchNames,
96  DynamicList<word>& allPatchTypes
97  );
98 
99  //- Index of zone in all zones
100  static label zoneIndex(const word&, DynamicList<word>&);
101 
102  static void mergePatchNames
103  (
104  const polyBoundaryMesh& patches0,
105  const polyBoundaryMesh& patches1,
106 
107  DynamicList<word>& allPatchNames,
108  DynamicList<word>& allPatchTypes,
109 
110  labelList& from1ToAllPatches,
111  labelList& fromAllTo1Patches
112  );
113 
114  //- Get starts of patches
115  static labelList getPatchStarts(const polyBoundaryMesh&);
116  //- Get sizes of patches
117  static labelList getPatchSizes(const polyBoundaryMesh&);
118 
119  static List<polyPatch*> combinePatches
120  (
121  const polyMesh& mesh0,
122  const polyMesh& mesh1,
123  const polyBoundaryMesh& allBoundaryMesh,
124  const label nAllPatches,
125  const labelList& fromAllTo1Patches,
126 
127  const label nInternalFaces,
128  const labelList& nFaces,
129 
130  labelList& from0ToAllPatches,
131  labelList& from1ToAllPatches
132  );
133 
134  //- Determine order for internalFaces to be upper-triangular.
135  // Does not change order of external faces.
136  static labelList getFaceOrder
137  (
138  const cellList& cells,
139  const label nInternalFaces,
140  const labelList& owner,
141  const labelList& neighbour
142  );
143 
144  //- Extends face f with split points. cutEdgeToPoints gives for every
145  // edge the points introduced inbetween the endpoints.
146  static void insertVertices
147  (
148  const edgeLookup& cutEdgeToPoints,
149  const Map<label>& meshToMaster,
150  const labelList& masterToCutPoints,
151  const face& masterFace,
152 
153  DynamicList<label>& workFace,
154  face& f
155  );
156 
157  //- Merges primitives of two meshes.
158  static void mergePrimitives
159  (
160  const polyMesh& mesh0,
161  const polyMesh& mesh1,
162  const faceCoupleInfo& coupleInfo,
163 
164  const label nAllPatches,
165  const labelList& fromAllTo1Patches,
166  const labelList& from1ToAllPatches,
167 
168  pointField& allPoints,
169  labelList& from0ToAllPoints,
170  labelList& from1ToAllPoints,
171 
172  faceList& allFaces,
173  labelList& allOwner,
174  labelList& allNeighbour,
175  label& nInternalFaces,
176  labelList& nFacesPerPatch,
177  label& nCells,
178 
179  labelList& from0ToAllFaces,
180  labelList& from1ToAllFaces,
181  labelList& from1ToAllCells
182  );
183 
184  //- Merge point zones
185  static void mergePointZones
186  (
187  const pointZoneMesh& pz0,
188  const pointZoneMesh& pz1,
189  const labelList& from0ToAllPoints,
190  const labelList& from1ToAllPoints,
191 
192  DynamicList<word>& zoneNames,
193  labelList& from1ToAll,
194  List<DynamicList<label> >& pzPoints
195  );
196 
197  //- Merge face zones
198  static void mergeFaceZones
199  (
200  const faceZoneMesh& fz0,
201  const faceZoneMesh& fz1,
202  const labelList& from0ToAllFaces,
203  const labelList& from1ToAllFaces,
204 
205  DynamicList<word>& zoneNames,
206  labelList& from1ToAll,
207  List<DynamicList<label> >& fzFaces,
208  List<DynamicList<bool> >& fzFlips
209  );
210 
211  //- Merge cell zones
212  static void mergeCellZones
213  (
214  const cellZoneMesh& cz0,
215  const cellZoneMesh& cz1,
216  const labelList& from1ToAllCells,
217 
218  DynamicList<word>& zoneNames,
219  labelList& from1ToAll,
220  List<DynamicList<label> >& czCells
221  );
222 
223  //- Merge point/face/cell zone information
224  static void mergeZones
225  (
226  const polyMesh& mesh0,
227  const polyMesh& mesh1,
228  const labelList& from0ToAllPoints,
229  const labelList& from0ToAllFaces,
230  const labelList& from1ToAllPoints,
231  const labelList& from1ToAllFaces,
232  const labelList& from1ToAllCells,
233 
234  DynamicList<word>& pointZoneNames,
235  List<DynamicList<label> >& pzPoints,
236 
237  DynamicList<word>& faceZoneNames,
238  List<DynamicList<label> >& fzFaces,
239  List<DynamicList<bool> >& fzFlips,
240 
241  DynamicList<word>& cellZoneNames,
242  List<DynamicList<label> >& czCells
243  );
244 
245  //- Create new zones and add to new mesh.
246  static void addZones
247  (
248  const DynamicList<word>& pointZoneNames,
249  const List<DynamicList<label> >& pzPoints,
250 
251  const DynamicList<word>& faceZoneNames,
252  const List<DynamicList<label> >& fzFaces,
253  const List<DynamicList<bool> >& fzFlips,
254 
255  const DynamicList<word>& cellZoneNames,
256  const List<DynamicList<label> >& czCells,
257 
258  polyMesh& mesh
259  );
260 
261 public:
262 
263 
264  // Member Functions
265 
266 
267  //- Add two polyMeshes. Returns new polyMesh and map construct.
268  static autoPtr<polyMesh> add
269  (
270  const IOobject& io,
271  const polyMesh& mesh0,
272  const polyMesh& mesh1,
273  const faceCoupleInfo& coupleInfo,
275  );
276 
277  //- Inplace add mesh to polyMesh. Returns map construct.
279  (
280  polyMesh& mesh0,
281  const polyMesh& mesh1,
282  const faceCoupleInfo& coupleInfo,
283  const bool validBoundary = true
284  );
285 
286  // Point merging
287 
288  //- Find topologically&geometrically shared points.
289  // - should only be called for parallel correct mesh
290  // (since uses mesh.globalData)
291  // - returns Map from point to master point (all in mesh point
292  // labels) for any sets of points that need to be merged.
294  (
295  const polyMesh&,
296  const scalar mergeTol
297  );
298 
299  //- Helper: Merge points.
300  // - Gets map from point to destination point
301  // - Removes all points that don't map to themselves
302  // - Modifies all faces that use the points to be removed.
303  static void mergePoints
304  (
305  const polyMesh&,
306  const Map<label>& pointToMaster,
307  polyTopoChange& meshMod
308  );
309 };
310 
311 
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 
314 } // End namespace Foam
315 
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 
318 #ifdef NoRepository
320 #endif
321 
322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
323 
324 #endif
325 
326 // ************************ vim: set sw=4 sts=4 et: ************************ //