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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2015-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::mapDistributePolyMesh
29 
30 Description
31  Class containing mesh-to-mesh mapping information after a mesh distribution
32  where we send parts of meshes (using subsetting) to other processors
33  and receive and reconstruct mesh.
34 
35  We store mapping from the bits-to-send to the complete starting mesh
36  (subXXXMap) and from the received bits to their location in the new
37  mesh (constructXXXMap).
38 
39 SourceFiles
40  mapDistributePolyMesh.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef Foam_mapDistributePolyMesh_H
45 #define Foam_mapDistributePolyMesh_H
46 
47 #include "mapDistribute.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward Declarations
55 class mapPolyMesh;
56 class polyMesh;
57 class mapDistributePolyMesh;
58 
59 Istream& operator>>(Istream&, mapDistributePolyMesh&);
60 Ostream& operator<<(Ostream&, const mapDistributePolyMesh&);
61 
62 
63 /*---------------------------------------------------------------------------*\
64  Class mapDistributePolyMesh Declaration
65 \*---------------------------------------------------------------------------*/
66 
68 {
69  // Private Data
70 
71  //- Number of old live points
72  label nOldPoints_;
73 
74  //- Number of old live faces
75  label nOldFaces_;
76 
77  //- Number of old live cells
78  label nOldCells_;
79 
80  //- List of the old patch sizes
81  labelList oldPatchSizes_;
82 
83  //- List of the old patch start labels
84  labelList oldPatchStarts_;
85 
86  //- List of numbers of mesh points per old patch
87  labelList oldPatchNMeshPoints_;
88 
89 
90  //- Point distribute map
91  mapDistribute pointMap_;
92 
93  //- Face distribute map
94  mapDistribute faceMap_;
95 
96  //- Cell distribute map
97  mapDistribute cellMap_;
98 
99  //- Patch distribute map
100  mapDistribute patchMap_;
101 
102 
103  // Private Member Functions
104 
105  void calcPatchSizes();
106 
107  void deepCopy(const mapDistributePolyMesh& rhs);
108 
109 public:
110 
111  // Constructors
112 
113  //- Default construct - uses worldComm
115 
116  //- Default construct with specified communicator
117  explicit mapDistributePolyMesh(const label comm);
118 
119  //- Read construct from dictionary
120  explicit mapDistributePolyMesh
121  (
122  const dictionary& dict,
123  const label comm = UPstream::worldComm
124  );
125 
126  //- Copy construct
128 
129  //- Move construct
131 
132  //- Copy/move construct
134 
135  //- Construct from components. Note that mesh has to be changed already
136  // since uses mesh.nPoints etc as the new size.
138  (
139  const polyMesh& mesh,
140 
141  // mesh before changes
142  const label nOldPoints,
143  const label nOldFaces,
144  const label nOldCells,
147 
148  // how to subset pieces of mesh to send across
149  labelListList&& subPointMap,
150  labelListList&& subFaceMap,
151  labelListList&& subCellMap,
152  labelListList&& subPatchMap,
153 
154  // how to reconstruct received mesh
155  labelListList&& constructPointMap,
156  labelListList&& constructFaceMap,
157  labelListList&& constructCellMap,
158  labelListList&& constructPatchMap,
159 
160  const bool subFaceHasFlip = false,
161  const bool constructFaceHasFlip = false
162  );
163 
164  //- Move construct from components
166  (
167  // mesh before changes
168  const label nOldPoints,
169  const label nOldFaces,
170  const label nOldCells,
173 
174  // how to subset pieces of mesh to send across
179  );
180 
181  //- Construct from Istream
182  explicit mapDistributePolyMesh(Istream& is);
183 
184 
185  // Member Functions
186 
187  // Access
188 
189  //- Number of points in mesh before distribution
190  label nOldPoints() const noexcept
191  {
192  return nOldPoints_;
193  }
194 
195  //- Number of faces in mesh before distribution
196  label nOldFaces() const noexcept
197  {
198  return nOldFaces_;
199  }
200 
201  //- Number of cells in mesh before distribution
202  label nOldCells() const noexcept
203  {
204  return nOldCells_;
205  }
206 
207  //- List of the old patch sizes
208  const labelList& oldPatchSizes() const noexcept
209  {
210  return oldPatchSizes_;
211  }
212 
213  //- List of the old patch start labels
214  const labelList& oldPatchStarts() const noexcept
215  {
216  return oldPatchStarts_;
217  }
218 
219  //- List of numbers of mesh points per old patch
220  const labelList& oldPatchNMeshPoints() const noexcept
221  {
222  return oldPatchNMeshPoints_;
223  }
224 
225  //- Point distribute map
227  {
228  return pointMap_;
229  }
230 
231  //- Face distribute map
232  const mapDistribute& faceMap() const noexcept
233  {
234  return faceMap_;
235  }
236 
237  //- Cell distribute map
238  const mapDistribute& cellMap() const noexcept
239  {
240  return cellMap_;
241  }
243  //- Patch distribute map
244  const mapDistribute& patchMap() const noexcept
245  {
246  return patchMap_;
247  }
248 
249 
250  // Edit
251 
252  //- Reset to zero size, only retaining communicator(s)
253  void clear();
254 
255 
256  // Other
257 
258  //- Transfer the contents of the argument and annul the argument.
259  void transfer(mapDistributePolyMesh& map);
260 
261  //- Distribute list of point data
262  template<class T>
263  void distributePointData(List<T>& values) const
264  {
265  pointMap_.distribute(values);
266  }
267 
268  //- Distribute list of face data
269  template<class T>
270  void distributeFaceData(List<T>& values) const
271  {
272  faceMap_.distribute(values);
273  }
275  //- Distribute list of cell data
276  template<class T>
277  void distributeCellData(List<T>& values) const
278  {
279  cellMap_.distribute(values);
280  }
281 
282  //- Distribute list of patch data
283  template<class T>
284  void distributePatchData(List<T>& values) const
285  {
286  patchMap_.distribute(values);
287  }
288 
289 
290  //- Distribute list of point/face/cell/patch indices.
291  // (Converts to boolList, distributes boolList and reconstructs)
292  void distributePointIndices(labelList& pointIDs) const;
293 
294  void distributeFaceIndices(labelList& faceIDs) const;
296  void distributePatchIndices(labelList& patchIDs) const;
297 
299 
300  // Member Operators
301 
302  //- Copy assignment
303  void operator=(const mapDistributePolyMesh& map);
304 
305  //- Move assignment
306  void operator=(mapDistributePolyMesh&& map);
307 
308 
309  // IOstream Operators
310 
311  //- Info proxy to print summary information to a stream
313  {
314  return *this;
315  }
316 
317  //- Read entries from dictionary format
318  void readDict(const dictionary& dict);
319 
320 
321  //- Write cellMap in dictionary format
322  void writeCellMapEntries(Ostream& os) const;
324  //- Write faceMap in dictionary format
325  void writeFaceMapEntries(Ostream& os) const;
326 
327  //- Write pointMap entries in dictionary format
328  void writePointMapEntries(Ostream& os) const;
329 
330  //- Write patchMap in dictionary format
331  void writePatchMapEntries(Ostream& os) const;
333  //- Write all map entries in dictionary format
334  void writeEntries(Ostream& os) const;
335 
336 
337  //- Read plain content (not dictionary) from Istream
339 
340  //- Write plain content (not dictionary) to Ostream
342 
343 
344  // Housekeeping
345 
346  //- No correction for topo change
347  void updateMesh(const mapPolyMesh&)
348  {
350  }
351 };
352 
353 
354 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
355 
356 template<>
357 Ostream& operator<<(Ostream& os, const InfoProxy<mapDistributePolyMesh>& ip);
358 
359 
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361 
362 } // End namespace Foam
363 
364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
365 
366 #endif
367 
368 // ************************************************************************* //
friend Ostream & operator<<(Ostream &, const mapDistributePolyMesh &)
Write plain content (not dictionary) to Ostream.
dictionary dict
void writePointMapEntries(Ostream &os) const
Write pointMap entries in dictionary format.
void distributeCellIndices(labelList &cellIDs) const
const labelList & oldPatchSizes() const noexcept
List of the old patch sizes.
void distributePatchIndices(labelList &patchIDs) const
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
label nOldCells() const noexcept
Number of cells in mesh before distribution.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
void operator=(const mapDistributePolyMesh &map)
Copy assignment.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void writeEntries(Ostream &os) const
Write all map entries in dictionary format.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
void clear()
Reset to zero size, only retaining communicator(s)
static label worldComm
Default world communicator (all processors). May differ from globalComm if local worlds are in use...
Definition: UPstream.H:361
mapDistributePolyMesh()
Default construct - uses worldComm.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:157
const labelList & oldPatchStarts() const noexcept
List of the old patch start labels.
void distributeFaceData(List< T > &values) const
Distribute list of face data.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:164
label nOldPoints() const noexcept
Number of points in mesh before distribution.
const mapDistribute & pointMap() const noexcept
Point distribute map.
void transfer(mapDistributePolyMesh &map)
Transfer the contents of the argument and annul the argument.
void writeCellMapEntries(Ostream &os) const
Write cellMap in dictionary format.
dynamicFvMesh & mesh
label nOldFaces() const noexcept
Number of faces in mesh before distribution.
Istream & operator>>(Istream &, directionInfo &)
void writeFaceMapEntries(Ostream &os) const
Write faceMap in dictionary format.
void distributeCellData(List< T > &values) const
Distribute list of cell data.
const mapDistribute & cellMap() const noexcept
Cell distribute map.
InfoProxy< mapDistributePolyMesh > info() const
Info proxy to print summary information to a stream.
friend Istream & operator>>(Istream &, mapDistributePolyMesh &)
Read plain content (not dictionary) from Istream.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
const direction noexcept
Definition: Scalar.H:258
OBJstream os(runTime.globalPath()/outputName)
void writePatchMapEntries(Ostream &os) const
Write patchMap in dictionary format.
void distributeFaceIndices(labelList &faceIDs) const
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:76
void distributePointData(List< T > &values) const
Distribute list of point data.
Class containing processor-to-processor mapping information.
A helper class for outputting values to Ostream.
Definition: ensightCells.H:43
const labelList & oldPatchNMeshPoints() const noexcept
List of numbers of mesh points per old patch.
void distributePointIndices(labelList &pointIDs) const
Distribute list of point/face/cell/patch indices.
const mapDistribute & patchMap() const noexcept
Patch distribute map.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:73
void updateMesh(const mapPolyMesh &)
No correction for topo change.
void distributePatchData(List< T > &values) const
Distribute list of patch data.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:666
labelList cellIDs
const mapDistribute & faceMap() const noexcept
Face distribute map.
void readDict(const dictionary &dict)
Read entries from dictionary format.
Namespace for OpenFOAM.