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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::molecule
29
30Description
31 Foam::molecule
32
33SourceFiles
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
50namespace Foam
51{
52
53// Class forward declarations
54class moleculeCloud;
55
56
57// Forward declaration of friend functions and operators
58
59class molecule;
60
61Ostream& operator<<(Ostream&, const molecule&);
62
63
64/*---------------------------------------------------------------------------*\
65 Class molecule Declaration
66\*---------------------------------------------------------------------------*/
68class molecule
69:
70 public particle
71{
72public:
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)
82 enum specialTypes
83 {
86 NOT_SPECIAL = 0,
88 };
89
90
91 //- Class to hold molecule constant properties
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
181 :
183 part_(part)
184 {}
185
186 // Member functions
188 inline label part() const
189 {
190 return part_;
191 }
192 };
193
194
195private:
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;
231 tensor rotationTensorZ(scalar deltaT) const;
232
233
234public:
235
236 friend class Cloud<molecule>;
237
238 // Constructors
239
240 //- Construct from components
241 inline molecule
242 (
243 const polyMesh& mesh,
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
279 (
280 const polyMesh& mesh,
281 Istream& is,
282 bool readFields = true,
283 bool newFormat = true
284 );
285
286 //- Construct and return a clone
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:
300 iNew(const polyMesh& mesh)
301 :
302 mesh_(mesh)
303 {}
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
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// ************************************************************************* //
Base cloud calls templated on particle type.
Definition: Cloud.H:68
Generic templated field type.
Definition: Field.H:82
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:60
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Class to hold molecule constant properties.
Definition: molecule.H:92
const diagTensor & momentOfInertia() const
Definition: moleculeI.H:459
const Field< vector > & siteReferencePositions() const
Definition: moleculeI.H:374
const List< label > & siteIds() const
Definition: moleculeI.H:395
const List< bool > & pairPotentialSites() const
Definition: moleculeI.H:409
const List< scalar > & siteCharges() const
Definition: moleculeI.H:388
bool pairPotentialSite(label sId) const
Definition: moleculeI.H:416
bool electrostaticSite(label sId) const
Definition: moleculeI.H:441
const List< scalar > & siteMasses() const
Definition: moleculeI.H:381
const List< bool > & electrostaticSites() const
Definition: moleculeI.H:434
Factory class to read-construct particles used for.
Definition: molecule.H:294
iNew(const polyMesh &mesh)
Definition: molecule.H:299
autoPtr< molecule > operator()(Istream &is) const
Definition: molecule.H:304
Class used to pass tracking data to the trackToFace function.
Definition: molecule.H:170
trackingData(moleculeCloud &cloud, label part)
Definition: molecule.H:179
Foam::molecule.
Definition: molecule.H:70
virtual void transformProperties(const tensor &T)
Transform the physical properties of the particle.
Definition: molecule.C:191
const tensor & Q() const
Definition: moleculeI.H:509
bool move(moleculeCloud &, trackingData &, const scalar trackTime)
Definition: molecule.C:71
const vector & v() const
Definition: moleculeI.H:521
void setSiteSizes(label size)
Definition: molecule.C:232
const List< vector > & sitePositions() const
Definition: moleculeI.H:581
autoPtr< particle > clone() const
Construct and return a clone.
Definition: molecule.H:286
const vector & a() const
Definition: moleculeI.H:533
const List< vector > & siteForces() const
Definition: moleculeI.H:569
const vector & specialPosition() const
Definition: moleculeI.H:593
void setSitePositions(const constantProperties &constProps)
Definition: molecule.C:226
@ SPECIAL_TETHERED
Definition: molecule.H:83
label special() const
Definition: moleculeI.H:629
const tensor & rf() const
Definition: moleculeI.H:617
static const std::size_t sizeofFields
Size in bytes of the fields.
Definition: molecule.H:74
const vector & tau() const
Definition: moleculeI.H:557
scalar potentialEnergy() const
Definition: moleculeI.H:605
friend Ostream & operator<<(Ostream &, const molecule &)
static void writeFields(const Cloud< molecule > &mC)
Definition: moleculeIO.C:166
const vector & pi() const
Definition: moleculeI.H:545
static void readFields(Cloud< molecule > &mC)
Definition: moleculeIO.C:111
bool hitPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a patch.
Definition: molecule.C:240
void hitWallPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a wallPatch.
Definition: molecule.C:252
bool tethered() const
Definition: moleculeI.H:635
void hitProcessorPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a processorPatch.
Definition: molecule.C:246
label id() const
Definition: moleculeI.H:641
Base particle class.
Definition: particle.H:79
vector position() const
Return current particle position.
Definition: particleI.H:314
const polyMesh & mesh() const noexcept
Return the mesh database.
Definition: particleI.H:137
const barycentric & coordinates() const noexcept
Return current particle coordinates.
Definition: particleI.H:143
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
const volScalarField & T
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
dictionary dict