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 | Copyright (C) 2011-2014 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::domainDecomposition
26 
27 Description
28  Automatic domain decomposition class for finite-volume meshes
29 
30 SourceFiles
31  domainDecomposition.C
32  decomposeMesh.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef domainDecomposition_H
37 #define domainDecomposition_H
38 
39 #include "fvMesh.H"
40 #include "labelList.H"
41 #include "SLList.H"
42 #include "PtrList.H"
43 #include "point.H"
44 #include "Time.H"
45 #include "volFields.H"
46 
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class domainDecomposition Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 :
57  public fvMesh
58 {
59  // Private data
60 
61  //- Optional: points at the facesInstance
63 
64  //- Optional non-standard file for decomposeParDict
66 
67  //- Number of processors in decomposition
68  label nProcs_;
69 
70  //- Is the decomposition data to be distributed for each processor
71  bool distributed_;
72 
73  //- Processor label for each cell
75 
76  //- Labels of points for each processor
78 
79  //- Labels of faces for each processor
80  // Note: Face turning index is stored as the sign on addressing
81  // Only the processor boundary faces are affected: if the sign of the
82  // index is negative, the processor face is the reverse of the
83  // original face. In order to do this properly, all face
84  // indices will be incremented by 1 and the decremented as
85  // necessary to avoid the problem of face number zero having no
86  // sign.
88 
89  //- Labels of cells for each processor
91 
92  //- Sizes for processor mesh patches
93  // Excludes inter-processor boundaries
95 
96  //- Start indices for processor patches
97  // Excludes inter-processor boundaries
99 
100 
101  // Per inter-processor patch information
102 
103  //- Neighbour processor ID for inter-processor boundaries
105 
106  //- Sizes for inter-processor patches
108 
109  //- Start indices (in procFaceAddressing_) for inter-processor patches
111 
112  //- Sub patch IDs for inter-processor patches
114 
115  //- Sub patch sizes for inter-processor patches
117 
118  // Private Member Functions
119 
120  void distributeCells();
121 
122  //- Mark all elements with value or -2 if occur twice
123  static void mark
124  (
125  const labelList& zoneElems,
126  const label zoneI,
127  labelList& elementToZone
128  );
129 
130  //- Append single element to list
131  static void append(labelList&, const label);
132 
133  //- Add face to inter-processor patch
134  void addInterProcFace
135  (
136  const label facei,
137  const label ownerProc,
138  const label nbrProc,
139 
140  List<Map<label> >&,
142  ) const;
143 
144  //- Generate sub patch info for processor cyclics
145  template <class BinaryOp>
147  (
148  const polyBoundaryMesh& patches,
149  List<DynamicList<DynamicList<label> > >& interPatchFaces,
150  List<Map<label> >& procNbrToInterPatch,
151  List<labelListList>& subPatchIDs,
152  List<labelListList>& subPatchStarts,
153  bool owner,
154  BinaryOp bop
155  ) const;
156 
157 
158 public:
159 
160  // Constructors
161 
162  //- Construct from IOobjects (for mesh and optional non-standard
163  // decomposeParDict location)
165  (
166  const IOobject& io,
167  const fileName& decompDictFile = ""
168  );
169 
170 
171  //- Destructor
173 
174 
175  // Member Functions
176 
177  //- Number of processor in decomposition
178  label nProcs() const
179  {
180  return nProcs_;
181  }
182 
183  //- Is the decomposition data to be distributed for each processor
184  bool distributed() const
185  {
186  return distributed_;
187  }
188 
189  //- Decompose mesh.
190  void decomposeMesh();
191 
192  //- Write decomposition
193  bool writeDecomposition(const bool decomposeSets);
194 
195  //- Cell-processor decomposition labels
196  const labelList& cellToProc() const
197  {
198  return cellToProc_;
199  }
200 };
201 
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 } // End namespace Foam
206 
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #ifdef NoRepository
211  #include "domainDecompositionTemplates.C"
212 #endif
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #endif
217 
218 // ************************************************************************* //
Foam::domainDecomposition::procFaceAddressing_
List< DynamicList< label > > procFaceAddressing_
Labels of faces for each processor.
Definition: domainDecomposition.H:86
volFields.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::domainDecomposition::domainDecomposition
domainDecomposition(const IOobject &io, const fileName &decompDictFile="")
Construct from IOobjects (for mesh and optional non-standard.
Definition: domainDecomposition.C:74
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:56
Foam::domainDecomposition::facesInstancePointsPtr_
autoPtr< pointIOField > facesInstancePointsPtr_
Optional: points at the facesInstance.
Definition: domainDecomposition.H:61
Foam::domainDecomposition::distributed_
bool distributed_
Is the decomposition data to be distributed for each processor.
Definition: domainDecomposition.H:70
point.H
Foam::Map< label >
Foam::domainDecomposition::nProcs
label nProcs() const
Number of processor in decomposition.
Definition: domainDecomposition.H:177
Foam::domainDecomposition::mark
static void mark(const labelList &zoneElems, const label zoneI, labelList &elementToZone)
Mark all elements with value or -2 if occur twice.
Definition: domainDecomposition.C:46
Foam::domainDecomposition::~domainDecomposition
~domainDecomposition()
Destructor.
Definition: domainDecomposition.C:133
Foam::domainDecomposition::processInterCyclics
void processInterCyclics(const polyBoundaryMesh &patches, List< DynamicList< DynamicList< label > > > &interPatchFaces, List< Map< label > > &procNbrToInterPatch, List< labelListList > &subPatchIDs, List< labelListList > &subPatchStarts, bool owner, BinaryOp bop) const
Generate sub patch info for processor cyclics.
Definition: domainDecompositionTemplates.C:32
Foam::domainDecomposition::append
static void append(labelList &, const label)
Append single element to list.
Definition: domainDecompositionMesh.C:40
Foam::domainDecomposition::procProcessorPatchSubPatchStarts_
List< labelListList > procProcessorPatchSubPatchStarts_
Sub patch sizes for inter-processor patches.
Definition: domainDecomposition.H:115
Foam::domainDecomposition::procPatchSize_
labelListList procPatchSize_
Sizes for processor mesh patches.
Definition: domainDecomposition.H:93
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
labelList.H
Foam::domainDecomposition::writeDecomposition
bool writeDecomposition(const bool decomposeSets)
Write decomposition.
Definition: domainDecomposition.C:139
Foam::domainDecomposition::procCellAddressing_
labelListList procCellAddressing_
Labels of cells for each processor.
Definition: domainDecomposition.H:89
Foam::domainDecomposition
Automatic domain decomposition class for finite-volume meshes.
Definition: domainDecomposition.H:54
Foam::domainDecomposition::distributed
bool distributed() const
Is the decomposition data to be distributed for each processor.
Definition: domainDecomposition.H:183
Foam::domainDecomposition::decompDictFile_
const fileName decompDictFile_
Optional non-standard file for decomposeParDict.
Definition: domainDecomposition.H:64
Foam::domainDecomposition::procProcessorPatchSubPatchIDs_
List< labelListList > procProcessorPatchSubPatchIDs_
Sub patch IDs for inter-processor patches.
Definition: domainDecomposition.H:112
Foam::domainDecomposition::cellToProc_
labelList cellToProc_
Processor label for each cell.
Definition: domainDecomposition.H:73
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::domainDecomposition::distributeCells
void distributeCells()
Definition: domainDecompositionDistribute.C:37
Foam::fvMesh::owner
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:282
Foam::domainDecomposition::procProcessorPatchSize_
labelListList procProcessorPatchSize_
Sizes for inter-processor patches.
Definition: domainDecomposition.H:106
Foam::domainDecomposition::nProcs_
label nProcs_
Number of processors in decomposition.
Definition: domainDecomposition.H:67
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::domainDecomposition::decomposeMesh
void decomposeMesh()
Decompose mesh.
Definition: domainDecompositionMesh.C:97
SLList.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::domainDecomposition::cellToProc
const labelList & cellToProc() const
Cell-processor decomposition labels.
Definition: domainDecomposition.H:195
Foam::domainDecomposition::addInterProcFace
void addInterProcFace(const label facei, const label ownerProc, const label nbrProc, List< Map< label > > &, List< DynamicList< DynamicList< label > > > &) const
Add face to inter-processor patch.
Definition: domainDecompositionMesh.C:49
Foam::domainDecomposition::procNeighbourProcessors_
labelListList procNeighbourProcessors_
Neighbour processor ID for inter-processor boundaries.
Definition: domainDecomposition.H:103
Foam::domainDecomposition::procProcessorPatchStartIndex_
labelListList procProcessorPatchStartIndex_
Start indices (in procFaceAddressing_) for inter-processor patches.
Definition: domainDecomposition.H:109
PtrList.H
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::domainDecomposition::procPointAddressing_
labelListList procPointAddressing_
Labels of points for each processor.
Definition: domainDecomposition.H:76
Foam::domainDecomposition::procPatchStartIndex_
labelListList procPatchStartIndex_
Start indices for processor patches.
Definition: domainDecomposition.H:97