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-2018 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 setInteracionSiteBools
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  // label specifying which part of the integration algorithm is taking
171  label part_;
172 
173 
174  public:
175 
176  // Constructors
179  :
180  particle::trackingData(cloud),
181  part_(part)
182  {}
183 
184  // Member functions
186  inline label part() const
187  {
188  return part_;
189  }
190  };
191 
192 
193 private:
194 
195  // Private data
196 
197  tensor Q_;
198 
199  vector v_;
200 
201  vector a_;
202 
203  vector pi_;
204 
205  vector tau_;
206 
207  vector specialPosition_;
208 
209  scalar potentialEnergy_;
210 
211  // - r_ij f_ij, stress dyad
212  tensor rf_;
213 
214  label special_;
215 
216  label id_;
217 
218  List<vector> siteForces_;
219 
220  List<vector> sitePositions_;
221 
222 
223  // Private Member Functions
224 
225  tensor rotationTensorX(scalar deltaT) const;
226 
227  tensor rotationTensorY(scalar deltaT) const;
228 
229  tensor rotationTensorZ(scalar deltaT) const;
230 
231 
232 public:
234  friend class Cloud<molecule>;
235 
236  // Constructors
237 
238  //- Construct from components
239  inline molecule
240  (
241  const polyMesh& mesh,
242  const barycentric& coordinates,
243  const label celli,
244  const label tetFacei,
245  const label tetPti,
246  const tensor& Q,
247  const vector& v,
248  const vector& a,
249  const vector& pi,
250  const vector& tau,
251  const vector& specialPosition,
252  const constantProperties& constProps,
253  const label special,
254  const label id
255  );
256 
257  //- Construct from a position and a cell, searching for the rest of the
258  // required topology
259  inline molecule
260  (
261  const polyMesh& mesh,
262  const vector& position,
263  const label celli,
264  const tensor& Q,
265  const vector& v,
266  const vector& a,
267  const vector& pi,
268  const vector& tau,
269  const vector& specialPosition,
270  const constantProperties& constProps,
271  const label special,
272  const label id
273  );
274 
275  //- Construct from Istream
276  molecule
277  (
278  const polyMesh& mesh,
279  Istream& is,
280  bool readFields = true
281  );
282 
283  //- Construct and return a clone
284  autoPtr<particle> clone() const
285  {
286  return autoPtr<particle>(new molecule(*this));
287  }
288 
289  //- Factory class to read-construct particles used for
290  // parallel transfer
291  class iNew
292  {
293  const polyMesh& mesh_;
294 
295  public:
297  iNew(const polyMesh& mesh)
298  :
299  mesh_(mesh)
300  {}
302  autoPtr<molecule> operator()(Istream& is) const
303  {
304  return autoPtr<molecule>(new molecule(mesh_, is, true));
305  }
306  };
307 
308 
309  // Member Functions
310 
311  // Tracking
312 
313  bool move(moleculeCloud&, trackingData&, const scalar trackTime);
314 
315  virtual void transformProperties(const tensor& T);
316 
317  virtual void transformProperties(const vector& separation);
318 
319  void setSitePositions(const constantProperties& constProps);
320 
321  void setSiteSizes(label size);
322 
323 
324  // Access
325 
326  inline const tensor& Q() const;
327  inline tensor& Q();
328 
329  inline const vector& v() const;
330  inline vector& v();
331 
332  inline const vector& a() const;
333  inline vector& a();
334 
335  inline const vector& pi() const;
336  inline vector& pi();
337 
338  inline const vector& tau() const;
339  inline vector& tau();
340 
341  inline const List<vector>& siteForces() const;
342  inline List<vector>& siteForces();
343 
344  inline const List<vector>& sitePositions() const;
345  inline List<vector>& sitePositions();
346 
347  inline const vector& specialPosition() const;
348  inline vector& specialPosition();
349 
350  inline scalar potentialEnergy() const;
351  inline scalar& potentialEnergy();
352 
353  inline const tensor& rf() const;
354  inline tensor& rf();
355 
356  inline label special() const;
357 
358  inline bool tethered() const;
359 
360  inline label id() const;
361 
362 
363  // Member Operators
364 
365  //- Overridable function to handle the particle hitting a patch
366  // Executed before other patch-hitting functions
368 
369  //- Overridable function to handle the particle hitting a processorPatch
370  void hitProcessorPatch(moleculeCloud& cloud, trackingData& td);
371 
372  //- Overridable function to handle the particle hitting a wallPatch
373  void hitWallPatch(moleculeCloud& cloud, trackingData& td);
374 
375 
376  // I-O
377 
378  static void readFields(Cloud<molecule>& mC);
379 
380  static void writeFields(const Cloud<molecule>& mC);
381 
382 
383  // IOstream Operators
384 
385  friend Ostream& operator<<(Ostream&, const molecule&);
386 };
387 
388 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
389 
390 } // End namespace Foam
391 
392 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
393 
394 #include "moleculeI.H"
395 
396 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
397 
398 #endif
399 
400 // ************************************************************************* //
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:130
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
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:224
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
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:238
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:244
bool tethered() const
Definition: moleculeI.H:627
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
virtual void transformProperties(const tensor &T)
Transform the physical properties of the particle.
Definition: molecule.C:189
Base cloud calls templated on particle type.
Definition: Cloud.H:52
autoPtr< particle > clone() const
Construct and return a clone.
Definition: molecule.H:283
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:53
void hitWallPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a wallPatch.
Definition: molecule.C:250
Factory class to read-construct particles used for.
Definition: molecule.H:290
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
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:230
Ostream & operator<<(Ostream &, const ensightPart &)
const barycentric & coordinates() const
Return current particle coordinates.
Definition: particleI.H:136
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:283
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