![]() |
|
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 globalPoints 00027 00028 Description 00029 Calculates points shared by more than two processor patches or cyclic 00030 patches. Is used in parallelInfo. (this info is needed for point-edge 00031 communication where you do all but these shared points with patch to 00032 patch communication but need to do a reduce on these shared points) 00033 00034 Works purely topological and using local communication only. 00035 Needs: 00036 - domain to be one single domain (i.e. all faces can be reached through 00037 face-cell walk). 00038 - patch face ordering to be ok 00039 - f[0] ordering on patch faces to be ok. 00040 00041 Works by constructing equivalence lists for all the points on processor 00042 patches. These list are procPointList and give processor and meshPoint 00043 label on that processor. 00044 E.g. 00045 ((7 93)(4 731)(3 114)) 00046 00047 means point 93 on proc7 is connected to point 731 on proc4 and 114 on proc3. 00048 It then gets the lowest numbered processor (the 'master') to request a 00049 sharedPoint label from processor0 and it redistributes this label back to 00050 the other processors in the equivalence list. 00051 00052 Algorithm: 00053 - get meshPoints of all my points on processor patches and initialize 00054 equivalence lists to this. 00055 loop 00056 - send to all neighbours in relative form: 00057 - patchFace 00058 - index in face 00059 - receive and convert into meshPoints. Add to to my equivalence lists. 00060 - mark meshPoints for which information changed. 00061 - send data for these meshPoints again 00062 endloop until nothing changes 00063 00064 At this point one will have complete point-point connectivity for all 00065 points on processor patches. Now 00066 00067 - remove point equivalences of size 2. These are just normal points 00068 shared between two neighbouring procPatches. 00069 - collect on each processor points for which it is the master 00070 - request number of sharedPointLabels from the Pstream::master. 00071 00072 This information gets redistributed to all processors in a similar way 00073 as that in which the equivalence lists were collected: 00074 00075 - initialize the indices of shared points I am the master for 00076 loop 00077 - send my known sharedPoints + meshPoints to all neighbours 00078 - receive from all neighbour. Find which meshPoint on my processor 00079 the sharedpoint is connected to 00080 - mark indices for which information has changed 00081 endloop until nothing changes. 00082 00083 00084 SourceFiles 00085 globalPoints.C 00086 00087 \*---------------------------------------------------------------------------*/ 00088 00089 #ifndef globalPoints_H 00090 #define globalPoints_H 00091 00092 #include "DynamicList.H" 00093 #include "Map.H" 00094 #include "labelList.H" 00095 #include "FixedList.H" 00096 #include "primitivePatch.H" 00097 #include "className.H" 00098 #include "edgeList.H" 00099 00100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00101 00102 namespace Foam 00103 { 00104 00105 // Class forward declarations 00106 class polyMesh; 00107 class polyBoundaryMesh; 00108 class cyclicPolyPatch; 00109 00110 /*---------------------------------------------------------------------------*\ 00111 Class globalPoints Declaration 00112 \*---------------------------------------------------------------------------*/ 00113 00114 class globalPoints 00115 { 00116 // Private classes 00117 00118 //- Define procPointList as holding a list of meshPoint/processor labels 00119 typedef FixedList<label, 2> procPoint; 00120 typedef List<procPoint> procPointList; 00121 00122 // Private data 00123 00124 //- Mesh reference 00125 const polyMesh& mesh_; 00126 00127 //- Sum of points on processor patches (unfiltered, point on 2 patches 00128 // counts as 2) 00129 const label nPatchPoints_; 00130 00131 //- All points on boundaries and their corresponding connected points 00132 // on other processors. 00133 DynamicList<procPointList> procPoints_; 00134 00135 //- Map from mesh point to index in procPoints 00136 Map<label> meshToProcPoint_; 00137 00138 //- Shared points used by this processor (= global point number) 00139 labelList sharedPointAddr_; 00140 00141 //- My meshpoints corresponding to the shared points 00142 labelList sharedPointLabels_; 00143 00144 //- Total number of shared points. 00145 label nGlobalPoints_; 00146 00147 00148 // Private Member Functions 00149 00150 //- Count all points on processorPatches. Is all points for which 00151 // information is collected. 00152 static label countPatchPoints(const polyBoundaryMesh&); 00153 00154 //- Add information about patchPointI in relative indices to send 00155 // buffers (patchFaces, indexInFace etc.) 00156 static void addToSend 00157 ( 00158 const primitivePatch&, 00159 const label patchPointI, 00160 const procPointList&, 00161 DynamicList<label>& patchFaces, 00162 DynamicList<label>& indexInFace, 00163 DynamicList<procPointList>& allInfo 00164 ); 00165 00166 //- Merge info from neighbour into my data 00167 static bool mergeInfo 00168 ( 00169 const procPointList& nbrInfo, 00170 procPointList& myInfo 00171 ); 00172 00173 //- Store (and merge) info for meshPointI 00174 bool storeInfo(const procPointList& nbrInfo, const label meshPointI); 00175 00176 //- Initialize procPoints_ to my patch points. allPoints = true: 00177 // seed with all patch points, = false: only boundaryPoints(). 00178 void initOwnPoints(const bool allPoints, labelHashSet& changedPoints); 00179 00180 //- Send subset of procPoints to neighbours 00181 void sendPatchPoints(const labelHashSet& changedPoints) const; 00182 00183 //- Receive neighbour points and merge into my procPoints. 00184 void receivePatchPoints(labelHashSet& changedPoints); 00185 00186 //- Remove entries of size 2 where meshPoint is in provided Map. 00187 // Used to remove normal face-face connected points. 00188 void remove(const Map<label>&); 00189 00190 //- Get indices of point for which I am master (lowest numbered proc) 00191 labelList getMasterPoints() const; 00192 00193 //- Send subset of shared points to neighbours 00194 void sendSharedPoints(const labelList& changedIndices) const; 00195 00196 //- Receive shared points and update subset. 00197 void receiveSharedPoints(labelList& changedIndices); 00198 00199 00200 //- Should move into cyclicPolyPatch but some ordering problem 00201 // keeps on giving problems. 00202 static edgeList coupledPoints(const cyclicPolyPatch&); 00203 00204 //- Disallow default bitwise copy construct 00205 globalPoints(const globalPoints&); 00206 00207 //- Disallow default bitwise assignment 00208 void operator=(const globalPoints&); 00209 00210 00211 public: 00212 00213 //- Declare name of the class and it's debug switch 00214 ClassName("globalPoints"); 00215 00216 00217 // Constructors 00218 00219 //- Construct from mesh 00220 globalPoints(const polyMesh& mesh); 00221 00222 00223 // Member Functions 00224 00225 // Access 00226 00227 label nPatchPoints() const 00228 { 00229 return nPatchPoints_; 00230 } 00231 00232 const Map<label>& meshToProcPoint() const 00233 { 00234 return meshToProcPoint_; 00235 } 00236 00237 //- shared points used by this processor (= global point number) 00238 const labelList& sharedPointAddr() const 00239 { 00240 return sharedPointAddr_; 00241 } 00242 00243 //- my meshpoints corresponding to the shared points 00244 const labelList& sharedPointLabels() const 00245 { 00246 return sharedPointLabels_; 00247 } 00248 00249 label nGlobalPoints() const 00250 { 00251 return nGlobalPoints_; 00252 } 00253 00254 }; 00255 00256 00257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00258 00259 } // End namespace Foam 00260 00261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00262 00263 #endif 00264 00265 // ************************************************************************* //