randomDecomp.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) 2019-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::randomDecomp
28 
29 Description
30  Decomposition according to pseudo-random number generator,
31  which is useful for development and stress testing implementations
32  but obviously sub-optimal for normal uses.
33  Can optionally specify the number of consecutive cells to assign
34  to the same processor (agglomeration).
35 
36  Coefficients:
37  \table
38  Property | Description | Required | Default
39  agglom | Number of cells to agglomerate | no | 0
40  \endtable
41 
42 SourceFiles
43  randomDecomp.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef Foam_randomDecomp_H
48 #define Foam_randomDecomp_H
49 
50 #include "decompositionMethod.H"
51 
52 namespace Foam
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class randomDecomp Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class randomDecomp
60 :
61  public decompositionMethod
62 {
63  // Private Data
64 
65  //- Number of cells to agglomerate per random value (default: 0)
66  label agglom_;
67 
68 
69  // Private Member Functions
70 
71  //- Random distribution on the 0-nCells interval
72  labelList randomMap(const label nCells) const;
73 
74 public:
75 
76  // Generated Methods
77 
78  //- No copy construct
79  randomDecomp(const randomDecomp&) = delete;
80 
81  //- No copy assignment
82  void operator=(const randomDecomp&) = delete;
83 
84 
85  //- Runtime type information
86  TypeNameNoDebug("random");
87 
88 
89  // Constructors
90 
91  //- Construct with number of domains (no coefficients or constraints)
92  explicit randomDecomp(const label numDomains);
93 
94  //- Construct for decomposition dictionary and optional region name
95  explicit randomDecomp
96  (
97  const dictionary& decompDict,
98  const word& regionName = "",
99  int select = selectionType::DEFAULT
100  );
101 
102 
103  //- Destructor
104  virtual ~randomDecomp() = default;
105 
106 
107  // Member Functions
108 
109  //- Does not care about proc boundaries
110  virtual bool parallelAware() const
111  {
112  return true;
113  }
114 
115  //- Return for every coordinate the wanted processor number.
116  virtual labelList decompose
117  (
118  const pointField& points,
119  const scalarField& pointWeights_unused = scalarField::null()
120  ) const;
121 
122  //- Return for every coordinate the wanted processor number.
123  virtual labelList decompose
124  (
125  const polyMesh& mesh,
126  const pointField& cc_unused = pointField::null(),
127  const scalarField& cWeights_unused = scalarField::null()
128  ) const;
129 
130  //- Return for every coordinate the wanted processor number.
131  // Explicitly provided connectivity - does not use mesh_.
132  virtual labelList decompose
133  (
134  const CompactListList<label>& globalCellCells,
135  const pointField& cc_unused = pointField::null(),
136  const scalarField& cWeights_unused = scalarField::null()
137  ) const;
138 
139  //- Return for every coordinate the wanted processor number.
140  // Explicitly provided connectivity - does not use mesh_.
141  virtual labelList decompose
142  (
143  const labelListList& globalCellCells,
144  const pointField& cc_unused = pointField::null(),
145  const scalarField& cWeights_unused = scalarField::null()
146  ) const;
147 };
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 } // End namespace Foam
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #endif
157 
158 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
Definition: BitOps.C:134
void operator=(const randomDecomp &)=delete
No copy assignment.
dynamicFvMesh & mesh
const pointField & points
A class for handling words, derived from Foam::string.
Definition: word.H:63
randomDecomp(const randomDecomp &)=delete
No copy construct.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights_unused=scalarField::null()) const
Return for every coordinate the wanted processor number.
Definition: randomDecomp.C:105
A packed storage of objects of type <T> using an offset table for access.
Decomposition according to pseudo-random number generator, which is useful for development and stress...
Definition: randomDecomp.H:64
virtual ~randomDecomp()=default
Destructor.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
static const Field< scalar > & null()
Return nullObject reference Field.
Definition: FieldI.H:24
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
virtual bool parallelAware() const
Does not care about proc boundaries.
Definition: randomDecomp.H:133
TypeNameNoDebug("random")
Runtime type information.
Namespace for OpenFOAM.