molecule.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-2022 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::molecule
26 
27 Description
28  Foam::molecule
29 
30 SourceFiles
31  moleculeI.H
32  molecule.C
33  moleculeIO.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef molecule_H
38 #define molecule_H
39 
40 #include "particle.H"
41 #include "Cloud.H"
42 #include "IOstream.H"
43 #include "autoPtr.H"
44 #include "diagTensor.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Class forward declarations
52 class moleculeCloud;
53 
54 
55 // Forward declaration of friend functions and operators
56 
57 class molecule;
58 
59 Ostream& operator<<(Ostream&, const molecule&);
60 
61 
62 /*---------------------------------------------------------------------------*\
63  Class molecule Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class molecule
67 :
68  public particle
69 {
70  // Private Data
71 
72  //- Size in bytes of the fields
73  static const std::size_t sizeofFields_;
74 
75 
76 public:
77 
78  // Values of special that are less than zero are for built-in functionality.
79  // Values greater than zero are user specifiable/expandable (i.e. test
80  // special_ >= SPECIAL_USER)
81 
82  enum specialTypes
83  {
86  NOT_SPECIAL = 0,
88  };
89 
90  //- Class to hold molecule constant properties
91  class constantProperties
92  {
93  // Private Data
94 
95  Field<vector> siteReferencePositions_;
96 
97  List<scalar> siteMasses_;
98 
99  List<scalar> siteCharges_;
100 
101  List<label> siteIds_;
102 
103  List<bool> pairPotentialSites_;
104 
105  List<bool> electrostaticSites_;
106 
107  diagTensor momentOfInertia_;
108 
109  scalar mass_;
110 
111 
112  // Private Member Functions
113 
114  void checkSiteListSizes() const;
115 
116  void setInteractionSiteBools
117  (
118  const List<word>& siteIds,
119  const List<word>& pairPotSiteIds
120  );
121 
122  bool linearMoleculeTest() const;
123 
124 
125  public:
126 
127  inline constantProperties();
128 
129  //- Construct from dictionary
130  inline constantProperties(const dictionary& dict);
131 
132  // Member Functions
133 
134  inline const Field<vector>& siteReferencePositions() const;
135 
136  inline const List<scalar>& siteMasses() const;
137 
138  inline const List<scalar>& siteCharges() const;
139 
140  inline const List<label>& siteIds() const;
141 
142  inline List<label>& siteIds();
143 
144  inline const List<bool>& pairPotentialSites() const;
145 
146  inline bool pairPotentialSite(label sId) const;
147 
148  inline const List<bool>& electrostaticSites() const;
149 
150  inline bool electrostaticSite(label sId) const;
151 
152  inline const diagTensor& momentOfInertia() const;
153 
154  inline bool linearMolecule() const;
155 
156  inline bool pointMolecule() const;
157 
158  inline label degreesOfFreedom() const;
159 
160  inline scalar mass() const;
161 
162  inline label nSites() const;
163  };
164 
165 
166  //- Class used to pass tracking data to the trackToFace function
167  class trackingData
168  :
170  {
171  public:
172 
173  enum trackPart
174  {
179  };
180 
181 
182  private:
183 
184  // Private Data
185 
186  //- Which part of the integration algorithm is taking place
187  trackPart part_;
188 
189 
190  public:
191 
192  // Constructors
193 
194  //- Construct from components
196  :
198  {}
199 
200 
201  // Member Functions
202 
203  //- Return the part of the tracking operation taking place
204  inline trackPart part() const
205  {
206  return part_;
207  }
208 
209  //- Access to the part of the tracking operation taking place
210  inline trackPart& part()
211  {
212  return part_;
213  }
214  };
215 
216 
217 private:
218 
219  // Private Data
220 
221  tensor Q_;
222 
223  vector v_;
224 
225  vector a_;
226 
227  vector pi_;
228 
229  vector tau_;
230 
231  vector specialPosition_;
232 
233  scalar potentialEnergy_;
234 
235  // - r_ij f_ij, stress dyad
236  tensor rf_;
237 
238  label special_;
239 
240  label id_;
241 
242  List<vector> siteForces_;
243 
244  List<vector> sitePositions_;
245 
246 
247  // Private Member Functions
248 
249  tensor rotationTensorX(scalar deltaT) const;
250 
251  tensor rotationTensorY(scalar deltaT) const;
252 
253  tensor rotationTensorZ(scalar deltaT) const;
254 
255 
256 public:
257 
258  friend class Cloud<molecule>;
259 
260  // Constructors
261 
262  //- Construct from a position and a cell, searching for the rest of the
263  // required topology
264  inline molecule
265  (
266  const polyMesh& mesh,
267  const vector& position,
268  const label celli,
269  const tensor& Q,
270  const vector& v,
271  const vector& a,
272  const vector& pi,
273  const vector& tau,
274  const vector& specialPosition,
275  const constantProperties& constProps,
276  const label special,
277  const label id
278  );
279 
280  //- Construct from Istream
281  molecule(Istream& is, bool readFields = true);
282 
283  //- Construct and return a clone
284  autoPtr<particle> clone() const
285  {
286  return autoPtr<particle>(new molecule(*this));
287  }
288 
289  //- Construct from Istream and return
290  static autoPtr<molecule> New(Istream& is)
291  {
292  return autoPtr<molecule>(new molecule(is));
293  }
294 
295 
296  // Member Functions
297 
298  // Tracking
299 
300  bool move(moleculeCloud&, trackingData&);
301 
302  virtual void transformProperties(const transformer&);
303 
304  void setSitePositions
305  (
306  const polyMesh& mesh,
307  const constantProperties& constProps
308  );
309 
310  void setSiteSizes(label size);
311 
312 
313  // Access
314 
315  inline const tensor& Q() const;
316  inline tensor& Q();
317 
318  inline const vector& v() const;
319  inline vector& v();
320 
321  inline const vector& a() const;
322  inline vector& a();
323 
324  inline const vector& pi() const;
325  inline vector& pi();
326 
327  inline const vector& tau() const;
328  inline vector& tau();
329 
330  inline const List<vector>& siteForces() const;
331  inline List<vector>& siteForces();
332 
333  inline const List<vector>& sitePositions() const;
334  inline List<vector>& sitePositions();
335 
336  inline const vector& specialPosition() const;
337  inline vector& specialPosition();
338 
339  inline scalar potentialEnergy() const;
340  inline scalar& potentialEnergy();
341 
342  inline const tensor& rf() const;
343  inline tensor& rf();
344 
345  inline label special() const;
346 
347  inline bool tethered() const;
348 
349  inline label id() const;
350 
351 
352  // Member Operators
353 
354  //- Overridable function to handle the particle hitting a wallPatch
355  void hitWallPatch(moleculeCloud& cloud, trackingData& td);
356 
357 
358  // I-O
359 
360  static void readFields(Cloud<molecule>& mC);
361 
362  static void writeFields(const Cloud<molecule>& mC);
363 
364 
365  // IOstream Operators
366 
367  friend Ostream& operator<<(Ostream&, const molecule&);
368 };
369 
370 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
371 
372 } // End namespace Foam
373 
374 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
375 
376 #include "moleculeI.H"
377 
378 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
379 
380 #endif
381 
382 // ************************************************************************* //
Base cloud calls templated on particle type.
Definition: Cloud.H:74
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A cloud is a collection of lagrangian particles.
Definition: cloud.H:55
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Class to hold molecule constant properties.
Definition: molecule.H:91
const diagTensor & momentOfInertia() const
Definition: moleculeI.H:416
const Field< vector > & siteReferencePositions() const
Definition: moleculeI.H:331
const List< label > & siteIds() const
Definition: moleculeI.H:352
const List< bool > & pairPotentialSites() const
Definition: moleculeI.H:366
const List< scalar > & siteCharges() const
Definition: moleculeI.H:345
bool pairPotentialSite(label sId) const
Definition: moleculeI.H:373
bool electrostaticSite(label sId) const
Definition: moleculeI.H:398
const List< scalar > & siteMasses() const
Definition: moleculeI.H:338
const List< bool > & electrostaticSites() const
Definition: moleculeI.H:391
Class used to pass tracking data to the trackToFace function.
Definition: molecule.H:169
trackingData(const moleculeCloud &cloud)
Construct from components.
Definition: molecule.H:194
trackPart part() const
Return the part of the tracking operation taking place.
Definition: molecule.H:203
Foam::molecule.
Definition: molecule.H:68
const tensor & Q() const
Definition: moleculeI.H:466
const vector & v() const
Definition: moleculeI.H:478
void setSiteSizes(label size)
Definition: molecule.C:229
const List< vector > & sitePositions() const
Definition: moleculeI.H:538
const vector & a() const
Definition: moleculeI.H:490
const List< vector > & siteForces() const
Definition: moleculeI.H:526
const vector & specialPosition() const
Definition: moleculeI.H:550
void setSitePositions(const polyMesh &mesh, const constantProperties &constProps)
Definition: molecule.C:218
@ SPECIAL_TETHERED
Definition: molecule.H:83
label special() const
Definition: moleculeI.H:586
const tensor & rf() const
Definition: moleculeI.H:574
friend Ostream & operator<<(Ostream &, const molecule &)
const vector & tau() const
Definition: moleculeI.H:514
static autoPtr< molecule > New(Istream &is)
Construct from Istream and return.
Definition: molecule.H:289
scalar potentialEnergy() const
Definition: moleculeI.H:562
bool move(moleculeCloud &, trackingData &)
Definition: molecule.C:69
static void writeFields(const Cloud< molecule > &mC)
Definition: moleculeIO.C:145
const vector & pi() const
Definition: moleculeI.H:502
static void readFields(Cloud< molecule > &mC)
Definition: moleculeIO.C:89
virtual void transformProperties(const transformer &)
Transform the physical properties of the particle.
Definition: molecule.C:190
autoPtr< particle > clone() const
Construct and return a clone.
Definition: molecule.H:283
void hitWallPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a wallPatch.
Definition: molecule.C:237
bool tethered() const
Definition: moleculeI.H:592
molecule(const polyMesh &mesh, const vector &position, const label celli, const tensor &Q, const vector &v, const vector &a, const vector &pi, const vector &tau, const vector &specialPosition, const constantProperties &constProps, const label special, const label id)
Construct from a position and a cell, searching for the rest of the.
Definition: moleculeI.H:223
label id() const
Definition: moleculeI.H:598
Base particle class.
Definition: particle.H:83
vector position(const polyMesh &mesh) const
Return current particle position.
Definition: particleI.H:255
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
Namespace for OpenFOAM.
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
Ostream & operator<<(Ostream &, const ensightPart &)
dictionary dict