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 | Copyright (C) 2011-2013 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 contrete 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  // Private Member Functions
77 
78  //- Get size of all meshes
79  static label totalSize(const PtrList<lduPrimitiveMesh>&);
80 
81  static labelList upperTriOrder
82  (
83  const label nCells,
84  const labelUList& lower,
85  const labelUList& upper
86  );
87 
88  //- Check if in upper-triangular ordering
89  static void checkUpperTriangular
90  (
91  const label size,
92  const labelUList& l,
93  const labelUList& u
94  );
95 
96  //- Disallow default bitwise copy construct
98 
99  //- Disallow default bitwise assignment
100  void operator=(const lduPrimitiveMesh&);
101 
102 
103 public:
104 
105  // Static data
106 
107  // Declare name of the class and its debug switch
108  ClassName("lduPrimitiveMesh");
109 
110  // Constructors
111 
112  //- Construct from components but without interfaces. Add interfaces
113  // separately using addInterfaces
115  (
116  const label nCells,
117  labelList& l,
118  labelList& u,
119  const label comm,
120  bool reUse
121  );
122 
123  //- Add interfaces to a mesh constructed without
124  void addInterfaces
125  (
127  const lduSchedule& ps
128  );
129 
130  //- Construct from components and re-use storage.
132  (
133  const label nCells,
134  labelList& l,
135  labelList& u,
136  PtrList<const lduInterface>& primitiveInterfaces,
137  const lduSchedule& ps,
138  const label comm
139  );
140 
141  //- Construct by combining multiple meshes. The meshes come from
142  // processors procIDs:
143  // procIDs[0] : local processor (myMesh)
144  // procIDs[i] : processor where otherMeshes[i-1] comes from
145  // procAgglomMap : for every processor which processor it agglomerates
146  // onto. The new processor numbers are in compact
147  // numbering (so ranks in communicator comm), i.e.
148  // similar to cell-restrict-addressing.
149  // We need this information to be able to map
150  // inter-processor interfaces
151  // cellOffsets : for every processor the offset it gets in the mesh
152  // faceMap : for every processor, for every face, the destination
153  // face. Negative for flipped faces.
154  // boundaryMap : for every processor, for every patch, -1 or the new
155  // patch index in the mesh.
156  // boundaryFaceMap : for every processor, for every patch, for every
157  // patch face:
158  // - the new internal face (if boundaryMap=-1)
159  // - the new patch face (if boundaryMap>=0)
160  // Faces becoming internal are negative for flipped
161  // faces.
163  (
164  const label comm,
165  const labelList& procAgglomMap,
166 
167  const labelList& procIDs,
168  const lduMesh& myMesh,
169  const PtrList<lduPrimitiveMesh>& otherMeshes,
170 
171  labelList& cellOffsets,
172  labelList& faceOffsets,
174  labelListList& boundaryMap,
175  labelListListList& boundaryFaceMap
176  );
177 
178 
179  //- Destructor
180  virtual ~lduPrimitiveMesh()
181  {}
182 
183 
184  // Member Functions
185 
186  // Access
187 
188  //- Return ldu addressing
189  virtual const lduAddressing& lduAddr() const
190  {
191  return *this;
192  }
193 
194  //- Return a list of pointers for each patch
195  // with only those pointing to interfaces being set
196  virtual lduInterfacePtrsList interfaces() const
197  {
198  return interfaces_;
199  }
200 
201  //- Return a list of pointers for each patch
202  // with only those pointing to interfaces being set
203  // (reference to cached interfaces)
204  const lduInterfacePtrsList& rawInterfaces() const
205  {
206  return interfaces_;
207  }
208 
209  //- Return communicator used for parallel communication
210  virtual label comm() const
211  {
212  return comm_;
213  }
214 
215  //- Return Lower addressing
216  virtual const labelUList& lowerAddr() const
217  {
218  return lowerAddr_;
219  }
220 
221  //- Return Upper addressing
222  virtual const labelUList& upperAddr() const
223  {
224  return upperAddr_;
225  }
226 
227  //- Return patch addressing
228  virtual const labelUList& patchAddr(const label i) const
229  {
230  return interfaces_[i].faceCells();
231  }
232 
233  //- Return patch evaluation schedule
234  virtual const lduSchedule& patchSchedule() const
235  {
236  return patchSchedule_;
237  }
238 
239 
240  // Helper
241 
242  //- Select either mesh0 (meshI is 0) or otherMeshes[meshI-1]
243  static const lduMesh& mesh
244  (
245  const lduMesh& mesh0,
246  const PtrList<lduPrimitiveMesh>& otherMeshes,
247  const label meshI
248  );
249 
250  //- Gather meshes from other processors onto procIDs[0].
251  // Received meshes get GAMGInterface and communicator comm
252  static void gather
253  (
254  const label comm,
255  const lduMesh& mesh,
256  const labelList& procIDs,
257  PtrList<lduPrimitiveMesh>& otherMeshes
258  );
259 
260  //- Get non-scheduled send/receive schedule
261  template<class ProcPatch>
263 
264 };
265 
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 } // End namespace Foam
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 #ifdef NoRepository
274 # include "lduPrimitiveMeshTemplates.C"
275 #endif
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 #endif
280 
281 // ************************************************************************* //
label size() const
Return number of equations.
virtual ~lduPrimitiveMesh()
Destructor.
void addInterfaces(lduInterfacePtrsList &interfaces, const lduSchedule &ps)
Add interfaces to a mesh constructed without.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
virtual label comm() const
Return communicator used for parallel communication.
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
const lduInterfacePtrsList & rawInterfaces() const
Return a list of pointers for each patch.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:51
static const lduMesh & mesh(const lduMesh &mesh0, const PtrList< lduPrimitiveMesh > &otherMeshes, const label meshI)
Select either mesh0 (meshI is 0) or otherMeshes[meshI-1].
Namespace for OpenFOAM.
virtual const labelUList & upperAddr() const
Return Upper addressing.
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
virtual const labelUList & lowerAddr() const
Return Lower addressing.
static lduSchedule nonBlockingSchedule(const lduInterfacePtrsList &)
Get non-scheduled send/receive schedule.
static void gather(const label comm, const lduMesh &mesh, const labelList &procIDs, PtrList< lduPrimitiveMesh > &otherMeshes)
Gather meshes from other processors onto procIDs[0].
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
virtual const lduSchedule & patchSchedule() const
Return patch evaluation schedule.
ClassName("lduPrimitiveMesh")
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Simplest contrete lduMesh which stores the addressing needed by lduMatrix.
virtual const labelUList & patchAddr(const label i) const
Return patch addressing.