1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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 elements of a list to a DynamicList
71 static void append(const List<T>&, DynamicList<T>&);
73 //- Append all mapped elements of a list to a DynamicList
81 //- Append all mapped elements of a list to a DynamicList that are
82 // not already present in the sorted list.
87 const SortableList<label>& sortedLst,
91 //- Index of patch in allPatches. Add if nonexisting.
92 static label patchIndex
95 DynamicList<word>& allPatchNames,
96 DynamicList<word>& allPatchTypes
99 //- Index of zone in all zones
100 static label zoneIndex(const word&, DynamicList<word>&);
102 static void mergePatchNames
104 const polyBoundaryMesh& patches0,
105 const polyBoundaryMesh& patches1,
107 DynamicList<word>& allPatchNames,
108 DynamicList<word>& allPatchTypes,
110 labelList& from1ToAllPatches,
111 labelList& fromAllTo1Patches
114 //- Get starts of patches
115 static labelList getPatchStarts(const polyBoundaryMesh&);
116 //- Get sizes of patches
117 static labelList getPatchSizes(const polyBoundaryMesh&);
119 static List<polyPatch*> combinePatches
121 const polyMesh& mesh0,
122 const polyMesh& mesh1,
123 const polyBoundaryMesh& allBoundaryMesh,
124 const label nAllPatches,
125 const labelList& fromAllTo1Patches,
127 const label nInternalFaces,
128 const labelList& nFaces,
130 labelList& from0ToAllPatches,
131 labelList& from1ToAllPatches
134 //- Determine order for internalFaces to be upper-triangular.
135 // Does not change order of external faces.
136 static labelList getFaceOrder
138 const cellList& cells,
139 const label nInternalFaces,
140 const labelList& owner,
141 const labelList& neighbour
144 //- Extends face f with split points. cutEdgeToPoints gives for every
145 // edge the points introduced inbetween the endpoints.
146 static void insertVertices
148 const edgeLookup& cutEdgeToPoints,
149 const Map<label>& meshToMaster,
150 const labelList& masterToCutPoints,
151 const face& masterFace,
153 DynamicList<label>& workFace,
157 //- Merges primitives of two meshes.
158 static void mergePrimitives
160 const polyMesh& mesh0,
161 const polyMesh& mesh1,
162 const faceCoupleInfo& coupleInfo,
164 const label nAllPatches,
165 const labelList& fromAllTo1Patches,
166 const labelList& from1ToAllPatches,
168 pointField& allPoints,
169 labelList& from0ToAllPoints,
170 labelList& from1ToAllPoints,
174 labelList& allNeighbour,
175 label& nInternalFaces,
176 labelList& nFacesPerPatch,
179 labelList& from0ToAllFaces,
180 labelList& from1ToAllFaces,
181 labelList& from1ToAllCells
184 //- Merge point zones
185 static void mergePointZones
187 const pointZoneMesh& pz0,
188 const pointZoneMesh& pz1,
189 const labelList& from0ToAllPoints,
190 const labelList& from1ToAllPoints,
192 DynamicList<word>& zoneNames,
193 labelList& from1ToAll,
194 List<DynamicList<label> >& pzPoints
198 static void mergeFaceZones
200 const faceZoneMesh& fz0,
201 const faceZoneMesh& fz1,
202 const labelList& from0ToAllFaces,
203 const labelList& from1ToAllFaces,
205 DynamicList<word>& zoneNames,
206 labelList& from1ToAll,
207 List<DynamicList<label> >& fzFaces,
208 List<DynamicList<bool> >& fzFlips
212 static void mergeCellZones
214 const cellZoneMesh& cz0,
215 const cellZoneMesh& cz1,
216 const labelList& from1ToAllCells,
218 DynamicList<word>& zoneNames,
219 labelList& from1ToAll,
220 List<DynamicList<label> >& czCells
223 //- Merge point/face/cell zone information
224 static void mergeZones
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,
234 DynamicList<word>& pointZoneNames,
235 List<DynamicList<label> >& pzPoints,
237 DynamicList<word>& faceZoneNames,
238 List<DynamicList<label> >& fzFaces,
239 List<DynamicList<bool> >& fzFlips,
241 DynamicList<word>& cellZoneNames,
242 List<DynamicList<label> >& czCells
245 //- Create new zones and add to new mesh.
248 const DynamicList<word>& pointZoneNames,
249 const List<DynamicList<label> >& pzPoints,
251 const DynamicList<word>& faceZoneNames,
252 const List<DynamicList<label> >& fzFaces,
253 const List<DynamicList<bool> >& fzFlips,
255 const DynamicList<word>& cellZoneNames,
256 const List<DynamicList<label> >& czCells,
267 //- Add two polyMeshes. Returns new polyMesh and map construct.
268 static autoPtr<polyMesh> add
271 const polyMesh& mesh0,
272 const polyMesh& mesh1,
273 const faceCoupleInfo& coupleInfo,
274 autoPtr<mapAddedPolyMesh>& mapPtr
277 //- Inplace add mesh to polyMesh. Returns map construct.
278 static autoPtr<mapAddedPolyMesh> add
281 const polyMesh& mesh1,
282 const faceCoupleInfo& coupleInfo,
283 const bool validBoundary = true
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.
293 static Map<label> findSharedPoints
296 const scalar mergeTol
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
306 const Map<label>& pointToMaster,
307 polyTopoChange& meshMod
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
314 } // End namespace Foam
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
319 # include "polyMeshAdderTemplates.C"
322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326 // ************************************************************************* //