metisLikeDecomp.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) 2017-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::metisLikeDecomp
28 
29 Description
30  Domain decomposition using METIS-like data structures.
31 
32  When run in parallel will collect the entire graph on to the master,
33  decompose and send back.
34 
35 SourceFiles
36  metisLikeDecomp.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef Foam_metisLikeDecomp_H
41 #define Foam_metisLikeDecomp_H
42 
43 #include "decompositionMethod.H"
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class metisLikeDecomp Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class metisLikeDecomp
53 :
54  public decompositionMethod
55 {
56 protected:
57 
58  // Protected Data
59 
60  //- Coefficients for all derived methods
61  const dictionary& coeffsDict_;
62 
63 
64  // Protected Member Functions
65 
66  //- Serial and/or collect/distribute for parallel operation
67  virtual label decomposeGeneral
68  (
69  const labelList& adjncy,
70  const labelList& xadj,
71  const List<scalar>& cellWeights,
72  labelList& decomp
73  ) const;
74 
75  //- Decomposition with metis-like parameters
76  virtual label decomposeSerial
77  (
78  const labelList& adjncy,
79  const labelList& xadj,
80  const List<scalar>& cellWeights,
81  labelList& decomp
82  ) const = 0;
83 
84 
85  //- No copy construct
86  metisLikeDecomp(const metisLikeDecomp&) = delete;
87 
88  //- No copy assignment
89  void operator=(const metisLikeDecomp&) = delete;
90 
91 
92  // Constructors
93 
94  //- Construct with number of domains (no coefficients or constraints)
95  explicit metisLikeDecomp(const label numDomains);
96 
97  //- Construct for derived type name and decomposition dictionary.
99  (
100  const word& derivedType,
101  const dictionary& decompDict,
102  int select = selectionType::NULL_DICT
103  )
104  :
105  metisLikeDecomp(derivedType, decompDict, "", select)
106  {}
107 
108  //- Construct for derived type name, decomposition dictionary
109  //- and (optional) region name
110  // The default search for the coefficients will return dictionary::null
111  // on failure. This avoids a name clash of a metis "method" with the
112  // top level.
114  (
115  const word& derivedType,
116  const dictionary& decompDict,
117  const word& regionName,
118  int select = selectionType::NULL_DICT
119  );
120 
121 public:
122 
123  //- Destructor
124  virtual ~metisLikeDecomp() = default;
125 
126 
127  // Member Functions
128 
129  //- Inherit decompose from decompositionMethod
131 
132  //- Return for every coordinate the wanted processor number.
133  // Uses the mesh connectivity (if needed).
134  // Weights get normalised so the minimum value is 1 before truncation
135  // to an integer so the weights should be multiples of the minimum
136  // value. The overall sum of weights might otherwise overflow.
137  virtual labelList decompose
138  (
139  const polyMesh& mesh,
141  const scalarField& pointWeights = scalarField::null()
142  ) const;
143 
144  //- Return for every coordinate the wanted processor number.
145  // Gets passed agglomeration map (from fine to coarse cells) and coarse
146  // cell location. Can be overridden by decomposers that provide this
147  // functionality natively.
148  // See note on weights above.
149  virtual labelList decompose
150  (
151  const polyMesh& mesh,
152  const labelList& agglom,
153  const pointField& agglomPoints,
154  const scalarField& agglomWeights = scalarField::null()
155  ) const;
156 
157  //- Return for every coordinate the wanted processor number.
158  // Explicitly provided mesh connectivity.
159  // The connectivity is equal to mesh.cellCells() except for
160  // - in parallel the cell numbers are global cell numbers (starting
161  // from 0 at processor0 and then incrementing all through the
162  // processors)
163  // - the connections are across coupled patches
164  // See note on weights above.
165  virtual labelList decompose
166  (
167  const CompactListList<label>& globalCellCells,
168  const pointField& cellCentres = pointField::null(),
169  const scalarField& cellWeights = scalarField::null()
170  ) const;
171 
172  //- Return for every coordinate the wanted processor number.
173  // Explicitly provided mesh connectivity.
174  // The connectivity is equal to mesh.cellCells() except for
175  // - in parallel the cell numbers are global cell numbers (starting
176  // from 0 at processor0 and then incrementing all through the
177  // processors)
178  // - the connections are across coupled patches
179  // See note on weights above.
180  virtual labelList decompose
181  (
182  const labelListList& globalCellCells,
183  const pointField& cellCentres = pointField::null(),
184  const scalarField& cellWeights = scalarField::null()
185  ) const;
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #endif
196 
197 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
Definition: BitOps.C:134
virtual ~metisLikeDecomp()=default
Destructor.
const dictionary & coeffsDict_
Coefficients for all derived methods.
void operator=(const metisLikeDecomp &)=delete
No copy assignment.
dynamicFvMesh & mesh
const pointField & points
A class for handling words, derived from Foam::string.
Definition: word.H:63
metisLikeDecomp(const metisLikeDecomp &)=delete
No copy construct.
Abstract base class for domain decomposition.
Domain decomposition using METIS-like data structures.
virtual labelList decompose(const polyMesh &mesh, const pointField &points=pointField::null(), const scalarField &pointWeights=scalarField::null()) const
Return for every coordinate the wanted processor number.
A packed storage of objects of type <T> using an offset table for access.
virtual label decomposeSerial(const labelList &adjncy, const labelList &xadj, const List< scalar > &cellWeights, labelList &decomp) const =0
Decomposition with metis-like parameters.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
static const Field< vector > & null()
Return nullObject reference Field.
Definition: FieldI.H:24
virtual label decomposeGeneral(const labelList &adjncy, const labelList &xadj, const List< scalar > &cellWeights, labelList &decomp) const
Serial and/or collect/distribute for parallel operation.
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...