InteractionLists.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-2016 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::InteractionLists
26 
27 Description
28 
29  Builds direct interaction list, specifying which local (real)
30  cells are potentially in range of each other.
31 
32  Builds referred interaction list, specifying which cells are
33  required to provide interactions across coupled patches (cyclic or
34  processor). Generates referred cells, and refers particles to the
35  correct processor, applying the appropriate transform.
36 
37  Simultaneous communication and computation is possible using:
38 
39  \verbatim
40  PstreamBuffers pBufs(Pstream::nonBlocking);
41  label startOfRequests = Pstream::nRequests();
42  il_.sendReferredData(cellOccupancy_, pBufs);
43  // Do other things
44  il_.receiveReferredData(pBufs, startOfRequests);
45  \endverbatim
46 
47  Requiring data:
48 
49  \verbatim
50  List<DynamicList<typename CloudType::parcelType*>> cellOccupancy_;
51  \endverbatim
52 
53 SourceFiles
54  InteractionListsI.H
55  InteractionLists.C
56  InteractionListsIO.C
57 
58 \*---------------------------------------------------------------------------*/
59 
60 #ifndef InteractionLists_H
61 #define InteractionLists_H
62 
63 #include "polyMesh.H"
64 #include "referredWallFace.H"
65 //#include "mapDistribute.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 class globalIndexAndTransform;
73 class mapDistribute;
74 
75 /*---------------------------------------------------------------------------*\
76  Class InteractionLists Declaration
77 \*---------------------------------------------------------------------------*/
78 
79 template<class ParticleType>
80 class InteractionLists
81 {
82  // Private data
83 
84  //- Reference to mesh
85  const polyMesh& mesh_;
86 
87  //- Dummy cloud to give to particles
88  Cloud<ParticleType> cloud_;
89 
90  //- Switch controlling whether or not the cloud gets populated
91  // with the referred particles, hence gets written out
92  const Switch writeCloud_;
93 
94  //- mapDistribute to exchange referred particles into referred cells
95  autoPtr<mapDistribute> cellMapPtr_;
96 
97  //- mapDistribute to exchange wall face data
98  autoPtr<mapDistribute> wallFaceMapPtr_;
99 
100  //- Maximum distance over which interactions will be detected
101  scalar maxDistance_;
102 
103  //- Direct interaction list
104  labelListList dil_;
105 
106  //- Wall faces on this processor that are in interaction range
107  // of each each cell (direct wall face interaction list)
108  labelListList dwfil_;
109 
110  //- Referred interaction list - which real cells are to be
111  // supplied with particle interactions from the referred
112  // particle container with the same index.
113  labelListList ril_;
114 
115  //- Inverse addressing for referred cells, specifies which
116  // referred cells (indices of entries in the ril_ and
117  // referredParticles_ lists) interact with the real cell
118  // indexed in this container.
119  labelListList rilInverse_;
120 
121  //- Which real cells on this on this processor are in
122  // interaction range of each referred wall face (referred
123  // wall face interaction list)
124  labelListList rwfil_;
125 
126  //- Inverse addressing for referred wall faces, specifies
127  // which referred wall faces interact with the real cells
128  // indexed in this container.
129  labelListList rwfilInverse_;
130 
131  //- Which cells are to be sent via the cellMap, and an index
132  // specifying how they should be transformed.
133  List<labelPair> cellIndexAndTransformToDistribute_;
134 
135  //- Which wallFaces are to be sent via the wallFaceMap, and an index
136  // specifying how they should be transformed.
137  List<labelPair> wallFaceIndexAndTransformToDistribute_;
138 
139  //- Referred wall faces
140  List<referredWallFace> referredWallFaces_;
141 
142  //- Velocity field name, default to "U"
143  const word UName_;
144 
145  //- Referred wall face velocity field values;
146  List<vector> referredWallData_;
147 
148  //- Referred particle container
149  List<IDLList<ParticleType>> referredParticles_;
150 
151 
152  // Private Member Functions
153 
154  //- Construct all interaction lists
155  void buildInteractionLists();
156 
157  //- Find the other processors which have interaction range
158  // extended bound boxes in range
159  void findExtendedProcBbsInRange
160  (
161  const treeBoundBox& procBb,
162  const List<treeBoundBox>& allExtendedProcBbs,
163  const globalIndexAndTransform& globalTransforms,
164  List<treeBoundBox>& extendedProcBbsInRange,
165  List<label>& extendedProcBbsTransformIndex,
166  List<label>& extendedProcBbsOrigProc
167  );
168 
169  //- Build the mapDistribute from information about which entry
170  // is to be sent to which processor
171  void buildMap
172  (
173  autoPtr<mapDistribute>& mapPtr,
174  const List<label>& toProc
175  );
176 
177  //- Fill the referredParticles container with particles that
178  // will be referred
179  void prepareParticlesToRefer
180  (
182  );
183 
184  //- Prepare particle to be referred
185  void prepareParticleToBeReferred
186  (
187  ParticleType* particle,
188  labelPair iat
189  );
190 
191  //- Fill the referredParticles so that it will be written out
192  void fillReferredParticleCloud();
193 
194  //- Populate the referredWallData container with data that
195  // will be referred.
196  void prepareWallDataToRefer();
197 
198  //- Write the referred wall faces out for debug
199  void writeReferredWallFaces() const;
200 
201  //- Disallow default bitwise copy construct
203 
204  //- Disallow default bitwise assignment
205  void operator=(const InteractionLists&);
206 
207 
208 public:
209 
210  // Constructors
211 
212  //- Construct null from mesh
214 
215  //- Construct and call function to create all information from
216  // the mesh
218  (
219  const polyMesh& mesh,
220  scalar maxDistance,
221  Switch writeCloud = false,
222  const word& UName = "U"
223  );
224 
225  // Destructor
226 
228 
229 
230  // Member Functions
231 
232  //- Prepare and send referred particles and wall data,
233  // nonBlocking communication
234  void sendReferredData
235  (
237  PstreamBuffers& pBufs
238  );
239 
240  //- Receive referred data
242  (
243  PstreamBuffers& pBufs,
244  const label startReq = 0
245  );
246 
247 
248  // Access
249 
250  //- Return access to the mesh
251  inline const polyMesh& mesh() const;
252 
253  //- Return access to the cellMap
254  inline const mapDistribute& cellMap() const;
255 
256  //- Return access to the wallFaceMap
257  inline const mapDistribute& wallFaceMap() const;
258 
259  //- Return access to the direct interaction list
260  inline const labelListList& dil() const;
261 
262  //- Return access to the direct wall face interaction list
263  inline const labelListList& dwfil() const;
264 
265  //- Return access to the referred interaction list
266  inline const labelListList& ril() const;
267 
268  //- Return access to the inverse referred interaction list
269  inline const labelListList& rilInverse() const;
270 
271  //- Return access to the referred wall face interaction list
272  inline const labelListList& rwfil() const;
273 
274  //- Return access to the inverse referred wall face
275  // interaction list
276  inline const labelListList& rwfilInverse() const;
277 
278  //- Return access to the cellIndexAndTransformToDistribute list
279  inline const List<labelPair>&
281 
282  //- Return access to the wallFaceIndexAndTransformToDistribute list
283  inline const List<labelPair>&
285 
286  //- Return access to the referred wall faces
287  inline const List<referredWallFace>& referredWallFaces() const;
288 
289  //- Return the name of the velocity field
290  inline const word& UName() const;
291 
292  //- Return access to the referred wall data
293  inline const List<vector>& referredWallData() const;
294 
295  //- Return access to the referred particle container
296  inline const List<IDLList<ParticleType>>&
297  referredParticles() const;
298 
299  //- Return non-const access to the referred particle container
301 };
302 
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 } // End namespace Foam
307 
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309 
310 #include "InteractionListsI.H"
311 
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 
314 #ifdef NoRepository
315  #include "InteractionLists.C"
316 #endif
317 
318 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
319 
320 #endif
321 
322 // ************************************************************************* //
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
Builds direct interaction list, specifying which local (real) cells are potentially in range of each ...
void sendReferredData(const List< DynamicList< ParticleType * >> &cellOccupancy, PstreamBuffers &pBufs)
Prepare and send referred particles and wall data,.
const mapDistribute & cellMap() const
Return access to the cellMap.
const List< vector > & referredWallData() const
Return access to the referred wall data.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
const word & UName() const
Return the name of the velocity field.
Base particle class.
Definition: particle.H:78
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
const polyMesh & mesh() const
Return access to the mesh.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
A class for handling words, derived from string.
Definition: word.H:59
Base cloud calls templated on particle type.
Definition: Cloud.H:52
const List< labelPair > & cellIndexAndTransformToDistribute() const
Return access to the cellIndexAndTransformToDistribute list.
const labelListList & rilInverse() const
Return access to the inverse referred interaction list.
void receiveReferredData(PstreamBuffers &pBufs, const label startReq=0)
Receive referred data.
const labelListList & dwfil() const
Return access to the direct wall face interaction list.
const labelListList & rwfil() const
Return access to the referred wall face interaction list.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
const labelListList & rwfilInverse() const
Return access to the inverse referred wall face.
const List< IDLList< ParticleType > > & referredParticles() const
Return access to the referred particle container.
Class containing processor-to-processor mapping information.
const List< DynamicList< molecule * > > & cellOccupancy
const labelListList & ril() const
Return access to the referred interaction list.
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
const mapDistribute & wallFaceMap() const
Return access to the wallFaceMap.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const List< referredWallFace > & referredWallFaces() const
Return access to the referred wall faces.
Namespace for OpenFOAM.
Determination and storage of the possible independent transforms introduced by coupledPolyPatches, as well as all of the possible permutations of these transforms generated by the presence of multiple coupledPolyPatches, i.e. more than one cyclic boundary.
const List< labelPair > & wallFaceIndexAndTransformToDistribute() const
Return access to the wallFaceIndexAndTransformToDistribute list.
const labelListList & dil() const
Return access to the direct interaction list.