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-2023 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 Foam_ptscotchDecomp_H
58 #define Foam_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  //- Decompose. Handles size 0 arrays
85  label decompose
86  (
87  const labelList& adjncy,
88  const labelList& xadj,
89  const List<scalar>& cWeights,
90  labelList& decomp
91  ) const;
92 
93 public:
94 
95  // Generated Methods
96 
97  //- No copy construct
98  ptscotchDecomp(const ptscotchDecomp&) = delete;
99 
100  //- No copy assignment
101  void operator=(const ptscotchDecomp&) = delete;
102 
103 
104  //- Runtime type information
105  TypeName("ptscotch");
106 
107 
108  // Constructors
109 
110  //- Construct with number of domains (no coefficients or constraints)
111  explicit ptscotchDecomp(const label numDomains);
112 
113  //- Construct given decomposition dictionary and optional region name
114  explicit ptscotchDecomp
115  (
116  const dictionary& decompDict,
117  const word& regionName = ""
118  );
119 
120 
121  //- Destructor
122  virtual ~ptscotchDecomp() = default;
123 
124 
125  // Member Functions
126 
127  //- Knows about coupled boundaries
128  virtual bool parallelAware() const
129  {
130  return true;
131  }
132 
133  //- Inherit decompose from decompositionMethod
135 
136  //- Return for every coordinate the wanted processor number.
137  // Use the mesh connectivity (if needed).
138  // See note on weights in scotchDecomp.H
139  virtual labelList decompose
140  (
141  const polyMesh& mesh,
143  const scalarField& pointWeights = scalarField::null()
144  ) const;
145 
146  //- Return for every coordinate the wanted processor number.
147  // Gets passed agglomeration map (from fine to coarse cells) and
148  // coarse cell location.
149  // Can be overridden by decomposers that provide this
150  // functionality natively. See note on weights in scotchDecomp.H
151  virtual labelList decompose
152  (
153  const polyMesh& mesh,
154  const labelList& agglom,
155  const pointField& agglomPoints,
156  const scalarField& agglomWeights = scalarField::null()
157  ) const;
158 
159  //- Return for every coordinate the wanted processor number.
160  virtual labelList decompose
161  (
162  const CompactListList<label>& globalCellCells,
163  const pointField& cc = pointField::null(),
164  const scalarField& cWeights = scalarField::null()
165  ) const;
166 
167  //- Return for every coordinate the wanted processor number.
168  // Explicitly provided mesh connectivity.
169  // The connectivity is equal to mesh.cellCells() except for
170  // - in parallel the cell numbers are global cell numbers (starting
171  // from 0 at processor0 and then incrementing all through the
172  // processors)
173  // - the connections are across coupled patches
174  // See note on weights in scotchDecomp.H
175  virtual labelList decompose
176  (
177  const labelListList& globalCellCells,
178  const pointField& cc = pointField::null(),
179  const scalarField& cWeights = scalarField::null()
180  ) const;
181 };
182 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 } // End namespace Foam
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 #endif
191 
192 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
ptscotchDecomp(const ptscotchDecomp &)=delete
No copy construct.
dynamicFvMesh & mesh
const pointField & points
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual ~ptscotchDecomp()=default
Destructor.
Abstract base class for domain decomposition.
virtual bool parallelAware() const
Knows about coupled boundaries.
A packed storage of objects of type <T> using an offset table for access.
PTScotch domain decomposition.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
static const Field< vector > & null()
Return nullObject reference Field.
Definition: FieldI.H:24
TypeName("ptscotch")
Runtime type information.
void operator=(const ptscotchDecomp &)=delete
No copy assignment.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights=scalarField::null()) const
Return the wanted processor number for every coordinate, using uniform or specified point weights...