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-2024 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  label& nLocateBoundaryHits,
270  const tensor& Q,
271  const vector& v,
272  const vector& a,
273  const vector& pi,
274  const vector& tau,
275  const vector& specialPosition,
276  const constantProperties& constProps,
277  const label special,
278  const label id
279  );
280 
281  //- Construct from Istream
282  molecule(Istream& is, bool readFields = true);
283 
284  //- Construct and return a clone
285  autoPtr<particle> clone() const
286  {
287  return autoPtr<particle>(new molecule(*this));
288  }
289 
290  //- Construct from Istream and return
291  static autoPtr<molecule> New(Istream& is)
292  {
293  return autoPtr<molecule>(new molecule(is));
294  }
295 
296 
297  // Member Functions
298 
299  // Tracking
300 
301  bool move(moleculeCloud&, trackingData&);
302 
303  virtual void transformProperties(const transformer&);
304 
305  void setSitePositions
306  (
307  const polyMesh& mesh,
308  const constantProperties& constProps
309  );
310 
311  void setSiteSizes(label size);
312 
313 
314  // Access
315 
316  inline const tensor& Q() const;
317  inline tensor& Q();
318 
319  inline const vector& v() const;
320  inline vector& v();
321 
322  inline const vector& a() const;
323  inline vector& a();
324 
325  inline const vector& pi() const;
326  inline vector& pi();
327 
328  inline const vector& tau() const;
329  inline vector& tau();
330 
331  inline const List<vector>& siteForces() const;
332  inline List<vector>& siteForces();
333 
334  inline const List<vector>& sitePositions() const;
335  inline List<vector>& sitePositions();
336 
337  inline const vector& specialPosition() const;
338  inline vector& specialPosition();
339 
340  inline scalar potentialEnergy() const;
341  inline scalar& potentialEnergy();
342 
343  inline const tensor& rf() const;
344  inline tensor& rf();
345 
346  inline label special() const;
347 
348  inline bool tethered() const;
349 
350  inline label id() const;
351 
352 
353  // Member Operators
354 
355  //- Overridable function to handle the particle hitting a wallPatch
356  void hitWallPatch(moleculeCloud& cloud, trackingData& td);
357 
358 
359  // I-O
360 
361  static void readFields(Cloud<molecule>& mC);
362 
363  static void writeFields(const Cloud<molecule>& mC);
364 
365 
366  // IOstream Operators
367 
368  friend Ostream& operator<<(Ostream&, const molecule&);
369 };
370 
371 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
372 
373 } // End namespace Foam
374 
375 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
376 
377 #include "moleculeI.H"
378 
379 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
380 
381 #endif
382 
383 // ************************************************************************* //
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:162
Class to hold molecule constant properties.
Definition: molecule.H:91
const diagTensor & momentOfInertia() const
Definition: moleculeI.H:417
const Field< vector > & siteReferencePositions() const
Definition: moleculeI.H:332
const List< label > & siteIds() const
Definition: moleculeI.H:353
const List< bool > & pairPotentialSites() const
Definition: moleculeI.H:367
const List< scalar > & siteCharges() const
Definition: moleculeI.H:346
bool pairPotentialSite(label sId) const
Definition: moleculeI.H:374
bool electrostaticSite(label sId) const
Definition: moleculeI.H:399
const List< scalar > & siteMasses() const
Definition: moleculeI.H:339
const List< bool > & electrostaticSites() const
Definition: moleculeI.H:392
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:467
molecule(const polyMesh &mesh, const vector &position, const label celli, label &nLocateBoundaryHits, 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
const vector & v() const
Definition: moleculeI.H:479
void setSiteSizes(label size)
Definition: molecule.C:229
const List< vector > & sitePositions() const
Definition: moleculeI.H:539
const vector & a() const
Definition: moleculeI.H:491
const List< vector > & siteForces() const
Definition: moleculeI.H:527
const vector & specialPosition() const
Definition: moleculeI.H:551
void setSitePositions(const polyMesh &mesh, const constantProperties &constProps)
Definition: molecule.C:218
@ SPECIAL_TETHERED
Definition: molecule.H:83
label special() const
Definition: moleculeI.H:587
const tensor & rf() const
Definition: moleculeI.H:575
friend Ostream & operator<<(Ostream &, const molecule &)
const vector & tau() const
Definition: moleculeI.H:515
static autoPtr< molecule > New(Istream &is)
Construct from Istream and return.
Definition: molecule.H:290
scalar potentialEnergy() const
Definition: moleculeI.H:563
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:503
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:284
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:593
label id() const
Definition: moleculeI.H:599
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 &os, const fvConstraints &constraints)
dictionary dict