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