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 
86  Field<vector> siteReferencePositions_;
87 
88  List<scalar> siteMasses_;
89 
90  List<scalar> siteCharges_;
91 
92  List<label> siteIds_;
93 
94  List<bool> pairPotentialSites_;
95 
96  List<bool> electrostaticSites_;
97 
98  diagTensor momentOfInertia_;
99 
100  scalar mass_;
101 
102 
103  // Private Member Functions
104 
105  void checkSiteListSizes() const;
106 
107  void setInteracionSiteBools
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
171  :
173  part_(part)
174  {}
175 
176  // Member functions
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 
199  vector specialPosition_;
200 
201  scalar potentialEnergy_;
202 
203  // - r_ij f_ij, stress dyad
204  tensor rf_;
205 
206  label special_;
207 
208  label id_;
209 
210  List<vector> siteForces_;
211 
212  List<vector> sitePositions_;
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:
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:
271  iNew(const polyMesh& mesh)
272  :
273  mesh_(mesh)
274  {}
276  autoPtr<molecule> operator()(Istream& is) const
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 // ************************************************************************* //
const Field< vector > & siteReferencePositions() const
Definition: moleculeI.H:331
void setSitePositions(const constantProperties &constProps)
Definition: molecule.C:227
const vector & v() const
Definition: moleculeI.H:480
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const vector & tau() const
Definition: moleculeI.H:516
const List< vector > & sitePositions() const
Definition: moleculeI.H:540
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
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
Class used to pass tracking data to the trackToFace function.
Definition: molecule.H:157
const List< vector > & siteForces() const
Definition: moleculeI.H:528
const vector & a() const
Definition: moleculeI.H:492
const List< scalar > & siteCharges() const
Definition: moleculeI.H:345
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const vector & pi() const
Definition: moleculeI.H:504
Namespace for OpenFOAM.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
const List< scalar > & siteMasses() const
Definition: moleculeI.H:338
Class to hold molecule constant properties.
Definition: molecule.H:81
void hitProcessorPatch(const processorPolyPatch &, trackingData &td)
Overridable function to handle the particle hitting a processorPatch.
Definition: molecule.C:255
const List< label > & siteIds() const
Definition: moleculeI.H:352
label id() const
Definition: moleculeI.H:600
bool move(trackingData &, const scalar trackTime)
Definition: molecule.C:68
dictionary dict
Neighbour processor patch.
const vector & position() const
Return current particle position.
Definition: particleI.H:603
Base particle class.
Definition: particle.H:78
autoPtr< particle > clone() const
Construct and return a clone.
Definition: molecule.H:257
const tensor & Q() const
Definition: moleculeI.H:468
const polyMesh & mesh_
Reference to the polyMesh database.
Definition: particle.H:137
const polyMesh & mesh() const
Return the mesh database.
Definition: particleI.H:597
label special() const
Definition: moleculeI.H:588
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
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
const List< bool > & pairPotentialSites() const
Definition: moleculeI.H:366
friend Ostream & operator<<(Ostream &, const 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
virtual void transformProperties(const tensor &T)
Transform the physical properties of the particle.
Definition: molecule.C:192
void hitWallPatch(const wallPolyPatch &, trackingData &td, const tetIndices &)
Overridable function to handle the particle hitting a wallPatch.
Definition: molecule.C:265
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::wallPolyPatch.
Definition: wallPolyPatch.H:48
const tensor & rf() const
Definition: moleculeI.H:576
bool tethered() const
Definition: moleculeI.H:594
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
bool pairPotentialSite(label sId) const
Definition: moleculeI.H:373
bool electrostaticSite(label sId) const
Definition: moleculeI.H:398
static void writeFields(const Cloud< molecule > &mC)
Definition: moleculeIO.C:148
Base cloud calls templated on particle type.
Definition: Cloud.H:52
Foam::molecule.
Definition: molecule.H:56
const diagTensor & momentOfInertia() const
Definition: moleculeI.H:418
void setSiteSizes(label size)
Definition: molecule.C:233
Factory class to read-construct particles used for.
Definition: molecule.H:264
This function object reads fields from the time directories and adds them to the mesh database for fu...
Definition: readFields.H:102
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:73
const List< bool > & electrostaticSites() const
Definition: moleculeI.H:391
This function object calculates and outputs the second invariant of the velocity gradient tensor [1/s...
Definition: Q.H:66
static void readFields(Cloud< molecule > &mC)
Definition: moleculeIO.C:94
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
const vector & specialPosition() const
Definition: moleculeI.H:552
scalar potentialEnergy() const
Definition: moleculeI.H:564