lduPrimitiveMesh.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) 2016-2019 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::lduPrimitiveMesh
29 
30 Description
31  Simplest concrete lduMesh that stores the addressing needed by lduMatrix.
32 
33 SourceFiles
34  lduPrimitiveMesh.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef lduPrimitiveMesh_H
39 #define lduPrimitiveMesh_H
40 
41 #include "lduMesh.H"
42 #include "labelList.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class lduPrimitiveMesh Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class lduPrimitiveMesh
54 :
55  public lduMesh,
56  public lduAddressing
57 {
58  // Private data
59 
60  //- Lower addressing
61  labelList lowerAddr_;
62 
63  //- Upper addressing
64  labelList upperAddr_;
65 
66  //- List of pointers for each patch
67  // with only those pointing to interfaces being set
68  lduInterfacePtrsList interfaces_;
69 
70  //- Concrete interfaces
71  PtrList<const lduInterface> primitiveInterfaces_;
72 
73  //- Patch field evaluation schedule
74  lduSchedule patchSchedule_;
75 
76  //- Communicator to use for any parallel communication
77  const label comm_;
78 
79 
80  // Private Member Functions
81 
82  //- Get size of all meshes
83  static label totalSize(const PtrList<lduPrimitiveMesh>&);
84 
85  //- No copy construct
86  lduPrimitiveMesh(const lduPrimitiveMesh&) = delete;
87 
88  //- No copy assignment
89  void operator=(const lduPrimitiveMesh&) = delete;
90 
91 
92 public:
93 
94  // Static data
95 
96  // Declare name of the class and its debug switch
97  ClassName("lduPrimitiveMesh");
98 
99 
100  // Constructors
101 
102  //- Construct from number of cells
103  explicit lduPrimitiveMesh(const label nCells);
104 
105  //- Construct from components but without interfaces. Add interfaces
106  // separately using addInterfaces
108  (
109  const label nCells,
110  labelList& l,
111  labelList& u,
112  const label comm,
113  bool reuse
114  );
115 
116 
117  //- Add interfaces to a mesh constructed without
118  void addInterfaces
119  (
121  const lduSchedule& ps
122  );
123 
124  //- Construct from components and re-use storage.
126  (
127  const label nCells,
128  labelList& l,
129  labelList& u,
131  const lduSchedule& ps,
132  const label comm
133  );
134 
135  //- Construct by combining multiple meshes. The meshes come from
136  // processors procIDs:
137  // procIDs[0] : local processor (myMesh)
138  // procIDs[i] : processor where otherMeshes[i-1] comes from
139  // procAgglomMap : for every processor which processor it agglomerates
140  // onto. The new processor numbers are in compact
141  // numbering (so ranks in communicator comm), i.e.
142  // similar to cell-restrict-addressing.
143  // We need this information to be able to map
144  // inter-processor interfaces
145  // cellOffsets : for every processor the offset it gets in the mesh
146  // faceMap : for every processor, for every face, the destination
147  // face. Negative for flipped faces.
148  // boundaryMap : for every processor, for every patch, -1 or the new
149  // patch index in the mesh.
150  // boundaryFaceMap : for every processor, for every patch, for every
151  // patch face:
152  // - the new internal face (if boundaryMap=-1)
153  // - the new patch face (if boundaryMap>=0)
154  // Faces becoming internal are negative for flipped
155  // faces.
157  (
158  const label comm,
159  const labelList& procAgglomMap,
160 
161  const labelList& procIDs,
162  const lduMesh& myMesh,
163  const PtrList<lduPrimitiveMesh>& otherMeshes,
164 
165  labelList& cellOffsets,
166  labelList& faceOffsets,
168  labelListList& boundaryMap,
169  labelListListList& boundaryFaceMap
170  );
171 
172 
173  //- Destructor
174  virtual ~lduPrimitiveMesh() = default;
175 
176 
177  // Member Functions
178 
179  // Access
180 
181  //- Return true if thisDb() is a valid DB
182  virtual bool hasDb() const
183  {
184  return false;
185  }
186 
187  //- Return ldu addressing
188  virtual const lduAddressing& lduAddr() const
189  {
190  return *this;
191  }
192 
193  //- Return non-const ldu addressing
194  virtual lduAddressing& lduAddr()
195  {
196  return *this;
197  }
198 
199  //- Return a list of pointers for each patch
200  //- with only those pointing to interfaces being set
201  virtual lduInterfacePtrsList interfaces() const
202  {
203  return interfaces_;
204  }
205 
206  //- Return a non-const list of pointers for each patch
207  //- with only those pointing to interfaces being set
209  {
210  return interfaces_;
211  }
212 
213  //- Return a non-const list of primitive interfaces
215  {
216  return primitiveInterfaces_;
217  }
218 
219  //- Return a list of pointers for each patch
220  // with only those pointing to interfaces being set
221  // (reference to cached interfaces)
222  const lduInterfacePtrsList& rawInterfaces() const
223  {
224  return interfaces_;
225  }
226 
227  //- Return communicator used for parallel communication
228  virtual label comm() const
229  {
230  return comm_;
231  }
232 
233  //- Return Lower addressing
234  virtual const labelUList& lowerAddr() const
235  {
236  return lowerAddr_;
237  }
238 
239  //- Return Upper addressing
240  virtual const labelUList& upperAddr() const
241  {
242  return upperAddr_;
243  }
244 
245  //- Return non-const Lower addressing
246  virtual labelList& lowerAddr()
247  {
248  return lowerAddr_;
249  }
250 
251  //- Return non-const Upper addressing
252  virtual labelList& upperAddr()
253  {
254  return upperAddr_;
255  }
256 
257  //- Return patch addressing
258  virtual const labelUList& patchAddr(const label i) const
259  {
260  return interfaces_[i].faceCells();
261  }
262 
263  //- Return patch evaluation schedule
264  virtual const lduSchedule& patchSchedule() const
265  {
266  return patchSchedule_;
267  }
268 
269 
270  // Helper
271 
272  //- Select either mesh0 (meshI is 0) or otherMeshes[meshI-1]
273  static const lduMesh& mesh
274  (
275  const lduMesh& mesh0,
276  const PtrList<lduPrimitiveMesh>& otherMeshes,
277  const label meshI
278  );
279 
280  //- Gather meshes from other processors onto procIDs[0].
281  // Received meshes get GAMGInterface and communicator comm
282  static void gather
283  (
284  const label comm,
285  const lduMesh& mesh,
286  const labelList& procIDs,
287  PtrList<lduPrimitiveMesh>& otherMeshes
288  );
289 
290  //- Get non-scheduled send/receive schedule
291  template<class ProcPatch>
293 
294  //- Calculate upper-triangular order
295  static labelList upperTriOrder
296  (
297  const label nCells,
298  const labelUList& lower,
299  const labelUList& upper
300  );
301 
302  //- Check if in upper-triangular ordering
303  static void checkUpperTriangular
304  (
305  const label size,
306  const labelUList& l,
307  const labelUList& u
308  );
309 
310  //- Calculate global cell-cells
312  (
313  const lduMesh& mesh,
314  const globalIndex& globalNumbering
315  );
316 };
317 
318 
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
320 
321 } // End namespace Foam
322 
323 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
324 
325 #ifdef NoRepository
326  #include "lduPrimitiveMeshTemplates.C"
327 #endif
328 
329 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 
331 #endif
332 
333 // ************************************************************************* //
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
Foam::lduPrimitiveMesh::hasDb
virtual bool hasDb() const
Return true if thisDb() is a valid DB.
Definition: lduPrimitiveMesh.H:181
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
Foam::lduPrimitiveMesh::interfaces
virtual lduInterfacePtrsList & interfaces()
Definition: lduPrimitiveMesh.H:207
Foam::lduPrimitiveMesh::gather
static void gather(const label comm, const lduMesh &mesh, const labelList &procIDs, PtrList< lduPrimitiveMesh > &otherMeshes)
Gather meshes from other processors onto procIDs[0].
Definition: lduPrimitiveMesh.C:1083
Foam::lduPrimitiveMesh::addInterfaces
void addInterfaces(lduInterfacePtrsList &interfaces, const lduSchedule &ps)
Add interfaces to a mesh constructed without.
Definition: lduPrimitiveMesh.C:349
Foam::lduPrimitiveMesh::patchSchedule
virtual const lduSchedule & patchSchedule() const
Return patch evaluation schedule.
Definition: lduPrimitiveMesh.H:263
Foam::lduPrimitiveMesh::globalCellCells
static labelListList globalCellCells(const lduMesh &mesh, const globalIndex &globalNumbering)
Calculate global cell-cells.
Definition: lduPrimitiveMesh.C:118
Foam::lduPrimitiveMesh::patchAddr
virtual const labelUList & patchAddr(const label i) const
Return patch addressing.
Definition: lduPrimitiveMesh.H:257
Foam::lduPrimitiveMesh::upperAddr
virtual const labelUList & upperAddr() const
Return Upper addressing.
Definition: lduPrimitiveMesh.H:239
Foam::lduPrimitiveMesh::upperTriOrder
static labelList upperTriOrder(const label nCells, const labelUList &lower, const labelUList &upper)
Calculate upper-triangular order.
Definition: lduPrimitiveMesh.C:259
Foam::lduPrimitiveMesh::checkUpperTriangular
static void checkUpperTriangular(const label size, const labelUList &l, const labelUList &u)
Check if in upper-triangular ordering.
Definition: lduPrimitiveMesh.C:65
Foam::lduPrimitiveMesh::lowerAddr
virtual labelList & lowerAddr()
Return non-const Lower addressing.
Definition: lduPrimitiveMesh.H:245
Foam::lduAddressing::size
label size() const
Return number of equations.
Definition: lduAddressing.H:171
Foam::lduPrimitiveMesh::lduAddr
virtual lduAddressing & lduAddr()
Return non-const ldu addressing.
Definition: lduPrimitiveMesh.H:193
Foam::lduPrimitiveMesh::primitiveInterfaces
PtrList< const lduInterface > & primitiveInterfaces()
Return a non-const list of primitive interfaces.
Definition: lduPrimitiveMesh.H:213
Foam::lduPrimitiveMesh::interfaces
virtual lduInterfacePtrsList interfaces() const
Definition: lduPrimitiveMesh.H:200
Foam::stringOps::lower
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
Definition: stringOps.C:1184
Foam::lduPrimitiveMesh::comm
virtual label comm() const
Return communicator used for parallel communication.
Definition: lduPrimitiveMesh.H:227
Foam::lduPrimitiveMesh::nonBlockingSchedule
static lduSchedule nonBlockingSchedule(const lduInterfacePtrsList &)
Get non-scheduled send/receive schedule.
labelList.H
Foam::UPtrList< const lduInterface >
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::lduPrimitiveMesh::lowerAddr
virtual const labelUList & lowerAddr() const
Return Lower addressing.
Definition: lduPrimitiveMesh.H:233
Foam::lduPrimitiveMesh::ClassName
ClassName("lduPrimitiveMesh")
lduPrimitiveMeshTemplates.C
Foam::lduPrimitiveMesh::lduAddr
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
Definition: lduPrimitiveMesh.H:187
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::globalIndex
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
Foam::lduPrimitiveMesh::mesh
static const lduMesh & mesh(const lduMesh &mesh0, const PtrList< lduPrimitiveMesh > &otherMeshes, const label meshI)
Select either mesh0 (meshI is 0) or otherMeshes[meshI-1].
Definition: lduPrimitiveMesh.C:1072
Foam::lduPrimitiveMesh
Simplest concrete lduMesh that stores the addressing needed by lduMatrix.
Definition: lduPrimitiveMesh.H:52
Foam::lduPrimitiveMesh::upperAddr
virtual labelList & upperAddr()
Return non-const Upper addressing.
Definition: lduPrimitiveMesh.H:251
Foam::List< label >
Foam::UList< label >
Foam::lduPrimitiveMesh::~lduPrimitiveMesh
virtual ~lduPrimitiveMesh()=default
Destructor.
Foam::stringOps::upper
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
Definition: stringOps.C:1200
lduMesh.H
Foam::lduMesh
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:62
Foam::lduPrimitiveMesh::rawInterfaces
const lduInterfacePtrsList & rawInterfaces() const
Return a list of pointers for each patch.
Definition: lduPrimitiveMesh.H:221