Merge branch 'upstream/OpenFOAM' into master
[freefoam.git] / src / OpenFOAM / meshes / polyMesh / mapPolyMesh / mapDistribute / mapDistributePolyMesh.H
blob94c9747e086d98a39957a28c77b98d6bf812f46d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::mapDistributePolyMesh
28 Description
29     Class containing mesh-to-mesh mapping information after a mesh distribution
30     where we send parts of meshes (using subsetting) to other processors 
31     and receive and reconstruct mesh.
33     We store mapping from the bits-to-send to the complete starting mesh
34     (subXXXMap) and from the received bits to their location in the new
35     mesh (constructXXXMap).
37 SourceFiles
38     mapDistributePolyMesh.C
40 \*---------------------------------------------------------------------------*/
42 #ifndef mapDistributePolyMesh_H
43 #define mapDistributePolyMesh_H
45 #include <OpenFOAM/mapDistribute.H>
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 class mapPolyMesh;
53 class polyMesh;
55 /*---------------------------------------------------------------------------*\
56                            Class mapDistributePolyMesh Declaration
57 \*---------------------------------------------------------------------------*/
59 class mapDistributePolyMesh
61     // Private data
63         const polyMesh& mesh_;
65         //- Number of old live points
66         const label nOldPoints_;
68         //- Number of old live faces
69         const label nOldFaces_;
71         //- Number of old live cells
72         const label nOldCells_;
74         //- List of the old patch sizes
75         labelList oldPatchSizes_;
77         //- List of the old patch start labels
78         const labelList oldPatchStarts_;
80         //- List of numbers of mesh points per old patch
81         const labelList oldPatchNMeshPoints_;
84         //- Point distribute map
85         const mapDistribute pointMap_;
87         //- Face distribute map
88         const mapDistribute faceMap_;
90         //- Cell distribute map
91         const mapDistribute cellMap_;
93         //- Patch distribute map
94         const mapDistribute patchMap_;
98     // Private Member Functions
100         void calcPatchSizes();
102         //- Disallow default bitwise copy construct
103         mapDistributePolyMesh(const mapDistributePolyMesh&);
105         //- Disallow default bitwise assignment
106         void operator=(const mapDistributePolyMesh&);
109 public:
111     // Constructors
113         //- Construct from components. Note that mesh has to be changed already
114         //  since uses mesh.nPoints etc as the new size.
115         mapDistributePolyMesh
116         (
117             const polyMesh& mesh,
119             // mesh before changes
120             const label nOldPoints,
121             const label nOldFaces,
122             const label nOldCells,
123             const labelList& oldPatchStarts,
124             const labelList& oldPatchNMeshPoints,
126             // how to subset pieces of mesh to send across
127             const labelListList& subPointMap,
128             const labelListList& subFaceMap,
129             const labelListList& subCellMap,
130             const labelListList& subPatchMap,
132             // how to reconstruct received mesh
133             const labelListList& constructPointMap,
134             const labelListList& constructFaceMap,
135             const labelListList& constructCellMap,
136             const labelListList& constructPatchMap
137         );
139         //- (optionally destructively) construct from components
140         //  Note that mesh has to be changed already!
141         mapDistributePolyMesh
142         (
143             const polyMesh& mesh,
144             const label nOldPoints,
145             const label nOldFaces,
146             const label nOldCells,
147             labelList& oldPatchStarts,
148             labelList& oldPatchNMeshPoints,
150             labelListList& subPointMap,
151             labelListList& subFaceMap,
152             labelListList& subCellMap,
153             labelListList& subPatchMap,
154             labelListList& constructPointMap,
155             labelListList& constructFaceMap,
156             labelListList& constructCellMap,
157             labelListList& constructPatchMap,
158             const bool reUse                // clone or reuse
159         );
162     // Member Functions
164         // Access
166             const polyMesh& mesh() const
167             {
168                 return mesh_;
169             }
171             //- Number of points in mesh before distribution
172             label nOldPoints() const
173             {
174                 return nOldPoints_;
175             }
177             //- Number of faces in mesh before distribution
178             label nOldFaces() const
179             {
180                 return nOldFaces_;
181             }
183             //- Number of cells in mesh before distribution
184             label nOldCells() const
185             {
186                 return nOldCells_;
187             }
189             //- List of the old patch sizes
190             const labelList& oldPatchSizes() const
191             {
192                 return oldPatchSizes_;
193             }
195             //- List of the old patch start labels
196             const labelList& oldPatchStarts() const
197             {
198                 return oldPatchStarts_;
199             }
201             //- List of numbers of mesh points per old patch
202             const labelList& oldPatchNMeshPoints() const
203             {
204                 return oldPatchNMeshPoints_;
205             }
207             //- Point distribute map
208             const mapDistribute& pointMap() const
209             {
210                 return pointMap_;
211             }
213             //- Face distribute map
214             const mapDistribute& faceMap() const
215             {
216                 return faceMap_;
217             }
219             //- Cell distribute map
220             const mapDistribute& cellMap() const
221             {
222                 return cellMap_;
223             }
225             //- Patch distribute map
226             const mapDistribute& patchMap() const
227             {
228                 return patchMap_;
229             }
232         // Edit
234             //- distribute list of point data
235             template<class T>
236             void distributePointData(List<T>& lst) const
237             {
238                 pointMap_.distribute(lst);
239             }
241             //- distribute list of face data
242             template<class T>
243             void distributeFaceData(List<T>& lst) const
244             {
245                 faceMap_.distribute(lst);
246             }
248             //- distribute list of cell data
249             template<class T>
250             void distributeCellData(List<T>& lst) const
251             {
252                 cellMap_.distribute(lst);
253             }
255             //- distribute list of patch data
256             template<class T>
257             void distributePatchData(List<T>& lst) const
258             {
259                 patchMap_.distribute(lst);
260             }
263             //- distribute list of point/face/cell/patch indices.
264             //  (Converts to boolList, distributes boolList and reconstructs)
265             void distributePointIndices(labelList& pointIDs) const;
267             void distributeFaceIndices(labelList& faceIDs) const;
268             void distributeCellIndices(labelList& cellIDs) const;
269             void distributePatchIndices(labelList& patchIDs) const;
272             //- Correct for topo change.
273             void updateMesh(const mapPolyMesh&)
274             {
275                 notImplemented
276                 (
277                     "mapDistributePolyMesh::updateMesh(const mapPolyMesh&)"
278                 );
279             }
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 } // End namespace Foam
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 #endif
291 // ************************ vim: set sw=4 sts=4 et: ************************ //