1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Calculates points shared by more than two processor patches or cyclic
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)
35 Works purely topological and using local communication only.
37 - domain to be one single domain (i.e. all faces can be reached through
39 - patch face ordering to be ok
40 - f[0] ordering on patch faces to be ok.
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.
47 ((7 93)(4 731)(3 114))
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.
56 - get meshPoints of all my points on processor patches and initialize
57 equivalence lists to this.
59 - send to all neighbours in relative form:
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
67 At this point one will have complete point-point connectivity for all
68 points on processor patches. Now
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.
75 This information gets redistributed to all processors in a similar way
76 as that in which the equivalence lists were collected:
78 - initialize the indices of shared points I am the master for
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.
90 \*---------------------------------------------------------------------------*/
92 #ifndef globalPoints_H
93 #define globalPoints_H
95 #include "DynamicList.H"
97 #include "labelList.H"
98 #include "FixedList.H"
99 #include "primitivePatch.H"
100 #include "className.H"
101 #include "edgeList.H"
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 // Forward declaration of classes
110 class polyBoundaryMesh;
111 class cyclicPolyPatch;
113 /*---------------------------------------------------------------------------*\
114 Class globalPoints Declaration
115 \*---------------------------------------------------------------------------*/
121 //- Define procPointList as holding a list of meshPoint/processor labels
122 typedef FixedList<label, 2> procPoint;
123 typedef List<procPoint> procPointList;
128 const polyMesh& mesh_;
130 //- Sum of points on processor patches (unfiltered, point on 2 patches
132 const label nPatchPoints_;
134 //- All points on boundaries and their corresponding connected points
135 // on other processors.
136 DynamicList<procPointList> procPoints_;
138 //- Map from mesh point to index in procPoints
139 Map<label> meshToProcPoint_;
141 //- Shared points used by this processor (= global point number)
142 labelList sharedPointAddr_;
144 //- My meshpoints corresponding to the shared points
145 labelList sharedPointLabels_;
147 //- Total number of shared points.
148 label nGlobalPoints_;
151 // Private Member Functions
153 //- Count all points on processorPatches. Is all points for which
154 // information is collected.
155 static label countPatchPoints(const polyBoundaryMesh&);
157 //- Add information about patchPointI in relative indices to send
158 // buffers (patchFaces, indexInFace etc.)
159 static void addToSend
161 const primitivePatch&,
162 const label patchPointI,
163 const procPointList&,
164 DynamicList<label>& patchFaces,
165 DynamicList<label>& indexInFace,
166 DynamicList<procPointList>& allInfo
169 //- Merge info from neighbour into my data
170 static bool mergeInfo
172 const procPointList& nbrInfo,
173 procPointList& myInfo
176 //- Store (and merge) info for meshPointI
177 bool storeInfo(const procPointList& nbrInfo, const label meshPointI);
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);
183 //- Send subset of procPoints to neighbours
184 void sendPatchPoints(const labelHashSet& changedPoints) const;
186 //- Receive neighbour points and merge into my procPoints.
187 void receivePatchPoints(labelHashSet& changedPoints);
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>&);
193 //- Get indices of point for which I am master (lowest numbered proc)
194 labelList getMasterPoints() const;
196 //- Send subset of shared points to neighbours
197 void sendSharedPoints(const labelList& changedIndices) const;
199 //- Receive shared points and update subset.
200 void receiveSharedPoints(labelList& changedIndices);
203 //- Should move into cyclicPolyPatch but some ordering problem
204 // keeps on giving problems.
205 static edgeList coupledPoints(const cyclicPolyPatch&);
207 //- Disallow default bitwise copy construct
208 globalPoints(const globalPoints&);
210 //- Disallow default bitwise assignment
211 void operator=(const globalPoints&);
216 //- Declare name of the class and its debug switch
217 ClassName("globalPoints");
222 //- Construct from mesh
223 globalPoints(const polyMesh& mesh);
230 label nPatchPoints() const
232 return nPatchPoints_;
235 const Map<label>& meshToProcPoint() const
237 return meshToProcPoint_;
240 //- shared points used by this processor (= global point number)
241 const labelList& sharedPointAddr() const
243 return sharedPointAddr_;
246 //- my meshpoints corresponding to the shared points
247 const labelList& sharedPointLabels() const
249 return sharedPointLabels_;
252 label nGlobalPoints() const
254 return nGlobalPoints_;
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 } // End namespace Foam
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 // ************************************************************************* //