![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 parallelInfo 00027 00028 Description 00029 Various mesh related information for a parallel run. Upon construction 00030 constructs all info by using parallel communication. 00031 00032 Requires: 00033 - all processor patches to have correct ordering. 00034 - all processorPatches to have their transforms set ('makeTransforms') 00035 00036 The shared point addressing is quite interesting. It gives on each processor 00037 the vertices that cannot be set using a normal swap on processor patches. 00038 These are the vertices that are shared between more than 2 processors. 00039 00040 There is an issue with these shared vertices if they originate from 00041 cyclics (i.e. are now separated processor patches). They will all be 00042 mapped to the same global point (so even though the processor points are 00043 not on the same location) since topologically they are one and the same. 00044 00045 So if you ask for sharedPoints() you get only one of the coordinates of 00046 the topologically shared points. 00047 00048 All the hard work of these shared points is done by the globalPoints class. 00049 00050 Shared edges: similar to shared points gives on all processors the edges 00051 that are shared between more than two patches (i.e. the edges on which 00052 data cannot be synchronized by a straightforward edge data swap). Note 00053 that shared edges will use shared points but not all edges between shared 00054 points need to be shared edges (e.g. there might be an edge connecting 00055 two disconnected regions of shared points). 00056 00057 Currently an edge is considered shared 00058 if it uses two shared points and is used more than once. This is not 00059 correct on processor patches but it only slightly overestimates the number 00060 of shared edges. Doing full analysis of how many patches use the edge 00061 would be too complicated. 00062 00063 Shared edge calculation is demand driven so always make sure to have 00064 your first call to one of the access functions synchronous amongst all 00065 processors! 00066 00067 00068 SourceFiles 00069 parallelInfo.C 00070 parallelInfoMorph.C 00071 00072 \*---------------------------------------------------------------------------*/ 00073 00074 #ifndef parallelInfo_H 00075 #define parallelInfo_H 00076 00077 #include "polyMesh.H" 00078 #include "Switch.H" 00079 #include "processorTopology.H" 00080 #include "labelPair.H" 00081 00082 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00083 00084 namespace Foam 00085 { 00086 00087 /*---------------------------------------------------------------------------*\ 00088 Class parallelInfo Declaration 00089 \*---------------------------------------------------------------------------*/ 00090 00091 class parallelInfo 00092 : 00093 public processorTopology 00094 { 00095 00096 // Private class 00097 00098 // To combineReduce a pointField. Just appends all lists. 00099 template <class T> 00100 class plusEqOp 00101 { 00102 00103 public: 00104 00105 void operator()(T& x, const T& y) const 00106 { 00107 label n = x.size(); 00108 00109 x.setSize(x.size() + y.size()); 00110 00111 forAll(y, i) 00112 { 00113 x[n++] = y[i]; 00114 } 00115 } 00116 }; 00117 00118 00119 typedef List<labelPair> labelPairList; 00120 00121 00122 // Private data 00123 00124 //- Reference to mesh 00125 const polyMesh& mesh_; 00126 00127 // Data related to the complete mesh 00128 00129 //- Are there cyclic-parallel faces 00130 // (interpolation/FEM problem in foam2.2). 00131 Switch cyclicParallel_; 00132 00133 //- Bounding box of complete mesh 00134 boundBox bb_; 00135 00136 //- Total number of points in the complete mesh 00137 label nTotalPoints_; 00138 00139 //- Total number of faces in the complete mesh 00140 label nTotalFaces_; 00141 00142 //- Total number of cells in the complete mesh 00143 label nTotalCells_; 00144 00145 00146 00147 // Processor patch addressing (be careful if not running in parallel!) 00148 00149 //- List of processor patch labels 00150 // (size of list = number of processor patches) 00151 labelList processorPatches_; 00152 00153 //- List of indices into processorPatches_ for each patch. 00154 // Index = -1 for non-processor patches. 00155 // (size of list = number of patches) 00156 labelList processorPatchIndices_; 00157 00158 //- processorPatchIndices_ of the neighbours processor patches 00159 labelList processorPatchNeighbours_; 00160 00161 00162 // Globally shared point addressing 00163 00164 //- Total number of global points 00165 label nGlobalPoints_; 00166 00167 //- Indices of local points that are globally shared 00168 labelList sharedPointLabels_; 00169 00170 //- Indices of globally shared points in the master list 00171 // This list contains all the shared points in the mesh 00172 labelList sharedPointAddr_; 00173 00174 //- Shared point global labels. 00175 // Global point index for every local shared point. 00176 // Only valid if constructed with this information or if 00177 // pointProcAddressing read. 00178 mutable labelList* sharedPointGlobalLabelsPtr_; 00179 00180 00181 // Globally shared edge addressing. Derived from shared points. 00182 // All demand driven since don't want to construct edges always. 00183 00184 //- Total number of global edges 00185 mutable label nGlobalEdges_; 00186 00187 //- Indices of local edges that are globally shared 00188 mutable labelList* sharedEdgeLabelsPtr_; 00189 00190 //- Indices of globally shared edge in the master list 00191 // This list contains all the shared edges in the mesh 00192 mutable labelList* sharedEdgeAddrPtr_; 00193 00194 00195 // Private Member Functions 00196 00197 //- Set up processor patch addressing 00198 void initProcAddr(); 00199 00200 //- Helper function for shared edge addressing 00201 static void countSharedEdges 00202 ( 00203 const HashTable<labelList, edge, Hash<edge> >& procSharedEdges, 00204 HashTable<label, edge, Hash<edge> >&, 00205 label& 00206 ); 00207 00208 //- Calculate shared edge addressing 00209 void calcSharedEdges() const; 00210 00211 00212 00213 //- Disallow default bitwise copy construct 00214 parallelInfo(const parallelInfo&); 00215 00216 //- Disallow default bitwise assignment 00217 void operator=(const parallelInfo&); 00218 00219 public: 00220 00221 //- Runtime type information 00222 ClassName("parallelInfo"); 00223 00224 00225 // Static data members 00226 00227 //- Geomtric tolerance (fraction of bounding box) 00228 static const Foam::scalar matchTol_; 00229 00230 00231 // Constructors 00232 00233 //- Construct from mesh, derive rest (does parallel communication!) 00234 parallelInfo(const polyMesh& mesh); 00235 00236 //- Old behaviour: read constructor given IOobject and a polyMesh 00237 // reference. Only use this for testing! 00238 parallelInfo(const IOobject& io, const polyMesh& mesh); 00239 00240 //- Construct from components. !To be removed when we trust above 00241 // construct from mesh! 00242 parallelInfo 00243 ( 00244 const polyMesh& mesh, 00245 const bool parallel, 00246 const bool cyclicParallel, 00247 const label nTotalPoints, 00248 const label nTotalFaces, 00249 const label nTotalCells, 00250 const label nGlobalPoints, 00251 const labelList& sharedPointLabels, 00252 const labelList& sharedPointAddr, 00253 const labelList& sharedPointGlobalLabels 00254 ); 00255 00256 00257 // Destructor 00258 00259 ~parallelInfo(); 00260 00261 //- Remove all demand driven data 00262 void clearOut(); 00263 00264 00265 // Member Functions 00266 00267 // Access 00268 00269 //- Return the mesh reference 00270 const polyMesh& mesh() const 00271 { 00272 return mesh_; 00273 } 00274 00275 //- Does the mesh contain processor patches? (also valid when 00276 // not running parallel) 00277 bool parallel() const 00278 { 00279 return processorPatches_.size() > 0; 00280 } 00281 00282 const boundBox& bb() const 00283 { 00284 return bb_; 00285 } 00286 00287 //- Does the mesh contain cyclic parallel faces (only valid when 00288 // running parallel) 00289 bool cyclicParallel() const 00290 { 00291 return cyclicParallel_; 00292 } 00293 00294 //- Return total number of points in decomposed mesh 00295 label nTotalPoints() const 00296 { 00297 return nTotalPoints_; 00298 } 00299 00300 //- Return total number of faces in decomposed mesh 00301 label nTotalFaces() const 00302 { 00303 return nTotalFaces_; 00304 } 00305 00306 //- Return total number of cells in decomposed mesh 00307 label nTotalCells() const 00308 { 00309 return nTotalCells_; 00310 } 00311 00312 00313 // Processor patch addressing (be careful when not running in parallel) 00314 00315 //- Return list of processor patch labels 00316 // (size of list = number of processor patches) 00317 const labelList& processorPatches() const 00318 { 00319 return processorPatches_; 00320 } 00321 00322 //- Return list of indices into processorPatches_ for each patch. 00323 // Index = -1 for non-processor parches. 00324 // (size of list = number of patches) 00325 const labelList& processorPatchIndices() const 00326 { 00327 return processorPatchIndices_; 00328 } 00329 00330 //- Return processorPatchIndices of the neighbours 00331 // processor patches. -1 if not running parallel. 00332 const labelList& processorPatchNeighbours() const 00333 { 00334 return processorPatchNeighbours_; 00335 } 00336 00337 00338 // Globally shared point addressing 00339 00340 //- Return number of globally shared points 00341 label nGlobalPoints() const 00342 { 00343 return nGlobalPoints_; 00344 } 00345 00346 //- Return indices of local points that are globally shared 00347 const labelList& sharedPointLabels() const 00348 { 00349 return sharedPointLabels_; 00350 } 00351 00352 //- Return addressing into the complete globally shared points 00353 // list 00354 // Note: It is assumed that a (never constructed) complete 00355 // list of globally shared points exists. The set of shared 00356 // points on the current processor is a subset of all shared 00357 // points. Shared point addressing gives the index in the 00358 // list of all globally shared points for each of the locally 00359 // shared points. 00360 const labelList& sharedPointAddr() const 00361 { 00362 return sharedPointAddr_; 00363 } 00364 00365 //- Return shared point global labels. Tries to read 00366 // 'pointProcAddressing' and returns list or -1 if none 00367 // available. 00368 const labelList& sharedPointGlobalLabels() const; 00369 00370 //- Collect coordinates of shared points on all processors. 00371 // (does parallel communication!) 00372 // Note: not valid for cyclicParallel since shared cyclic points 00373 // are merged into single global point. (use geometricSharedPoints 00374 // instead) 00375 pointField sharedPoints() const; 00376 00377 //- Like sharedPoints but keeps cyclic points separate. 00378 // (does geometric merging; uses matchTol_*bb as merging tolerance) 00379 // Use sharedPoints() instead. 00380 pointField geometricSharedPoints() const; 00381 00382 00383 00384 // Globally shared edge addressing 00385 00386 //- Return number of globally shared edges. Demand-driven 00387 // calculation so call needs to be synchronous among processors! 00388 label nGlobalEdges() const; 00389 00390 //- Return indices of local edges that are globally shared. 00391 // Demand-driven 00392 // calculation so call needs to be synchronous among processors! 00393 const labelList& sharedEdgeLabels() const; 00394 00395 //- Return addressing into the complete globally shared edge 00396 // list. The set of shared 00397 // edges on the current processor is a subset of all shared 00398 // edges. Shared edge addressing gives the index in the 00399 // list of all globally shared edges for each of the locally 00400 // shared edges. 00401 // Demand-driven 00402 // calculation so call needs to be synchronous among processors! 00403 const labelList& sharedEdgeAddr() const; 00404 00405 00406 // Edit 00407 00408 //- Update for moving points. 00409 void movePoints(const pointField& newPoints); 00410 00411 //- Change global mesh data given a topological change. Does a 00412 // full parallel analysis to determine shared points and 00413 // boundaries. 00414 void updateMesh(); 00415 00416 00417 // Write 00418 00419 bool write() const; 00420 00421 00422 // Ostream Operator 00423 00424 friend Ostream& operator<<(Ostream&, const parallelInfo&); 00425 }; 00426 00427 00428 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00429 00430 } // End namespace Foam 00431 00432 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00433 00434 #endif 00435 00436 // ************************************************************************* //