ptscotchDecomp.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::ptscotchDecomp
29 
30 Description
31  PTScotch domain decomposition.
32 
33  For the main details about how to define the strategies, see scotchDecomp.
34 
35  Coefficients dictionary: \a scotchCoeffs, \a coeffs.
36 
37  Nonetheless, when decomposing in parallel, using <tt>writeGraph=true</tt>
38  will write out \c .dgr files for debugging. For example, use these files
39  with \c dgpart as follows:
40 
41  \verbatim
42  mpirun -np 4 dgpart 2 'region0_%r.dgr'
43  \endverbatim
44 
45  where:
46  - %r gets replaced by current processor rank
47  - it will decompose into 2 domains
48 
49 See also
50  Foam::scotchDecomp
51 
52 SourceFiles
53  ptscotchDecomp.C
54 
55 \*---------------------------------------------------------------------------*/
56 
57 #ifndef ptscotchDecomp_H
58 #define ptscotchDecomp_H
59 
60 #include "decompositionMethod.H"
61 
62 namespace Foam
63 {
64 
65 /*---------------------------------------------------------------------------*\
66  Class ptscotchDecomp Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class ptscotchDecomp
70 :
71  public decompositionMethod
72 {
73  // Private data
74 
75  //- Original coefficients for this method
76  dictionary coeffsDict_;
77 
78  //- Output path and name for optional grf file.
79  mutable fileName graphPath_;
80 
81 
82  // Private Member Functions
83 
84  //- Set graph path and name (mutable)
85  void graphPath(const polyMesh& mesh) const;
86 
87  //- Check and print error message
88  static void check(const int, const char*);
89 
90  //- Decompose. Handles size 0 arrays
91  label decompose
92  (
93  const labelList& adjncy,
94  const labelList& xadj,
95  const List<scalar>& cWeights,
96  labelList& finalDecomp
97  ) const;
98 
99  //- Low level decompose
100  label decompose
101  (
102  const label adjncySize,
103  const label adjncy[],
104  const label xadjSize,
105  const label xadj[],
106  const List<scalar>& cWeights,
107  labelList& finalDecomp
108  ) const;
109 
110 
111  //- No copy construct
112  ptscotchDecomp(const ptscotchDecomp&) = delete;
113 
114  //- No copy assignment
115  void operator=(const ptscotchDecomp&) = delete;
116 
117 
118 public:
119 
120  //- Runtime type information
121  TypeName("ptscotch");
122 
123 
124  // Constructors
125 
126  //- Construct given the decomposition dictionary
127  ptscotchDecomp(const dictionary& decompDict);
128 
129 
130  //- Construct given the decomposition dictionary and region name
131  ptscotchDecomp(const dictionary& decompDict, const word& regionName);
132 
133 
134  //- Destructor
135  virtual ~ptscotchDecomp() = default;
136 
137 
138  // Member Functions
139 
140  virtual bool parallelAware() const
141  {
142  return true;
143  }
144 
145  //- Inherit decompose from decompositionMethod
147 
148  //- Return for every coordinate the wanted processor number.
149  // Use the mesh connectivity (if needed).
150  // See note on weights in scotchDecomp.H
151  virtual labelList decompose
152  (
153  const polyMesh& mesh,
154  const pointField& points,
155  const scalarField& pointWeights
156  ) const;
157 
158  //- Return for every coordinate the wanted processor number.
159  // Gets passed agglomeration map (from fine to coarse cells) and
160  // coarse cell location.
161  // Can be overridden by decomposers that provide this
162  // functionality natively. See note on weights in scotchDecomp.H
163  virtual labelList decompose
164  (
165  const polyMesh& mesh,
166  const labelList& agglom,
167  const pointField& regionPoints,
168  const scalarField& regionWeights
169  ) const;
170 
171  //- Return for every coordinate the wanted processor number.
172  // Explicitly provided mesh connectivity.
173  // The connectivity is equal to mesh.cellCells() except for
174  // - in parallel the cell numbers are global cell numbers (starting
175  // from 0 at processor0 and then incrementing all through the
176  // processors)
177  // - the connections are across coupled patches
178  // See note on weights in scotchDecomp.H
179  virtual labelList decompose
180  (
181  const labelListList& globalCellCells,
182  const pointField& cc,
183  const scalarField& cWeights
184  ) const;
185 };
186 
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 } // End namespace Foam
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 #endif
195 
196 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
decompositionMethod.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::Field< vector >
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::decompositionMethod
Abstract base class for domain decomposition.
Definition: decompositionMethod.H:51
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::ptscotchDecomp::parallelAware
virtual bool parallelAware() const
Is method parallel aware?
Definition: ptscotchDecomp.H:139
Foam::List< label >
Foam::decompositionMethod::decompose
virtual labelList decompose(const pointField &points, const scalarField &pointWeights) const
Return for every coordinate the wanted processor number.
Definition: decompositionMethod.H:244
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::ptscotchDecomp
PTScotch domain decomposition.
Definition: ptscotchDecomp.H:68
Foam::ptscotchDecomp::~ptscotchDecomp
virtual ~ptscotchDecomp()=default
Destructor.
Foam::ptscotchDecomp::TypeName
TypeName("ptscotch")
Runtime type information.