molecule.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 | Copyright (C) 2011-2015 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  Class molecule Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class molecule
58 :
59  public particle
60 {
61  // Private data
62 
63  //- Size in bytes of the fields
64  static const std::size_t sizeofFields_;
65 
66 
67 public:
68 
69  // Values of special that are less than zero are for built-in functionality.
70  // Values greater than zero are user specifiable/expandable (i.e. test
71  // special_ >= SPECIAL_USER)
72 
73  enum specialTypes
74  {
78  SPECIAL_USER = 1
79  };
80 
81  //- Class to hold molecule constant properties
82  class constantProperties
83  {
84  // Private data
85 
87 
89 
91 
93 
95 
97 
99 
100  scalar mass_;
101 
102 
103  // Private Member Functions
104 
105  void checkSiteListSizes() const;
106 
108  (
109  const List<word>& siteIds,
110  const List<word>& pairPotSiteIds
111  );
112 
113  bool linearMoleculeTest() const;
114 
115 
116  public:
117 
118  inline constantProperties();
119 
120  //- Construct from dictionary
121  inline constantProperties(const dictionary& dict);
122 
123  // Member functions
124 
125  inline const Field<vector>& siteReferencePositions() const;
126 
127  inline const List<scalar>& siteMasses() const;
128 
129  inline const List<scalar>& siteCharges() const;
130 
131  inline const List<label>& siteIds() const;
132 
133  inline List<label>& siteIds();
134 
135  inline const List<bool>& pairPotentialSites() const;
136 
137  inline bool pairPotentialSite(label sId) const;
138 
139  inline const List<bool>& electrostaticSites() const;
140 
141  inline bool electrostaticSite(label sId) const;
142 
143  inline const diagTensor& momentOfInertia() const;
144 
145  inline bool linearMolecule() const;
146 
147  inline bool pointMolecule() const;
148 
149  inline label degreesOfFreedom() const;
150 
151  inline scalar mass() const;
152 
153  inline label nSites() const;
154  };
155 
156 
157  //- Class used to pass tracking data to the trackToFace function
158  class trackingData
159  :
160  public particle::TrackingData<moleculeCloud>
161  {
162  // label specifying which part of the integration algorithm is taking
163  label part_;
164 
165 
166  public:
167 
168  // Constructors
169 
171  :
173  part_(part)
174  {}
175 
176  // Member functions
177 
178  inline label part() const
179  {
180  return part_;
181  }
182  };
183 
184 
185 private:
186 
187  // Private data
188 
189  tensor Q_;
190 
191  vector v_;
192 
193  vector a_;
194 
195  vector pi_;
196 
197  vector tau_;
198 
200 
201  scalar potentialEnergy_;
202 
203  // - r_ij f_ij, stress dyad
204  tensor rf_;
205 
206  label special_;
207 
208  label id_;
209 
211 
213 
214 
215  // Private Member Functions
216 
217  tensor rotationTensorX(scalar deltaT) const;
218 
219  tensor rotationTensorY(scalar deltaT) const;
220 
221  tensor rotationTensorZ(scalar deltaT) const;
222 
223 
224 public:
225 
226  friend class Cloud<molecule>;
227 
228  // Constructors
229 
230  //- Construct from components
231  inline molecule
232  (
233  const polyMesh& mesh,
234  const vector& position,
235  const label cellI,
236  const label tetFaceI,
237  const label tetPtI,
238  const tensor& Q,
239  const vector& v,
240  const vector& a,
241  const vector& pi,
242  const vector& tau,
243  const vector& specialPosition,
244  const constantProperties& constProps,
245  const label special,
246  const label id
247  );
248 
249  //- Construct from Istream
250  molecule
251  (
252  const polyMesh& mesh,
253  Istream& is,
254  bool readFields = true
255  );
256 
257  //- Construct and return a clone
258  autoPtr<particle> clone() const
259  {
260  return autoPtr<particle>(new molecule(*this));
261  }
262 
263  //- Factory class to read-construct particles used for
264  // parallel transfer
265  class iNew
266  {
267  const polyMesh& mesh_;
268 
269  public:
270 
271  iNew(const polyMesh& mesh)
272  :
273  mesh_(mesh)
274  {}
275 
277  {
278  return autoPtr<molecule>(new molecule(mesh_, is, true));
279  }
280  };
281 
282 
283  // Member Functions
284 
285  // Tracking
286 
287  bool move(trackingData&, const scalar trackTime);
288 
289  virtual void transformProperties(const tensor& T);
290 
291  virtual void transformProperties(const vector& separation);
292 
293  void setSitePositions(const constantProperties& constProps);
294 
295  void setSiteSizes(label size);
296 
297 
298  // Access
299 
300  inline const tensor& Q() const;
301  inline tensor& Q();
302 
303  inline const vector& v() const;
304  inline vector& v();
305 
306  inline const vector& a() const;
307  inline vector& a();
308 
309  inline const vector& pi() const;
310  inline vector& pi();
311 
312  inline const vector& tau() const;
313  inline vector& tau();
314 
315  inline const List<vector>& siteForces() const;
316  inline List<vector>& siteForces();
317 
318  inline const List<vector>& sitePositions() const;
319  inline List<vector>& sitePositions();
320 
321  inline const vector& specialPosition() const;
322  inline vector& specialPosition();
323 
324  inline scalar potentialEnergy() const;
325  inline scalar& potentialEnergy();
326 
327  inline const tensor& rf() const;
328  inline tensor& rf();
329 
330  inline label special() const;
331 
332  inline bool tethered() const;
333 
334  inline label id() const;
335 
336 
337  // Member Operators
338 
339  //- Overridable function to handle the particle hitting a patch
340  // Executed before other patch-hitting functions
341  bool hitPatch
342  (
343  const polyPatch&,
344  trackingData& td,
345  const label patchI,
346  const scalar trackFraction,
347  const tetIndices& tetIs
348  );
349 
350  //- Overridable function to handle the particle hitting a processorPatch
351  void hitProcessorPatch
352  (
353  const processorPolyPatch&,
354  trackingData& td
355  );
356 
357  //- Overridable function to handle the particle hitting a wallPatch
358  void hitWallPatch
359  (
360  const wallPolyPatch&,
361  trackingData& td,
362  const tetIndices&
363  );
364 
365  //- Overridable function to handle the particle hitting a polyPatch
366  void hitPatch
367  (
368  const polyPatch&,
369  trackingData& td
370  );
371 
372 
373  // I-O
374 
375  static void readFields(Cloud<molecule>& mC);
376 
377  static void writeFields(const Cloud<molecule>& mC);
378 
379 
380  // IOstream Operators
381 
382  friend Ostream& operator<<(Ostream&, const molecule&);
383 };
384 
385 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
386 
387 } // End namespace Foam
388 
389 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
390 
391 #include "moleculeI.H"
392 
393 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
394 
395 #endif
396 
397 // ************************************************************************* //
Foam::molecule::sizeofFields_
static const std::size_t sizeofFields_
Size in bytes of the fields.
Definition: molecule.H:63
Foam::Tensor
Templated 3D tensor derived from VectorSpace adding construction from 9 components,...
Definition: complexI.H:224
Foam::molecule::rf_
tensor rf_
Definition: molecule.H:203
Foam::molecule::rotationTensorY
tensor rotationTensorY(scalar deltaT) const
Definition: molecule.C:44
Foam::molecule::writeFields
static void writeFields(const Cloud< molecule > &mC)
Definition: moleculeIO.C:148
Foam::DiagTensor< scalar >
Foam::molecule::rotationTensorZ
tensor rotationTensorZ(scalar deltaT) const
Definition: molecule.C:55
Foam::molecule::iNew::mesh_
const polyMesh & mesh_
Definition: molecule.H:266
Foam::molecule::siteForces_
List< vector > siteForces_
Definition: molecule.H:209
Foam::molecule::operator<<
friend Ostream & operator<<(Ostream &, const molecule &)
Foam::molecule::v
const vector & v() const
Definition: moleculeI.H:478
Foam::molecule::id_
label id_
Definition: molecule.H:207
Foam::molecule::constantProperties::siteCharges_
List< scalar > siteCharges_
Definition: molecule.H:89
Foam::molecule::constantProperties::siteIds
const List< label > & siteIds() const
Definition: moleculeI.H:352
Foam::molecule::constantProperties::pairPotentialSite
bool pairPotentialSite(label sId) const
Definition: moleculeI.H:373
Foam::molecule::constantProperties::siteMasses_
List< scalar > siteMasses_
Definition: molecule.H:87
Foam::molecule::constantProperties::checkSiteListSizes
void checkSiteListSizes() const
Definition: moleculeI.H:259
Foam::molecule::id
label id() const
Definition: moleculeI.H:598
Foam::molecule::constantProperties::pairPotentialSites_
List< bool > pairPotentialSites_
Definition: molecule.H:93
Foam::readFields
This function object reads fields from the time directories and adds them to the mesh database for fu...
Definition: readFields.H:104
Foam::molecule::iNew::iNew
iNew(const polyMesh &mesh)
Definition: molecule.H:270
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::molecule::trackingData::part
label part() const
Definition: molecule.H:177
Foam::molecule::tau
const vector & tau() const
Definition: moleculeI.H:514
Foam::molecule::sitePositions
const List< vector > & sitePositions() const
Definition: moleculeI.H:538
Foam::molecule::setSitePositions
void setSitePositions(const constantProperties &constProps)
Definition: molecule.C:227
Foam::molecule::specialTypes
specialTypes
Definition: molecule.H:72
Foam::molecule::clone
autoPtr< particle > clone() const
Construct and return a clone.
Definition: molecule.H:257
Foam::Q
This function object calculates and outputs the second invariant of the velocity gradient tensor [1/s...
Definition: Q.H:119
Foam::molecule::constantProperties::siteCharges
const List< scalar > & siteCharges() const
Definition: moleculeI.H:345
Foam::molecule::Q_
tensor Q_
Definition: molecule.H:188
Foam::molecule::constantProperties::pointMolecule
bool pointMolecule() const
Definition: moleculeI.H:428
Foam::molecule::special
label special() const
Definition: moleculeI.H:586
Foam::molecule::Q
const tensor & Q() const
Definition: moleculeI.H:466
Foam::label
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
Foam::molecule::tau_
vector tau_
Definition: molecule.H:196
Foam::molecule
Foam::molecule.
Definition: molecule.H:56
Foam::Field< vector >
Foam::molecule::a
const vector & a() const
Definition: moleculeI.H:490
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::molecule::special_
label special_
Definition: molecule.H:205
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::molecule::constantProperties::momentOfInertia
const diagTensor & momentOfInertia() const
Definition: moleculeI.H:416
Foam::molecule::constantProperties::siteReferencePositions
const Field< vector > & siteReferencePositions() const
Definition: moleculeI.H:331
Foam::molecule::constantProperties::siteReferencePositions_
Field< vector > siteReferencePositions_
Definition: molecule.H:85
Foam::molecule::constantProperties::pairPotentialSites
const List< bool > & pairPotentialSites() const
Definition: moleculeI.H:366
Foam::molecule::constantProperties::linearMolecule
bool linearMolecule() const
Definition: moleculeI.H:422
Foam::molecule::rf
const tensor & rf() const
Definition: moleculeI.H:574
IOstream.H
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam::molecule::trackingData
Class used to pass tracking data to the trackToFace function.
Definition: molecule.H:157
Foam::molecule::constantProperties::electrostaticSites
const List< bool > & electrostaticSites() const
Definition: moleculeI.H:391
Foam::processorPolyPatch
Neighbour processor patch.
Definition: processorPolyPatch.H:55
Foam::particle::mesh
const polyMesh & mesh() const
Return the mesh database.
Definition: particleI.H:580
Foam::molecule::siteForces
const List< vector > & siteForces() const
Definition: moleculeI.H:526
Foam::molecule::setSiteSizes
void setSiteSizes(label size)
Definition: molecule.C:233
Foam::molecule::v_
vector v_
Definition: molecule.H:190
Foam::molecule::constantProperties::degreesOfFreedom
label degreesOfFreedom() const
Definition: moleculeI.H:434
Foam::molecule::molecule
molecule(const polyMesh &mesh, const vector &position, 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
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::molecule::potentialEnergy_
scalar potentialEnergy_
Definition: molecule.H:200
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::molecule::sitePositions_
List< vector > sitePositions_
Definition: molecule.H:211
Foam::wallPolyPatch
Foam::wallPolyPatch.
Definition: wallPolyPatch.H:48
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::molecule::constantProperties::nSites
label nSites() const
Definition: moleculeI.H:457
Foam::molecule::constantProperties::siteMasses
const List< scalar > & siteMasses() const
Definition: moleculeI.H:338
Foam::molecule::constantProperties::mass_
scalar mass_
Definition: molecule.H:99
Foam::molecule::pi_
vector pi_
Definition: molecule.H:194
Foam::molecule::specialPosition_
vector specialPosition_
Definition: molecule.H:198
Foam::tetIndices
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
Definition: tetIndices.H:73
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::cloud
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
Foam::molecule::trackingData::trackingData
trackingData(moleculeCloud &cloud, label part)
Definition: molecule.H:169
Foam::molecule::readFields
static void readFields(Cloud< molecule > &mC)
Definition: moleculeIO.C:94
moleculeI.H
Foam::molecule::iNew::operator()
autoPtr< molecule > operator()(Istream &is) const
Definition: molecule.H:275
Foam::molecule::potentialEnergy
scalar potentialEnergy() const
Definition: moleculeI.H:562
Foam::molecule::hitWallPatch
void hitWallPatch(const wallPolyPatch &, trackingData &td, const tetIndices &)
Overridable function to handle the particle hitting a wallPatch.
Definition: molecule.C:265
Foam::molecule::SPECIAL_USER
@ SPECIAL_USER
Definition: molecule.H:77
Foam::molecule::constantProperties::mass
scalar mass() const
Definition: moleculeI.H:451
Foam::moleculeCloud
Definition: moleculeCloud.H:56
Foam::molecule::rotationTensorX
tensor rotationTensorX(scalar deltaT) const
Definition: molecule.C:33
Foam::molecule::constantProperties::setInteracionSiteBools
void setInteracionSiteBools(const List< word > &siteIds, const List< word > &pairPotSiteIds)
Definition: moleculeI.H:276
Foam::Vector< scalar >
Foam::List< scalar >
Foam::molecule::constantProperties::siteIds_
List< label > siteIds_
Definition: molecule.H:91
Foam::molecule::specialPosition
const vector & specialPosition() const
Definition: moleculeI.H:550
Foam::particle
Base particle class.
Definition: particle.H:78
Foam::Cloud
Base cloud calls templated on particle type.
Definition: Cloud.H:52
Foam::molecule::hitPatch
bool hitPatch(const polyPatch &, trackingData &td, const label patchI, const scalar trackFraction, const tetIndices &tetIs)
Overridable function to handle the particle hitting a patch.
Definition: molecule.C:242
Foam::molecule::constantProperties
Class to hold molecule constant properties.
Definition: molecule.H:81
Foam::molecule::constantProperties::linearMoleculeTest
bool linearMoleculeTest() const
Definition: moleculeI.H:296
Foam::particle::position
const vector & position() const
Return current particle position.
Definition: particleI.H:586
particle.H
Foam::molecule::hitProcessorPatch
void hitProcessorPatch(const processorPolyPatch &, trackingData &td)
Overridable function to handle the particle hitting a processorPatch.
Definition: molecule.C:255
Foam::molecule::NOT_SPECIAL
@ NOT_SPECIAL
Definition: molecule.H:76
Foam::molecule::move
bool move(trackingData &, const scalar trackTime)
Definition: molecule.C:68
Foam::molecule::a_
vector a_
Definition: molecule.H:192
Foam::molecule::SPECIAL_TETHERED
@ SPECIAL_TETHERED
Definition: molecule.H:74
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::molecule::SPECIAL_FROZEN
@ SPECIAL_FROZEN
Definition: molecule.H:75
Foam::molecule::tethered
bool tethered() const
Definition: moleculeI.H:592
Foam::molecule::constantProperties::momentOfInertia_
diagTensor momentOfInertia_
Definition: molecule.H:97
Foam::molecule::constantProperties::electrostaticSites_
List< bool > electrostaticSites_
Definition: molecule.H:95
diagTensor.H
Foam::particle::TrackingData
Definition: particle.H:94
Foam::molecule::transformProperties
virtual void transformProperties(const tensor &T)
Transform the physical properties of the particle.
Definition: molecule.C:192
Foam::molecule::pi
const vector & pi() const
Definition: moleculeI.H:502
Foam::molecule::constantProperties::constantProperties
constantProperties()
Definition: moleculeI.H:28
Foam::molecule::constantProperties::electrostaticSite
bool electrostaticSite(label sId) const
Definition: moleculeI.H:398
Foam::molecule::iNew
Factory class to read-construct particles used for.
Definition: molecule.H:264
autoPtr.H
Foam::molecule::trackingData::part_
label part_
Definition: molecule.H:162