decompositionMethod.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
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::decompositionMethod
26 
27 Description
28  Abstract base class for decomposition
29 
30 SourceFiles
31  decompositionMethod.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef decompositionMethod_H
36 #define decompositionMethod_H
37 
38 #include "polyMesh.H"
39 #include "CompactListList.H"
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class decompositionMethod Declaration
47 \*---------------------------------------------------------------------------*/
48 
50 {
51 protected:
52 
53  // Protected data
54 
57 
58  //- Optional constraints
60 
61 
62 public:
63 
64  //- Runtime type information
65  TypeName("decompositionMethod");
66 
67 
68  // Declare run-time constructor selection tables
69 
71  (
72  autoPtr,
74  decomposer,
75  (
76  const dictionary& decompositionDict
77  ),
78  (decompositionDict)
79  );
80 
82  (
83  autoPtr,
85  distributor,
86  (
87  const dictionary& decompositionDict
88  ),
89  (decompositionDict)
90  );
91 
92 
93  // Constructors
94 
95  //- Construct given the decomposition dictionary
96  decompositionMethod(const dictionary& decompositionDict);
97 
98  //- Disallow default bitwise copy construction
100 
101 
102  // Selectors
103 
104  //- Return a reference to the selected decomposition method
106  (
107  const dictionary& decompositionDict
108  );
109 
110  //- Return a reference to the selected decomposition method
112  (
113  const dictionary& decompositionDict
114  );
115 
116 
117  //- Destructor
118  virtual ~decompositionMethod()
119  {}
120 
121 
122  // Member Functions
124  label nDomains() const
125  {
126  return nProcessors_;
127  }
128 
129  //- Read and return the decomposeParDict
130  static dictionary decomposeParDict(const Time& time);
131 
132 
133  // No topology (implemented by geometric decomposers)
134 
135  //- Return for every coordinate the wanted processor number.
137  (
138  const pointField& points,
139  const scalarField& pointWeights
140  )
141  {
143  return labelList(0);
144  }
145 
146  //- Like decompose but with uniform weights on the points
147  virtual labelList decompose(const pointField&)
148  {
150  return labelList(0);
151  }
152 
153 
154  // Topology provided by mesh
155 
156  //- Return for every coordinate the wanted processor number. Use the
157  // mesh connectivity (if needed)
158  virtual labelList decompose
159  (
160  const polyMesh& mesh,
161  const pointField& points,
162  const scalarField& pointWeights
163  ) = 0;
164 
165  //- Like decompose but with uniform weights on the points
166  virtual labelList decompose(const polyMesh&, const pointField&);
167 
168  //- Return for every coordinate the wanted processor number. Gets
169  // passed agglomeration map (from fine to coarse cells) and coarse
170  // cell
171  // location. Can be overridden by decomposers that provide this
172  // functionality natively. Coarse cells are local to the processor
173  // (if in parallel). If you want to have coarse cells spanning
174  // processors use the globalCellCells instead.
175  virtual labelList decompose
176  (
177  const polyMesh& mesh,
178  const labelList& cellToRegion,
179  const pointField& regionPoints,
180  const scalarField& regionWeights
181  );
182 
183  //- Like decompose but with uniform weights on the regions
184  virtual labelList decompose
185  (
186  const polyMesh& mesh,
187  const labelList& cellToRegion,
188  const pointField& regionPoints
189  );
190 
191 
192  // Topology provided explicitly addressing
193 
194  //- Return for every coordinate the wanted processor number.
195  // The connectivity is equal to mesh.cellCells() except for
196  // - in parallel the cell numbers are global cell numbers
197  // (starting
198  // from 0 at processor0 and then incrementing all through the
199  // processors)
200  // - the connections are across coupled patches
201  virtual labelList decompose
202  (
203  const labelListList& globalCellCells,
204  const pointField& cc,
205  const scalarField& cWeights
206  ) = 0;
207 
208  //- Like decompose but with uniform weights on the cells
209  virtual labelList decompose
210  (
211  const labelListList& globalCellCells,
212  const pointField& cc
213  );
214 
215 
216  // Other
217 
218  //- Helper: determine (local or global) cellCells from mesh
219  // agglomeration. Agglomeration is local to the processor.
220  // local : connections are in local indices. Coupled across
221  // cyclics but not processor patches.
222  // global : connections are in global indices. Coupled across
223  // cyclics and processor patches.
224  static void calcCellCells
225  (
226  const polyMesh& mesh,
227  const labelList& agglom,
228  const label nLocalCoarse,
229  const bool global,
230  CompactListList<label>& cellCells
231  );
232 
233  //- Helper: determine (local or global) cellCells and face weights
234  // from mesh agglomeration.
235  // Uses mag of faceArea as weights
236  static void calcCellCells
237  (
238  const polyMesh& mesh,
239  const labelList& agglom,
240  const label nLocalCoarse,
241  const bool parallel,
242  CompactListList<label>& cellCells,
243  CompactListList<scalar>& cellCellWeights
244  );
245 
246  //- Helper: extract constraints:
247  // blockedface: existing faces where owner and neighbour on same
248  // proc
249  // explicitConnections: sets of boundary faces ,, ,,
250  // specifiedProcessorFaces: groups of faces with all cells on
251  // same processor.
252  void setConstraints
253  (
254  const polyMesh& mesh,
255  boolList& blockedFace,
256  PtrList<labelList>& specifiedProcessorFaces,
257  labelList& specifiedProcessor,
258  List<labelPair>& explicitConnections
259  );
260 
261  //- Helper: apply constraints to a decomposition. This gives
262  // constraints opportunity to modify decomposition in case
263  // the native decomposition method has not obeyed all constraints
264  void applyConstraints
265  (
266  const polyMesh& mesh,
267  const boolList& blockedFace,
268  const PtrList<labelList>& specifiedProcessorFaces,
269  const labelList& specifiedProcessor,
270  const List<labelPair>& explicitConnections,
271  labelList& finalDecomp
272  );
273 
274  // Decompose a mesh with constraints:
275  // - blockedFace : whether owner and neighbour should be on same
276  // processor
277  // - specifiedProcessorFaces, specifiedProcessor : sets of faces
278  // that should go to same processor (as specified in
279  // specifiedProcessor, can be -1)
280  // - explicitConnections : connections between baffle faces
281  // (blockedFace should be false on these). Owner and
282  // neighbour on same processor.
283  // Set all to zero size to have unconstrained decomposition.
284  virtual labelList decompose
285  (
286  const polyMesh& mesh,
287  const scalarField& cellWeights,
288  const boolList& blockedFace,
289  const PtrList<labelList>& specifiedProcessorFaces,
290  const labelList& specifiedProcessor,
291  const List<labelPair>& explicitConnections
292  );
293 
294  //- Decompose a mesh. Apply all constraints from decomposeParDict
295  // ('preserveFaceZones' etc). Calls either
296  // - no constraints, empty weights:
297  // decompose(mesh, cellCentres())
298  // - no constraints, set weights:
299  // decompose(mesh, cellCentres(), cellWeights)
300  // - valid constraints:
301  // decompose(mesh, cellToRegion, regionPoints, regionWeights)
303  (
304  const polyMesh& mesh,
305  const scalarField& cWeights
306  );
307 
308 
309  // Member Operators
310 
311  //- Disallow default bitwise assignment
312  void operator=(const decompositionMethod&) = delete;
313 };
314 
315 
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 
318 } // End namespace Foam
319 
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
321 
322 #endif
323 
324 // ************************************************************************* //
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Return for every coordinate the wanted processor number.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual ~decompositionMethod()
Destructor.
PtrList< decompositionConstraint > constraints_
Optional constraints.
fvMesh & mesh
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
static void calcCellCells(const polyMesh &mesh, const labelList &agglom, const label nLocalCoarse, const bool global, CompactListList< label > &cellCells)
Helper: determine (local or global) cellCells from mesh.
const pointField & points
void setConstraints(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections)
Helper: extract constraints:
static autoPtr< decompositionMethod > NewDistributor(const dictionary &decompositionDict)
Return a reference to the selected decomposition method.
TypeName("decompositionMethod")
Runtime type information.
static autoPtr< decompositionMethod > NewDecomposer(const dictionary &decompositionDict)
Return a reference to the selected decomposition method.
List< label > labelList
A List of labels.
Definition: labelList.H:56
Abstract base class for decomposition.
static dictionary decomposeParDict(const Time &time)
Read and return the decomposeParDict.
decompositionMethod(const dictionary &decompositionDict)
Construct given the decomposition dictionary.
void operator=(const decompositionMethod &)=delete
Disallow default bitwise assignment.
A packed storage unstructured matrix of objects of type <T> using an offset table for access...
void applyConstraints(const polyMesh &mesh, const boolList &blockedFace, const PtrList< labelList > &specifiedProcessorFaces, const labelList &specifiedProcessor, const List< labelPair > &explicitConnections, labelList &finalDecomp)
Helper: apply constraints to a decomposition. This gives.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
declareRunTimeSelectionTable(autoPtr, decompositionMethod, decomposer,(const dictionary &decompositionDict),(decompositionDict))
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
Namespace for OpenFOAM.