FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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