Loading...
Searching...
No Matches
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-2023 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 Foam_decompositionMethod_H
39#define Foam_decompositionMethod_H
40
41#include "polyMesh.H"
42#include "CompactListList.H"
44
45namespace Foam
46{
48/*---------------------------------------------------------------------------*\
49 Class decompositionMethod Declaration
50\*---------------------------------------------------------------------------*/
51
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
67protected:
68
69 //- Selection type when handling the coefficients dictionary.
70 // To be used as a bit-mask for findCoeffsDict
71 enum selectionType
72 {
73 DEFAULT = 0,
74 EXACT = 1,
75 MANDATORY = 2,
78 };
80
81 // Protected Data
82
83 //- Top-level decomposition dictionary (eg, decomposeParDict)
85
86 //- Region-specific decomposition dictionary information
88
89 //- Number of domains for the decomposition
90 label nDomains_;
91
92 //- Optional constraints
95
96 // Protected Member Functions
97
98 //- Locate coeffsName dictionary or the fallback "coeffs" dictionary
99 //- within an enclosing dictionary.
100 //
101 // \param select choose to include "coeffs" in the search, make
102 // failure a FatalError, return dictionary::null instead on
103 // failure.
104 //
105 // \return the coefficients dictionary found. If nothing was found,
106 // return the enclosing dictionary or
107 // dictionary::null (depending on the select parameter).
109 static const dictionary& findCoeffsDict
110 (
111 const dictionary& dict,
112 const word& coeffsName,
113 int select = selectionType::DEFAULT
114 );
115
116
117 //- Locate coeffsName dictionary or the fallback "coeffs" dictionary.
118 // Searches both the region-specific decomposition dictionary
119 // and the top-level decomposition dictionary.
120 //
121 // \param select choose to include "coeffs" in the search, make
122 // failure a FatalError, return dictionary::null instead on
123 // failure.
124 //
125 // \return the coefficients dictionary found. If nothing was found,
126 // return the top-level (non-region) dictionary or
127 // dictionary::null (depending on the select parameter).
130 (
131 const word& coeffsName,
132 int select = selectionType::DEFAULT
133 ) const;
134
135
136 // Constructors
137
138 //- Construct with specified number of domains,
139 //- no coefficients or constraints
140 explicit decompositionMethod(const label numDomains);
141
142
143public:
144
145 // Generated Methods
146
147 //- No copy construct
149
150 //- No copy assignment
151 void operator=(const decompositionMethod&) = delete;
152
153
154 //- Runtime type information
155 TypeName("decompositionMethod");
156
157
158 // Declare run-time constructor selection tables
159
161 (
162 autoPtr,
165 (
166 const dictionary& decompDict,
167 const word& regionName
168 ),
169 (decompDict, regionName)
170 );
171
172
173 // Static Methods
175 //- Return region-specific or top-level \c numberOfSubdomains entry.
176 // The region-specific version is found within the "regions"
177 // sub-dictionary.
178 static label nDomains
179 (
180 const dictionary& decompDict,
181 const word& regionName = ""
182 );
183
184 //- Return an optional region-specific dictionary
185 //- from "regions" sub-dictionary, or dictionary::null on failure
186 static const dictionary& optionalRegionDict
187 (
188 const dictionary& decompDict,
189 const word& regionName
190 );
191
192
193 // Selectors
194
195 //- Return a reference to the selected decomposition method,
196 //- optionally region-specific
198 (
199 const dictionary& decompDict,
200 const word& regionName = ""
201 );
202
203
204 // Constructors
205
206 //- Construct given the decomposition dictionary,
207 //- optionally region-specific
208 explicit decompositionMethod
209 (
210 const dictionary& decompDict,
211 const word& regionName = ""
212 );
213
214
215 //- Destructor
216 virtual ~decompositionMethod() = default;
217
218
219 // Member Functions
220
221 //- Number of domains
222 label nDomains() const noexcept
223 {
224 return nDomains_;
225 }
226
227 //- Set number of domains. Return old value
228 label nDomains(const label n)
229 {
230 const label oldNum = nDomains_;
231 nDomains_ = n;
232 return oldNum;
233 }
234
235 //- True if the method is purely geometric,
236 //- often using cell centre points
237 virtual bool geometric() const { return false; }
238
239 //- Is method parallel aware?
240 // (i.e. does it synchronize domains across proc boundaries)
241 virtual bool parallelAware() const = 0;
242
243 // //- Is internally method parallel aware
244 // virtual bool parallelNative() const { return false; }
245
246
247 // No topology (implemented by geometric decomposers)
248
249 //- Return the wanted processor number for every coordinate,
250 //- using uniform or specified point weights.
251 virtual labelList decompose
253 const pointField& points,
254 const scalarField& pointWeights = scalarField::null()
255 ) const;
256
257
258 // Topology provided by mesh
259
260 //- Return for every coordinate the wanted processor number,
261 //- using uniform or specified point weights.
262 // Use the mesh connectivity (if needed)
263 virtual labelList decompose
264 (
265 const polyMesh& mesh,
266 const pointField& points,
267 const scalarField& pointWeights = scalarField::null()
268 ) const = 0;
269
270 //- Return for every coordinate the wanted processor number.
271 // Gets passed agglomeration map (from fine to coarse cells)
272 // and coarse cell
273 // location. Can be overridden by decomposers that provide this
274 // functionality natively. Coarse cells are local to the processor
275 // (if in parallel). If you want to have coarse cells spanning
276 // processors use the globalCellCells instead.
277 virtual labelList decompose
278 (
280 const labelList& cellToRegion,
281 const pointField& regionPoints,
282 const scalarField& regionWeights = scalarField::null()
283 ) const;
284
285
286 // Topology provided explicitly
287
288 //- Return for every coordinate the wanted processor number.
289 // The connectivity is equal to mesh.cellCells() except for
290 // - in parallel the cell numbers are global cell numbers
291 // (starting
292 // from 0 at processor0 and then incrementing all through the
293 // processors)
294 // - the connections are across coupled patches
295 virtual labelList decompose
296 (
297 const CompactListList<label>& globalCellCells,
298 const pointField& cc,
299 const scalarField& cWeights = scalarField::null()
300 ) const = 0;
301
302 //- Return for every coordinate the wanted processor number.
303 // The connectivity is equal to mesh.cellCells() except for
304 // - in parallel the cell numbers are global cell numbers
305 // (starting
306 // from 0 at processor0 and then incrementing all through the
307 // processors)
308 // - the connections are across coupled patches
309 virtual labelList decompose
310 (
311 const labelListList& globalCellCells,
312 const pointField& cc,
313 const scalarField& cWeights = scalarField::null()
314 ) const = 0;
315
316
317 // Other
318
319 //- Helper: extract constraints:
320 // blockedface: existing faces where owner and neighbour on same
321 // proc
322 // explicitConnections: sets of boundary faces ,, ,,
323 // specifiedProcessorFaces: groups of faces with all cells on
324 // same processor.
325 void setConstraints
326 (
327 const polyMesh& mesh,
328 boolList& blockedFace,
329 PtrList<labelList>& specifiedProcessorFaces,
330 labelList& specifiedProcessor,
331 List<labelPair>& explicitConnections
332 ) const;
333
334 //- Helper: apply constraints to a decomposition.
335 // This gives constraints opportunity to modify decomposition in case
336 // the native decomposition method has not obeyed all constraints
338 (
339 const polyMesh& mesh,
340 const boolList& blockedFace,
341 const PtrList<labelList>& specifiedProcessorFaces,
342 const labelList& specifiedProcessor,
343 const List<labelPair>& explicitConnections,
344 labelList& finalDecomp
345 ) const;
346
347 // Decompose a mesh with constraints:
348 // - blockedFace : whether owner and neighbour should be on same
349 // processor
350 // - specifiedProcessorFaces, specifiedProcessor : sets of faces
351 // that should go to same processor (as specified in
352 // specifiedProcessor, can be -1)
353 // - explicitConnections : connections between baffle faces
354 // (blockedFace should be false on these). Owner and
355 // neighbour on same processor.
356 // Set all to zero size to have unconstrained decomposition.
357 virtual labelList decompose
358 (
359 const polyMesh& mesh,
360 const scalarField& cellWeights,
361 const boolList& blockedFace,
362 const PtrList<labelList>& specifiedProcessorFaces,
363 const labelList& specifiedProcessor,
364 const List<labelPair>& explicitConnections
365 ) const;
366
367
368 //- Decompose a mesh.
369 // Apply all constraints from decomposeParDict
370 // ('preserveFaceZones' etc). Calls either
371 // - no constraints, empty weights:
372 // decompose(mesh, cellCentres())
373 // - no constraints, set weights:
374 // decompose(mesh, cellCentres(), cellWeights)
375 // - valid constraints:
376 // decompose(mesh, cellToRegion, regionPoints, regionWeights)
378 (
379 const polyMesh& mesh,
380 const scalarField& cWeights
381 ) const;
382
383
384 // Housekeeping
385
386 //- Determine (local or global) cellCells from mesh agglomeration.
387 // Agglomeration is local to the processor.
388 // local : connections are in local indices. Coupled across
389 // cyclics but not processor patches.
390 // global : connections are in global indices. Coupled across
391 // cyclics and processor patches.
392 FOAM_DEPRECATED_STRICT(2023-11, "globalMeshData::calcCellCells()")
393 static void calcCellCells
394 (
395 const polyMesh& mesh,
396 const labelList& agglom,
397 const label nLocalCoarse,
398 const bool parallel,
399 CompactListList<label>& cellCells
400 );
401
402 //- Determine (local or global) cellCells and face weights
403 //- from mesh agglomeration.
404 // Uses mag of faceArea as weights
405 FOAM_DEPRECATED_STRICT(2023-11, "globalMeshData::calcCellCells()")
406 static void calcCellCells
407 (
408 const polyMesh& mesh,
409 const labelList& agglom,
410 const label nLocalCoarse,
411 const bool parallel,
412 CompactListList<label>& cellCells,
413 CompactListList<scalar>& cellCellWeights
414 );
415};
416
417
418// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
419
420} // End namespace Foam
421
422// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
423
424#endif
425
426// ************************************************************************* //
label n
A packed storage of objects of type <T> using an offset table for access.
static const Field< scalar > & null() noexcept
Definition Field.H:192
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
label nDomains(const label n)
Set number of domains. Return old value.
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.
virtual labelList decompose(const polyMesh &mesh, const pointField &points, const scalarField &pointWeights=scalarField::null()) const =0
Return for every coordinate the wanted processor number, using uniform or specified point weights.
virtual bool geometric() const
True if the method is purely geometric, often using cell centre points.
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.
void operator=(const decompositionMethod &)=delete
No copy assignment.
virtual labelList decompose(const CompactListList< label > &globalCellCells, const pointField &cc, const scalarField &cWeights=scalarField::null()) const =0
Return for every coordinate the wanted processor number.
const dictionary & decompDict_
Top-level decomposition dictionary (eg, decomposeParDict).
TypeName("decompositionMethod")
Runtime type information.
virtual labelList decompose(const labelListList &globalCellCells, const pointField &cc, const scalarField &cWeights=scalarField::null()) const =0
Return for every coordinate the wanted processor number.
void setConstraints(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Helper: extract constraints:
virtual ~decompositionMethod()=default
Destructor.
decompositionMethod(const label numDomains)
Construct with specified number of domains, no coefficients or constraints.
static autoPtr< decompositionMethod > New(const dictionary &decompDict, const word &regionName="")
Return a reference to the selected decomposition method, optionally region-specific.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights=scalarField::null()) const
Return the wanted processor number for every coordinate, using uniform or specified point weights.
static FOAM_NO_DANGLING_REFERENCE const dictionary & findCoeffsDict(const dictionary &dict, const word &coeffsName, int select=selectionType::DEFAULT)
Locate coeffsName dictionary or the fallback "coeffs" dictionary within an enclosing dictionary.
virtual bool parallelAware() const =0
Is method parallel aware?
declareRunTimeSelectionTable(autoPtr, decompositionMethod, dictionary,(const dictionary &decompDict, const word &regionName),(decompDict, regionName))
static void calcCellCells(const polyMesh &mesh, const labelList &agglom, const label nLocalCoarse, const bool parallel, CompactListList< label > &cellCells)
Determine (local or global) cellCells from mesh agglomeration.
static const dictionary & optionalRegionDict(const dictionary &decompDict, const word &regionName)
Return an optional region-specific dictionary from "regions" sub-dictionary, or dictionary::null on f...
label nDomains() const noexcept
Number of domains.
decompositionMethod(const decompositionMethod &)=delete
No copy construct.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
const pointField & points
Namespace for OpenFOAM.
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< bool > boolList
A List of bools.
Definition List.H:60
const direction noexcept
Definition scalarImpl.H:265
vectorField pointField
pointField is a vectorField.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
#define FOAM_NO_DANGLING_REFERENCE
Definition stdFoam.H:80
#define FOAM_DEPRECATED_STRICT(since, replacement)
Definition stdFoam.H:53
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68