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