FreeFOAM The Cross-Platform CFD Toolkit
parMetisDecomp.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::parMetisDecomp
26 
27 Description
28 
29 SourceFiles
30  parMetisDecomp.C
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef parMetisDecomp_H
35 #define parMetisDecomp_H
36 
38 
39 namespace Foam
40 {
41 
42 /*---------------------------------------------------------------------------*\
43  Class parMetisDecomp Declaration
44 \*---------------------------------------------------------------------------*/
45 
46 class parMetisDecomp
47 :
48  public decompositionMethod
49 {
50  // Private data
51 
52  const polyMesh& mesh_;
53 
54 
55  // Private Member Functions
56 
57  //- Insert list in front of list.
58  template<class Type>
59  static void prepend(const UList<Type>&, List<Type>&);
60  //- Insert list at end of list.
61  template<class Type>
62  static void append(const UList<Type>&, List<Type>&);
63 
64  label decompose
65  (
66  Field<int>& xadj,
67  Field<int>& adjncy,
68  const pointField& cellCentres,
69  Field<int>& cellWeights,
70  Field<int>& faceWeights,
71  const List<int>& options,
72 
73  List<int>& finalDecomp
74  );
75 
76 
77  //- Disallow default bitwise copy construct and assignment
78  void operator=(const parMetisDecomp&);
79  parMetisDecomp(const parMetisDecomp&);
80 
81 
82 public:
83 
84  //- Runtime type information
85  TypeName("parMetis");
86 
87 
88  // Constructors
89 
90  //- Construct given the decomposition dictionary and mesh
91  parMetisDecomp
92  (
93  const dictionary& decompositionDict,
94  const polyMesh& mesh
95  );
96 
97 
98  // Destructor
99 
100  ~parMetisDecomp()
101  {}
102 
103 
104  // Member Functions
105 
106  //- parMetis handles Foam processor boundaries
107  virtual bool parallelAware() const
108  {
109  return true;
110  }
111 
112  //- Return for every coordinate the wanted processor number. Use the
113  // mesh connectivity (if needed)
114  // Weights get normalised so the minimum value is 1 before truncation
115  // to an integer so the weights should be multiples of the minimum
116  // value. The overall sum of weights might otherwise overflow.
117  virtual labelList decompose
118  (
119  const pointField& points,
120  const scalarField& pointWeights
121  );
122 
123  //- Return for every coordinate the wanted processor number. Gets
124  // passed agglomeration map (from fine to coarse cells) and coarse cell
125  // location. Can be overridden by decomposers that provide this
126  // functionality natively.
127  // See note on weights above.
128  virtual labelList decompose
129  (
130  const labelList& cellToRegion,
131  const pointField& regionPoints,
132  const scalarField& regionWeights
133  );
134 
135  //- Same but with uniform weights
136  virtual labelList decompose
137  (
138  const labelList& cellToRegion,
139  const pointField& regionPoints
140  )
141  {
142  return decompose
143  (
144  cellToRegion,
145  regionPoints,
146  scalarField(regionPoints.size(), 1.0)
147  );
148  }
149 
150  //- Return for every coordinate the wanted processor number. Explicitly
151  // provided mesh connectivity.
152  // The connectivity is equal to mesh.cellCells() except for
153  // - in parallel the cell numbers are global cell numbers (starting
154  // from 0 at processor0 and then incrementing all through the
155  // processors)
156  // - the connections are across coupled patches
157  // See note on weights above.
158  virtual labelList decompose
159  (
160  const labelListList& globalCellCells,
161  const pointField& cc,
162  const scalarField& cWeights
163  );
164 
165  //- Helper to convert mesh connectivity into distributed CSR
166  static void calcMetisDistributedCSR
167  (
168  const polyMesh&,
169  List<int>& adjncy,
170  List<int>& xadj
171  );
172 };
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace Foam
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #ifdef NoRepository
183 #endif
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 #endif
188 
189 // ************************ vim: set sw=4 sts=4 et: ************************ //