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 template<>
63 Ostream& operator<<(Ostream&, const InfoProxy<mapDistributePolyMesh>&);
64 
65 
66 /*---------------------------------------------------------------------------*\
67  Class mapDistributePolyMesh Declaration
68 \*---------------------------------------------------------------------------*/
69 
71 {
72  // Private Data
73 
74  //- Number of old live points
75  label nOldPoints_;
76 
77  //- Number of old live faces
78  label nOldFaces_;
79 
80  //- Number of old live cells
81  label nOldCells_;
82 
83  //- List of the old patch sizes
84  labelList oldPatchSizes_;
85 
86  //- List of the old patch start labels
87  labelList oldPatchStarts_;
88 
89  //- List of numbers of mesh points per old patch
90  labelList oldPatchNMeshPoints_;
91 
92 
93  //- Point distribute map
94  mapDistribute pointMap_;
95 
96  //- Face distribute map
97  mapDistribute faceMap_;
98 
99  //- Cell distribute map
100  mapDistribute cellMap_;
101 
102  //- Patch distribute map
103  mapDistribute patchMap_;
104 
105 
106  // Private Member Functions
107 
108  void calcPatchSizes();
109 
110  void deepCopy(const mapDistributePolyMesh& rhs);
111 
112 public:
113 
114  // Constructors
115 
116  //- Default construct - uses worldComm
118 
119  //- Default construct with specified communicator
120  explicit mapDistributePolyMesh(const label comm);
121 
122  //- Read construct from dictionary
123  explicit mapDistributePolyMesh
124  (
125  const dictionary& dict,
126  const label comm = UPstream::worldComm
127  );
128 
129  //- Copy construct
131 
132  //- Move construct
134 
135  //- Copy/move construct
137 
138  //- Construct from components. Note that mesh has to be changed already
139  // since uses mesh.nPoints etc as the new size.
141  (
142  const polyMesh& mesh,
143 
144  // mesh before changes
145  const label nOldPoints,
146  const label nOldFaces,
147  const label nOldCells,
150 
151  // how to subset pieces of mesh to send across
152  labelListList&& subPointMap,
153  labelListList&& subFaceMap,
154  labelListList&& subCellMap,
155  labelListList&& subPatchMap,
156 
157  // how to reconstruct received mesh
158  labelListList&& constructPointMap,
159  labelListList&& constructFaceMap,
160  labelListList&& constructCellMap,
161  labelListList&& constructPatchMap,
162 
163  const bool subFaceHasFlip = false,
164  const bool constructFaceHasFlip = false
165  );
166 
167  //- Move construct from components
169  (
170  // mesh before changes
171  const label nOldPoints,
172  const label nOldFaces,
173  const label nOldCells,
176 
177  // how to subset pieces of mesh to send across
182  );
183 
184  //- Construct from Istream
185  explicit mapDistributePolyMesh(Istream& is);
186 
187 
188  // Member Functions
189 
190  // Access
191 
192  //- Number of points in mesh before distribution
193  label nOldPoints() const noexcept
194  {
195  return nOldPoints_;
196  }
197 
198  //- Number of faces in mesh before distribution
199  label nOldFaces() const noexcept
200  {
201  return nOldFaces_;
202  }
203 
204  //- Number of cells in mesh before distribution
205  label nOldCells() const noexcept
206  {
207  return nOldCells_;
208  }
209 
210  //- List of the old patch sizes
211  const labelList& oldPatchSizes() const noexcept
212  {
213  return oldPatchSizes_;
214  }
215 
216  //- List of the old patch start labels
217  const labelList& oldPatchStarts() const noexcept
218  {
219  return oldPatchStarts_;
220  }
221 
222  //- List of numbers of mesh points per old patch
223  const labelList& oldPatchNMeshPoints() const noexcept
224  {
225  return oldPatchNMeshPoints_;
226  }
227 
228  //- Point distribute map
230  {
231  return pointMap_;
232  }
233 
234  //- Face distribute map
235  const mapDistribute& faceMap() const noexcept
236  {
237  return faceMap_;
238  }
239 
240  //- Cell distribute map
241  const mapDistribute& cellMap() const noexcept
242  {
243  return cellMap_;
244  }
246  //- Patch distribute map
247  const mapDistribute& patchMap() const noexcept
248  {
249  return patchMap_;
250  }
251 
252 
253  // Edit
254 
255  //- Reset to zero size, only retaining communicator(s)
256  void clear();
257 
258 
259  // Other
260 
261  //- Transfer the contents of the argument and annul the argument.
262  void transfer(mapDistributePolyMesh& map);
263 
264  //- Distribute list of point data
265  template<class T>
266  void distributePointData(List<T>& values) const
267  {
268  pointMap_.distribute(values);
269  }
270 
271  //- Distribute list of face data
272  template<class T>
273  void distributeFaceData(List<T>& values) const
274  {
275  faceMap_.distribute(values);
276  }
278  //- Distribute list of cell data
279  template<class T>
280  void distributeCellData(List<T>& values) const
281  {
282  cellMap_.distribute(values);
283  }
284 
285  //- Distribute list of patch data
286  template<class T>
287  void distributePatchData(List<T>& values) const
288  {
289  patchMap_.distribute(values);
290  }
291 
292 
293  //- Distribute list of point/face/cell/patch indices.
294  // (Converts to boolList, distributes boolList and reconstructs)
295  void distributePointIndices(labelList& pointIDs) const;
296 
297  void distributeFaceIndices(labelList& faceIDs) const;
300 
302 
303  // Member Operators
304 
305  //- Copy assignment
306  void operator=(const mapDistributePolyMesh& map);
307 
308  //- Move assignment
309  void operator=(mapDistributePolyMesh&& map);
310 
311 
312  // IOstream Operators
313 
314  //- Return info proxy,
315  //- used to print summary information to a stream
317  {
318  return *this;
319  }
320 
321  //- Read entries from dictionary format
322  void readDict(const dictionary& dict);
323 
324 
325  //- Write cellMap in dictionary format
327 
328  //- Write faceMap in dictionary format
329  void writeFaceMapEntries(Ostream& os) const;
330 
331  //- Write pointMap entries in dictionary format
332  void writePointMapEntries(Ostream& os) const;
333 
334  //- Write patchMap in dictionary format
336 
337  //- Write all map entries in dictionary format
338  void writeEntries(Ostream& os) const;
339 
340 
341  //- Read plain content (not dictionary) from Istream
343 
344  //- Write plain content (not dictionary) to Ostream
346 
347 
348  // Housekeeping
349 
350  //- No correction for topo change
351  void updateMesh(const mapPolyMesh&)
352  {
354  }
355 };
356 
357 
358 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
359 
360 } // End namespace Foam
361 
362 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
363 
364 #endif
365 
366 // ************************************************************************* //
friend Ostream & operator<<(Ostream &, const mapDistributePolyMesh &)
Write plain content (not dictionary) to Ostream.
const labelList patchIDs(pbm.indices(polyPatchNames, true))
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:129
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 List data using default commsType, default flip/negate operator.
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
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
Definition: UPstream.H:409
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.
InfoProxy< mapDistributePolyMesh > info() const noexcept
Return info proxy, used to print summary information to a stream.
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.
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:56
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:77
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:74
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:686
labelList cellIDs
const mapDistribute & faceMap() const noexcept
Face distribute map.
void readDict(const dictionary &dict)
Read entries from dictionary format.
Namespace for OpenFOAM.