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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::InteractionLists
28 
29 Description
30 
31  Builds direct interaction list, specifying which local (real)
32  cells are potentially in range of each other.
33 
34  Builds referred interaction list, specifying which cells are
35  required to provide interactions across coupled patches (cyclic or
36  processor). Generates referred cells, and refers particles to the
37  correct processor, applying the appropriate transform.
38 
39  Simultaneous communication and computation is possible using:
40 
41  \verbatim
42  PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
43  label startOfRequests = Pstream::nRequests();
44  il_.sendReferredData(cellOccupancy_, pBufs);
45  // Do other things
46  il_.receiveReferredData(pBufs, startOfRequests);
47  \endverbatim
48 
49  Requiring data:
50 
51  \verbatim
52  List<DynamicList<typename CloudType::parcelType*>> cellOccupancy_;
53  \endverbatim
54 
55 SourceFiles
56  InteractionListsI.H
57  InteractionLists.C
58  InteractionListsIO.C
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef InteractionLists_H
63 #define InteractionLists_H
64 
65 #include "polyMesh.H"
66 #include "referredWallFace.H"
67 //#include "mapDistribute.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 
74 class globalIndexAndTransform;
75 class mapDistribute;
76 
77 /*---------------------------------------------------------------------------*\
78  Class InteractionLists Declaration
79 \*---------------------------------------------------------------------------*/
80 
81 template<class ParticleType>
82 class InteractionLists
83 {
84  // Private data
85 
86  //- Reference to mesh
87  const polyMesh& mesh_;
88 
89  //- Dummy cloud to give to particles
90  Cloud<ParticleType> cloud_;
91 
92  //- Switch controlling whether or not the cloud gets populated
93  // with the referred particles, hence gets written out
94  const bool writeCloud_;
95 
96  //- mapDistribute to exchange referred particles into referred cells
97  autoPtr<mapDistribute> cellMapPtr_;
98 
99  //- mapDistribute to exchange wall face data
100  autoPtr<mapDistribute> wallFaceMapPtr_;
101 
102  //- Maximum distance over which interactions will be detected
103  scalar maxDistance_;
104 
105  //- Direct interaction list
106  labelListList dil_;
107 
108  //- Wall faces on this processor that are in interaction range
109  // of each each cell (direct wall face interaction list)
110  labelListList dwfil_;
111 
112  //- Referred interaction list - which real cells are to be
113  // supplied with particle interactions from the referred
114  // particle container with the same index.
115  labelListList ril_;
116 
117  //- Inverse addressing for referred cells, specifies which
118  // referred cells (indices of entries in the ril_ and
119  // referredParticles_ lists) interact with the real cell
120  // indexed in this container.
121  labelListList rilInverse_;
122 
123  //- Which real cells on this on this processor are in
124  // interaction range of each referred wall face (referred
125  // wall face interaction list)
126  labelListList rwfil_;
127 
128  //- Inverse addressing for referred wall faces, specifies
129  // which referred wall faces interact with the real cells
130  // indexed in this container.
131  labelListList rwfilInverse_;
132 
133  //- Which cells are to be sent via the cellMap, and an index
134  // specifying how they should be transformed.
135  List<labelPair> cellIndexAndTransformToDistribute_;
136 
137  //- Which wallFaces are to be sent via the wallFaceMap, and an index
138  // specifying how they should be transformed.
139  List<labelPair> wallFaceIndexAndTransformToDistribute_;
140 
141  //- Referred wall faces
142  List<referredWallFace> referredWallFaces_;
143 
144  //- Velocity field name, default to "U"
145  const word UName_;
146 
147  //- Referred wall face velocity field values;
148  List<vector> referredWallData_;
149 
150  //- Referred particle container
151  List<IDLList<ParticleType>> referredParticles_;
152 
153 
154  // Private Member Functions
155 
156  //- Construct all interaction lists
157  void buildInteractionLists();
158 
159  //- Find the other processors which have interaction range
160  // extended bound boxes in range
161  void findExtendedProcBbsInRange
162  (
163  const treeBoundBox& procBb,
164  const List<treeBoundBox>& allExtendedProcBbs,
165  const globalIndexAndTransform& globalTransforms,
166  List<treeBoundBox>& extendedProcBbsInRange,
167  List<label>& extendedProcBbsTransformIndex,
168  List<label>& extendedProcBbsOrigProc
169  );
170 
171  //- Build the mapDistribute from information about which entry
172  // is to be sent to which processor
173  void buildMap
174  (
175  autoPtr<mapDistribute>& mapPtr,
176  const List<label>& toProc
177  );
178 
179  //- Fill the referredParticles container with particles that
180  // will be referred
181  void prepareParticlesToRefer
182  (
184  );
185 
186  //- Prepare particle to be referred
187  void prepareParticleToBeReferred
188  (
189  ParticleType* particle,
190  labelPair iat
191  );
192 
193  //- Fill the referredParticles so that it will be written out
194  void fillReferredParticleCloud();
195 
196  //- Populate the referredWallData container with data that
197  // will be referred.
198  void prepareWallDataToRefer();
199 
200  //- Write the referred wall faces out for debug
201  void writeReferredWallFaces() const;
202 
203  //- No copy construct
204  InteractionLists(const InteractionLists&) = delete;
205 
206  //- No copy assignment
207  void operator=(const InteractionLists&) = delete;
208 
209 
210 public:
211 
212  // Constructors
213 
214  //- Construct null from mesh
216 
217  //- Construct and call function to create all information from
218  // the mesh
220  (
221  const polyMesh& mesh,
222  scalar maxDistance,
223  bool writeCloud = false,
224  const word& UName = "U"
225  );
226 
227  // Destructor
228 
230 
231 
232  // Member Functions
233 
234  //- Prepare and send referred particles and wall data,
235  // nonBlocking communication
236  void sendReferredData
237  (
239  PstreamBuffers& pBufs
240  );
241 
242  //- Receive referred data
244  (
245  PstreamBuffers& pBufs,
246  const label startReq = 0
247  );
248 
249 
250  // Access
251 
252  //- Return access to the mesh
253  inline const polyMesh& mesh() const;
254 
255  //- Return access to the cellMap
256  inline const mapDistribute& cellMap() const;
257 
258  //- Return access to the wallFaceMap
259  inline const mapDistribute& wallFaceMap() const;
260 
261  //- Return access to the direct interaction list
262  inline const labelListList& dil() const;
263 
264  //- Return access to the direct wall face interaction list
265  inline const labelListList& dwfil() const;
266 
267  //- Return access to the referred interaction list
268  inline const labelListList& ril() const;
269 
270  //- Return access to the inverse referred interaction list
271  inline const labelListList& rilInverse() const;
272 
273  //- Return access to the referred wall face interaction list
274  inline const labelListList& rwfil() const;
275 
276  //- Return access to the inverse referred wall face
277  // interaction list
278  inline const labelListList& rwfilInverse() const;
279 
280  //- Return access to the cellIndexAndTransformToDistribute list
281  inline const List<labelPair>&
283 
284  //- Return access to the wallFaceIndexAndTransformToDistribute list
285  inline const List<labelPair>&
287 
288  //- Return access to the referred wall faces
289  inline const List<referredWallFace>& referredWallFaces() const;
290 
291  //- Return the name of the velocity field
292  inline const word& UName() const;
293 
294  //- Return access to the referred wall data
295  inline const List<vector>& referredWallData() const;
296 
297  //- Return access to the referred particle container
298  inline const List<IDLList<ParticleType>>&
299  referredParticles() const;
300 
301  //- Return non-const access to the referred particle container
303 };
304 
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 } // End namespace Foam
309 
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 
312 #include "InteractionListsI.H"
313 
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
315 
316 #ifdef NoRepository
317  #include "InteractionLists.C"
318 #endif
319 
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
321 
322 #endif
323 
324 // ************************************************************************* //
Foam::InteractionLists::cellIndexAndTransformToDistribute
const List< labelPair > & cellIndexAndTransformToDistribute() const
Return access to the cellIndexAndTransformToDistribute list.
Definition: InteractionListsI.H:102
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::InteractionLists::cellMap
const mapDistribute & cellMap() const
Return access to the cellMap.
Definition: InteractionListsI.H:41
Foam::InteractionLists::~InteractionLists
~InteractionLists()
Definition: InteractionLists.C:1149
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:55
referredWallFace.H
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:86
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:88
Foam::InteractionLists::wallFaceMap
const mapDistribute & wallFaceMap() const
Return access to the wallFaceMap.
Definition: InteractionListsI.H:49
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::InteractionLists::rilInverse
const labelListList & rilInverse() const
Return access to the inverse referred interaction list.
Definition: InteractionListsI.H:79
Foam::InteractionLists::referredWallData
const List< vector > & referredWallData() const
Return access to the referred wall data.
Definition: InteractionListsI.H:134
cellOccupancy
const List< DynamicList< molecule * > > & cellOccupancy
Definition: calculateMDFields.H:1
Foam::InteractionLists::UName
const word & UName() const
Return the name of the velocity field.
Definition: InteractionListsI.H:126
Foam::InteractionLists::dwfil
const labelListList & dwfil() const
Return access to the direct wall face interaction list.
Definition: InteractionListsI.H:64
Foam::InteractionLists::dil
const labelListList & dil() const
Return access to the direct interaction list.
Definition: InteractionListsI.H:56
Foam::InteractionLists
Builds direct interaction list, specifying which local (real) cells are potentially in range of each ...
Definition: InteractionLists.H:81
Foam::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:163
Foam::InteractionLists::receiveReferredData
void receiveReferredData(PstreamBuffers &pBufs, const label startReq=0)
Receive referred data.
Definition: InteractionLists.C:1205
Foam::InteractionLists::wallFaceIndexAndTransformToDistribute
const List< labelPair > & wallFaceIndexAndTransformToDistribute() const
Return access to the wallFaceIndexAndTransformToDistribute list.
Definition: InteractionListsI.H:111
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::InteractionLists::mesh
const polyMesh & mesh() const
Return access to the mesh.
Definition: InteractionListsI.H:33
Foam::InteractionLists::sendReferredData
void sendReferredData(const List< DynamicList< ParticleType * >> &cellOccupancy, PstreamBuffers &pBufs)
Prepare and send referred particles and wall data,.
Definition: InteractionLists.C:1157
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::Pair< label >
Foam::List< labelList >
Foam::particle
Base particle class.
Definition: particle.H:76
Foam::Cloud
Base cloud calls templated on particle type.
Definition: Cloud.H:55
InteractionLists.C
Foam::InteractionLists::referredParticles
const List< IDLList< ParticleType > > & referredParticles() const
Return access to the referred particle container.
Definition: InteractionListsI.H:142
Foam::globalIndexAndTransform
Determination and storage of the possible independent transforms introduced by coupledPolyPatches,...
Definition: globalIndexAndTransform.H:64
Foam::InteractionLists::ril
const labelListList & ril() const
Return access to the referred interaction list.
Definition: InteractionListsI.H:71
InteractionListsI.H
Foam::InteractionLists::rwfilInverse
const labelListList & rwfilInverse() const
Return access to the inverse referred wall face.
Definition: InteractionListsI.H:94
Foam::InteractionLists::referredWallFaces
const List< referredWallFace > & referredWallFaces() const
Return access to the referred wall faces.
Definition: InteractionListsI.H:119
Foam::InteractionLists::rwfil
const labelListList & rwfil() const
Return access to the referred wall face interaction list.
Definition: InteractionListsI.H:86