Loading...
Searching...
No Matches
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-2024 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 "diagTensor.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52// Class forward declarations
53class moleculeCloud;
54
55
56// Forward declaration of friend functions and operators
57
58class molecule;
59
61
63/*---------------------------------------------------------------------------*\
64 Class molecule Declaration
65\*---------------------------------------------------------------------------*/
66
67class molecule
68:
69 public particle
70{
71public:
72
73 //- Size in bytes of the fields
74 static const std::size_t sizeofFields;
75
76
77 // Values of special that are less than zero are for built-in functionality.
78 // Values greater than zero are user specifiable/expandable
79 // (i.e. test special_ >= SPECIAL_USER)
82 {
84 SPECIAL_FROZEN = -2,
85 NOT_SPECIAL = 0,
86 SPECIAL_USER = 1
87 };
88
89
90 //- Class to hold molecule constant properties
92 {
93 // Private data
94
95 Field<vector> siteReferencePositions_;
96
97 List<scalar> siteMasses_;
98
99 List<scalar> siteCharges_;
100
101 List<label> siteIds_;
102
103 List<bool> pairPotentialSites_;
104
105 List<bool> electrostaticSites_;
106
107 diagTensor momentOfInertia_;
108
109 scalar mass_;
110
111
112 // Private Member Functions
113
114 void checkSiteListSizes() const;
115
116 void setInteracionSiteBools
117 (
118 const List<word>& siteIds,
119 const List<word>& pairPotSiteIds
120 );
121
122 bool linearMoleculeTest() const;
123
124
125 public:
126
127 inline constantProperties();
128
129 //- Construct from dictionary
130 inline constantProperties(const dictionary& dict);
131
132 // Member functions
133
134 inline const Field<vector>& siteReferencePositions() const;
135
136 inline const List<scalar>& siteMasses() const;
137
138 inline const List<scalar>& siteCharges() const;
139
140 inline const List<label>& siteIds() const;
141
142 inline List<label>& siteIds();
143
144 inline const List<bool>& pairPotentialSites() const;
145
146 inline bool pairPotentialSite(label sId) const;
147
148 inline const List<bool>& electrostaticSites() const;
149
150 inline bool electrostaticSite(label sId) const;
151
152 inline const diagTensor& momentOfInertia() const;
153
154 inline bool linearMolecule() const;
155
156 inline bool pointMolecule() const;
157
158 inline label degreesOfFreedom() const;
159
160 inline scalar mass() const;
161
162 inline label nSites() const;
163 };
164
165
166 //- Class used to pass tracking data to the trackToFace function
167 class trackingData
168 :
171 // label specifying which part of the integration algorithm is taking
172 label part_;
173
174
175 public:
176
177 // Constructors
178
180 :
182 part_(part)
183 {}
184
185 // Member functions
186
187 inline label part() const
188 {
189 return part_;
191 };
192
193
194private:
195
196 // Private data
197
198 tensor Q_;
199
200 vector v_;
201
202 vector a_;
203
204 vector pi_;
205
206 vector tau_;
207
208 vector specialPosition_;
209
210 scalar potentialEnergy_;
211
212 // - r_ij f_ij, stress dyad
213 tensor rf_;
214
215 label special_;
216
217 label id_;
218
219 List<vector> siteForces_;
220
221 List<vector> sitePositions_;
222
223
224 // Private Member Functions
225
226 tensor rotationTensorX(scalar deltaT) const;
227
228 tensor rotationTensorY(scalar deltaT) const;
229
230 tensor rotationTensorZ(scalar deltaT) const;
231
232
233public:
234
235 friend class Cloud<molecule>;
236
237 // Constructors
238
239 //- Construct from components
240 inline molecule
241 (
242 const polyMesh& mesh,
244 const label celli,
245 const label tetFacei,
246 const label tetPti,
247 const tensor& Q,
248 const vector& v,
249 const vector& a,
250 const vector& pi,
251 const vector& tau,
252 const vector& specialPosition,
253 const constantProperties& constProps,
254 const label special,
255 const label id
256 );
257
258 //- Construct from a position and a cell, searching for the rest of the
259 // required topology
260 inline molecule
261 (
262 const polyMesh& mesh,
263 const vector& position,
264 const label celli,
265 const tensor& Q,
266 const vector& v,
267 const vector& a,
268 const vector& pi,
269 const vector& tau,
270 const vector& specialPosition,
271 const constantProperties& constProps,
272 const label special,
273 const label id
274 );
275
276 //- Construct from Istream
278 (
279 const polyMesh& mesh,
280 Istream& is,
281 bool readFields = true,
282 bool newFormat = true
283 );
284
285 //- Return a clone
286 virtual autoPtr<particle> clone() const
287 {
288 return particle::Clone(*this);
289 }
290
291 //- Factory class to read-construct particles (for parallel transfer)
292 class iNew
293 {
294 const polyMesh& mesh_;
295
296 public:
297
299 :
300 mesh_(mesh)
301 {}
302
304 {
305 return autoPtr<molecule>::New(mesh_, is, true);
307 };
308
309
310 // Member Functions
311
312 // Tracking
313
314 bool move(moleculeCloud&, trackingData&, const scalar trackTime);
315
316 virtual void transformProperties(const tensor& T);
318 virtual void transformProperties(const vector& separation);
319
320 void setSitePositions(const constantProperties& constProps);
321
322 void setSiteSizes(label size);
323
324
325 // Access
326
327 inline const tensor& Q() const;
328 inline tensor& Q();
329
330 inline const vector& v() const;
331 inline vector& v();
332
333 inline const vector& a() const;
334 inline vector& a();
335
336 inline const vector& pi() const;
337 inline vector& pi();
338
339 inline const vector& tau() const;
340 inline vector& tau();
341
342 inline const List<vector>& siteForces() const;
343 inline List<vector>& siteForces();
344
345 inline const List<vector>& sitePositions() const;
346 inline List<vector>& sitePositions();
347
348 inline const vector& specialPosition() const;
349 inline vector& specialPosition();
350
351 inline scalar potentialEnergy() const;
352 inline scalar& potentialEnergy();
353
354 inline const tensor& rf() const;
355 inline tensor& rf();
356
357 inline label special() const;
358
359 inline bool tethered() const;
360
361 inline label id() const;
362
363
364 // Member Operators
365
366 //- Overridable function to handle the particle hitting a patch
367 // Executed before other patch-hitting functions
369
370 //- Overridable function to handle the particle hitting a processorPatch
372
373 //- Overridable function to handle the particle hitting a wallPatch
375
376
377 // I-O
378
379 static void readFields(Cloud<molecule>& mC);
380
381 static void writeFields(const Cloud<molecule>& mC);
382
383
384 // IOstream Operators
385
386 friend Ostream& operator<<(Ostream&, const molecule&);
387};
388
389// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
390
391} // End namespace Foam
392
393// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
394
395#include "moleculeI.H"
396
397// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
398
399#endif
400
401// ************************************************************************* //
Base cloud calls templated on particle type.
Definition Cloud.H:64
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
A cloud is a registry collection of lagrangian particles.
Definition cloud.H:56
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Class to hold molecule constant properties.
Definition molecule.H:91
const diagTensor & momentOfInertia() const
Definition moleculeI.H:452
const Field< vector > & siteReferencePositions() const
Definition moleculeI.H:367
const List< label > & siteIds() const
Definition moleculeI.H:388
const List< bool > & pairPotentialSites() const
Definition moleculeI.H:402
const List< scalar > & siteCharges() const
Definition moleculeI.H:381
bool pairPotentialSite(label sId) const
Definition moleculeI.H:409
bool electrostaticSite(label sId) const
Definition moleculeI.H:434
const List< scalar > & siteMasses() const
Definition moleculeI.H:374
const List< bool > & electrostaticSites() const
Definition moleculeI.H:427
iNew(const polyMesh &mesh)
Definition molecule.H:312
autoPtr< molecule > operator()(Istream &is) const
Definition molecule.H:317
Class used to pass tracking data to the trackToFace function.
Definition molecule.H:173
trackingData(moleculeCloud &cloud, label part)
Definition molecule.H:182
Foam::molecule.
Definition molecule.H:65
virtual void transformProperties(const tensor &T)
Transform the physical properties of the particle.
Definition molecule.C:184
const tensor & Q() const
Definition moleculeI.H:502
bool move(moleculeCloud &, trackingData &, const scalar trackTime)
Definition molecule.C:64
const vector & v() const
Definition moleculeI.H:514
void setSiteSizes(label size)
Definition molecule.C:225
const List< vector > & sitePositions() const
Definition moleculeI.H:574
const vector & a() const
Definition moleculeI.H:526
const List< vector > & siteForces() const
Definition moleculeI.H:562
const vector & specialPosition() const
Definition moleculeI.H:586
void setSitePositions(const constantProperties &constProps)
Definition molecule.C:219
label special() const
Definition moleculeI.H:622
const tensor & rf() const
Definition moleculeI.H:610
virtual autoPtr< particle > clone() const
Return a clone.
Definition molecule.H:298
static const std::size_t sizeofFields
Size in bytes of the fields.
Definition molecule.H:71
const vector & tau() const
Definition moleculeI.H:550
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:219
scalar potentialEnergy() const
Definition moleculeI.H:598
friend Ostream & operator<<(Ostream &, const molecule &)
static void writeFields(const Cloud< molecule > &mC)
Definition moleculeIO.C:147
const vector & pi() const
Definition moleculeI.H:538
static void readFields(Cloud< molecule > &mC)
Definition moleculeIO.C:88
bool hitPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a patch.
Definition molecule.C:233
void hitWallPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a wallPatch.
Definition molecule.C:245
bool tethered() const
Definition moleculeI.H:628
void hitProcessorPatch(moleculeCloud &cloud, trackingData &td)
Overridable function to handle the particle hitting a processorPatch.
Definition molecule.C:239
label id() const
Definition moleculeI.H:634
vector position() const
Return current particle position.
Definition particleI.H:283
static autoPtr< particle > Clone(const Derived &p)
Clone a particle.
Definition particle.H:552
const polyMesh & mesh() const noexcept
Return the mesh database.
Definition particleI.H:110
const barycentric & coordinates() const noexcept
Return current particle coordinates.
Definition particleI.H:116
particle(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPti)
Construct from components.
Definition particle.C:507
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
Namespace for OpenFOAM.
DiagTensor< scalar > diagTensor
DiagTensor of scalars, i.e. DiagTensor<scalar>.
Definition diagTensor.H:49
Tensor< scalar > tensor
Definition symmTensor.H:57
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
Definition barycentric.H:45
Vector< scalar > vector
Definition vector.H:57
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dictionary dict