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-2021 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 metisLikeDecomp_H
41 #define 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 for derived type name and decomposition dictionary.
96  (
97  const word& derivedType,
98  const dictionary& decompDict,
99  int select = selectionType::NULL_DICT
100  )
101  :
102  metisLikeDecomp(derivedType, decompDict, "", select)
103  {}
104 
105  //- Construct for derived type name, decomposition dictionary
106  //- and (optional) region name
107  // The default search for the coefficients will return dictionary::null
108  // on failure. This avoids a name clash of a metis "method" with the
109  // top level.
111  (
112  const word& derivedType,
113  const dictionary& decompDict,
114  const word& regionName,
115  int select = selectionType::NULL_DICT
116  );
117 
118 public:
119 
120  //- Destructor
121  virtual ~metisLikeDecomp() = default;
122 
123 
124  // Member Functions
125 
126  //- Inherit decompose from decompositionMethod
128 
129  //- Return for every coordinate the wanted processor number.
130  // Uses the mesh connectivity (if needed).
131  // Weights get normalised so the minimum value is 1 before truncation
132  // to an integer so the weights should be multiples of the minimum
133  // value. The overall sum of weights might otherwise overflow.
134  virtual labelList decompose
135  (
136  const polyMesh& mesh,
137  const pointField& points,
138  const scalarField& pointWeights
139  ) const;
140 
141  //- Return for every coordinate the wanted processor number.
142  // Gets passed agglomeration map (from fine to coarse cells) and coarse
143  // cell location. Can be overridden by decomposers that provide this
144  // functionality natively.
145  // See note on weights above.
146  virtual labelList decompose
147  (
148  const polyMesh& mesh,
149  const labelList& agglom,
150  const pointField& regionPoints,
151  const scalarField& regionWeights
152  ) const;
153 
154  //- Return for every coordinate the wanted processor number.
155  // Explicitly provided mesh connectivity.
156  // The connectivity is equal to mesh.cellCells() except for
157  // - in parallel the cell numbers are global cell numbers (starting
158  // from 0 at processor0 and then incrementing all through the
159  // processors)
160  // - the connections are across coupled patches
161  // See note on weights above.
162  virtual labelList decompose
163  (
164  const labelListList& globalCellCells,
165  const pointField& cellCentres,
166  const scalarField& cellWeights
167  ) const;
168 };
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::metisLikeDecomp::decomposeGeneral
virtual label decomposeGeneral(const labelList &adjncy, const labelList &xadj, const List< scalar > &cellWeights, labelList &decomp) const
Serial and/or collect/distribute for parallel operation.
Definition: metisLikeDecomp.C:35
Foam::metisLikeDecomp::coeffsDict_
const dictionary & coeffsDict_
Coefficients for all derived methods.
Definition: metisLikeDecomp.H:60
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::metisLikeDecomp
Domain decomposition using METIS-like data structures.
Definition: metisLikeDecomp.H:51
Foam::metisLikeDecomp::decomposeSerial
virtual label decomposeSerial(const labelList &adjncy, const labelList &xadj, const List< scalar > &cellWeights, labelList &decomp) const =0
Decomposition with metis-like parameters.
Foam::metisLikeDecomp::operator=
void operator=(const metisLikeDecomp &)=delete
No copy assignment.
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
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::metisLikeDecomp::decompose
virtual labelList decompose(const polyMesh &mesh, const pointField &points, const scalarField &pointWeights) const
Return for every coordinate the wanted processor number.
Definition: metisLikeDecomp.C:173
Foam::decompositionMethod::decompose
virtual labelList decompose(const pointField &points, const scalarField &pointWeights) const
Return the wanted processor number for every coordinate.
Definition: decompositionMethod.C:1325
Foam::List< label >
Foam::metisLikeDecomp::metisLikeDecomp
metisLikeDecomp(const metisLikeDecomp &)=delete
No copy construct.
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::metisLikeDecomp::~metisLikeDecomp
virtual ~metisLikeDecomp()=default
Destructor.