globalPoints.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 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 distributionMap to send all data to this master.
51 
52  Algorithm:
53  - get meshPoints of all my points on processor patches and initialise
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 distributionMap;
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 distributionMap addressing
127 
128  //- Non-transformed connected points per point (in distributionMap
129  // indices)
130  labelListList pointPoints_;
131 
132  //- Transformed points per point (in distributionMap 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  //- Initialise 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 
266 public:
267 
268  //- Declare name of the class and its debug switch
269  ClassName("globalPoints");
270 
271 
272  // Constructors
273 
274  //- Construct from mesh.
275  // keepAllPoints = false : filter out points that are on two
276  // neighbouring coupled patches only (so can be swapped)
277  // mergeSeparated:
278  // true : merge coupled points across separated patches.
279  // false : do not merge across coupled separated patches.
281  (
282  const polyMesh& mesh,
283  const bool keepAllPoints,
284  const bool mergeSeparated
285  );
286 
287  //- Construct from mesh and patch of coupled faces. Difference with
288  // construct from mesh only is that this stores the meshToProcPoint,
289  // procPoints as patch local point labels instead of mesh point labels.
291  (
292  const polyMesh& mesh,
293  const indirectPrimitivePatch& coupledPatch,
294  const bool keepAllPoints,
295  const bool mergeSeparated
296  );
297 
298  //- Disallow default bitwise copy construction
299  globalPoints(const globalPoints&) = delete;
300 
301 
302  // Member Functions
303 
304  // Access
305 
306  //- Global numbering of untransformed (mesh or patch) points
307  const globalIndex& globalIndices() const
308  {
309  return globalIndices_;
310  }
311 
312  //- Global numbering of transformed (mesh or patch) points
314  {
315  return globalTransforms_;
316  }
317 
318  //- Non-transformed connected points per point (in distributionMap
319  // indices)
320  const labelListList& pointPoints() const
321  {
322  return pointPoints_;
323  }
324 
325  //- Non-transformed connected points per point (in distributionMap
326  // indices)
328  {
329  return pointPoints_;
330  }
331 
332  //- Transformed points per point (in distributionMap indices)
334  {
335  return transformedPointPoints_;
336  }
337 
338  //- Transformed points per point (in distributionMap indices)
340  {
341  return transformedPointPoints_;
342  }
343 
344  //- Corresponding map
345  const distributionMap& map() const
346  {
347  return map_();
348  }
349 
350  //- Corresponding map
352  {
353  return map_();
354  }
355 
356  //- From (mesh or patch) point to index in procPoints
357  const Map<label>& meshToProcPoint() const
358  {
359  return meshToProcPoint_;
360  }
361 
362  //- procPoints is per point the connected points (in
363  // globalTransformAndIndex point numbers)
365  {
366  return procPoints_;
367  }
368 
369 
370  // Member Operators
371 
372  //- Disallow default bitwise assignment
373  void operator=(const globalPoints&) = delete;
374 };
375 
376 
377 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
378 
379 } // End namespace Foam
380 
381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
382 
383 #endif
384 
385 // ************************************************************************* //
const labelListList & transformedPointPoints() const
Transformed points per point (in distributionMap indices)
Definition: globalPoints.H:332
const Map< label > & meshToProcPoint() const
From (mesh or patch) point to index in procPoints.
Definition: globalPoints.H:356
fvMesh & mesh
const distributionMap & map() const
Corresponding map.
Definition: globalPoints.H:344
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
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:363
Foam::polyBoundaryMesh.
const labelListList & pointPoints() const
Non-transformed connected points per point (in distributionMap.
Definition: globalPoints.H:319
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Calculates points shared by more than two processor patches or cyclic patches.
Definition: globalPoints.H:100
Class containing processor-to-processor mapping information.
label patchi
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:76
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:312
void operator=(const globalPoints &)=delete
Disallow default bitwise assignment.
const globalIndex & globalIndices() const
Global numbering of untransformed (mesh or patch) points.
Definition: globalPoints.H:306
globalPoints(const polyMesh &mesh, const bool keepAllPoints, const bool mergeSeparated)
Construct from mesh.
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)