1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Various mesh related information for a parallel run. Upon construction
30 constructs all info by using parallel communication.
33 - all processor patches to have correct ordering.
34 - all processorPatches to have their transforms set ('makeTransforms')
36 The shared point addressing is quite interesting. It gives on each processor
37 the vertices that cannot be set using a normal swap on processor patches.
38 These are the vertices that are shared between more than 2 processors.
40 There is an issue with these shared vertices if they originate from
41 cyclics (i.e. are now separated processor patches). They will all be
42 mapped to the same global point (so even though the processor points are
43 not on the same location) since topologically they are one and the same.
45 So if you ask for sharedPoints() you get only one of the coordinates of
46 the topologically shared points.
48 All the hard work of these shared points is done by the globalPoints class.
50 Shared edges: similar to shared points gives on all processors the edges
51 that are shared between more than two patches (i.e. the edges on which
52 data cannot be synchronized by a straightforward edge data swap). Note
53 that shared edges will use shared points but not all edges between shared
54 points need to be shared edges (e.g. there might be an edge connecting
55 two disconnected regions of shared points).
57 Currently an edge is considered shared
58 if it uses two shared points and is used more than once. This is not
59 correct on processor patches but it only slightly overestimates the number
60 of shared edges. Doing full analysis of how many patches use the edge
61 would be too complicated.
63 Shared edge calculation is demand driven so always make sure to have
64 your first call to one of the access functions synchronous amongst all
72 \*---------------------------------------------------------------------------*/
74 #ifndef globalMeshData_H
75 #define globalMeshData_H
79 #include "processorTopology.H"
80 #include "labelPair.H"
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
87 // Forward declaration of friend functions and operators
90 Ostream& operator<<(Ostream&, const globalMeshData&);
93 /*---------------------------------------------------------------------------*\
94 Class globalMeshData Declaration
95 \*---------------------------------------------------------------------------*/
99 public processorTopology
104 // To combineReduce a pointField. Just appends all lists.
111 void operator()(T& x, const T& y) const
115 x.setSize(x.size() + y.size());
125 typedef List<labelPair> labelPairList;
130 //- Reference to mesh
131 const polyMesh& mesh_;
134 // Data related to the complete mesh
136 //- Bounding box of complete mesh
139 //- Total number of points in the complete mesh
142 //- Total number of faces in the complete mesh
145 //- Total number of cells in the complete mesh
149 // Processor patch addressing (be careful if not running in parallel!)
151 //- List of processor patch labels
152 // (size of list = number of processor patches)
153 labelList processorPatches_;
155 //- List of indices into processorPatches_ for each patch.
156 // Index = -1 for non-processor patches.
157 // (size of list = number of patches)
158 labelList processorPatchIndices_;
160 //- processorPatchIndices_ of the neighbours processor patches
161 labelList processorPatchNeighbours_;
164 // Globally shared point addressing
166 //- Total number of global points
167 label nGlobalPoints_;
169 //- Indices of local points that are globally shared
170 labelList sharedPointLabels_;
172 //- Indices of globally shared points in the master list
173 // This list contains all the shared points in the mesh
174 labelList sharedPointAddr_;
176 //- Shared point global labels.
177 // Global point index for every local shared point.
178 // Only valid if constructed with this information or if
179 // pointProcAddressing read.
180 mutable labelList* sharedPointGlobalLabelsPtr_;
183 // Globally shared edge addressing. Derived from shared points.
184 // All demand driven since don't want to construct edges always.
186 //- Total number of global edges
187 mutable label nGlobalEdges_;
189 //- Indices of local edges that are globally shared
190 mutable labelList* sharedEdgeLabelsPtr_;
192 //- Indices of globally shared edge in the master list
193 // This list contains all the shared edges in the mesh
194 mutable labelList* sharedEdgeAddrPtr_;
197 // Private Member Functions
199 //- Set up processor patch addressing
202 //- Helper function for shared edge addressing
203 static void countSharedEdges
205 const HashTable<labelList, edge, Hash<edge> >& procSharedEdges,
206 HashTable<label, edge, Hash<edge> >&,
210 //- Calculate shared edge addressing
211 void calcSharedEdges() const;
213 //- Count coincident faces.
214 static label countCoincidentFaces
217 const vectorField& separationDist
220 //- Disallow default bitwise copy construct
221 globalMeshData(const globalMeshData&);
223 //- Disallow default bitwise assignment
224 void operator=(const globalMeshData&);
229 //- Runtime type information
230 ClassName("globalMeshData");
233 // Static data members
235 //- Geomtric tolerance (fraction of bounding box)
236 static const Foam::scalar matchTol_;
241 //- Construct from mesh, derive rest (does parallel communication!)
242 globalMeshData(const polyMesh& mesh);
244 //- Old behaviour: read constructor given IOobject and a polyMesh
245 // reference. Only use this for testing!
246 globalMeshData(const IOobject& io, const polyMesh& mesh);
253 //- Remove all demand driven data
261 //- Return the mesh reference
262 const polyMesh& mesh() const
267 //- Does the mesh contain processor patches? (also valid when
268 // not running parallel)
269 bool parallel() const
271 return processorPatches_.size() > 0;
274 const boundBox& bb() const
279 //- Return total number of points in decomposed mesh
280 label nTotalPoints() const
282 return nTotalPoints_;
285 //- Return total number of faces in decomposed mesh
286 label nTotalFaces() const
291 //- Return total number of cells in decomposed mesh
292 label nTotalCells() const
298 // Processor patch addressing (be careful when not running in parallel)
300 //- Return list of processor patch labels
301 // (size of list = number of processor patches)
302 const labelList& processorPatches() const
304 return processorPatches_;
307 //- Return list of indices into processorPatches_ for each patch.
308 // Index = -1 for non-processor parches.
309 // (size of list = number of patches)
310 const labelList& processorPatchIndices() const
312 return processorPatchIndices_;
315 //- Return processorPatchIndices of the neighbours
316 // processor patches. -1 if not running parallel.
317 const labelList& processorPatchNeighbours() const
319 return processorPatchNeighbours_;
323 // Globally shared point addressing
325 //- Return number of globally shared points
326 label nGlobalPoints() const
328 return nGlobalPoints_;
331 //- Return indices of local points that are globally shared
332 const labelList& sharedPointLabels() const
334 return sharedPointLabels_;
337 //- Return addressing into the complete globally shared points
339 // Note: It is assumed that a (never constructed) complete
340 // list of globally shared points exists. The set of shared
341 // points on the current processor is a subset of all shared
342 // points. Shared point addressing gives the index in the
343 // list of all globally shared points for each of the locally
345 const labelList& sharedPointAddr() const
347 return sharedPointAddr_;
350 //- Return shared point global labels. Tries to read
351 // 'pointProcAddressing' and returns list or -1 if none
353 const labelList& sharedPointGlobalLabels() const;
355 //- Collect coordinates of shared points on all processors.
356 // (does parallel communication!)
357 // Note: not valid for cyclicParallel since shared cyclic points
358 // are merged into single global point. (use geometricSharedPoints
360 pointField sharedPoints() const;
362 //- Like sharedPoints but keeps cyclic points separate.
363 // (does geometric merging; uses matchTol_*bb as merging tolerance)
364 // Use sharedPoints() instead.
365 pointField geometricSharedPoints() const;
369 // Globally shared edge addressing
371 //- Return number of globally shared edges. Demand-driven
372 // calculation so call needs to be synchronous among processors!
373 label nGlobalEdges() const;
375 //- Return indices of local edges that are globally shared.
377 // calculation so call needs to be synchronous among processors!
378 const labelList& sharedEdgeLabels() const;
380 //- Return addressing into the complete globally shared edge
381 // list. The set of shared
382 // edges on the current processor is a subset of all shared
383 // edges. Shared edge addressing gives the index in the
384 // list of all globally shared edges for each of the locally
387 // calculation so call needs to be synchronous among processors!
388 const labelList& sharedEdgeAddr() const;
393 //- Update for moving points.
394 void movePoints(const pointField& newPoints);
396 //- Change global mesh data given a topological change. Does a
397 // full parallel analysis to determine shared points and
409 friend Ostream& operator<<(Ostream&, const globalMeshData&);
413 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
415 } // End namespace Foam
417 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
421 // ************************************************************************* //