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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::lduPrimitiveMesh
29
30Description
31 Simplest concrete lduMesh that stores the addressing needed by lduMatrix.
32
33SourceFiles
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
46namespace Foam
47{
48
49/*---------------------------------------------------------------------------*\
50 Class lduPrimitiveMesh Declaration
51\*---------------------------------------------------------------------------*/
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
92public:
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)
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
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
327#endif
328
329// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330
331#endif
332
333// ************************************************************************* //
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
The class contains the addressing required by the lduMatrix: upper, lower and losort.
label size() const
Return number of equations.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:63
Simplest concrete lduMesh that stores the addressing needed by lduMatrix.
virtual const labelUList & upperAddr() const
Return Upper addressing.
static void checkUpperTriangular(const label size, const labelUList &l, const labelUList &u)
Check if in upper-triangular ordering.
const lduInterfacePtrsList & rawInterfaces() const
Return a list of pointers for each patch.
ClassName("lduPrimitiveMesh")
static labelListList globalCellCells(const lduMesh &mesh, const globalIndex &globalNumbering)
Calculate global cell-cells.
void addInterfaces(lduInterfacePtrsList &interfaces, const lduSchedule &ps)
Add interfaces to a mesh constructed without.
virtual ~lduPrimitiveMesh()=default
Destructor.
PtrList< const lduInterface > & primitiveInterfaces()
Return a non-const list of primitive interfaces.
virtual labelList & upperAddr()
Return non-const Upper addressing.
static labelList upperTriOrder(const label nCells, const labelUList &lower, const labelUList &upper)
Calculate upper-triangular order.
virtual lduInterfacePtrsList & interfaces()
virtual const lduSchedule & patchSchedule() const
Return patch evaluation schedule.
virtual const labelUList & patchAddr(const label i) const
Return patch addressing.
virtual label comm() const
Return communicator used for parallel communication.
static lduSchedule nonBlockingSchedule(const lduInterfacePtrsList &)
Get non-scheduled send/receive schedule.
virtual lduInterfacePtrsList interfaces() const
virtual bool hasDb() const
Return true if thisDb() is a valid DB.
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
virtual lduAddressing & lduAddr()
Return non-const ldu addressing.
static void gather(const label comm, const lduMesh &mesh, const labelList &procIDs, PtrList< lduPrimitiveMesh > &otherMeshes)
Gather meshes from other processors onto procIDs[0].
virtual const labelUList & lowerAddr() const
Return Lower addressing.
virtual labelList & lowerAddr()
Return non-const Lower addressing.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
dynamicFvMesh & mesh
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)