domainDecomposition.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 -------------------------------------------------------------------------------
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::domainDecomposition
28 
29 Description
30  Automatic domain decomposition class for finite-volume meshes
31 
32 SourceFiles
33  domainDecomposition.C
34  decomposeMesh.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef domainDecomposition_H
39 #define domainDecomposition_H
40 
41 #include "fvMesh.H"
42 #include "labelList.H"
43 #include "SLList.H"
44 #include "PtrList.H"
45 #include "point.H"
46 #include "Time.H"
47 #include "volFields.H"
48 
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class domainDecomposition Declaration
55 \*---------------------------------------------------------------------------*/
56 
58 :
59  public fvMesh
60 {
61  // Private data
62 
63  //- Optional: points at the facesInstance
64  autoPtr<pointIOField> facesInstancePointsPtr_;
65 
66  //- Optional non-standard file for decomposeParDict
67  const fileName decompDictFile_;
68 
69  //- Number of processors in decomposition
70  label nProcs_;
71 
72  //- Is the decomposition data to be distributed for each processor
73  bool distributed_;
74 
75  //- Processor label for each cell
76  labelList cellToProc_;
77 
78  //- Labels of points for each processor
79  labelListList procPointAddressing_;
80 
81  //- Labels of faces for each processor
82  // Note: Face turning index is stored as the sign on addressing
83  // Only the processor boundary faces are affected: if the sign of the
84  // index is negative, the processor face is the reverse of the
85  // original face. In order to do this properly, all face
86  // indices will be incremented by 1 and the decremented as
87  // necessary to avoid the problem of face number zero having no
88  // sign.
89  List<DynamicList<label>> procFaceAddressing_;
90 
91  //- Labels of cells for each processor
92  labelListList procCellAddressing_;
93 
94  //- Sizes for processor mesh patches
95  // Excludes inter-processor boundaries
96  labelListList procPatchSize_;
97 
98  //- Start indices for processor patches
99  // Excludes inter-processor boundaries
100  labelListList procPatchStartIndex_;
101 
102 
103  // Per inter-processor patch information
104 
105  //- Neighbour processor ID for inter-processor boundaries
106  labelListList procNeighbourProcessors_;
107 
108  //- Sizes for inter-processor patches
109  labelListList procProcessorPatchSize_;
110 
111  //- Start indices (in procFaceAddressing_) for inter-processor patches
112  labelListList procProcessorPatchStartIndex_;
113 
114  //- Sub patch IDs for inter-processor patches
115  List<labelListList> procProcessorPatchSubPatchIDs_;
116 
117  //- Sub patch sizes for inter-processor patches
118  List<labelListList> procProcessorPatchSubPatchStarts_;
119 
120  // Private Member Functions
121 
122  void distributeCells();
123 
124  //- Mark all elements with value or -2 if occur twice
125  static void mark
126  (
127  const labelList& zoneElems,
128  const label zoneI,
129  labelList& elementToZone
130  );
131 
132  //- Append single element to list
133  static void append(labelList&, const label);
134 
135  //- Add face to inter-processor patch
136  void addInterProcFace
137  (
138  const label facei,
139  const label ownerProc,
140  const label nbrProc,
141 
142  List<Map<label>>&,
144  ) const;
145 
146  //- Generate sub patch info for processor cyclics
147  template<class BinaryOp>
148  void processInterCyclics
149  (
150  const polyBoundaryMesh& patches,
151  List<DynamicList<DynamicList<label>>>& interPatchFaces,
152  List<Map<label>>& procNbrToInterPatch,
153  List<labelListList>& subPatchIDs,
154  List<labelListList>& subPatchStarts,
155  bool owner,
156  BinaryOp bop
157  ) const;
158 
159 
160 public:
161 
162  // Constructors
163 
164  //- Construct from components.
165  // \param io the IOobject for mesh
166  // \param decompDictFile optional non-standard location for the
167  // decomposeParDict file
169  (
170  const IOobject& io,
171  const fileName& decompDictFile = ""
172  );
173 
174 
175  //- Destructor
176  ~domainDecomposition() = default;
177 
178 
179  // Member Functions
180 
181  //- Number of processor in decomposition
182  label nProcs() const
183  {
184  return nProcs_;
185  }
186 
187  //- Is the decomposition data to be distributed for each processor
188  bool distributed() const
189  {
190  return distributed_;
191  }
192 
193  //- Decompose mesh
194  void decomposeMesh();
195 
196  //- Write decomposition
197  bool writeDecomposition(const bool decomposeSets);
198 
199  //- Cell-processor decomposition labels
200  const labelList& cellToProc() const
201  {
202  return cellToProc_;
203  }
204 };
205 
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 } // End namespace Foam
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 #ifdef NoRepository
215 #endif
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #endif
220 
221 // ************************************************************************* //
volFields.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::domainDecomposition::domainDecomposition
domainDecomposition(const IOobject &io, const fileName &decompDictFile="")
Construct from components.
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:62
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:55
point.H
Foam::Map< label >
Foam::domainDecomposition::nProcs
label nProcs() const
Number of processor in decomposition.
Definition: domainDecomposition.H:181
labelList.H
Foam::domainDecomposition::writeDecomposition
bool writeDecomposition(const bool decomposeSets)
Write decomposition.
Foam::domainDecomposition
Automatic domain decomposition class for finite-volume meshes.
Definition: domainDecomposition.H:56
Foam::domainDecomposition::distributed
bool distributed() const
Is the decomposition data to be distributed for each processor.
Definition: domainDecomposition.H:187
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fvMesh::owner
const labelUList & owner() const
Internal face owner. Note bypassing virtual mechanism so.
Definition: fvMesh.H:405
domainDecompositionTemplates.C
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::domainDecomposition::decomposeMesh
void decomposeMesh()
Decompose mesh.
SLList.H
Non-intrusive singly-linked list.
Foam::List< label >
Foam::domainDecomposition::cellToProc
const labelList & cellToProc() const
Cell-processor decomposition labels.
Definition: domainDecomposition.H:199
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
PtrList.H
Foam::domainDecomposition::~domainDecomposition
~domainDecomposition()=default
Destructor.