faMeshDecomposition.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::faMeshDecomposition
29 
30 Description
31  Automatic faMesh decomposition class
32 
33 Author
34  Zeljko Tukovic, FSB Zagreb
35  Hrvoje Jasak, Wikki Ltd.
36 
37 SourceFiles
38  faMeshDecomposition.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef faMeshDecomposition_H
43 #define faMeshDecomposition_H
44 
45 #include "polyMesh.H"
46 #include "faMesh.H"
47 #include "labelList.H"
48 #include "PtrList.H"
49 #include "point.H"
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class faMeshDecomposition Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 :
60  public faMesh
61 {
62  // Private Data
63 
64  //- Number of processors in decomposition
65  label nProcs_;
66 
67  //- Is the decomposition data to be distributed for each processor
68  bool distributed_;
69 
70  //- Are globalFaceZones being used
71  bool hasGlobalFaceZones_;
72 
73  //- Processor label for each cell
74  labelList faceToProc_;
75 
76  //- Face labels for each processor mesh
77  labelListList procFaceLabels_;
78 
79  //-
80  List<Map<label>> procMeshEdgesMap_;
81 
82  //- Number of internal edges for each processor mesh
83  labelList procNInternalEdges_;
84 
85  //- Edge labels for patches of processor meshes
86  List<labelListList> procPatchEdgeLabels_;
87 
88  //- Labels of points for each processor
89  labelListList procPatchPointAddressing_;
90 
91  //- Labels of edges for each processor
92  labelListList procPatchEdgeAddressing_;
93 
94  //- Labels of edges for each processor
95  labelListList procEdgeAddressing_;
96 
97  //- Labels of faces for each processor
98  labelListList procFaceAddressing_;
99 
100  //- Original patch index for every processor patch
101  labelListList procBoundaryAddressing_;
102 
103  //- Sizes for processor mesh patches
104  // Excludes inter-processor boundaries
105  labelListList procPatchSize_;
106 
107  //- Start indices for processor patches
108  // Excludes inter-processor boundaries
109  labelListList procPatchStartIndex_;
110 
111  //- Neighbour processor ID for inter-processor boundaries
112  labelListList procNeighbourProcessors_;
113 
114  //- Sizes for inter-processor patches
115  labelListList procProcessorPatchSize_;
116 
117  //- Start indices for inter-processor patches
118  labelListList procProcessorPatchStartIndex_;
119 
120  //- List of globally shared point labels
121  labelList globallySharedPoints_;
122 
123  //- Are there cyclic-parallel faces
124  bool cyclicParallel_;
125 
126 
127  // Private Member Functions
128 
129  void distributeFaces();
130 
131 
132 public:
133 
134  // Constructors
135 
136  //- Construct from components.
137  //- Values will come from the volume decomposition
138  // \param mesh the fvMesh
139  // \param nProcessors the number of processors
140  // \param params additional parameters, sent to updateParameters
142  (
143  const polyMesh& mesh,
144  const label nProcessors,
145  const dictionary& params = dictionary::null
146  );
147 
148 
149  //- Destructor
150  ~faMeshDecomposition() = default;
151 
152 
153  // Member Functions
154 
155  // Settings
156 
157  //- Number of processor in decomposition
158  label nProcs() const noexcept
159  {
160  return nProcs_;
161  }
162 
163  //- Is decomposition data to be distributed for each processor
164  bool distributed() const noexcept
165  {
166  return distributed_;
167  }
168 
169  //- Change distributed flag
170  bool distributed(const bool on) noexcept
171  {
172  bool old(distributed_);
173  distributed_ = on;
174  return old;
175  }
176 
177  //- Are global face zones used
178  bool useGlobalFaceZones() const noexcept
179  {
180  return distributed_;
181  }
182 
183  //- Change global face zones flag
184  bool useGlobalFaceZones(const bool on) noexcept
185  {
186  bool old(hasGlobalFaceZones_);
187  hasGlobalFaceZones_ = on;
188  return old;
189  }
190 
191  //- Update flags based on the decomposition model settings
192  // Sets "distributed", detects presence of "globalFaceZones"
193  void updateParameters(const dictionary& params);
194 
195 
196  // Mappings
197 
198  //- Face-processor decomposition labels
199  const labelList& faceToProc() const noexcept
200  {
201  return faceToProc_;
202  }
203 
204 
205  // Decompose
206 
207  //- Decompose mesh
208  void decomposeMesh();
209 
210  //- Write decomposition
211  bool writeDecomposition();
212 };
213 
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 } // End namespace Foam
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #endif
222 
223 // ************************************************************************* //
point.H
Foam::faMeshDecomposition::decomposeMesh
void decomposeMesh()
Decompose mesh.
Definition: faMeshDecomposition.C:210
faMesh.H
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::dictionary::null
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition: dictionary.H:392
Foam::faMeshDecomposition::updateParameters
void updateParameters(const dictionary &params)
Update flags based on the decomposition model settings.
Definition: faMeshDecomposition.C:198
labelList.H
Foam::faMeshDecomposition::useGlobalFaceZones
bool useGlobalFaceZones(const bool on) noexcept
Change global face zones flag.
Definition: faMeshDecomposition.H:183
Foam::faMeshDecomposition::faceToProc
const labelList & faceToProc() const noexcept
Face-processor decomposition labels.
Definition: faMeshDecomposition.H:198
Foam::faMesh::mesh
const polyMesh & mesh() const
Return access to polyMesh.
Definition: faMeshI.H:31
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::faMeshDecomposition::distributed
bool distributed(const bool on) noexcept
Change distributed flag.
Definition: faMeshDecomposition.H:169
Foam::faMeshDecomposition
Automatic faMesh decomposition class.
Definition: faMeshDecomposition.H:57
Foam::faMeshDecomposition::useGlobalFaceZones
bool useGlobalFaceZones() const noexcept
Are global face zones used.
Definition: faMeshDecomposition.H:177
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::List< label >
Foam::faMeshDecomposition::faMeshDecomposition
faMeshDecomposition(const polyMesh &mesh, const label nProcessors, const dictionary &params=dictionary::null)
Definition: faMeshDecomposition.C:163
Foam::faMeshDecomposition::~faMeshDecomposition
~faMeshDecomposition()=default
Destructor.
Foam::faMeshDecomposition::nProcs
label nProcs() const noexcept
Number of processor in decomposition.
Definition: faMeshDecomposition.H:157
PtrList.H
Foam::faMesh
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Definition: faMesh.H:82
Foam::faMeshDecomposition::distributed
bool distributed() const noexcept
Is decomposition data to be distributed for each processor.
Definition: faMeshDecomposition.H:163
Foam::faMeshDecomposition::writeDecomposition
bool writeDecomposition()
Write decomposition.
Definition: faMeshDecomposition.C:1143