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 Various mesh related information for a parallel run. Upon construction
29 constructs all info by using parallel communication.
32 - all processor patches to have correct ordering.
33 - all processorPatches to have their transforms set ('makeTransforms')
35 The shared point addressing gives on each processor
36 the vertices that cannot be set using a normal swap on processor patches.
37 These are the vertices that are shared between more than 2 processors.
39 There is an issue with these shared vertices if they originate from
40 cyclics (i.e. are now separated processor patches). They will all be
41 mapped to the same global point (so even though the processor points are
42 not on the same location) since topologically they are one and the same.
44 So if you ask for sharedPoints() you get only one of the coordinates of
45 the topologically shared points.
47 All the hard work of these shared points is done by the globalPoints class.
49 Shared edges: similar to shared points gives on all processors the edges
50 that are shared between more than two patches (i.e. the edges on which
51 data cannot be synchronized by a straightforward edge data swap). Note
52 that shared edges will use shared points but not all edges between shared
53 points need to be shared edges (e.g. there might be an edge connecting
54 two disconnected regions of shared points).
56 Currently an edge is considered shared
57 if it uses two shared points and is used more than once. This is not
58 correct on processor patches but it only slightly overestimates the number
59 of shared edges. Doing full analysis of how many patches use the edge
60 would be too complicated.
62 Shared edge calculation is demand driven so always make sure to have
63 your first call to one of the access functions synchronous amongst all
69 \*---------------------------------------------------------------------------*/
71 #ifndef globalMeshData_H
72 #define globalMeshData_H
76 #include "processorTopology.H"
77 #include "labelPairList.H"
78 #include "tolerancesSwitch.H"
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 // Forward declaration of friend functions and operators
88 Ostream& operator<<(Ostream&, const globalMeshData&);
91 /*---------------------------------------------------------------------------*\
92 Class globalMeshData Declaration
93 \*---------------------------------------------------------------------------*/
97 public processorTopology
102 // To combineReduce a pointField. Just appends all lists.
109 void operator()(T& x, const T& y) const
113 x.setSize(x.size() + y.size());
125 //- Reference to mesh
126 const polyMesh& mesh_;
129 // Data related to the complete mesh
131 //- Bounding box of complete mesh
134 //- Total number of points in the complete mesh
137 //- Total number of faces in the complete mesh
140 //- Total number of cells in the complete mesh
144 // Processor patch addressing (be careful if not running in parallel!)
146 //- List of processor patch labels
147 // (size of list = number of processor patches)
148 labelList processorPatches_;
150 //- List of indices into processorPatches_ for each patch.
151 // Index = -1 for non-processor patches.
152 // (size of list = number of patches)
153 labelList processorPatchIndices_;
155 //- processorPatchIndices_ of the neighbours processor patches
156 labelList processorPatchNeighbours_;
159 // Globally shared point addressing
161 //- Total number of global points
162 label nGlobalPoints_;
164 //- Indices of local points that are globally shared
165 labelList sharedPointLabels_;
167 //- Indices of globally shared points in the master list
168 // This list contains all the shared points in the mesh
169 labelList sharedPointAddr_;
171 //- Shared point global labels.
172 // Global point index for every local shared point.
173 // Only valid if constructed with this information or if
174 // pointProcAddressing read.
175 mutable labelList* sharedPointGlobalLabelsPtr_;
178 // Globally shared edge addressing. Derived from shared points.
179 // All demand driven since don't want to construct edges always.
181 //- Total number of global edges
182 mutable label nGlobalEdges_;
184 //- Indices of local edges that are globally shared
185 mutable labelList* sharedEdgeLabelsPtr_;
187 //- Indices of globally shared edge in the master list
188 // This list contains all the shared edges in the mesh
189 mutable labelList* sharedEdgeAddrPtr_;
192 // Private Member Functions
194 //- Set up processor patch addressing
197 //- Helper function for shared edge addressing
198 static void countSharedEdges
200 const HashTable<labelList, edge, Hash<edge> >& procSharedEdges,
201 HashTable<label, edge, Hash<edge> >&,
205 //- Calculate shared edge addressing
206 void calcSharedEdges() const;
208 //- Count coincident faces.
209 static label countCoincidentFaces
212 const vectorField& separationDist
215 //- Disallow default bitwise copy construct
216 globalMeshData(const globalMeshData&);
218 //- Disallow default bitwise assignment
219 void operator=(const globalMeshData&);
224 //- Runtime type information
225 ClassName("globalMeshData");
228 // Static data members
230 //- Geomtric tolerance (fraction of bounding box)
231 static const debug::tolerancesSwitch matchTol_;
236 //- Construct from mesh, derive rest (does parallel communication!)
237 globalMeshData(const polyMesh& mesh);
239 //- Old behaviour: read constructor given IOobject and a polyMesh
240 // reference. Only use this for testing!
241 globalMeshData(const IOobject& io, const polyMesh& mesh);
248 //- Remove all demand driven data
256 //- Return the mesh reference
257 const polyMesh& mesh() const
262 //- Does the mesh contain processor patches? (also valid when
263 // not running parallel)
264 bool parallel() const
266 return processorPatches_.size() > 0;
269 const boundBox& bb() const
274 //- Return total number of points in decomposed mesh
275 label nTotalPoints() const
277 return nTotalPoints_;
280 //- Return total number of faces in decomposed mesh
281 label nTotalFaces() const
286 //- Return total number of cells in decomposed mesh
287 label nTotalCells() const
293 // Processor patch addressing (be careful when not running in parallel)
295 //- Return list of processor patch labels
296 // (size of list = number of processor patches)
297 const labelList& processorPatches() const
299 return processorPatches_;
302 //- Return list of indices into processorPatches_ for each patch.
303 // Index = -1 for non-processor parches.
304 // (size of list = number of patches)
305 const labelList& processorPatchIndices() const
307 return processorPatchIndices_;
310 //- Return processorPatchIndices of the neighbours
311 // processor patches. -1 if not running parallel.
312 const labelList& processorPatchNeighbours() const
314 return processorPatchNeighbours_;
318 // Globally shared point addressing
320 //- Return number of globally shared points
321 label nGlobalPoints() const
323 return nGlobalPoints_;
326 //- Return indices of local points that are globally shared
327 const labelList& sharedPointLabels() const
329 return sharedPointLabels_;
332 //- Return addressing into the complete globally shared points
334 // Note: It is assumed that a (never constructed) complete
335 // list of globally shared points exists. The set of shared
336 // points on the current processor is a subset of all shared
337 // points. Shared point addressing gives the index in the
338 // list of all globally shared points for each of the locally
340 const labelList& sharedPointAddr() const
342 return sharedPointAddr_;
345 //- Return shared point global labels. Tries to read
346 // 'pointProcAddressing' and returns list or -1 if none
348 const labelList& sharedPointGlobalLabels() const;
350 //- Collect coordinates of shared points on all processors.
351 // (does parallel communication!)
352 // Note: not valid for cyclicParallel since shared cyclic points
353 // are merged into single global point. (use geometricSharedPoints
355 pointField sharedPoints() const;
357 //- Like sharedPoints but keeps cyclic points separate.
358 // (does geometric merging; uses matchTol_*bb as merge tolerance)
359 // Use sharedPoints() instead.
360 pointField geometricSharedPoints() const;
364 // Globally shared edge addressing
366 //- Return number of globally shared edges. Demand-driven
367 // calculation so call needs to be synchronous among processors!
368 label nGlobalEdges() const;
370 //- Return indices of local edges that are globally shared.
372 // calculation so call needs to be synchronous among processors!
373 const labelList& sharedEdgeLabels() const;
375 //- Return addressing into the complete globally shared edge
376 // list. The set of shared
377 // edges on the current processor is a subset of all shared
378 // edges. Shared edge addressing gives the index in the
379 // list of all globally shared edges for each of the locally
382 // calculation so call needs to be synchronous among processors!
383 const labelList& sharedEdgeAddr() const;
388 //- Update for moving points.
389 void movePoints(const pointField& newPoints);
391 //- Change global mesh data given a topological change. Does a
392 // full parallel analysis to determine shared points and
404 friend Ostream& operator<<(Ostream&, const globalMeshData&);
408 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
410 } // End namespace Foam
412 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
416 // ************************************************************************* //