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 contrete lduMesh which 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 components but without interfaces. Add interfaces
103  // separately using addInterfaces
105  (
106  const label nCells,
107  labelList& l,
108  labelList& u,
109  const label comm,
110  bool reuse
111  );
112 
113  //- Add interfaces to a mesh constructed without
114  void addInterfaces
115  (
117  const lduSchedule& ps
118  );
119 
120  //- Construct from components and re-use storage.
122  (
123  const label nCells,
124  labelList& l,
125  labelList& u,
126  PtrList<const lduInterface>& primitiveInterfaces,
127  const lduSchedule& ps,
128  const label comm
129  );
130 
131  //- Construct by combining multiple meshes. The meshes come from
132  // processors procIDs:
133  // procIDs[0] : local processor (myMesh)
134  // procIDs[i] : processor where otherMeshes[i-1] comes from
135  // procAgglomMap : for every processor which processor it agglomerates
136  // onto. The new processor numbers are in compact
137  // numbering (so ranks in communicator comm), i.e.
138  // similar to cell-restrict-addressing.
139  // We need this information to be able to map
140  // inter-processor interfaces
141  // cellOffsets : for every processor the offset it gets in the mesh
142  // faceMap : for every processor, for every face, the destination
143  // face. Negative for flipped faces.
144  // boundaryMap : for every processor, for every patch, -1 or the new
145  // patch index in the mesh.
146  // boundaryFaceMap : for every processor, for every patch, for every
147  // patch face:
148  // - the new internal face (if boundaryMap=-1)
149  // - the new patch face (if boundaryMap>=0)
150  // Faces becoming internal are negative for flipped
151  // faces.
153  (
154  const label comm,
155  const labelList& procAgglomMap,
156 
157  const labelList& procIDs,
158  const lduMesh& myMesh,
159  const PtrList<lduPrimitiveMesh>& otherMeshes,
160 
161  labelList& cellOffsets,
162  labelList& faceOffsets,
164  labelListList& boundaryMap,
165  labelListListList& boundaryFaceMap
166  );
167 
168 
169  //- Destructor
170  virtual ~lduPrimitiveMesh() = default;
171 
172 
173  // Member Functions
174 
175  // Access
176 
177  //- Return true if thisDb() is a valid DB
178  virtual bool hasDb() const
179  {
180  return false;
181  }
182 
183  //- Return ldu addressing
184  virtual const lduAddressing& lduAddr() const
185  {
186  return *this;
187  }
188 
189  //- Return a list of pointers for each patch
190  // with only those pointing to interfaces being set
191  virtual lduInterfacePtrsList interfaces() const
192  {
193  return interfaces_;
194  }
195 
196  //- Return a list of pointers for each patch
197  // with only those pointing to interfaces being set
198  // (reference to cached interfaces)
199  const lduInterfacePtrsList& rawInterfaces() const
200  {
201  return interfaces_;
202  }
203 
204  //- Return communicator used for parallel communication
205  virtual label comm() const
206  {
207  return comm_;
208  }
209 
210  //- Return Lower addressing
211  virtual const labelUList& lowerAddr() const
212  {
213  return lowerAddr_;
214  }
215 
216  //- Return Upper addressing
217  virtual const labelUList& upperAddr() const
218  {
219  return upperAddr_;
220  }
221 
222  //- Return patch addressing
223  virtual const labelUList& patchAddr(const label i) const
224  {
225  return interfaces_[i].faceCells();
226  }
227 
228  //- Return patch evaluation schedule
229  virtual const lduSchedule& patchSchedule() const
230  {
231  return patchSchedule_;
232  }
233 
234 
235  // Helper
236 
237  //- Select either mesh0 (meshI is 0) or otherMeshes[meshI-1]
238  static const lduMesh& mesh
239  (
240  const lduMesh& mesh0,
241  const PtrList<lduPrimitiveMesh>& otherMeshes,
242  const label meshI
243  );
244 
245  //- Gather meshes from other processors onto procIDs[0].
246  // Received meshes get GAMGInterface and communicator comm
247  static void gather
248  (
249  const label comm,
250  const lduMesh& mesh,
251  const labelList& procIDs,
252  PtrList<lduPrimitiveMesh>& otherMeshes
253  );
254 
255  //- Get non-scheduled send/receive schedule
256  template<class ProcPatch>
258 
259  //- Calculate upper-triangular order
260  static labelList upperTriOrder
261  (
262  const label nCells,
263  const labelUList& lower,
264  const labelUList& upper
265  );
266 
267  //- Check if in upper-triangular ordering
268  static void checkUpperTriangular
269  (
270  const label size,
271  const labelUList& l,
272  const labelUList& u
273  );
274 };
275 
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 } // End namespace Foam
280 
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 
283 #ifdef NoRepository
284  #include "lduPrimitiveMeshTemplates.C"
285 #endif
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 #endif
290 
291 // ************************************************************************* //
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:177
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
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:949
Foam::lduPrimitiveMesh::addInterfaces
void addInterfaces(lduInterfacePtrsList &interfaces, const lduSchedule &ps)
Add interfaces to a mesh constructed without.
Definition: lduPrimitiveMesh.C:221
Foam::lduPrimitiveMesh::patchSchedule
virtual const lduSchedule & patchSchedule() const
Return patch evaluation schedule.
Definition: lduPrimitiveMesh.H:228
Foam::lduPrimitiveMesh::patchAddr
virtual const labelUList & patchAddr(const label i) const
Return patch addressing.
Definition: lduPrimitiveMesh.H:222
Foam::lduPrimitiveMesh::upperAddr
virtual const labelUList & upperAddr() const
Return Upper addressing.
Definition: lduPrimitiveMesh.H:216
Foam::lduPrimitiveMesh::upperTriOrder
static labelList upperTriOrder(const label nCells, const labelUList &lower, const labelUList &upper)
Calculate upper-triangular order.
Definition: lduPrimitiveMesh.C:132
Foam::lduPrimitiveMesh::checkUpperTriangular
static void checkUpperTriangular(const label size, const labelUList &l, const labelUList &u)
Check if in upper-triangular ordering.
Definition: lduPrimitiveMesh.C:64
Foam::lduAddressing::size
label size() const
Return number of equations.
Definition: lduAddressing.H:171
Foam::lduPrimitiveMesh::interfaces
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
Definition: lduPrimitiveMesh.H:190
Foam::stringOps::lower
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
Definition: stringOps.C:1186
Foam::lduPrimitiveMesh::comm
virtual label comm() const
Return communicator used for parallel communication.
Definition: lduPrimitiveMesh.H:204
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:62
Foam::lduPrimitiveMesh::lowerAddr
virtual const labelUList & lowerAddr() const
Return Lower addressing.
Definition: lduPrimitiveMesh.H:210
Foam::lduPrimitiveMesh::ClassName
ClassName("lduPrimitiveMesh")
lduPrimitiveMeshTemplates.C
Foam::lduPrimitiveMesh::lduAddr
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
Definition: lduPrimitiveMesh.H:183
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
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:938
Foam::lduPrimitiveMesh
Simplest contrete lduMesh which stores the addressing needed by lduMatrix.
Definition: lduPrimitiveMesh.H:52
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:1202
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::lduInterfacePtrsList
UPtrList< const lduInterface > lduInterfacePtrsList
List of coupled interface fields to be used in coupling.
Definition: lduInterfacePtrsList.H:44
Foam::lduPrimitiveMesh::rawInterfaces
const lduInterfacePtrsList & rawInterfaces() const
Return a list of pointers for each patch.
Definition: lduPrimitiveMesh.H:198