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 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
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
96 
97  //- mapDistribute to exchange wall face data
99 
100  //- Maximum distance over which interactions will be detected
101  scalar maxDistance_;
102 
103  //- Direct interaction list
105 
106  //- Wall faces on this processor that are in interaction range
107  // of each each cell (direct wall face interaction list)
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.
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.
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)
125 
126  //- Inverse addressing for referred wall faces, specifies
127  // which referred wall faces interact with the real cells
128  // indexed in this container.
130 
131  //- Which cells are to be sent via the cellMap, and an index
132  // specifying how they should be transformed.
134 
135  //- Which wallFaces are to be sent via the wallFaceMap, and an index
136  // specifying how they should be transformed.
138 
139  //- Referred wall faces
141 
142  //- Velocity field name, default to "U"
143  const word UName_;
144 
145  //- Referred wall face velocity field values;
147 
148  //- Referred particle container
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
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
180  (
182  );
183 
184  //- Prepare particle to be referred
186  (
187  ParticleType* particle,
188  labelPair iat
189  );
190 
191  //- Fill the referredParticles so that it will be written out
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 // ************************************************************************* //
Foam::InteractionLists::cellIndexAndTransformToDistribute
const List< labelPair > & cellIndexAndTransformToDistribute() const
Return access to the cellIndexAndTransformToDistribute list.
Definition: InteractionListsI.H:100
Foam::InteractionLists::prepareWallDataToRefer
void prepareWallDataToRefer()
Populate the referredWallData container with data that.
Definition: InteractionLists.C:1006
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::InteractionLists::maxDistance_
scalar maxDistance_
Maximum distance over which interactions will be detected.
Definition: InteractionLists.H:100
Foam::InteractionLists::referredParticles_
List< IDLList< ParticleType > > referredParticles_
Referred particle container.
Definition: InteractionLists.H:148
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::InteractionLists::findExtendedProcBbsInRange
void findExtendedProcBbsInRange(const treeBoundBox &procBb, const List< treeBoundBox > &allExtendedProcBbs, const globalIndexAndTransform &globalTransforms, List< treeBoundBox > &extendedProcBbsInRange, List< label > &extendedProcBbsTransformIndex, List< label > &extendedProcBbsOrigProc)
Find the other processors which have interaction range.
Definition: InteractionLists.C:637
Foam::InteractionLists::cellIndexAndTransformToDistribute_
List< labelPair > cellIndexAndTransformToDistribute_
Which cells are to be sent via the cellMap, and an index.
Definition: InteractionLists.H:132
Foam::InteractionLists::cellMap
const mapDistribute & cellMap() const
Return access to the cellMap.
Definition: InteractionListsI.H:39
Foam::InteractionLists::~InteractionLists
~InteractionLists()
Definition: InteractionLists.C:1153
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:56
referredWallFace.H
Foam::treeBoundBox
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:85
Foam::InteractionLists::cellMapPtr_
autoPtr< mapDistribute > cellMapPtr_
mapDistribute to exchange referred particles into referred cells
Definition: InteractionLists.H:94
Foam::InteractionLists::wallFaceMap
const mapDistribute & wallFaceMap() const
Return access to the wallFaceMap.
Definition: InteractionListsI.H:47
Foam::InteractionLists::ril_
labelListList ril_
Referred interaction list - which real cells are to be.
Definition: InteractionLists.H:112
polyMesh.H
Foam::InteractionLists::prepareParticlesToRefer
void prepareParticlesToRefer(const List< DynamicList< ParticleType * > > &cellOccupancy)
Fill the referredParticles container with particles that.
Definition: InteractionLists.C:916
Foam::InteractionLists::dil_
labelListList dil_
Direct interaction list.
Definition: InteractionLists.H:103
Foam::InteractionLists::fillReferredParticleCloud
void fillReferredParticleCloud()
Fill the referredParticles so that it will be written out.
Definition: InteractionLists.C:984
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::InteractionLists::referredWallData_
List< vector > referredWallData_
Referred wall face velocity field values;.
Definition: InteractionLists.H:145
Foam::InteractionLists::rilInverse
const labelListList & rilInverse() const
Return access to the inverse referred interaction list.
Definition: InteractionListsI.H:77
Foam::InteractionLists::cloud_
Cloud< ParticleType > cloud_
Dummy cloud to give to particles.
Definition: InteractionLists.H:87
Foam::InteractionLists::buildMap
void buildMap(autoPtr< mapDistribute > &mapPtr, const List< label > &toProc)
Build the mapDistribute from information about which entry.
Definition: InteractionLists.C:829
Foam::label
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
Foam::InteractionLists::referredWallData
const List< vector > & referredWallData() const
Return access to the referred wall data.
Definition: InteractionListsI.H:132
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:124
Foam::InteractionLists::dwfil
const labelListList & dwfil() const
Return access to the direct wall face interaction list.
Definition: InteractionListsI.H:62
Foam::InteractionLists::dil
const labelListList & dil() const
Return access to the direct interaction list.
Definition: InteractionListsI.H:54
Foam::InteractionLists
Builds direct interaction list, specifying which local (real) cells are potentially in range of each ...
Definition: InteractionLists.H:79
Foam::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:152
Foam::InteractionLists::prepareParticleToBeReferred
void prepareParticleToBeReferred(ParticleType *particle, labelPair iat)
Prepare particle to be referred.
Definition: InteractionLists.C:959
Foam::InteractionLists::dwfil_
labelListList dwfil_
Wall faces on this processor that are in interaction range.
Definition: InteractionLists.H:107
Foam::InteractionLists::receiveReferredData
void receiveReferredData(PstreamBuffers &pBufs, const label startReq=0)
Receive referred data.
Definition: InteractionLists.C:1209
Foam::InteractionLists::UName_
const word UName_
Velocity field name, default to "U".
Definition: InteractionLists.H:142
Foam::InteractionLists::wallFaceIndexAndTransformToDistribute
const List< labelPair > & wallFaceIndexAndTransformToDistribute() const
Return access to the wallFaceIndexAndTransformToDistribute list.
Definition: InteractionListsI.H:109
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::InteractionLists::rwfilInverse_
labelListList rwfilInverse_
Inverse addressing for referred wall faces, specifies.
Definition: InteractionLists.H:128
Foam::InteractionLists::mesh_
const polyMesh & mesh_
Reference to mesh.
Definition: InteractionLists.H:84
Foam::InteractionLists::mesh
const polyMesh & mesh() const
Return access to the mesh.
Definition: InteractionListsI.H:31
Foam::InteractionLists::sendReferredData
void sendReferredData(const List< DynamicList< ParticleType * > > &cellOccupancy, PstreamBuffers &pBufs)
Prepare and send referred particles and wall data,.
Definition: InteractionLists.C:1161
Foam::InteractionLists::operator=
void operator=(const InteractionLists &)
Disallow default bitwise assignment.
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::InteractionLists::buildInteractionLists
void buildInteractionLists()
Construct all interaction lists.
Definition: InteractionLists.C:37
Foam::InteractionLists::wallFaceMapPtr_
autoPtr< mapDistribute > wallFaceMapPtr_
mapDistribute to exchange wall face data
Definition: InteractionLists.H:97
Foam::Pair
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
Foam::InteractionLists::writeReferredWallFaces
void writeReferredWallFaces() const
Write the referred wall faces out for debug.
Definition: InteractionLists.C:1052
Foam::InteractionLists::rilInverse_
labelListList rilInverse_
Inverse addressing for referred cells, specifies which.
Definition: InteractionLists.H:118
Foam::InteractionLists::rwfil_
labelListList rwfil_
Which real cells on this on this processor are in.
Definition: InteractionLists.H:123
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::particle
Base particle class.
Definition: particle.H:78
Foam::InteractionLists::wallFaceIndexAndTransformToDistribute_
List< labelPair > wallFaceIndexAndTransformToDistribute_
Which wallFaces are to be sent via the wallFaceMap, and an index.
Definition: InteractionLists.H:136
Foam::Cloud< ParticleType >
InteractionLists.C
Foam::InteractionLists::InteractionLists
InteractionLists(const InteractionLists &)
Disallow default bitwise copy construct.
Foam::globalIndexAndTransform
Determination and storage of the possible independent transforms introduced by coupledPolyPatches,...
Definition: globalIndexAndTransform.H:60
Foam::InteractionLists::referredParticles
const List< IDLList< ParticleType > > & referredParticles() const
Return access to the referred particle container.
Definition: InteractionListsI.H:140
Foam::InteractionLists::writeCloud_
const Switch writeCloud_
Switch controlling whether or not the cloud gets populated.
Definition: InteractionLists.H:91
Foam::InteractionLists::ril
const labelListList & ril() const
Return access to the referred interaction list.
Definition: InteractionListsI.H:69
InteractionListsI.H
Foam::InteractionLists::rwfilInverse
const labelListList & rwfilInverse() const
Return access to the inverse referred wall face.
Definition: InteractionListsI.H:92
Foam::InteractionLists::referredWallFaces_
List< referredWallFace > referredWallFaces_
Referred wall faces.
Definition: InteractionLists.H:139
Foam::InteractionLists::referredWallFaces
const List< referredWallFace > & referredWallFaces() const
Return access to the referred wall faces.
Definition: InteractionListsI.H:117
Foam::InteractionLists::rwfil
const labelListList & rwfil() const
Return access to the referred wall face interaction list.
Definition: InteractionListsI.H:84