1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
28 Adds two meshes without using any polyMesh morphing.
30 Gets faces to couple as faceCoupleInfo which is list of faces on both
31 meshes. Returns map from last mesh addition.
36 \*---------------------------------------------------------------------------*/
38 #ifndef polyMeshAdder_H
39 #define polyMeshAdder_H
43 #include "mapAddedPolyMesh.H"
44 #include "faceCoupleInfo.H"
45 #include "SortableList.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 // Forward declaration of classes
56 /*---------------------------------------------------------------------------*\
57 Class polyMeshAdder Declaration
58 \*---------------------------------------------------------------------------*/
67 // Private Member Functions
69 //- Append all mapped elements of a list to a DynamicList
77 //- Append all mapped elements of a list to a DynamicList that are
78 // not already present in the sorted list.
83 const SortableList<label>& sortedLst,
87 //- Index of patch in allPatches. Add if nonexisting.
88 static label patchIndex
91 DynamicList<word>& allPatchNames,
92 DynamicList<word>& allPatchTypes
95 //- Index of zone in all zones
96 static label zoneIndex(const word&, DynamicList<word>&);
98 static void mergePatchNames
100 const polyBoundaryMesh& patches0,
101 const polyBoundaryMesh& patches1,
103 DynamicList<word>& allPatchNames,
104 DynamicList<word>& allPatchTypes,
106 labelList& from1ToAllPatches,
107 labelList& fromAllTo1Patches
110 //- Get starts of patches
111 static labelList getPatchStarts(const polyBoundaryMesh&);
112 //- Get sizes of patches
113 static labelList getPatchSizes(const polyBoundaryMesh&);
115 static List<polyPatch*> combinePatches
117 const polyMesh& mesh0,
118 const polyMesh& mesh1,
119 const polyBoundaryMesh& allBoundaryMesh,
120 const label nAllPatches,
121 const labelList& fromAllTo1Patches,
123 const label nInternalFaces,
124 const labelList& nFaces,
126 labelList& from0ToAllPatches,
127 labelList& from1ToAllPatches
130 //- Determine order for internalFaces to be upper-triangular.
131 // Does not change order of external faces.
132 static labelList getFaceOrder
134 const cellList& cells,
135 const label nInternalFaces,
136 const labelList& owner,
137 const labelList& neighbour
140 //- Extends face f with split points. cutEdgeToPoints gives for every
141 // edge the points introduced inbetween the endpoints.
142 static void insertVertices
144 const edgeLookup& cutEdgeToPoints,
145 const Map<label>& meshToMaster,
146 const labelList& masterToCutPoints,
147 const face& masterFace,
149 DynamicList<label>& workFace,
153 //- Merges primitives of two meshes.
154 static void mergePrimitives
156 const polyMesh& mesh0,
157 const polyMesh& mesh1,
158 const faceCoupleInfo& coupleInfo,
160 const label nAllPatches,
161 const labelList& fromAllTo1Patches,
162 const labelList& from1ToAllPatches,
164 pointField& allPoints,
165 labelList& from0ToAllPoints,
166 labelList& from1ToAllPoints,
170 labelList& allNeighbour,
171 label& nInternalFaces,
172 labelList& nFacesPerPatch,
175 labelList& from0ToAllFaces,
176 labelList& from1ToAllFaces,
177 labelList& from1ToAllCells
180 //- Merge point zones
181 static void mergePointZones
183 const pointZoneMesh& pz0,
184 const pointZoneMesh& pz1,
185 const labelList& from0ToAllPoints,
186 const labelList& from1ToAllPoints,
188 DynamicList<word>& zoneNames,
189 labelList& from1ToAll,
190 List<DynamicList<label> >& pzPoints
194 static void mergeFaceZones
196 const faceZoneMesh& fz0,
197 const faceZoneMesh& fz1,
198 const labelList& from0ToAllFaces,
199 const labelList& from1ToAllFaces,
201 DynamicList<word>& zoneNames,
202 labelList& from1ToAll,
203 List<DynamicList<label> >& fzFaces,
204 List<DynamicList<bool> >& fzFlips
208 static void mergeCellZones
210 const cellZoneMesh& cz0,
211 const cellZoneMesh& cz1,
212 const labelList& from1ToAllCells,
214 DynamicList<word>& zoneNames,
215 labelList& from1ToAll,
216 List<DynamicList<label> >& czCells
219 //- Merge point/face/cell zone information
220 static void mergeZones
222 const polyMesh& mesh0,
223 const polyMesh& mesh1,
224 const labelList& from0ToAllPoints,
225 const labelList& from0ToAllFaces,
226 const labelList& from1ToAllPoints,
227 const labelList& from1ToAllFaces,
228 const labelList& from1ToAllCells,
230 DynamicList<word>& pointZoneNames,
231 List<DynamicList<label> >& pzPoints,
233 DynamicList<word>& faceZoneNames,
234 List<DynamicList<label> >& fzFaces,
235 List<DynamicList<bool> >& fzFlips,
237 DynamicList<word>& cellZoneNames,
238 List<DynamicList<label> >& czCells
241 //- Create new zones and add to new mesh.
244 const DynamicList<word>& pointZoneNames,
245 const List<DynamicList<label> >& pzPoints,
247 const DynamicList<word>& faceZoneNames,
248 const List<DynamicList<label> >& fzFaces,
249 const List<DynamicList<bool> >& fzFlips,
251 const DynamicList<word>& cellZoneNames,
252 const List<DynamicList<label> >& czCells,
263 //- Add two polyMeshes. Returns new polyMesh and map construct.
264 static autoPtr<polyMesh> add
267 const polyMesh& mesh0,
268 const polyMesh& mesh1,
269 const faceCoupleInfo& coupleInfo,
270 autoPtr<mapAddedPolyMesh>& mapPtr
273 //- Inplace add mesh to polyMesh. Returns map construct.
274 static autoPtr<mapAddedPolyMesh> add
277 const polyMesh& mesh1,
278 const faceCoupleInfo& coupleInfo,
279 const bool validBoundary = true
284 //- Find topologically and geometrically shared points.
286 // - should only be called for parallel correct mesh
287 // (since uses mesh.globalData)
288 // - returns Map from point to master point (all in mesh point
289 // labels) for any sets of points that need to be merged.
290 static Map<label> findSharedPoints
293 const scalar mergeTol
296 //- Helper: Merge points.
298 // - Gets map from point to destination point
299 // - Removes all points that don't map to themselves
300 // - Modifies all faces that use the points to be removed.
301 static void mergePoints
304 const Map<label>& pointToMaster,
305 polyTopoChange& meshMod
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 } // End namespace Foam
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 // ************************************************************************* //