1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
25 Foam::InteractionLists
29 Builds direct interaction list, specifying which local (real)
30 cells are potentially in range of each other.
32 Builds referred interaction list, specifying which cells are
33 required to provide interactions across coupled patched (cyclic or
34 processor). Generates referred cells, and refers particles to the
35 correct processor, applying the appropriate transform.
37 Simultaneous communication and computation is possible using:
40 PstreamBuffers pBufs(Pstream::nonBlocking);
41 il_.sendReferredData(cellOccupancy_, pBufs);
43 il_.receiveReferredData(pBufs);
49 List<DynamicList<typename CloudType::parcelType*> > cellOccupancy_;
57 \*---------------------------------------------------------------------------*/
59 #ifndef InteractionLists_H
60 #define InteractionLists_H
63 #include "referredWallFace.H"
64 //#include "mapDistribute.H"
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 class globalIndexAndTransform;
74 /*---------------------------------------------------------------------------*\
75 Class InteractionLists Declaration
76 \*---------------------------------------------------------------------------*/
78 template<class ParticleType>
79 class InteractionLists
84 const polyMesh& mesh_;
86 //- Dummy cloud to give to particles
87 Cloud<ParticleType> cloud_;
89 //- Switch controlling whether or not the cloud gets populated
90 // with the referred particles, hence gets written out
91 const Switch writeCloud_;
93 //- mapDistribute to exchange referred particles into referred cells
94 autoPtr<mapDistribute> cellMapPtr_;
96 //- mapDistribute to exchange wall face data
97 autoPtr<mapDistribute> wallFaceMapPtr_;
99 //- Maximum distance over which interactions will be detected
102 //- Direct interaction list
105 //- Wall faces on this processor that are in interaction range
106 // of each each cell (direct wall face interaction list)
107 labelListList dwfil_;
109 //- Referred interaction list - which real cells are to be
110 // supplied with particle interactions from the referred
111 // particle container with the same index.
114 //- Inverse addressing for referred cells, specifies which
115 // referred cells (indices of entries in the ril_ and
116 // referredParticles_ lists) interact with the real cell
117 // indexed in this container.
118 labelListList rilInverse_;
120 //- Which real cells on this on this processor are in
121 // interaction range of each referred wall face (referred
122 // wall face interaction list)
123 labelListList rwfil_;
125 //- Inverse addressing for referred wall faces, specifies
126 // which referred wall faces interact with the real cells
127 // indexed in this container.
128 labelListList rwfilInverse_;
130 //- Which cells are to be sent via the cellMap, and an index
131 // specifying how they should be transformed.
132 List<labelPair> cellIndexAndTransformToDistribute_;
134 //- Which wallFaces are to be sent via the wallFaceMap, and an index
135 // specifying how they should be transformed.
136 List<labelPair> wallFaceIndexAndTransformToDistribute_;
138 //- Referred wall faces
139 List<referredWallFace> referredWallFaces_;
141 //- Velocity field name, default to "U"
144 //- Referred wall face velocity field values;
145 List<vector> referredWallData_;
147 //- Referred particle container
148 List<IDLList<ParticleType> > referredParticles_;
151 // Private Member Functions
153 //- Construct all interaction lists
154 void buildInteractionLists();
156 //- Find the other processors which have interaction range
157 // extended bound boxes in range
158 void findExtendedProcBbsInRange
160 const treeBoundBox& procBb,
161 const List<treeBoundBox>& allExtendedProcBbs,
162 const globalIndexAndTransform& globalTransforms,
163 List<treeBoundBox>& extendedProcBbsInRange,
164 List<label>& extendedProcBbsTransformIndex,
165 List<label>& extendedProcBbsOrigProc
168 //- Build the mapDistribute from information about which entry
169 // is to be sent to which processor
172 autoPtr<mapDistribute>& mapPtr,
173 const List<label>& toProc
176 //- Fill the referredParticles container with particles that
178 void prepareParticlesToRefer
180 const List<DynamicList<ParticleType*> >& cellOccupancy
183 //- Prepare particle to be referred
184 void prepareParticleToBeReferred
186 ParticleType* particle,
190 //- Fill the referredParticles so that it will be written out
191 void fillReferredParticleCloud();
193 //- Populate the referredWallData container with data that
195 void prepareWallDataToRefer();
197 //- Write the referred wall faces out for debug
198 void writeReferredWallFaces() const;
200 //- Disallow default bitwise copy construct
201 InteractionLists(const InteractionLists&);
203 //- Disallow default bitwise assignment
204 void operator=(const InteractionLists&);
211 //- Construct null from mesh
212 InteractionLists(const polyMesh& mesh);
214 //- Construct and call function to create all information from
218 const polyMesh& mesh,
220 Switch writeCloud = false,
221 const word& UName = "U"
231 //- Prepare and send referred particles and wall data,
232 // nonBlocking communication
233 void sendReferredData
235 const List<DynamicList<ParticleType*> >& cellOccupancy,
236 PstreamBuffers& pBufs
239 //- Receive referred data
240 void receiveReferredData(PstreamBuffers& pBufs);
245 //- Return access to the mesh
246 inline const polyMesh& mesh() const;
248 //- Return access to the cellMap
249 inline const mapDistribute& cellMap() const;
251 //- Return access to the wallFaceMap
252 inline const mapDistribute& wallFaceMap() const;
254 //- Return access to the direct interaction list
255 inline const labelListList& dil() const;
257 //- Return access to the direct wall face interaction list
258 inline const labelListList& dwfil() const;
260 //- Return access to the referred interaction list
261 inline const labelListList& ril() const;
263 //- Return access to the inverse referred interaction list
264 inline const labelListList& rilInverse() const;
266 //- Return access to the referred wall face interaction list
267 inline const labelListList& rwfil() const;
269 //- Return access to the inverse referred wall face
271 inline const labelListList& rwfilInverse() const;
273 //- Return access to the cellIndexAndTransformToDistribute list
274 inline const List<labelPair>&
275 cellIndexAndTransformToDistribute() const;
277 //- Return access to the wallFaceIndexAndTransformToDistribute list
278 inline const List<labelPair>&
279 wallFaceIndexAndTransformToDistribute() const;
281 //- Return access to the referred wall faces
282 inline const List<referredWallFace>& referredWallFaces() const;
284 //- Return the name of the velocity field
285 inline const word& UName() const;
287 //- Return access to the referred wall data
288 inline const List<vector>& referredWallData() const;
290 //- Return access to the referred particle container
291 inline const List<IDLList<ParticleType> >&
292 referredParticles() const;
294 //- Return non-const access to the referred particle container
295 inline List<IDLList<ParticleType> >& referredParticles();
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 } // End namespace Foam
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 #include "InteractionListsI.H"
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 # include "InteractionLists.C"
313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 // ************************************************************************* //