FreeFOAM The Cross-Platform CFD Toolkit
scotchDecomp.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::scotchDecomp
26 
27 Description
28  Scotch domain decomposition
29 
30 SourceFiles
31  scotchDecomp.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef scotchDecomp_H
36 #define scotchDecomp_H
37 
39 
40 namespace Foam
41 {
42 
43 /*---------------------------------------------------------------------------*\
44  Class scotchDecomp Declaration
45 \*---------------------------------------------------------------------------*/
46 
48 :
49  public decompositionMethod
50 {
51  // Private data
52 
53  const polyMesh& mesh_;
54 
55 
56  // Private Member Functions
57 
58  //- Check and print error message
59  static void check(const int, const char*);
60 
61  label decompose
62  (
63  const List<int>& adjncy,
64  const List<int>& xadj,
65  const scalarField& cWeights,
66  List<int>& finalDecomp
67  );
68 
69  //- Disallow default bitwise copy construct and assignment
70  void operator=(const scotchDecomp&);
71  scotchDecomp(const scotchDecomp&);
72 
73 
74 public:
75 
76  //- Runtime type information
77  TypeName("scotch");
78 
79 
80  // Constructors
81 
82  //- Construct given the decomposition dictionary and mesh
84  (
85  const dictionary& decompositionDict,
86  const polyMesh& mesh
87  );
88 
89 
90  // Destructor
91 
92  virtual ~scotchDecomp()
93  {}
94 
95 
96  // Member Functions
97 
98  virtual bool parallelAware() const
99  {
100  // Metis does not know about proc boundaries
101  return false;
102  }
103 
104  //- Return for every coordinate the wanted processor number. Use the
105  // mesh connectivity (if needed)
106  // Weights get normalised so the minimum value is 1 before truncation
107  // to an integer so the weights should be multiples of the minimum
108  // value. The overall sum of weights might otherwise overflow.
109  virtual labelList decompose
110  (
111  const pointField& points,
112  const scalarField& pointWeights
113  );
114 
115  //- Return for every coordinate the wanted processor number. Gets
116  // passed agglomeration map (from fine to coarse cells) and coarse cell
117  // location. Can be overridden by decomposers that provide this
118  // functionality natively.
119  // See note on weights above.
120  virtual labelList decompose
121  (
122  const labelList& agglom,
123  const pointField& regionPoints,
124  const scalarField& regionWeights
125  );
126 
127  //- Same but with uniform weights
128  virtual labelList decompose
129  (
130  const labelList& agglom,
131  const pointField& regionPoints
132  )
133  {
134  return decompose
135  (
136  agglom,
137  regionPoints,
138  scalarField(regionPoints.size(), 1.0)
139  );
140  }
141 
142  //- Return for every coordinate the wanted processor number. Explicitly
143  // provided mesh connectivity.
144  // The connectivity is equal to mesh.cellCells() except for
145  // - in parallel the cell numbers are global cell numbers (starting
146  // from 0 at processor0 and then incrementing all through the
147  // processors)
148  // - the connections are across coupled patches
149  // See note on weights above.
150  virtual labelList decompose
151  (
152  const labelListList& globalCellCells,
153  const pointField& cc,
154  const scalarField& cWeights
155  );
156 
157 
158  //- Helper to convert local connectivity (supplied as owner,neighbour)
159  // into CSR (Metis,scotch) storage. Does cyclics but not processor
160  // patches
161  static void calcCSR
162  (
163  const polyMesh& mesh,
164  List<int>& adjncy,
165  List<int>& xadj
166  );
167 
168  //- Helper to convert connectivity (supplied as cellcells) into
169  // CSR (Metis,scotch) storage
170  static void calcCSR
171  (
172  const labelListList& globalCellCells,
173  List<int>& adjncy,
174  List<int>& xadj
175  );
176 };
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #endif
186 
187 // ************************ vim: set sw=4 sts=4 et: ************************ //