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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2015-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::decompositionMethod
29
30Description
31 Abstract base class for domain decomposition
32
33SourceFiles
34 decompositionMethod.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef decompositionMethod_H
39#define decompositionMethod_H
40
41#include "polyMesh.H"
42#include "CompactListList.H"
44
45namespace Foam
46{
47
48/*---------------------------------------------------------------------------*\
49 Class decompositionMethod Declaration
50\*---------------------------------------------------------------------------*/
53{
54 // Private Member Functions
55
56 //- Check (and warn) about existence of old constraint syntax.
57 // The syntax changed MAY-2014.
58 //
59 // \return true if this model name was found in the decompDict_
60 // but not previously added with the newer syntax.
61 bool constraintCompat(const word& modelType) const;
62
63 //- Set PtrList of constraints by reading decompDict_.
64 void readConstraints();
65
66 //- No copy construct
68
69 //- No copy assignment
70 void operator=(const decompositionMethod&) = delete;
71
72
73protected:
74
75 //- Selection type when handling the coefficients dictionary.
76 // To be used as a bit-mask for findCoeffsDict
77 enum selectionType
78 {
79 DEFAULT = 0,
80 EXACT = 1,
81 MANDATORY = 2,
84 };
85
86
87 // Protected data
88
89 //- Top-level decomposition dictionary (eg, decomposeParDict)
91
92 //- Region-specific decomposition dictionary information
94
95 //- Number of domains for the decomposition
96 label nDomains_;
97
98 //- Optional constraints
100
101
102 // Protected Member Functions
103
104 //- Locate coeffsName dictionary or the fallback "coeffs" dictionary
105 //- within an enclosing dictionary.
106 //
107 // \param select choose to include "coeffs" in the search, make
108 // failure a FatalError, return dictionary::null instead on
109 // failure.
110 //
111 // \return the coefficients dictionary found. If nothing was found,
112 // return the enclosing dictionary or
113 // dictionary::null (depending on the select parameter).
114 static const dictionary& findCoeffsDict
115 (
116 const dictionary& dict,
117 const word& coeffsName,
118 int select = selectionType::DEFAULT
119 );
120
121
122 //- Locate coeffsName dictionary or the fallback "coeffs" dictionary.
123 // Searches both the region-specific decomposition dictionary
124 // and the top-level decomposition dictionary.
125 //
126 // \param select choose to include "coeffs" in the search, make
127 // failure a FatalError, return dictionary::null instead on
128 // failure.
129 //
130 // \return the coefficients dictionary found. If nothing was found,
131 // return the top-level (non-region) dictionary or
132 // dictionary::null (depending on the select parameter).
134 (
135 const word& coeffsName,
136 int select = selectionType::DEFAULT
137 ) const;
138
139
140public:
141
142 //- Runtime type information
143 TypeName("decompositionMethod");
144
145
146 // Declare run-time constructor selection tables
149 (
150 autoPtr,
153 (
154 const dictionary& decompDict,
155 const word& regionName
156 ),
157 (decompDict, regionName)
158 );
159
160
161 // Static Methods
162
163 //- Return region-specific or top-level \c numberOfSubdomains entry.
164 // The region-specific version is found within the "regions"
165 // sub-dictionary.
166 static label nDomains
167 (
168 const dictionary& decompDict,
169 const word& regionName = ""
170 );
171
172 //- Return an optional region-specific dictionary
173 //- from "regions" sub-dictionary, or dictionary::null on failure
174 static const dictionary& optionalRegionDict
175 (
176 const dictionary& decompDict,
177 const word& regionName
178 );
179
180
181 // Selectors
182
183 //- Return a reference to the selected decomposition method,
184 //- optionally region-specific
186 (
187 const dictionary& decompDict,
188 const word& regionName = ""
189 );
190
191
192 // Constructors
193
194 //- Construct given the decomposition dictionary,
195 //- optionally region-specific
196 explicit decompositionMethod
197 (
198 const dictionary& decompDict,
199 const word& regionName = ""
200 );
201
202
203 //- Destructor
204 virtual ~decompositionMethod() = default;
205
206
207 // Member Functions
208
209 //- Number of domains
210 inline label nDomains() const noexcept
211 {
212 return nDomains_;
213 }
214
215 //- Is method parallel aware?
216 // (i.e. does it synchronize domains across proc boundaries)
217 virtual bool parallelAware() const = 0;
218
219
220 // No topology (implemented by geometric decomposers)
221
222 //- Return the wanted processor number for every coordinate.
223 virtual labelList decompose
224 (
225 const pointField& points,
226 const scalarField& pointWeights
227 ) const;
228
229 //- Decompose with uniform weights on the points
230 virtual labelList decompose(const pointField& points) const;
231
232
233 // Topology provided by mesh
234
235 //- Return for every coordinate the wanted processor number.
236 // Use the mesh connectivity (if needed)
237 virtual labelList decompose
238 (
239 const polyMesh& mesh,
240 const pointField& points,
241 const scalarField& pointWeights
242 ) const = 0;
243
244 //- Decompose with uniform weights on the points
245 virtual labelList decompose
246 (
247 const polyMesh& mesh,
248 const pointField& points
249 ) const;
250
251
252 //- Return for every coordinate the wanted processor number. Gets
253 // passed agglomeration map (from fine to coarse cells) and coarse
254 // cell
255 // location. Can be overridden by decomposers that provide this
256 // functionality natively. Coarse cells are local to the processor
257 // (if in parallel). If you want to have coarse cells spanning
258 // processors use the globalCellCells instead.
259 virtual labelList decompose
260 (
261 const polyMesh& mesh,
262 const labelList& cellToRegion,
263 const pointField& regionPoints,
264 const scalarField& regionWeights
265 ) const;
266
267 //- Like decompose but with uniform weights on the regions
268 virtual labelList decompose
269 (
270 const polyMesh& mesh,
271 const labelList& cellToRegion,
272 const pointField& regionPoints
273 ) const;
274
275
276 // Topology provided explicitly addressing
277
278 //- Return for every coordinate the wanted processor number.
279 // The connectivity is equal to mesh.cellCells() except for
280 // - in parallel the cell numbers are global cell numbers
281 // (starting
282 // from 0 at processor0 and then incrementing all through the
283 // processors)
284 // - the connections are across coupled patches
285 virtual labelList decompose
286 (
287 const labelListList& globalCellCells,
288 const pointField& cc,
289 const scalarField& cWeights
290 ) const = 0;
291
292 //- Like decompose but with uniform weights on the cells
293 virtual labelList decompose
294 (
295 const labelListList& globalCellCells,
296 const pointField& cc
297 ) const;
298
299
300 // Other
301
302 //- Helper: determine (local or global) cellCells from mesh
303 // agglomeration. Agglomeration is local to the processor.
304 // local : connections are in local indices. Coupled across
305 // cyclics but not processor patches.
306 // global : connections are in global indices. Coupled across
307 // cyclics and processor patches.
308 static void calcCellCells
309 (
310 const polyMesh& mesh,
311 const labelList& agglom,
312 const label nLocalCoarse,
313 const bool global,
314 CompactListList<label>& cellCells
315 );
316
317 //- Helper: determine (local or global) cellCells and face weights
318 // from mesh agglomeration.
319 // Uses mag of faceArea as weights
320 static void calcCellCells
321 (
322 const polyMesh& mesh,
323 const labelList& agglom,
324 const label nLocalCoarse,
325 const bool parallel,
326 CompactListList<label>& cellCells,
327 CompactListList<scalar>& cellCellWeights
328 );
329
330 //- Helper: extract constraints:
331 // blockedface: existing faces where owner and neighbour on same
332 // proc
333 // explicitConnections: sets of boundary faces ,, ,,
334 // specifiedProcessorFaces: groups of faces with all cells on
335 // same processor.
336 void setConstraints
337 (
338 const polyMesh& mesh,
339 boolList& blockedFace,
340 PtrList<labelList>& specifiedProcessorFaces,
341 labelList& specifiedProcessor,
342 List<labelPair>& explicitConnections
343 ) const;
344
345 //- Helper: apply constraints to a decomposition.
346 // This gives constraints opportunity to modify decomposition in case
347 // the native decomposition method has not obeyed all constraints
349 (
350 const polyMesh& mesh,
351 const boolList& blockedFace,
352 const PtrList<labelList>& specifiedProcessorFaces,
353 const labelList& specifiedProcessor,
354 const List<labelPair>& explicitConnections,
355 labelList& finalDecomp
356 ) const;
357
358 // Decompose a mesh with constraints:
359 // - blockedFace : whether owner and neighbour should be on same
360 // processor
361 // - specifiedProcessorFaces, specifiedProcessor : sets of faces
362 // that should go to same processor (as specified in
363 // specifiedProcessor, can be -1)
364 // - explicitConnections : connections between baffle faces
365 // (blockedFace should be false on these). Owner and
366 // neighbour on same processor.
367 // Set all to zero size to have unconstrained decomposition.
368 virtual labelList decompose
369 (
370 const polyMesh& mesh,
371 const scalarField& cellWeights,
372 const boolList& blockedFace,
373 const PtrList<labelList>& specifiedProcessorFaces,
374 const labelList& specifiedProcessor,
375 const List<labelPair>& explicitConnections
376 ) const;
377
378
379 //- Decompose a mesh.
380 // Apply all constraints from decomposeParDict
381 // ('preserveFaceZones' etc). Calls either
382 // - no constraints, empty weights:
383 // decompose(mesh, cellCentres())
384 // - no constraints, set weights:
385 // decompose(mesh, cellCentres(), cellWeights)
386 // - valid constraints:
387 // decompose(mesh, cellToRegion, regionPoints, regionWeights)
389 (
390 const polyMesh& mesh,
391 const scalarField& cWeights
392 ) const;
393};
394
395
396// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
397
398} // End namespace Foam
399
400// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
401
402#endif
403
404// ************************************************************************* //
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Abstract base class for domain decomposition.
selectionType
Selection type when handling the coefficients dictionary.
@ EXACT
No fallback to "coeffs" if main name not found.
@ MANDATORY
Fatal if dictionary could not be found.
const dictionary & decompRegionDict_
Region-specific decomposition dictionary information.
label nDomains_
Number of domains for the decomposition.
PtrList< decompositionConstraint > constraints_
Optional constraints.
void applyConstraints(const polyMesh &mesh, const boolList &blockedFace, const PtrList< labelList > &specifiedProcessorFaces, const labelList &specifiedProcessor, const List< labelPair > &explicitConnections, labelList &finalDecomp) const
Helper: apply constraints to a decomposition.
const dictionary & decompDict_
Top-level decomposition dictionary (eg, decomposeParDict)
TypeName("decompositionMethod")
Runtime type information.
void setConstraints(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Helper: extract 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.
virtual ~decompositionMethod()=default
Destructor.
static autoPtr< decompositionMethod > New(const dictionary &decompDict, const word &regionName="")
virtual labelList decompose(const pointField &points, const scalarField &pointWeights) const
Return the wanted processor number for every coordinate.
static const dictionary & findCoeffsDict(const dictionary &dict, const word &coeffsName, int select=selectionType::DEFAULT)
virtual bool parallelAware() const =0
Is method parallel aware?
declareRunTimeSelectionTable(autoPtr, decompositionMethod, dictionary,(const dictionary &decompDict, const word &regionName),(decompDict, regionName))
static const dictionary & optionalRegionDict(const dictionary &decompDict, const word &regionName)
label nDomains() const noexcept
Number of domains.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
Foam::word regionName(Foam::polyMesh::defaultRegion)
const pointField & points
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73