FreeFOAM The Cross-Platform CFD Toolkit
mapDistributePolyMesh.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::mapDistributePolyMesh
26 
27 Description
28  Class containing mesh-to-mesh mapping information after a mesh distribution
29  where we send parts of meshes (using subsetting) to other processors
30  and receive and reconstruct mesh.
31 
32  We store mapping from the bits-to-send to the complete starting mesh
33  (subXXXMap) and from the received bits to their location in the new
34  mesh (constructXXXMap).
35 
36 SourceFiles
37  mapDistributePolyMesh.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef mapDistributePolyMesh_H
42 #define mapDistributePolyMesh_H
43 
44 #include <OpenFOAM/mapDistribute.H>
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 class mapPolyMesh;
52 class polyMesh;
53 
54 /*---------------------------------------------------------------------------*\
55  Class mapDistributePolyMesh Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 {
60  // Private data
61 
62  const polyMesh& mesh_;
63 
64  //- Number of old live points
65  const label nOldPoints_;
66 
67  //- Number of old live faces
68  const label nOldFaces_;
69 
70  //- Number of old live cells
71  const label nOldCells_;
72 
73  //- List of the old patch sizes
74  labelList oldPatchSizes_;
75 
76  //- List of the old patch start labels
77  const labelList oldPatchStarts_;
78 
79  //- List of numbers of mesh points per old patch
80  const labelList oldPatchNMeshPoints_;
81 
82 
83  //- Point distribute map
84  const mapDistribute pointMap_;
85 
86  //- Face distribute map
87  const mapDistribute faceMap_;
88 
89  //- Cell distribute map
90  const mapDistribute cellMap_;
91 
92  //- Patch distribute map
93  const mapDistribute patchMap_;
94 
95 
96 
97  // Private Member Functions
98 
99  void calcPatchSizes();
100 
101  //- Disallow default bitwise copy construct
103 
104  //- Disallow default bitwise assignment
105  void operator=(const mapDistributePolyMesh&);
106 
107 
108 public:
109 
110  // Constructors
111 
112  //- Construct from components. Note that mesh has to be changed already
113  // since uses mesh.nPoints etc as the new size.
115  (
116  const polyMesh& mesh,
117 
118  // mesh before changes
119  const label nOldPoints,
120  const label nOldFaces,
121  const label nOldCells,
122  const labelList& oldPatchStarts,
124 
125  // how to subset pieces of mesh to send across
126  const labelListList& subPointMap,
127  const labelListList& subFaceMap,
128  const labelListList& subCellMap,
129  const labelListList& subPatchMap,
130 
131  // how to reconstruct received mesh
132  const labelListList& constructPointMap,
133  const labelListList& constructFaceMap,
134  const labelListList& constructCellMap,
135  const labelListList& constructPatchMap
136  );
137 
138  //- (optionally destructively) construct from components
139  // Note that mesh has to be changed already!
141  (
142  const polyMesh& mesh,
143  const label nOldPoints,
144  const label nOldFaces,
145  const label nOldCells,
146  labelList& oldPatchStarts,
147  labelList& oldPatchNMeshPoints,
148 
149  labelListList& subPointMap,
150  labelListList& subFaceMap,
151  labelListList& subCellMap,
152  labelListList& subPatchMap,
153  labelListList& constructPointMap,
154  labelListList& constructFaceMap,
155  labelListList& constructCellMap,
156  labelListList& constructPatchMap,
157  const bool reUse // clone or reuse
158  );
159 
160 
161  // Member Functions
162 
163  // Access
164 
165  const polyMesh& mesh() const
166  {
167  return mesh_;
168  }
169 
170  //- Number of points in mesh before distribution
171  label nOldPoints() const
172  {
173  return nOldPoints_;
174  }
175 
176  //- Number of faces in mesh before distribution
177  label nOldFaces() const
178  {
179  return nOldFaces_;
180  }
181 
182  //- Number of cells in mesh before distribution
183  label nOldCells() const
184  {
185  return nOldCells_;
186  }
187 
188  //- List of the old patch sizes
189  const labelList& oldPatchSizes() const
190  {
191  return oldPatchSizes_;
192  }
193 
194  //- List of the old patch start labels
195  const labelList& oldPatchStarts() const
196  {
197  return oldPatchStarts_;
198  }
199 
200  //- List of numbers of mesh points per old patch
202  {
203  return oldPatchNMeshPoints_;
204  }
205 
206  //- Point distribute map
207  const mapDistribute& pointMap() const
208  {
209  return pointMap_;
210  }
211 
212  //- Face distribute map
213  const mapDistribute& faceMap() const
214  {
215  return faceMap_;
216  }
217 
218  //- Cell distribute map
219  const mapDistribute& cellMap() const
220  {
221  return cellMap_;
222  }
223 
224  //- Patch distribute map
225  const mapDistribute& patchMap() const
226  {
227  return patchMap_;
228  }
229 
230 
231  // Edit
232 
233  //- distribute list of point data
234  template<class T>
235  void distributePointData(List<T>& lst) const
236  {
237  pointMap_.distribute(lst);
238  }
239 
240  //- distribute list of face data
241  template<class T>
242  void distributeFaceData(List<T>& lst) const
243  {
244  faceMap_.distribute(lst);
245  }
246 
247  //- distribute list of cell data
248  template<class T>
249  void distributeCellData(List<T>& lst) const
250  {
251  cellMap_.distribute(lst);
252  }
253 
254  //- distribute list of patch data
255  template<class T>
256  void distributePatchData(List<T>& lst) const
257  {
258  patchMap_.distribute(lst);
259  }
260 
261 
262  //- distribute list of point/face/cell/patch indices.
263  // (Converts to boolList, distributes boolList and reconstructs)
264  void distributePointIndices(labelList& pointIDs) const;
265 
266  void distributeFaceIndices(labelList& faceIDs) const;
267  void distributeCellIndices(labelList& cellIDs) const;
268  void distributePatchIndices(labelList& patchIDs) const;
269 
270 
271  //- Correct for topo change.
272  void updateMesh(const mapPolyMesh&)
273  {
275  (
276  "mapDistributePolyMesh::updateMesh(const mapPolyMesh&)"
277  );
278  }
279 };
280 
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 } // End namespace Foam
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 #endif
289 
290 // ************************ vim: set sw=4 sts=4 et: ************************ //