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