InteractionLists.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-2019 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::commsTypes::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 
202 public:
203 
204  // Constructors
205 
206  //- Construct null from mesh
208 
209  //- Construct and call function to create all information from
210  // the mesh
212  (
213  const polyMesh& mesh,
214  scalar maxDistance,
215  Switch writeCloud = false,
216  const word& UName = "U"
217  );
218 
219  //- Disallow default bitwise copy construction
220  InteractionLists(const InteractionLists&) = delete;
221 
222 
223  // Destructor
224 
226 
227 
228  // Member Functions
229 
230  //- Prepare and send referred particles and wall data,
231  // nonBlocking communication
232  void sendReferredData
233  (
235  PstreamBuffers& pBufs
236  );
237 
238  //- Receive referred data
240  (
241  PstreamBuffers& pBufs,
242  const label startReq = 0
243  );
244 
245 
246  // Access
247 
248  //- Return access to the mesh
249  inline const polyMesh& mesh() const;
250 
251  //- Return access to the cellMap
252  inline const mapDistribute& cellMap() const;
253 
254  //- Return access to the wallFaceMap
255  inline const mapDistribute& wallFaceMap() const;
256 
257  //- Return access to the direct interaction list
258  inline const labelListList& dil() const;
259 
260  //- Return access to the direct wall face interaction list
261  inline const labelListList& dwfil() const;
262 
263  //- Return access to the referred interaction list
264  inline const labelListList& ril() const;
265 
266  //- Return access to the inverse referred interaction list
267  inline const labelListList& rilInverse() const;
268 
269  //- Return access to the referred wall face interaction list
270  inline const labelListList& rwfil() const;
271 
272  //- Return access to the inverse referred wall face
273  // interaction list
274  inline const labelListList& rwfilInverse() const;
275 
276  //- Return access to the cellIndexAndTransformToDistribute list
277  inline const List<labelPair>&
279 
280  //- Return access to the wallFaceIndexAndTransformToDistribute list
281  inline const List<labelPair>&
283 
284  //- Return access to the referred wall faces
285  inline const List<referredWallFace>& referredWallFaces() const;
286 
287  //- Return the name of the velocity field
288  inline const word& UName() const;
289 
290  //- Return access to the referred wall data
291  inline const List<vector>& referredWallData() const;
292 
293  //- Return access to the referred particle container
294  inline const List<IDLList<ParticleType>>&
295  referredParticles() const;
296 
297  //- Return non-const access to the referred particle container
299 
300 
301  // Member Operators
302 
303  //- Disallow default bitwise assignment
304  void operator=(const InteractionLists&) = delete;
305 };
306 
307 
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309 
310 } // End namespace Foam
311 
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 
314 #include "InteractionListsI.H"
315 
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 
318 #ifdef NoRepository
319  #include "InteractionLists.C"
320 #endif
321 
322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
323 
324 #endif
325 
326 // ************************************************************************* //
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 labelListList & rwfil() const
Return access to the referred wall face interaction list.
Builds direct interaction list, specifying which local (real) cells are potentially in range of each ...
const List< labelPair > & cellIndexAndTransformToDistribute() const
Return access to the cellIndexAndTransformToDistribute list.
const mapDistribute & wallFaceMap() const
Return access to the wallFaceMap.
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/any.
Definition: Switch.H:60
const labelListList & dwfil() const
Return access to the direct wall face interaction list.
Base particle class.
Definition: particle.H:84
const List< labelPair > & wallFaceIndexAndTransformToDistribute() const
Return access to the wallFaceIndexAndTransformToDistribute list.
const List< referredWallFace > & referredWallFaces() const
Return access to the referred wall faces.
const labelListList & ril() const
Return access to the referred interaction list.
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
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
const labelListList & rwfilInverse() const
Return access to the inverse referred wall face.
Base cloud calls templated on particle type.
Definition: Cloud.H:52
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 & dil() const
Return access to the direct interaction list.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
const polyMesh & mesh() const
Return access to the mesh.
const List< vector > & referredWallData() const
Return access to the referred wall data.
Class containing processor-to-processor mapping information.
const List< DynamicList< molecule * > > & cellOccupancy
void operator=(const InteractionLists &)=delete
Disallow default bitwise assignment.
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
InteractionLists(const polyMesh &mesh)
Construct null from mesh.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const word & UName() const
Return the name of the velocity field.
const mapDistribute & cellMap() const
Return access to the cellMap.
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. Note that any given point can be on maximum 3 transforms only (and these transforms have to be perpendicular)
void sendReferredData(const List< DynamicList< ParticleType *>> &cellOccupancy, PstreamBuffers &pBufs)
Prepare and send referred particles and wall data,.
const List< IDLList< ParticleType > > & referredParticles() const
Return access to the referred particle container.