lduPrimitiveMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 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::lduPrimitiveMesh
26 
27 Description
28  Simplest concrete lduMesh which stores the addressing needed by lduMatrix.
29 
30 SourceFiles
31  lduPrimitiveMesh.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef lduPrimitiveMesh_H
36 #define lduPrimitiveMesh_H
37 
38 #include "lduMesh.H"
39 #include "labelList.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class lduPrimitiveMesh Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class lduPrimitiveMesh
51 :
52  public lduMesh,
53  public lduAddressing
54 {
55  // Private Data
56 
57  //- Lower addressing
58  labelList lowerAddr_;
59 
60  //- Upper addressing
61  labelList upperAddr_;
62 
63  //- List of pointers for each patch
64  // with only those pointing to interfaces being set
65  lduInterfacePtrsList interfaces_;
66 
67  //- Concrete interfaces
68  PtrList<const lduInterface> primitiveInterfaces_;
69 
70  //- Patch field evaluation schedule
71  lduSchedule patchSchedule_;
72 
73  //- Communicator to use for any parallel communication
74  const label comm_;
75 
76 
77  // Private Member Functions
78 
79  //- Get size of all meshes
80  static label totalSize(const PtrList<lduPrimitiveMesh>&);
81 
82  static labelList upperTriOrder
83  (
84  const label nCells,
85  const labelUList& lower,
86  const labelUList& upper
87  );
88 
89  //- Check if in upper-triangular ordering
90  static void checkUpperTriangular
91  (
92  const label size,
93  const labelUList& l,
94  const labelUList& u
95  );
96 
97 
98 public:
99 
100  // Static data
101 
102  // Declare name of the class and its debug switch
103  ClassName("lduPrimitiveMesh");
104 
105  // Constructors
106 
107  //- Construct from components but without interfaces. Add interfaces
108  // separately using addInterfaces
110  (
111  const label nCells,
112  labelList& l,
113  labelList& u,
114  const label comm,
115  bool reuse
116  );
117 
118  //- Add interfaces to a mesh constructed without
119  void addInterfaces
120  (
122  const lduSchedule& ps
123  );
124 
125  //- Construct from components and reuse storage.
127  (
128  const label nCells,
129  labelList& l,
130  labelList& u,
131  PtrList<const lduInterface>& primitiveInterfaces,
132  const lduSchedule& ps,
133  const label comm
134  );
135 
136  //- Construct by combining multiple meshes. The meshes come from
137  // processors procIDs:
138  // procIDs[0] : local processor (myMesh)
139  // procIDs[i] : processor where otherMeshes[i-1] comes from
140  // procAgglomMap : for every processor which processor it agglomerates
141  // onto. The new processor numbers are in compact
142  // numbering (so ranks in communicator comm), i.e.
143  // similar to cell-restrict-addressing.
144  // We need this information to be able to map
145  // inter-processor interfaces
146  // cellOffsets : for every processor the offset it gets in the mesh
147  // faceMap : for every processor, for every face, the destination
148  // face. Negative for flipped faces.
149  // boundaryMap : for every processor, for every patch, -1 or the new
150  // patch index in the mesh.
151  // boundaryFaceMap : for every processor, for every patch, for every
152  // patch face:
153  // - the new internal face (if boundaryMap=-1)
154  // - the new patch face (if boundaryMap>=0)
155  // Faces becoming internal are negative for flipped
156  // faces.
158  (
159  const label comm,
160  const labelList& procAgglomMap,
161 
162  const labelList& procIDs,
163  const lduMesh& myMesh,
164  const PtrList<lduPrimitiveMesh>& otherMeshes,
165 
166  labelList& cellOffsets,
167  labelList& faceOffsets,
169  labelListList& boundaryMap,
170  labelListListList& boundaryFaceMap
171  );
172 
173  //- Disallow default bitwise copy construction
174  lduPrimitiveMesh(const lduPrimitiveMesh&) = delete;
175 
176 
177  //- Destructor
178  virtual ~lduPrimitiveMesh()
179  {}
180 
181 
182  // Member Functions
183 
184  // Access
185 
186  //- Return ldu addressing
187  virtual const lduAddressing& lduAddr() const
188  {
189  return *this;
190  }
191 
192  //- Return a list of pointers for each patch
193  // with only those pointing to interfaces being set
194  virtual lduInterfacePtrsList interfaces() const
195  {
196  return interfaces_;
197  }
198 
199  //- Return a list of pointers for each patch
200  // with only those pointing to interfaces being set
201  // (reference to cached interfaces)
202  const lduInterfacePtrsList& rawInterfaces() const
203  {
204  return interfaces_;
205  }
206 
207  //- Return communicator used for parallel communication
208  virtual label comm() const
209  {
210  return comm_;
211  }
212 
213  //- Return Lower addressing
214  virtual const labelUList& lowerAddr() const
215  {
216  return lowerAddr_;
217  }
218 
219  //- Return Upper addressing
220  virtual const labelUList& upperAddr() const
221  {
222  return upperAddr_;
223  }
224 
225  //- Return patch addressing
226  virtual const labelUList& patchAddr(const label i) const
227  {
228  return interfaces_[i].faceCells();
229  }
230 
231  //- Return patch evaluation schedule
232  virtual const lduSchedule& patchSchedule() const
233  {
234  return patchSchedule_;
235  }
236 
237 
238  // Helper
239 
240  //- Select either mesh0 (meshI is 0) or otherMeshes[meshI-1]
241  static const lduMesh& mesh
242  (
243  const lduMesh& mesh0,
244  const PtrList<lduPrimitiveMesh>& otherMeshes,
245  const label meshI
246  );
247 
248  //- Gather meshes from other processors onto procIDs[0].
249  // Received meshes get GAMGInterface and communicator comm
250  static void gather
251  (
252  const label comm,
253  const lduMesh& mesh,
254  const labelList& procIDs,
255  PtrList<lduPrimitiveMesh>& otherMeshes
256  );
257 
258  //- Get non-scheduled send/receive schedule
259  template<class ProcPatch>
261 
262 
263  // Member Operators
264 
265  //- Disallow default bitwise assignment
266  void operator=(const lduPrimitiveMesh&) = delete;
267 };
268 
269 
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 
272 } // End namespace Foam
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 #ifdef NoRepository
277  #include "lduPrimitiveMeshTemplates.C"
278 #endif
279 
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 
282 #endif
283 
284 // ************************************************************************* //
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
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:60
Simplest concrete lduMesh which stores the addressing needed by lduMatrix.
virtual ~lduPrimitiveMesh()
Destructor.
ClassName("lduPrimitiveMesh")
virtual const labelUList & patchAddr(const label i) const
Return patch addressing.
void addInterfaces(lduInterfacePtrsList &interfaces, const lduSchedule &ps)
Add interfaces to a mesh constructed without.
virtual const labelUList & lowerAddr() const
Return Lower addressing.
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
lduPrimitiveMesh(const label nCells, labelList &l, labelList &u, const label comm, bool reuse)
Construct from components but without interfaces. Add interfaces.
const lduInterfacePtrsList & rawInterfaces() const
Return a list of pointers for each patch.
virtual label comm() const
Return communicator used for parallel communication.
static lduSchedule nonBlockingSchedule(const lduInterfacePtrsList &)
Get non-scheduled send/receive schedule.
virtual const labelUList & upperAddr() const
Return Upper addressing.
static const lduMesh & mesh(const lduMesh &mesh0, const PtrList< lduPrimitiveMesh > &otherMeshes, const label meshI)
Select either mesh0 (meshI is 0) or otherMeshes[meshI-1].
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
virtual const lduSchedule & patchSchedule() const
Return patch evaluation schedule.
static void gather(const label comm, const lduMesh &mesh, const labelList &procIDs, PtrList< lduPrimitiveMesh > &otherMeshes)
Gather meshes from other processors onto procIDs[0].
void operator=(const lduPrimitiveMesh &)=delete
Disallow default bitwise assignment.
Namespace for OpenFOAM.
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
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)