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-2019 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  dictionary,
75  (
76  const dictionary& decompositionDict
77  ),
78  (decompositionDict)
79  );
80 
81 
82  // Constructors
83 
84  //- Construct given the decomposition dictionary
85  decompositionMethod(const dictionary& decompositionDict);
86 
87  //- Disallow default bitwise copy construction
89 
90 
91  // Selectors
92 
93  //- Return a reference to the selected decomposition method
95  (
96  const dictionary& decompositionDict
97  );
98 
99 
100  //- Destructor
101  virtual ~decompositionMethod()
102  {}
103 
104 
105  // Member Functions
107  label nDomains() const
108  {
109  return nProcessors_;
110  }
111 
112  //- Is method parallel aware (i.e. does it synchronize domains across
113  // proc boundaries)
114  virtual bool parallelAware() const = 0;
115 
116 
117  // No topology (implemented by geometric decomposers)
118 
119  //- Return for every coordinate the wanted processor number.
121  (
122  const pointField& points,
123  const scalarField& pointWeights
124  )
125  {
127  return labelList(0);
128  }
129 
130  //- Like decompose but with uniform weights on the points
131  virtual labelList decompose(const pointField&)
132  {
134  return labelList(0);
135  }
136 
137 
138  // Topology provided by mesh
139 
140  //- Return for every coordinate the wanted processor number. Use the
141  // mesh connectivity (if needed)
142  virtual labelList decompose
143  (
144  const polyMesh& mesh,
145  const pointField& points,
146  const scalarField& pointWeights
147  ) = 0;
148 
149  //- Like decompose but with uniform weights on the points
150  virtual labelList decompose(const polyMesh&, const pointField&);
151 
152 
153  //- Return for every coordinate the wanted processor number. Gets
154  // passed agglomeration map (from fine to coarse cells) and coarse
155  // cell
156  // location. Can be overridden by decomposers that provide this
157  // functionality natively. Coarse cells are local to the processor
158  // (if in parallel). If you want to have coarse cells spanning
159  // processors use the globalCellCells instead.
160  virtual labelList decompose
161  (
162  const polyMesh& mesh,
163  const labelList& cellToRegion,
164  const pointField& regionPoints,
165  const scalarField& regionWeights
166  );
167 
168  //- Like decompose but with uniform weights on the regions
169  virtual labelList decompose
170  (
171  const polyMesh& mesh,
172  const labelList& cellToRegion,
173  const pointField& regionPoints
174  );
175 
176 
177  // Topology provided explicitly addressing
178 
179  //- Return for every coordinate the wanted processor number.
180  // The connectivity is equal to mesh.cellCells() except for
181  // - in parallel the cell numbers are global cell numbers
182  // (starting
183  // from 0 at processor0 and then incrementing all through the
184  // processors)
185  // - the connections are across coupled patches
186  virtual labelList decompose
187  (
188  const labelListList& globalCellCells,
189  const pointField& cc,
190  const scalarField& cWeights
191  ) = 0;
192 
193  //- Like decompose but with uniform weights on the cells
194  virtual labelList decompose
195  (
196  const labelListList& globalCellCells,
197  const pointField& cc
198  );
199 
200 
201  // Other
202 
203  //- Helper: determine (local or global) cellCells from mesh
204  // agglomeration. Agglomeration is local to the processor.
205  // local : connections are in local indices. Coupled across
206  // cyclics but not processor patches.
207  // global : connections are in global indices. Coupled across
208  // cyclics and processor patches.
209  static void calcCellCells
210  (
211  const polyMesh& mesh,
212  const labelList& agglom,
213  const label nLocalCoarse,
214  const bool global,
215  CompactListList<label>& cellCells
216  );
217 
218  //- Helper: determine (local or global) cellCells and face weights
219  // from mesh agglomeration.
220  // Uses mag of faceArea as weights
221  static void calcCellCells
222  (
223  const polyMesh& mesh,
224  const labelList& agglom,
225  const label nLocalCoarse,
226  const bool parallel,
227  CompactListList<label>& cellCells,
228  CompactListList<scalar>& cellCellWeights
229  );
230 
231  //- Helper: extract constraints:
232  // blockedface: existing faces where owner and neighbour on same
233  // proc
234  // explicitConnections: sets of boundary faces ,, ,,
235  // specifiedProcessorFaces: groups of faces with all cells on
236  // same processor.
237  void setConstraints
238  (
239  const polyMesh& mesh,
240  boolList& blockedFace,
241  PtrList<labelList>& specifiedProcessorFaces,
242  labelList& specifiedProcessor,
243  List<labelPair>& explicitConnections
244  );
245 
246  //- Helper: apply constraints to a decomposition. This gives
247  // constraints opportunity to modify decomposition in case
248  // the native decomposition method has not obeyed all constraints
249  void applyConstraints
250  (
251  const polyMesh& mesh,
252  const boolList& blockedFace,
253  const PtrList<labelList>& specifiedProcessorFaces,
254  const labelList& specifiedProcessor,
255  const List<labelPair>& explicitConnections,
256  labelList& finalDecomp
257  );
258 
259  // Decompose a mesh with constraints:
260  // - blockedFace : whether owner and neighbour should be on same
261  // processor
262  // - specifiedProcessorFaces, specifiedProcessor : sets of faces
263  // that should go to same processor (as specified in
264  // specifiedProcessor, can be -1)
265  // - explicitConnections : connections between baffle faces
266  // (blockedFace should be false on these). Owner and
267  // neighbour on same processor.
268  // Set all to zero size to have unconstrained decomposition.
269  virtual labelList decompose
270  (
271  const polyMesh& mesh,
272  const scalarField& cellWeights,
273  const boolList& blockedFace,
274  const PtrList<labelList>& specifiedProcessorFaces,
275  const labelList& specifiedProcessor,
276  const List<labelPair>& explicitConnections
277  );
278 
279 
280  //- Decompose a mesh. Apply all constraints from decomposeParDict
281  // ('preserveFaceZones' etc). Calls either
282  // - no constraints, empty weights:
283  // decompose(mesh, cellCentres())
284  // - no constraints, set weights:
285  // decompose(mesh, cellCentres(), cellWeights)
286  // - valid constraints:
287  // decompose(mesh, cellToRegion, regionPoints, regionWeights)
289  (
290  const polyMesh& mesh,
291  const scalarField& cWeights
292  );
293 
294 
295  // Member Operators
296 
297  //- Disallow default bitwise assignment
298  void operator=(const decompositionMethod&) = delete;
299 };
300 
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 } // End namespace Foam
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 #endif
309 
310 // ************************************************************************* //
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Return for every coordinate the wanted processor number.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual bool parallelAware() const =0
Is method parallel aware (i.e. does it synchronize domains across.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
declareRunTimeSelectionTable(autoPtr, decompositionMethod, dictionary,(const dictionary &decompositionDict),(decompositionDict))
virtual ~decompositionMethod()
Destructor.
PtrList< decompositionConstraint > constraints_
Optional constraints.
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.
dynamicFvMesh & mesh
const pointField & points
void setConstraints(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections)
Helper: extract constraints:
TypeName("decompositionMethod")
Runtime type information.
List< label > labelList
A List of labels.
Definition: labelList.H:56
Abstract base class for decomposition.
decompositionMethod(const dictionary &decompositionDict)
Construct given the decomposition dictionary.
void operator=(const decompositionMethod &)=delete
Disallow default bitwise assignment.
static autoPtr< decompositionMethod > New(const dictionary &decompositionDict)
Return a reference to the selected decomposition method.
A packed storage unstructured matrix of objects of type <T> using an offset table for access...
const dictionary & decompositionDict_
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:74
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
Namespace for OpenFOAM.