All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2020 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 "IOstream.H"
42 #include "autoPtr.H"
43 #include "diagTensor.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Class forward declarations
51 class moleculeCloud;
52 
53 
54 // Forward declaration of friend functions and operators
55 
56 class molecule;
57 
58 Ostream& operator<<(Ostream&, const molecule&);
59 
60 
61 /*---------------------------------------------------------------------------*\
62  Class molecule Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class molecule
66 :
67  public particle
68 {
69  // Private Data
70 
71  //- Size in bytes of the fields
72  static const std::size_t sizeofFields_;
73 
74 
75 public:
76 
77  // Values of special that are less than zero are for built-in functionality.
78  // Values greater than zero are user specifiable/expandable (i.e. test
79  // special_ >= SPECIAL_USER)
80 
81  enum specialTypes
82  {
86  SPECIAL_USER = 1
87  };
88 
89  //- Class to hold molecule constant properties
90  class constantProperties
91  {
92  // Private Data
93 
94  Field<vector> siteReferencePositions_;
95 
96  List<scalar> siteMasses_;
97 
98  List<scalar> siteCharges_;
99 
100  List<label> siteIds_;
101 
102  List<bool> pairPotentialSites_;
103 
104  List<bool> electrostaticSites_;
105 
106  diagTensor momentOfInertia_;
107 
108  scalar mass_;
109 
110 
111  // Private Member Functions
112 
113  void checkSiteListSizes() const;
114 
115  void setInteractionSiteBools
116  (
117  const List<word>& siteIds,
118  const List<word>& pairPotSiteIds
119  );
120 
121  bool linearMoleculeTest() const;
122 
123 
124  public:
125 
126  inline constantProperties();
127 
128  //- Construct from dictionary
129  inline constantProperties(const dictionary& dict);
130 
131  // Member Functions
132 
133  inline const Field<vector>& siteReferencePositions() const;
134 
135  inline const List<scalar>& siteMasses() const;
136 
137  inline const List<scalar>& siteCharges() const;
138 
139  inline const List<label>& siteIds() const;
140 
141  inline List<label>& siteIds();
142 
143  inline const List<bool>& pairPotentialSites() const;
144 
145  inline bool pairPotentialSite(label sId) const;
146 
147  inline const List<bool>& electrostaticSites() const;
148 
149  inline bool electrostaticSite(label sId) const;
150 
151  inline const diagTensor& momentOfInertia() const;
152 
153  inline bool linearMolecule() const;
154 
155  inline bool pointMolecule() const;
156 
157  inline label degreesOfFreedom() const;
158 
159  inline scalar mass() const;
160 
161  inline label nSites() const;
162  };
163 
164 
165  //- Class used to pass tracking data to the trackToFace function
166  class trackingData
167  :
169  {
170  public:
172  enum trackPart
173  {
174  tpVelocityHalfStep0,
175  tpLinearTrack,
176  tpRotationalTrack,
177  tpVelocityHalfStep1
178  };
179 
180 
181  private:
182 
183  // Private Data
184 
185  //- Which part of the integration algorithm is taking place
186  trackPart part_;
187 
188 
189  public:
190 
191  // Constructors
192 
193  //- Construct from components
195  :
196  particle::trackingData(cloud)
197  {}
198 
199 
200  // Member Functions
201 
202  //- Return the part of the tracking operation taking place
203  inline trackPart part() const
204  {
205  return part_;
206  }
207 
208  //- Access to the part of the tracking operation taking place
209  inline trackPart& part()
210  {
211  return part_;
212  }
213  };
214 
215 
216 private:
217 
218  // Private Data
219 
220  tensor Q_;
221 
222  vector v_;
223 
224  vector a_;
225 
226  vector pi_;
227 
228  vector tau_;
229 
230  vector specialPosition_;
231 
232  scalar potentialEnergy_;
233 
234  // - r_ij f_ij, stress dyad
235  tensor rf_;
236 
237  label special_;
238 
239  label id_;
240 
241  List<vector> siteForces_;
242 
243  List<vector> sitePositions_;
244 
245 
246  // Private Member Functions
247 
248  tensor rotationTensorX(scalar deltaT) const;
249 
250  tensor rotationTensorY(scalar deltaT) const;
251 
252  tensor rotationTensorZ(scalar deltaT) const;
253 
254 
255 public:
257  friend class Cloud<molecule>;
258 
259  // Constructors
260 
261  //- Construct from components
262  inline molecule
263  (
264  const polyMesh& mesh,
265  const barycentric& coordinates,
266  const label celli,
267  const label tetFacei,
268  const label tetPti,
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 a position and a cell, searching for the rest of the
281  // required topology
282  inline molecule
283  (
284  const polyMesh& mesh,
285  const vector& position,
286  const label celli,
287  const tensor& Q,
288  const vector& v,
289  const vector& a,
290  const vector& pi,
291  const vector& tau,
292  const vector& specialPosition,
293  const constantProperties& constProps,
294  const label special,
295  const label id
296  );
297 
298  //- Construct from Istream
299  molecule
300  (
301  const polyMesh& mesh,
302  Istream& is,
303  bool readFields = true
304  );
305 
306  //- Construct and return a clone
307  autoPtr<particle> clone() const
308  {
309  return autoPtr<particle>(new molecule(*this));
310  }
311 
312  //- Factory class to read-construct particles used for
313  // parallel transfer
314  class iNew
315  {
316  const polyMesh& mesh_;
317 
318  public:
320  iNew(const polyMesh& mesh)
321  :
322  mesh_(mesh)
323  {}
325  autoPtr<molecule> operator()(Istream& is) const
326  {
327  return autoPtr<molecule>(new molecule(mesh_, is, true));
328  }
329  };
330 
331 
332  // Member Functions
333 
334  // Tracking
335 
336  bool move(moleculeCloud&, trackingData&, const scalar trackTime);
337 
338  virtual void transformProperties(const transformer&);
339 
340  void setSitePositions(const constantProperties& constProps);
341 
342  void setSiteSizes(label size);
343 
344 
345  // Access
346 
347  inline const tensor& Q() const;
348  inline tensor& Q();
349 
350  inline const vector& v() const;
351  inline vector& v();
352 
353  inline const vector& a() const;
354  inline vector& a();
355 
356  inline const vector& pi() const;
357  inline vector& pi();
358 
359  inline const vector& tau() const;
360  inline vector& tau();
361 
362  inline const List<vector>& siteForces() const;
363  inline List<vector>& siteForces();
364 
365  inline const List<vector>& sitePositions() const;
366  inline List<vector>& sitePositions();
367 
368  inline const vector& specialPosition() const;
369  inline vector& specialPosition();
370 
371  inline scalar potentialEnergy() const;
372  inline scalar& potentialEnergy();
373 
374  inline const tensor& rf() const;
375  inline tensor& rf();
376 
377  inline label special() const;
378 
379  inline bool tethered() const;
380 
381  inline label id() const;
382 
383 
384  // Member Operators
385 
386  //- Overridable function to handle the particle hitting a patch
387  // Executed before other patch-hitting functions
389 
390  //- Overridable function to handle the particle hitting a processorPatch
391  void hitProcessorPatch(moleculeCloud& cloud, trackingData& td);
392 
393  //- Overridable function to handle the particle hitting a wallPatch
394  void hitWallPatch(moleculeCloud& cloud, trackingData& td);
395 
396 
397  // I-O
398 
399  static void readFields(Cloud<molecule>& mC);
400 
401  static void writeFields(const Cloud<molecule>& mC);
402 
403 
404  // IOstream Operators
405 
406  friend Ostream& operator<<(Ostream&, const molecule&);
407 };
408 
409 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
410 
411 } // End namespace Foam
412 
413 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
414 
415 #include "moleculeI.H"
416 
417 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
418 
419 #endif
420 
421 // ************************************************************************* //
scalar potentialEnergy() const
Definition: moleculeI.H:597
const tensor & Q() const
Definition: moleculeI.H:501
dictionary dict
const List< bool > & electrostaticSites() const
Definition: moleculeI.H:426
const polyMesh & mesh() const
Return the mesh database.
Definition: particleI.H:125
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
const List< vector > & sitePositions() const
Definition: moleculeI.H:573
Vector-tensor class used to perform translations and rotations in 3D space.
Definition: transformer.H:83
const tensor & rf() const
Definition: moleculeI.H:609
const diagTensor & momentOfInertia() const
Definition: moleculeI.H:451
Class to hold molecule constant properties.
Definition: molecule.H:89
void setSitePositions(const constantProperties &constProps)
Definition: molecule.C:216
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
const List< vector > & siteForces() const
Definition: moleculeI.H:561
bool hitPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a patch.
Definition: molecule.C:230
label special() const
Definition: moleculeI.H:621
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const List< label > & siteIds() const
Definition: moleculeI.H:387
void hitProcessorPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a processorPatch.
Definition: molecule.C:236
bool tethered() const
Definition: moleculeI.H:627
virtual void transformProperties(const transformer &)
Transform the physical properties of the particle.
Definition: molecule.C:189
const vector & pi() const
Definition: moleculeI.H:537
static void writeFields(const Cloud< molecule > &mC)
Definition: moleculeIO.C:150
bool move(moleculeCloud &, trackingData &, const scalar trackTime)
Definition: molecule.C:69
static void readFields(Cloud< molecule > &mC)
Definition: moleculeIO.C:94
Base particle class.
Definition: particle.H:84
const Field< vector > & siteReferencePositions() const
Definition: moleculeI.H:366
const vector & a() const
Definition: moleculeI.H:525
friend Ostream & operator<<(Ostream &, const molecule &)
molecule(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPti, 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 components.
Definition: moleculeI.H:221
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
Base cloud calls templated on particle type.
Definition: Cloud.H:52
autoPtr< particle > clone() const
Construct and return a clone.
Definition: molecule.H:306
const List< bool > & pairPotentialSites() const
Definition: moleculeI.H:401
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void hitWallPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a wallPatch.
Definition: molecule.C:242
Factory class to read-construct particles used for.
Definition: molecule.H:313
bool electrostaticSite(label sId) const
Definition: moleculeI.H:433
Class used to pass tracking data to the trackToFace function.
Definition: molecule.H:165
void setSiteSizes(label size)
Definition: molecule.C:222
Ostream & operator<<(Ostream &, const ensightPart &)
const barycentric & coordinates() const
Return current particle coordinates.
Definition: particleI.H:131
Foam::molecule.
Definition: molecule.H:64
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
bool pairPotentialSite(label sId) const
Definition: moleculeI.H:408
label id() const
Definition: moleculeI.H:633
const List< scalar > & siteMasses() const
Definition: moleculeI.H:373
const vector & tau() const
Definition: moleculeI.H:549
vector position() const
Return current particle position.
Definition: particleI.H:278
Namespace for OpenFOAM.
const List< scalar > & siteCharges() const
Definition: moleculeI.H:380
const vector & specialPosition() const
Definition: moleculeI.H:585
const vector & v() const
Definition: moleculeI.H:513