CollisionRecordList.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-2016 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::CollisionRecordList
29 
30 Description
31 
32 SourceFiles
33  CollisionRecordListI.H
34  CollisionRecordList.C
35  CollisionRecordListIO.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef CollisionRecordList_H
40 #define CollisionRecordList_H
41 
42 #include "DynamicList.H"
43 #include "PairCollisionRecord.H"
44 #include "WallCollisionRecord.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward Declarations
52 template<class PairType, class WallType>
54 
55 template<class PairType, class WallType>
56 inline bool operator==
57 (
60 );
61 
62 template<class PairType, class WallType>
63 inline bool operator!=
64 (
67 );
68 
69 template<class PairType, class WallType>
71 
72 template<class PairType, class WallType>
73 Ostream& operator<<(Ostream&, const CollisionRecordList<PairType, WallType>&);
74 
75 
76 /*---------------------------------------------------------------------------*\
77  Class CollisionRecordList Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 template<class PairType, class WallType>
82 {
83  // Private Data
84 
85  //- List of active pair collisions
87 
88  //- List of active wall collisions
90 
91 
92 public:
93 
94  // Generated Methods
95 
96  //- Default construct
97  CollisionRecordList() = default;
98 
99 
100  // Constructors
101 
102  //- Construct from Istream
103  explicit CollisionRecordList(Istream& is);
104 
105  //- Construct from component fields (for IO)
107  (
108  const labelField& pairAccessed,
111  const Field<PairType>& pairData,
112  const labelField& wallAccessed,
113  const vectorField& wallPRel,
115  );
116 
117 
118  // Member Functions
119 
120  //- Return the active pair collisions
122  pairRecords() const;
123 
124  //- Return the active wall collisions
126  wallRecords() const;
127 
128  // Fields representing the data from each record, i.e if the
129  // records 0-N containing each data members {a, b, c, d...}
130  // are organised:
131  //
132  // a0 b0 c0 d0 ...
133  // a1 b1 c1 d1 ...
134  // a2 b2 c2 d2 ...
135  // ...
136  // aN bN cN dN ...
137  //
138  // Then these field return, for example, (c0, c1, c2,... cN)
139 
140  //- Return field of pair accessed from each record, used for
141  // field IO
142  labelField pairAccessed() const;
143 
144  //- Return field of pair origProcOfOther from each record,
145  // used for field IO
147 
148  //- Return field of pair origIdOfOther from each record, used
149  // for field IO
151 
152  //- Return field of pair data from each record, used for field IO
153  Field<PairType> pairData() const;
154 
155  //- Return field of wall accessed from each record, used for field IO
156  labelField wallAccessed() const;
157 
158  //- Return field of wall pRel from each record, used for field IO
159  vectorField wallPRel() const;
160 
161  //- Return field of wall data from each record, used for field IO
162  Field<WallType> wallData() const;
163 
164  //- Enquires if the proc and id pair of the other particle are
165  // present in the records. If so, return non-const access to
166  // the PairCollisionRecord (hence the data) and mark the
167  // PairCollisionRecord as accessed this step, if not, create
168  // the record and return access to it.
170  (
171  label origProcOfOther,
172  label origIdOfOther
173  );
174 
175  //- Enquire if the specified record exists without modifying
176  // its accessed status
177  bool checkPairRecord(label origProcOfOther, label origIdOfOther);
178 
179  //- Enquires if the position of wall impact relative to the
180  // particle centre is present in the records. If so, return
181  // access to the WallCollisionRecord (hence the data) and
182  // mark the WallCollisionRecord as accesses this step, if
183  // not, create the record and return access to it.
185  (
186  const vector& pRel,
187  scalar radius
188  );
189 
190  //- Enquire if the specified record exists without modifying
191  // its accessed status
192  bool checkWallRecord(const vector& pRel, scalar radius);
193 
194  //- Update the collision records, deleting any records not
195  // marked as having been accessed, then mark all records as
196  // not accessed ready for the next evaluation
197  void update();
198 
199 
200  // Friend Operators
201 
202  friend bool operator== <PairType, WallType>
203  (
206  );
207 
208  friend bool operator!= <PairType, WallType>
209  (
212  );
213 
214 
215  // IOstream Operators
216 
217  friend Istream& operator>> <PairType, WallType>
218  (
219  Istream&,
221  );
222 
223  friend Ostream& operator<< <PairType, WallType>
224  (
225  Ostream&,
227  );
228 };
229 
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 } // End namespace Foam
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #include "CollisionRecordListI.H"
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #ifdef NoRepository
242  #include "CollisionRecordList.C"
243 #endif
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
Field< WallType > wallData() const
Return field of wall data from each record, used for field IO.
labelField wallAccessed() const
Return field of wall accessed from each record, used for field IO.
const DynamicList< PairCollisionRecord< PairType > > & pairRecords() const
Return the active pair collisions.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Field< PairType > pairData() const
Return field of pair data from each record, used for field IO.
labelField pairAccessed() const
Return field of pair accessed from each record, used for.
void update()
Update the collision records, deleting any records not.
bool checkWallRecord(const vector &pRel, scalar radius)
Enquire if the specified record exists without modifying.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:51
Istream & operator>>(Istream &, directionInfo &)
labelField pairOrigProcOfOther() const
Return field of pair origProcOfOther from each record,.
labelField pairOrigIdOfOther() const
Return field of pair origIdOfOther from each record, used.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
PairCollisionRecord< PairType > & matchPairRecord(label origProcOfOther, label origIdOfOther)
Enquires if the proc and id pair of the other particle are.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
CollisionRecordList()=default
Default construct.
Record of a collision between the particle holding the record and a wall face at the position relativ...
const DynamicList< WallCollisionRecord< WallType > > & wallRecords() const
Return the active wall collisions.
WallCollisionRecord< WallType > & matchWallRecord(const vector &pRel, scalar radius)
Enquires if the position of wall impact relative to the.
Record of a collision between the particle holding the record and the particle with the stored id...
vectorField wallPRel() const
Return field of wall pRel from each record, used for field IO.
bool checkPairRecord(label origProcOfOther, label origIdOfOther)
Enquire if the specified record exists without modifying.
Namespace for OpenFOAM.