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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2016 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::molecule
29 
30 Description
31  Foam::molecule
32 
33 SourceFiles
34  moleculeI.H
35  molecule.C
36  moleculeIO.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef molecule_H
41 #define molecule_H
42 
43 #include "particle.H"
44 #include "IOstream.H"
45 #include "autoPtr.H"
46 #include "diagTensor.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Class forward declarations
54 class moleculeCloud;
55 
56 
57 // Forward declaration of friend functions and operators
58 
59 class molecule;
60 
61 Ostream& operator<<(Ostream&, const molecule&);
62 
63 
64 /*---------------------------------------------------------------------------*\
65  Class molecule Declaration
66 \*---------------------------------------------------------------------------*/
67 
68 class molecule
69 :
70  public particle
71 {
72 public:
73 
74  //- Size in bytes of the fields
75  static const std::size_t sizeofFields;
76 
77 
78  // Values of special that are less than zero are for built-in functionality.
79  // Values greater than zero are user specifiable/expandable
80  // (i.e. test special_ >= SPECIAL_USER)
81 
82  enum specialTypes
83  {
87  SPECIAL_USER = 1
88  };
89 
90 
91  //- Class to hold molecule constant properties
92  class constantProperties
93  {
94  // Private data
95 
96  Field<vector> siteReferencePositions_;
97 
98  List<scalar> siteMasses_;
99 
100  List<scalar> siteCharges_;
101 
102  List<label> siteIds_;
103 
104  List<bool> pairPotentialSites_;
105 
106  List<bool> electrostaticSites_;
107 
108  diagTensor momentOfInertia_;
109 
110  scalar mass_;
111 
112 
113  // Private Member Functions
114 
115  void checkSiteListSizes() const;
116 
117  void setInteracionSiteBools
118  (
119  const List<word>& siteIds,
120  const List<word>& pairPotSiteIds
121  );
122 
123  bool linearMoleculeTest() const;
124 
125 
126  public:
127 
128  inline constantProperties();
129 
130  //- Construct from dictionary
131  inline constantProperties(const dictionary& dict);
132 
133  // Member functions
134 
135  inline const Field<vector>& siteReferencePositions() const;
136 
137  inline const List<scalar>& siteMasses() const;
138 
139  inline const List<scalar>& siteCharges() const;
140 
141  inline const List<label>& siteIds() const;
142 
143  inline List<label>& siteIds();
144 
145  inline const List<bool>& pairPotentialSites() const;
146 
147  inline bool pairPotentialSite(label sId) const;
148 
149  inline const List<bool>& electrostaticSites() const;
150 
151  inline bool electrostaticSite(label sId) const;
152 
153  inline const diagTensor& momentOfInertia() const;
154 
155  inline bool linearMolecule() const;
156 
157  inline bool pointMolecule() const;
158 
159  inline label degreesOfFreedom() const;
160 
161  inline scalar mass() const;
162 
163  inline label nSites() const;
164  };
165 
166 
167  //- Class used to pass tracking data to the trackToFace function
168  class trackingData
169  :
171  {
172  // label specifying which part of the integration algorithm is taking
173  label part_;
174 
175 
176  public:
177 
178  // Constructors
179 
181  :
183  part_(part)
184  {}
185 
186  // Member functions
187 
188  inline label part() const
189  {
190  return part_;
191  }
192  };
193 
194 
195 private:
196 
197  // Private data
198 
199  tensor Q_;
200 
201  vector v_;
202 
203  vector a_;
204 
205  vector pi_;
206 
207  vector tau_;
208 
209  vector specialPosition_;
210 
211  scalar potentialEnergy_;
212 
213  // - r_ij f_ij, stress dyad
214  tensor rf_;
215 
216  label special_;
217 
218  label id_;
219 
220  List<vector> siteForces_;
221 
222  List<vector> sitePositions_;
223 
224 
225  // Private Member Functions
226 
227  tensor rotationTensorX(scalar deltaT) const;
228 
229  tensor rotationTensorY(scalar deltaT) const;
230 
231  tensor rotationTensorZ(scalar deltaT) const;
232 
233 
234 public:
235 
236  friend class Cloud<molecule>;
237 
238  // Constructors
239 
240  //- Construct from components
241  inline molecule
242  (
243  const polyMesh& mesh,
244  const barycentric& coordinates,
245  const label celli,
246  const label tetFacei,
247  const label tetPti,
248  const tensor& Q,
249  const vector& v,
250  const vector& a,
251  const vector& pi,
252  const vector& tau,
253  const vector& specialPosition,
254  const constantProperties& constProps,
255  const label special,
256  const label id
257  );
258 
259  //- Construct from a position and a cell, searching for the rest of the
260  // required topology
261  inline molecule
262  (
263  const polyMesh& mesh,
264  const vector& position,
265  const label celli,
266  const tensor& Q,
267  const vector& v,
268  const vector& a,
269  const vector& pi,
270  const vector& tau,
271  const vector& specialPosition,
272  const constantProperties& constProps,
273  const label special,
274  const label id
275  );
276 
277  //- Construct from Istream
278  molecule
279  (
280  const polyMesh& mesh,
281  Istream& is,
282  bool readFields = true,
283  bool newFormat = true
284  );
285 
286  //- Construct and return a clone
287  autoPtr<particle> clone() const
288  {
289  return autoPtr<particle>(new molecule(*this));
290  }
291 
292  //- Factory class to read-construct particles used for
293  // parallel transfer
294  class iNew
295  {
296  const polyMesh& mesh_;
297 
298  public:
299 
300  iNew(const polyMesh& mesh)
301  :
302  mesh_(mesh)
303  {}
304 
306  {
307  return autoPtr<molecule>::New(mesh_, is, true);
308  }
309  };
310 
311 
312  // Member Functions
313 
314  // Tracking
315 
316  bool move(moleculeCloud&, trackingData&, const scalar trackTime);
317 
318  virtual void transformProperties(const tensor& T);
319 
320  virtual void transformProperties(const vector& separation);
321 
322  void setSitePositions(const constantProperties& constProps);
323 
324  void setSiteSizes(label size);
325 
326 
327  // Access
328 
329  inline const tensor& Q() const;
330  inline tensor& Q();
331 
332  inline const vector& v() const;
333  inline vector& v();
334 
335  inline const vector& a() const;
336  inline vector& a();
337 
338  inline const vector& pi() const;
339  inline vector& pi();
340 
341  inline const vector& tau() const;
342  inline vector& tau();
343 
344  inline const List<vector>& siteForces() const;
345  inline List<vector>& siteForces();
346 
347  inline const List<vector>& sitePositions() const;
348  inline List<vector>& sitePositions();
349 
350  inline const vector& specialPosition() const;
351  inline vector& specialPosition();
352 
353  inline scalar potentialEnergy() const;
354  inline scalar& potentialEnergy();
355 
356  inline const tensor& rf() const;
357  inline tensor& rf();
358 
359  inline label special() const;
360 
361  inline bool tethered() const;
362 
363  inline label id() const;
364 
365 
366  // Member Operators
367 
368  //- Overridable function to handle the particle hitting a patch
369  // Executed before other patch-hitting functions
370  bool hitPatch(moleculeCloud& cloud, trackingData& td);
371 
372  //- Overridable function to handle the particle hitting a processorPatch
373  void hitProcessorPatch(moleculeCloud& cloud, trackingData& td);
374 
375  //- Overridable function to handle the particle hitting a wallPatch
376  void hitWallPatch(moleculeCloud& cloud, trackingData& td);
377 
378 
379  // I-O
380 
381  static void readFields(Cloud<molecule>& mC);
382 
383  static void writeFields(const Cloud<molecule>& mC);
384 
385 
386  // IOstream Operators
387 
388  friend Ostream& operator<<(Ostream&, const molecule&);
389 };
390 
391 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
392 
393 } // End namespace Foam
394 
395 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
396 
397 #include "moleculeI.H"
398 
399 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
400 
401 #endif
402 
403 // ************************************************************************* //
Foam::autoPtr::New
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
Foam::molecule::constantProperties::siteIds
const List< label > & siteIds() const
Definition: moleculeI.H:395
Foam::Tensor< scalar >
Foam::molecule::writeFields
static void writeFields(const Cloud< molecule > &mC)
Definition: moleculeIO.C:166
Foam::DiagTensor< scalar >
Foam::molecule::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:226
Foam::molecule::operator<<
friend Ostream & operator<<(Ostream &, const molecule &)
Foam::molecule::constantProperties::pairPotentialSite
bool pairPotentialSite(label sId) const
Definition: moleculeI.H:416
Foam::molecule::specialPosition
const vector & specialPosition() const
Definition: moleculeI.H:593
Foam::molecule::id
label id() const
Definition: moleculeI.H:641
Foam::molecule::tau
const vector & tau() const
Definition: moleculeI.H:557
Foam::molecule::iNew::iNew
iNew(const polyMesh &mesh)
Definition: molecule.H:299
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::molecule::trackingData::part
label part() const
Definition: molecule.H:187
Foam::molecule::hitWallPatch
void hitWallPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a wallPatch.
Definition: molecule.C:252
Foam::molecule::setSitePositions
void setSitePositions(const constantProperties &constProps)
Definition: molecule.C:226
Foam::molecule::specialTypes
specialTypes
Definition: molecule.H:81
Foam::molecule::clone
autoPtr< particle > clone() const
Construct and return a clone.
Definition: molecule.H:286
Foam::molecule::constantProperties::siteCharges
const List< scalar > & siteCharges() const
Definition: moleculeI.H:388
Foam::particle::coordinates
const barycentric & coordinates() const
Return current particle coordinates.
Definition: particleI.H:143
Foam::molecule::constantProperties::pointMolecule
bool pointMolecule() const
Definition: moleculeI.H:471
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::molecule::special
label special() const
Definition: moleculeI.H:629
Foam::molecule
Foam::molecule.
Definition: molecule.H:67
Foam::Field< vector >
Foam::molecule::sitePositions
const List< vector > & sitePositions() const
Definition: moleculeI.H:581
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::molecule::constantProperties::momentOfInertia
const diagTensor & momentOfInertia() const
Definition: moleculeI.H:459
Foam::molecule::constantProperties::siteReferencePositions
const Field< vector > & siteReferencePositions() const
Definition: moleculeI.H:374
Foam::molecule::rf
const tensor & rf() const
Definition: moleculeI.H:617
Foam::molecule::constantProperties::pairPotentialSites
const List< bool > & pairPotentialSites() const
Definition: moleculeI.H:409
Foam::molecule::constantProperties::linearMolecule
bool linearMolecule() const
Definition: moleculeI.H:465
Foam::molecule::siteForces
const List< vector > & siteForces() const
Definition: moleculeI.H:569
Foam::molecule::sizeofFields
static const std::size_t sizeofFields
Size in bytes of the fields.
Definition: molecule.H:74
IOstream.H
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::molecule::trackingData
Class used to pass tracking data to the trackToFace function.
Definition: molecule.H:167
Foam::molecule::constantProperties::electrostaticSites
const List< bool > & electrostaticSites() const
Definition: moleculeI.H:434
Foam::particle::position
vector position() const
Return current particle position.
Definition: particleI.H:314
Foam::Barycentric< scalar >
Foam::particle::mesh
const polyMesh & mesh() const
Return the mesh database.
Definition: particleI.H:137
Foam::molecule::setSiteSizes
void setSiteSizes(label size)
Definition: molecule.C:232
Foam::molecule::constantProperties::degreesOfFreedom
label degreesOfFreedom() const
Definition: moleculeI.H:477
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::molecule::hitProcessorPatch
void hitProcessorPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a processorPatch.
Definition: molecule.C:246
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::molecule::constantProperties::nSites
label nSites() const
Definition: moleculeI.H:500
Foam::molecule::constantProperties::siteMasses
const List< scalar > & siteMasses() const
Definition: moleculeI.H:381
Foam::molecule::Q
const tensor & Q() const
Definition: moleculeI.H:509
Foam::molecule::potentialEnergy
scalar potentialEnergy() const
Definition: moleculeI.H:605
Foam::molecule::a
const vector & a() const
Definition: moleculeI.H:533
Foam::molecule::move
bool move(moleculeCloud &, trackingData &, const scalar trackTime)
Definition: molecule.C:71
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::cloud
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:57
Foam::molecule::trackingData::trackingData
trackingData(moleculeCloud &cloud, label part)
Definition: molecule.H:179
Foam::molecule::readFields
static void readFields(Cloud< molecule > &mC)
Definition: moleculeIO.C:111
moleculeI.H
Foam::molecule::v
const vector & v() const
Definition: moleculeI.H:521
Foam::molecule::iNew::operator()
autoPtr< molecule > operator()(Istream &is) const
Definition: molecule.H:304
Foam::molecule::SPECIAL_USER
Definition: molecule.H:86
Foam::molecule::constantProperties::mass
scalar mass() const
Definition: moleculeI.H:494
Foam::moleculeCloud
Definition: moleculeCloud.H:58
Foam::Vector< scalar >
Foam::List< scalar >
Foam::particle
Base particle class.
Definition: particle.H:76
Foam::Cloud
Base cloud calls templated on particle type.
Definition: Cloud.H:55
Foam::molecule::constantProperties
Class to hold molecule constant properties.
Definition: molecule.H:91
particle.H
Foam::molecule::NOT_SPECIAL
Definition: molecule.H:85
Foam::molecule::SPECIAL_TETHERED
Definition: molecule.H:83
Foam::molecule::hitPatch
bool hitPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a patch.
Definition: molecule.C:240
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::molecule::SPECIAL_FROZEN
Definition: molecule.H:84
Foam::molecule::tethered
bool tethered() const
Definition: moleculeI.H:635
Foam::particle::trackingData
Definition: particle.H:95
diagTensor.H
Foam::molecule::transformProperties
virtual void transformProperties(const tensor &T)
Transform the physical properties of the particle.
Definition: molecule.C:191
Foam::molecule::constantProperties::constantProperties
constantProperties()
Definition: moleculeI.H:31
Foam::molecule::constantProperties::electrostaticSite
bool electrostaticSite(label sId) const
Definition: moleculeI.H:441
Foam::molecule::pi
const vector & pi() const
Definition: moleculeI.H:545
Foam::molecule::iNew
Factory class to read-construct particles used for.
Definition: molecule.H:293
autoPtr.H