OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

globalPoints.H

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