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

scotchDecomp.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::scotchDecomp
00026 
00027 Description
00028     Scotch domain decomposition
00029 
00030 SourceFiles
00031     scotchDecomp.C
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef scotchDecomp_H
00036 #define scotchDecomp_H
00037 
00038 #include <decompositionMethods/decompositionMethod.H>
00039 
00040 namespace Foam
00041 {
00042 
00043 /*---------------------------------------------------------------------------*\
00044                            Class scotchDecomp Declaration
00045 \*---------------------------------------------------------------------------*/
00046 
00047 class scotchDecomp
00048 :
00049     public decompositionMethod
00050 {
00051     // Private data
00052 
00053         const polyMesh& mesh_;
00054 
00055 
00056     // Private Member Functions
00057 
00058         //- Check and print error message
00059         static void check(const int, const char*);
00060 
00061         label decompose
00062         (
00063             const List<int>& adjncy,
00064             const List<int>& xadj,
00065             const scalarField& cWeights,
00066             List<int>& finalDecomp
00067         );
00068 
00069         //- Disallow default bitwise copy construct and assignment
00070         void operator=(const scotchDecomp&);
00071         scotchDecomp(const scotchDecomp&);
00072 
00073 
00074 public:
00075 
00076     //- Runtime type information
00077     TypeName("scotch");
00078 
00079 
00080     // Constructors
00081 
00082         //- Construct given the decomposition dictionary and mesh
00083         scotchDecomp
00084         (
00085             const dictionary& decompositionDict,
00086             const polyMesh& mesh
00087         );
00088 
00089 
00090     // Destructor
00091 
00092         virtual ~scotchDecomp()
00093         {}
00094 
00095 
00096     // Member Functions
00097 
00098         virtual bool parallelAware() const
00099         {
00100             // Metis does not know about proc boundaries
00101             return false;
00102         }
00103 
00104         //- Return for every coordinate the wanted processor number. Use the
00105         //  mesh connectivity (if needed)
00106         //  Weights get normalised so the minimum value is 1 before truncation
00107         //  to an integer so the weights should be multiples of the minimum
00108         //  value. The overall sum of weights might otherwise overflow.
00109         virtual labelList decompose
00110         (
00111             const pointField& points,
00112             const scalarField& pointWeights
00113         );
00114 
00115         //- Return for every coordinate the wanted processor number. Gets
00116         //  passed agglomeration map (from fine to coarse cells) and coarse cell
00117         //  location. Can be overridden by decomposers that provide this
00118         //  functionality natively.
00119         //  See note on weights above.
00120         virtual labelList decompose
00121         (
00122             const labelList& agglom,
00123             const pointField& regionPoints,
00124             const scalarField& regionWeights
00125         );
00126 
00127         //- Same but with uniform weights
00128         virtual labelList decompose
00129         (
00130             const labelList& agglom,
00131             const pointField& regionPoints
00132         )
00133         {
00134             return decompose
00135             (
00136                 agglom,
00137                 regionPoints,
00138                 scalarField(regionPoints.size(), 1.0)
00139             );
00140         }
00141 
00142         //- Return for every coordinate the wanted processor number. Explicitly
00143         //  provided mesh connectivity.
00144         //  The connectivity is equal to mesh.cellCells() except for
00145         //  - in parallel the cell numbers are global cell numbers (starting
00146         //    from 0 at processor0 and then incrementing all through the
00147         //    processors)
00148         //  - the connections are across coupled patches
00149         //  See note on weights above.
00150         virtual labelList decompose
00151         (
00152             const labelListList& globalCellCells,
00153             const pointField& cc,
00154             const scalarField& cWeights
00155         );
00156 
00157 
00158         //- Helper to convert local connectivity (supplied as owner,neighbour)
00159         //  into CSR (Metis,scotch) storage. Does cyclics but not processor
00160         //  patches
00161         static void calcCSR
00162         (
00163             const polyMesh& mesh,
00164             List<int>& adjncy,
00165             List<int>& xadj
00166         );
00167 
00168         //- Helper to convert connectivity (supplied as cellcells) into
00169         //  CSR (Metis,scotch) storage
00170         static void calcCSR
00171         (
00172             const labelListList& globalCellCells,
00173             List<int>& adjncy,
00174             List<int>& xadj
00175         );
00176 };
00177 
00178 
00179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00180 
00181 } // End namespace Foam
00182 
00183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00184 
00185 #endif
00186 
00187 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines