globalPoints.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) 2011-2016 OpenFOAM Foundation
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::globalPoints
26 
27 Description
28  Calculates points shared by more than two processor patches or cyclic
29  patches.
30 
31  Is used in globalMeshData. (this info is needed for point/edge
32  communication where processor swaps are not enough to exchange data)
33 
34  Works purely topological and using local communication only.
35  Needs:
36  - domain to be one single domain (i.e. all faces can be reached through
37  face-cell walk).
38  - patch face ordering to be ok
39  - f[0] ordering on patch faces to be ok.
40 
41  Works by constructing equivalence lists for all the points on processor
42  patches. These list are in globalIndexAndTransform numbering
43  E.g.
44  \verbatim
45  ((7 93)(4 731)(3 114))
46  \endverbatim
47 
48  means point 93 on proc7 is connected to point 731 on proc4 and 114 on proc3.
49  It then assigns the lowest numbered processor to be the local 'master' and
50  constructs a mapDistribute to send all data to this master.
51 
52  Algorithm:
53  - get meshPoints of all my points on processor patches and initialize
54  equivalence lists to this.
55  loop
56  - send to all neighbours in relative form:
57  - patchFace
58  - index in face
59  - receive and convert into meshPoints. Add to to my equivalence lists.
60  - mark meshPoints for which information changed.
61  - send data for these meshPoints again
62  endloop until nothing changes
63 
64  At this point one will have complete point-point connectivity for all
65  points on processor patches. Now (optionally) remove point
66  equivalences of size 2. These are just normal points shared
67  between two neighbouring procPatches.
68 
69  Note: the data held is either mesh point labels (construct from mesh only)
70  or patch point labels (construct from mesh and patch).
71 
72 SourceFiles
73  globalPoints.C
74 
75 \*---------------------------------------------------------------------------*/
76 
77 #ifndef globalPoints_H
78 #define globalPoints_H
79 
80 #include "DynamicList.H"
81 #include "indirectPrimitivePatch.H"
82 #include "globalIndex.H"
84 
85 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 
87 namespace Foam
88 {
89 
90 // Forward declaration of classes
91 class polyMesh;
92 class polyBoundaryMesh;
93 class cyclicPolyPatch;
94 class polyPatch;
95 class mapDistribute;
96 
97 /*---------------------------------------------------------------------------*\
98  Class globalPoints Declaration
99 \*---------------------------------------------------------------------------*/
101 class globalPoints
102 {
103  // Private data
104 
105  //- Mesh reference
106  const polyMesh& mesh_;
107 
108  //- Global numbering of untransformed points
109  globalIndex globalIndices_;
110 
111  //- Global numbering of transformed points
112  const globalIndexAndTransform globalTransforms_;
113 
114  //- Sum of points on processor patches (unfiltered, point on 2 patches
115  // counts as 2)
116  const label nPatchPoints_;
117 
118  //- All points on boundaries and their corresponding connected points
119  // on other processors.
120  DynamicList<labelPairList> procPoints_;
121 
122  //- Map from mesh (or patch) point to index in procPoints
123  Map<label> meshToProcPoint_;
124 
125 
126  // Calculated mapDistribute addressing
127 
128  //- Non-transformed connected points per point (in mapDistribute
129  // indices)
130  labelListList pointPoints_;
131 
132  //- Transformed points per point (in mapDistribute indices)
133  labelListList transformedPointPoints_;
134 
135  //- Corresponding map
137 
138 
139 
140  // Private Member Functions
141 
142  //- Count all points on processorPatches. Is all points for which
143  // information is collected.
144  static label countPatchPoints(const polyBoundaryMesh&);
145 
146  //- Find index of same processor+index
147  label findSamePoint
148  (
149  const labelPairList& allInfo,
150  const labelPair& info
151  ) const;
152 
153  labelPairList addSendTransform
154  (
155  const label patchi,
156  const labelPairList& info
157  ) const;
158 
159  //- Add information about patchPointi in relative indices to send
160  // buffers (patchFaces, indexInFace etc.)
161  void addToSend
162  (
163  const polyPatch&,
164  const label patchPointi,
165  const labelPairList&,
166  DynamicList<label>& patchFaces,
167  DynamicList<label>& indexInFace,
169  ) const;
170 
171  //- Merge info from neighbour into my data
172  bool mergeInfo
173  (
174  const labelPairList& nbrInfo,
175  const label localPointi,
176  labelPairList& myInfo
177  ) const;
178 
179  //- From mesh point to 'local point'. Is the mesh point itself
180  // if meshToPatchPoint is empty.
181  static label meshToLocalPoint
182  (
183  const Map<label>& meshToPatchPoint,
184  const label meshPointi
185  );
186 
187  //- Opposite of meshToLocalPoint.
188  static label localToMeshPoint
189  (
190  const labelList& patchToMeshPoint,
191  const label localPointi
192  );
193 
194  //- Store (and merge) info for meshPointi
195  bool storeInitialInfo
196  (
197  const labelPairList& nbrInfo,
198  const label localPointi
199  );
200 
201  //- Store (and merge) info for meshPointi
202  bool mergeInfo
203  (
204  const labelPairList& nbrInfo,
205  const label localPointi
206  );
207 
208  //- Debug printing
209  void printProcPoint
210  (
211  const labelList& patchToMeshPoint,
212  const labelPair& pointInfo
213  ) const;
214 
215  void printProcPoints
216  (
217  const labelList& patchToMeshPoint,
218  const labelPairList& pointInfo
219  ) const;
220 
221  //- Initialize procPoints_ to my patch points. allPoints = true:
222  // seed with all patch points, = false: only boundaryPoints().
223  void initOwnPoints
224  (
225  const Map<label>& meshToPatchPoint,
226  const bool allPoints,
227  labelHashSet& changedPoints
228  );
229 
230  //- Send subset of procPoints to neighbours
231  void sendPatchPoints
232  (
233  const bool mergeSeparated,
234  const Map<label>&,
236  const labelHashSet&
237  ) const;
238 
239  //- Receive neighbour points and merge into my procPoints.
240  void receivePatchPoints
241  (
242  const bool mergeSeparated,
243  const Map<label>&,
244  const labelList&,
246  labelHashSet&
247  );
248 
249  //- Remove entries of size 2 where meshPoint is in provided Map.
250  // Used to remove normal face-face connected points.
251  void remove(const labelList& patchToMeshPoint, const Map<label>&);
252 
253  //- Return mesh points of other side in same order as my meshPoints.
254  static labelList reverseMeshPoints(const cyclicPolyPatch&);
255 
256  //- Do all calculations.
257  void calculateSharedPoints
258  (
259  const Map<label>&,
260  const labelList&,
261  const bool keepAllPoints,
262  const bool mergeSeparated
263  );
264 
265  //- Disallow default bitwise copy construct
266  globalPoints(const globalPoints&);
267 
268  //- Disallow default bitwise assignment
269  void operator=(const globalPoints&);
270 
271 
272 public:
273 
274  //- Declare name of the class and its debug switch
275  ClassName("globalPoints");
276 
277 
278  // Constructors
279 
280  //- Construct from mesh.
281  // keepAllPoints = false : filter out points that are on two
282  // neighbouring coupled patches only (so can be swapped)
283  // mergeSeparated:
284  // true : merge coupled points across separated patches.
285  // false : do not merge across coupled separated patches.
287  (
288  const polyMesh& mesh,
289  const bool keepAllPoints,
290  const bool mergeSeparated
291  );
292 
293  //- Construct from mesh and patch of coupled faces. Difference with
294  // construct from mesh only is that this stores the meshToProcPoint,
295  // procPoints as patch local point labels instead of mesh point labels.
297  (
298  const polyMesh& mesh,
299  const indirectPrimitivePatch& coupledPatch,
300  const bool keepAllPoints,
301  const bool mergeSeparated
302  );
303 
304 
305  // Member Functions
306 
307  // Access
308 
309  //- Global numbering of untransformed (mesh or patch) points
310  const globalIndex& globalIndices() const
311  {
312  return globalIndices_;
313  }
314 
315  //- Global numbering of transformed (mesh or patch) points
317  {
318  return globalTransforms_;
319  }
320 
321  //- Non-transformed connected points per point (in mapDistribute
322  // indices)
323  const labelListList& pointPoints() const
324  {
325  return pointPoints_;
326  }
327 
328  //- Non-transformed connected points per point (in mapDistribute
329  // indices)
331  {
332  return pointPoints_;
333  }
334 
335  //- Transformed points per point (in mapDistribute indices)
337  {
338  return transformedPointPoints_;
339  }
340 
341  //- Transformed points per point (in mapDistribute indices)
343  {
344  return transformedPointPoints_;
345  }
346 
347  //- Corresponding map
348  const mapDistribute& map() const
349  {
350  return map_();
351  }
352 
353  //- Corresponding map
354  mapDistribute& map()
355  {
356  return map_();
357  }
358 
359  //- From (mesh or patch) point to index in procPoints
360  const Map<label>& meshToProcPoint() const
361  {
362  return meshToProcPoint_;
363  }
364 
365  //- procPoints is per point the connected points (in
366  // globalTransformAndIndex point numbers)
368  {
369  return procPoints_;
370  }
371 };
372 
373 
374 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
375 
376 } // End namespace Foam
377 
378 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
379 
380 #endif
381 
382 // ************************************************************************* //
const labelListList & transformedPointPoints() const
Transformed points per point (in mapDistribute indices)
Definition: globalPoints.H:335
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const Map< label > & meshToProcPoint() const
From (mesh or patch) point to index in procPoints.
Definition: globalPoints.H:359
const mapDistribute & map() const
Corresponding map.
Definition: globalPoints.H:347
A list of faces which address into the list of points.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:63
dynamicFvMesh & mesh
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
Cyclic plane patch.
ClassName("globalPoints")
Declare name of the class and its debug switch.
const DynamicList< labelPairList > & procPoints() const
procPoints is per point the connected points (in
Definition: globalPoints.H:366
Foam::polyBoundaryMesh.
const labelListList & pointPoints() const
Non-transformed connected points per point (in mapDistribute.
Definition: globalPoints.H:322
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Calculates points shared by more than two processor patches or cyclic patches.
Definition: globalPoints.H:100
label patchi
Class containing processor-to-processor mapping information.
tmp< pointField > allPoints(const Triangulation &t)
Extract all points in vertex-index order.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
const globalIndexAndTransform & globalTransforms() const
Global numbering of transformed (mesh or patch) points.
Definition: globalPoints.H:315
const globalIndex & globalIndices() const
Global numbering of untransformed (mesh or patch) points.
Definition: globalPoints.H:309
Namespace for OpenFOAM.
Determination and storage of the possible independent transforms introduced by coupledPolyPatches, as well as all of the possible permutations of these transforms generated by the presence of multiple coupledPolyPatches, i.e. more than one cyclic boundary. Note that any given point can be on maximum 3 transforms only (and these transforms have to be perpendicular)