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