Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / dynamicMesh / polyMeshAdder / polyMeshAdder.H
blobeb5d52c153433a71b0b394ecde3866f4f3875791
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2011 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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/>.
24 Class
25     Foam::polyMeshAdder
27 Description
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.
33 SourceFiles
34     polyMeshAdder.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef polyMeshAdder_H
39 #define polyMeshAdder_H
41 #include "autoPtr.H"
42 #include "polyMesh.H"
43 #include "mapAddedPolyMesh.H"
44 #include "faceCoupleInfo.H"
45 #include "SortableList.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 // Forward declaration of classes
53 class IOobject;
54 class polyTopoChange;
56 /*---------------------------------------------------------------------------*\
57                         Class polyMeshAdder Declaration
58 \*---------------------------------------------------------------------------*/
60 class polyMeshAdder
63 private:
64     // Private data
67     // Private Member Functions
69         //- Append all mapped elements of a list to a DynamicList
70         static void append
71         (
72             const labelList& map,
73             const labelList& lst,
74             DynamicList<label>&
75         );
77         //- Append all mapped elements of a list to a DynamicList that are
78         //  not already present in the sorted list.
79         static void append
80         (
81             const labelList& map,
82             const labelList& lst,
83             const SortableList<label>& sortedLst,
84             DynamicList<label>&
85         );
87         //- Index of patch in allPatches. Add if nonexisting.
88         static label patchIndex
89         (
90             const polyPatch&,
91             DynamicList<word>& allPatchNames,
92             DynamicList<word>& allPatchTypes
93         );
95         //- Index of zone in all zones
96         static label zoneIndex(const word&, DynamicList<word>&);
98         static void mergePatchNames
99         (
100             const polyBoundaryMesh& patches0,
101             const polyBoundaryMesh& patches1,
103             DynamicList<word>& allPatchNames,
104             DynamicList<word>& allPatchTypes,
106             labelList& from1ToAllPatches,
107             labelList& fromAllTo1Patches
108         );
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
116         (
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
128         );
130         //- Determine order for internalFaces to be upper-triangular.
131         //  Does not change order of external faces.
132         static labelList getFaceOrder
133         (
134             const cellList& cells,
135             const label nInternalFaces,
136             const labelList& owner,
137             const labelList& neighbour
138         );
140         //- Extends face f with split points. cutEdgeToPoints gives for every
141         // edge the points introduced inbetween the endpoints.
142         static void insertVertices
143         (
144             const edgeLookup& cutEdgeToPoints,
145             const Map<label>& meshToMaster,
146             const labelList& masterToCutPoints,
147             const face& masterFace,
149             DynamicList<label>& workFace,
150             face& f
151         );
153         //- Merges primitives of two meshes.
154         static void mergePrimitives
155         (
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,
168             faceList& allFaces,
169             labelList& allOwner,
170             labelList& allNeighbour,
171             label& nInternalFaces,
172             labelList& nFacesPerPatch,
173             label& nCells,
175             labelList& from0ToAllFaces,
176             labelList& from1ToAllFaces,
177             labelList& from1ToAllCells
178         );
180         //- Merge point zones
181         static void mergePointZones
182         (
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
191         );
193         //- Merge face zones
194         static void mergeFaceZones
195         (
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
205         );
207         //- Merge cell zones
208         static void mergeCellZones
209         (
210             const cellZoneMesh& cz0,
211             const cellZoneMesh& cz1,
212             const labelList& from1ToAllCells,
214             DynamicList<word>& zoneNames,
215             labelList& from1ToAll,
216             List<DynamicList<label> >& czCells
217         );
219         //- Merge point/face/cell zone information
220         static void mergeZones
221         (
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
239         );
241         //- Create new zones and add to new mesh.
242         static void addZones
243         (
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,
254             polyMesh& mesh
255         );
257 public:
260     // Member Functions
263         //- Add two polyMeshes. Returns new polyMesh and map construct.
264         static autoPtr<polyMesh> add
265         (
266             const IOobject& io,
267             const polyMesh& mesh0,
268             const polyMesh& mesh1,
269             const faceCoupleInfo& coupleInfo,
270             autoPtr<mapAddedPolyMesh>& mapPtr
271         );
273         //- Inplace add mesh to polyMesh. Returns map construct.
274         static autoPtr<mapAddedPolyMesh> add
275         (
276             polyMesh& mesh0,
277             const polyMesh& mesh1,
278             const faceCoupleInfo& coupleInfo,
279             const bool validBoundary = true
280         );
282         // Point merging
284             //- Find topologically and geometrically shared points.
285             //
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
291             (
292                 const polyMesh&,
293                 const scalar mergeTol
294             );
296             //- Helper: Merge points.
297             //
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
302             (
303                 const polyMesh&,
304                 const Map<label>& pointToMaster,
305                 polyTopoChange& meshMod
306             );
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 } // End namespace Foam
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316 #endif
318 // ************************************************************************* //