FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 you do all but these shared points with patch to
33  patch communication but need to do a reduce on these shared points)
34 
35  Works purely topological and using local communication only.
36  Needs:
37  - domain to be one single domain (i.e. all faces can be reached through
38  face-cell walk).
39  - patch face ordering to be ok
40  - f[0] ordering on patch faces to be ok.
41 
42  Works by constructing equivalence lists for all the points on processor
43  patches. These list are procPointList and give processor and meshPoint
44  label on that processor.
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 gets the lowest numbered processor (the 'master') to request a
52  sharedPoint label from processor0 and it redistributes this label back to
53  the other processors in the equivalence list.
54 
55  Algorithm:
56  - get meshPoints of all my points on processor patches and initialize
57  equivalence lists to this.
58  loop
59  - send to all neighbours in relative form:
60  - patchFace
61  - index in face
62  - receive and convert into meshPoints. Add to to my equivalence lists.
63  - mark meshPoints for which information changed.
64  - send data for these meshPoints again
65  endloop until nothing changes
66 
67  At this point one will have complete point-point connectivity for all
68  points on processor patches. Now
69 
70  - remove point equivalences of size 2. These are just normal points
71  shared between two neighbouring procPatches.
72  - collect on each processor points for which it is the master
73  - request number of sharedPointLabels from the Pstream::master.
74 
75  This information gets redistributed to all processors in a similar way
76  as that in which the equivalence lists were collected:
77 
78  - initialize the indices of shared points I am the master for
79  loop
80  - send my known sharedPoints + meshPoints to all neighbours
81  - receive from all neighbour. Find which meshPoint on my processor
82  the sharedpoint is connected to
83  - mark indices for which information has changed
84  endloop until nothing changes.
85 
86 
87 SourceFiles
88  globalPoints.C
89 
90 \*---------------------------------------------------------------------------*/
91 
92 #ifndef globalPoints_H
93 #define globalPoints_H
94 
95 #include <OpenFOAM/DynamicList.H>
96 #include <OpenFOAM/Map.H>
97 #include <OpenFOAM/labelList.H>
98 #include <OpenFOAM/FixedList.H>
100 #include <OpenFOAM/className.H>
101 #include <OpenFOAM/edgeList.H>
102 
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 
105 namespace Foam
106 {
107 
108 // Forward declaration of classes
109 class polyMesh;
110 class polyBoundaryMesh;
111 class cyclicPolyPatch;
112 
113 /*---------------------------------------------------------------------------*\
114  Class globalPoints Declaration
115 \*---------------------------------------------------------------------------*/
116 
118 {
119  // Private classes
120 
121  //- Define procPointList as holding a list of meshPoint/processor labels
124 
125  // Private data
126 
127  //- Mesh reference
128  const polyMesh& mesh_;
129 
130  //- Sum of points on processor patches (unfiltered, point on 2 patches
131  // counts as 2)
132  const label nPatchPoints_;
133 
134  //- All points on boundaries and their corresponding connected points
135  // on other processors.
136  DynamicList<procPointList> procPoints_;
137 
138  //- Map from mesh point to index in procPoints
139  Map<label> meshToProcPoint_;
140 
141  //- Shared points used by this processor (= global point number)
142  labelList sharedPointAddr_;
143 
144  //- My meshpoints corresponding to the shared points
145  labelList sharedPointLabels_;
146 
147  //- Total number of shared points.
148  label nGlobalPoints_;
149 
150 
151  // Private Member Functions
152 
153  //- Count all points on processorPatches. Is all points for which
154  // information is collected.
155  static label countPatchPoints(const polyBoundaryMesh&);
156 
157  //- Add information about patchPointI in relative indices to send
158  // buffers (patchFaces, indexInFace etc.)
159  static void addToSend
160  (
161  const primitivePatch&,
162  const label patchPointI,
163  const procPointList&,
164  DynamicList<label>& patchFaces,
165  DynamicList<label>& indexInFace,
167  );
168 
169  //- Merge info from neighbour into my data
170  static bool mergeInfo
171  (
172  const procPointList& nbrInfo,
173  procPointList& myInfo
174  );
175 
176  //- Store (and merge) info for meshPointI
177  bool storeInfo(const procPointList& nbrInfo, const label meshPointI);
178 
179  //- Initialize procPoints_ to my patch points. allPoints = true:
180  // seed with all patch points, = false: only boundaryPoints().
181  void initOwnPoints(const bool allPoints, labelHashSet& changedPoints);
182 
183  //- Send subset of procPoints to neighbours
184  void sendPatchPoints(const labelHashSet& changedPoints) const;
185 
186  //- Receive neighbour points and merge into my procPoints.
187  void receivePatchPoints(labelHashSet& changedPoints);
188 
189  //- Remove entries of size 2 where meshPoint is in provided Map.
190  // Used to remove normal face-face connected points.
191  void remove(const Map<label>&);
192 
193  //- Get indices of point for which I am master (lowest numbered proc)
194  labelList getMasterPoints() const;
195 
196  //- Send subset of shared points to neighbours
197  void sendSharedPoints(const labelList& changedIndices) const;
198 
199  //- Receive shared points and update subset.
200  void receiveSharedPoints(labelList& changedIndices);
201 
202 
203  //- Should move into cyclicPolyPatch but some ordering problem
204  // keeps on giving problems.
205  static edgeList coupledPoints(const cyclicPolyPatch&);
206 
207  //- Disallow default bitwise copy construct
208  globalPoints(const globalPoints&);
209 
210  //- Disallow default bitwise assignment
211  void operator=(const globalPoints&);
212 
213 
214 public:
215 
216  //- Declare name of the class and its debug switch
217  ClassName("globalPoints");
218 
219 
220  // Constructors
221 
222  //- Construct from mesh
223  globalPoints(const polyMesh& mesh);
224 
225 
226  // Member Functions
227 
228  // Access
229 
230  label nPatchPoints() const
231  {
232  return nPatchPoints_;
233  }
234 
236  {
237  return meshToProcPoint_;
238  }
239 
240  //- shared points used by this processor (= global point number)
241  const labelList& sharedPointAddr() const
242  {
243  return sharedPointAddr_;
244  }
245 
246  //- my meshpoints corresponding to the shared points
248  {
249  return sharedPointLabels_;
250  }
251 
252  label nGlobalPoints() const
253  {
254  return nGlobalPoints_;
255  }
256 
257 };
258 
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 } // End namespace Foam
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 #endif
267 
268 // ************************ vim: set sw=4 sts=4 et: ************************ //