FreeFOAM The Cross-Platform CFD Toolkit
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) 2008-2010 OpenCFD Ltd.
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 <lagrangian/Particle.H>
41 #include <OpenFOAM/IOstream.H>
42 #include <OpenFOAM/autoPtr.H>
43 #include <OpenFOAM/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<molecule>
60 {
61 
62 public:
63 
64  // Values of special that are less than zero are for built-in functionality.
65  // Values greater than zero are user specifiable/expandable (i.e. test
66  // special_ >= SPECIAL_USER)
67 
69  {
74  };
75 
76  //- Class to hold molecule constant properties
78  {
79 
80  // Private data
81 
82  Field<vector> siteReferencePositions_;
83 
84  List<scalar> siteMasses_;
85 
86  List<scalar> siteCharges_;
87 
88  List<label> siteIds_;
89 
90  List<bool> pairPotentialSites_;
91 
92  List<bool> electrostaticSites_;
93 
94  diagTensor momentOfInertia_;
95 
96  scalar mass_;
97 
98  // Private Member Functions
99 
100  void checkSiteListSizes() const;
101 
102  void setInteracionSiteBools
103  (
104  const List<word>& siteIds,
105  const List<word>& pairPotSiteIds
106  );
107 
108  bool linearMoleculeTest() const;
109 
110 
111  public:
112 
113  inline constantProperties();
114 
115  //- Construct from dictionary
116  inline constantProperties(const dictionary& dict);
117 
118  // Member functions
119 
120  inline const Field<vector>& siteReferencePositions() const;
121 
122  inline const List<scalar>& siteMasses() const;
123 
124  inline const List<scalar>& siteCharges() const;
125 
126  inline const List<label>& siteIds() const;
127 
128  inline List<label>& siteIds();
129 
130  inline const List<bool>& pairPotentialSites() const;
131 
132  inline bool pairPotentialSite(label sId) const;
133 
134  inline const List<bool>& electrostaticSites() const;
135 
136  inline bool electrostaticSite(label sId) const;
137 
138  inline const diagTensor& momentOfInertia() const;
139 
140  inline bool linearMolecule() const;
141 
142  inline bool pointMolecule() const;
143 
144  inline label degreesOfFreedom() const;
145 
146  inline scalar mass() const;
147 
148  inline label nSites() const;
149  };
150 
151 
152  //- Class used to pass tracking data to the trackToFace function
153  class trackData
154  :
155  public Particle<molecule>::trackData
156  {
157  moleculeCloud& molCloud_;
158 
159  // label specifying which part of the integration algorithm is taking
160  label part_;
161 
162 
163  public:
164 
165  // Constructors
166 
167  trackData
168  (
170  label part
171  );
172 
173  // Member functions
174 
175  inline moleculeCloud& molCloud();
176 
177  inline label part() const;
178  };
179 
180 
181 private:
182 
183  // Private data
184 
185  //- Be careful with the ordering of data.
186  // It has an impact on binary transfer:
187  // -# Put the largest data members 1st
188  // -# Pair up labels,
189  // -# Don't go scalar-label, scalar-label, because in 64bit mode,
190  // the labels will be padded by 4bytes.
191 
192  tensor Q_;
193 
194  vector v_;
195 
196  vector a_;
197 
198  vector pi_;
199 
200  vector tau_;
201 
202  vector specialPosition_;
203 
204  scalar potentialEnergy_;
205 
206  // - r_ij f_ij, stress dyad
207  tensor rf_;
208 
209  label special_;
210 
211  label id_;
212 
213  List<vector> siteForces_;
214 
215  List<vector> sitePositions_;
216 
217 
218  // Private Member Functions
219 
220  tensor rotationTensorX(scalar deltaT) const;
221 
222  tensor rotationTensorY(scalar deltaT) const;
223 
224  tensor rotationTensorZ(scalar deltaT) const;
225 
226 
227 public:
228 
229  friend class Cloud<molecule>;
230 
231  // Constructors
232 
233  //- Construct from components
234  inline molecule
235  (
236  const Cloud<molecule>& c,
237  const vector& position,
238  const label celli,
239  const tensor& Q,
240  const vector& v,
241  const vector& a,
242  const vector& pi,
243  const vector& tau,
244  const vector& specialPosition,
245  const constantProperties& constProps,
246  const label special,
247  const label id
248  );
249 
250  //- Construct from Istream
251  molecule
252  (
253  const Cloud<molecule>& c,
254  Istream& is,
255  bool readFields = true
256  );
257 
258  //- Construct and return a clone
260  {
261  return autoPtr<molecule>(new molecule(*this));
262  }
263 
264 
265  // Member Functions
266 
267  // Tracking
268 
269  bool move(trackData&);
270 
271  void transformProperties(const tensor& T);
272 
273  void transformProperties(const vector& separation);
274 
275  void setSitePositions(const constantProperties& constProps);
276 
277  void setSiteSizes(label size);
278 
279 
280  // Access
281 
282  inline const tensor& Q() const;
283  inline tensor& Q();
284 
285  inline const vector& v() const;
286  inline vector& v();
287 
288  inline const vector& a() const;
289  inline vector& a();
290 
291  inline const vector& pi() const;
292  inline vector& pi();
293 
294  inline const vector& tau() const;
295  inline vector& tau();
296 
297  inline const List<vector>& siteForces() const;
298  inline List<vector>& siteForces();
299 
300  inline const List<vector>& sitePositions() const;
301  inline List<vector>& sitePositions();
302 
303  inline const vector& specialPosition() const;
304  inline vector& specialPosition();
305 
306  inline scalar potentialEnergy() const;
307  inline scalar& potentialEnergy();
308 
309  inline const tensor& rf() const;
310  inline tensor& rf();
311 
312  inline label special() const;
313 
314  inline bool tethered() const;
315 
316  inline label id() const;
317 
318 
319  // Member Operators
320 
321  //- Overridable function to handle the particle hitting a patch
322  // Executed before other patch-hitting functions
323  bool hitPatch
324  (
325  const polyPatch&,
327  const label patchI
328  );
329 
330  //- Overridable function to handle the particle hitting a patch
331  // Executed before other patch-hitting functions without trackData
332  bool hitPatch
333  (
334  const polyPatch& p,
335  int& td,
336  const label patchI
337  );
338 
339  //- Overridable function to handle the particle hitting a processorPatch
340  void hitProcessorPatch
341  (
342  const processorPolyPatch&,
344  );
345 
346  //- Overridable function to handle the particle hitting a processorPatch
347  // without trackData
348  void hitProcessorPatch
349  (
350  const processorPolyPatch&,
351  int&
352  );
353 
354  //- Overridable function to handle the particle hitting a wallPatch
355  void hitWallPatch
356  (
357  const wallPolyPatch&,
359  );
360 
361  //- Overridable function to handle the particle hitting a wallPatch
362  // without trackData
363  void hitWallPatch
364  (
365  const wallPolyPatch&,
366  int&
367  );
368 
369  //- Overridable function to handle the particle hitting a polyPatch
370  void hitPatch
371  (
372  const polyPatch&,
374  );
375 
376  //- Overridable function to handle the particle hitting a polyPatch
377  // without trackData
378  void hitPatch
379  (
380  const polyPatch&,
381  int&
382  );
383 
384 
385  // I-O
386 
387  static void readFields(Cloud<molecule>& mC);
388 
389  static void writeFields(const Cloud<molecule>& mC);
390 
391 
392  // IOstream Operators
393 
394  friend Ostream& operator<<(Ostream&, const molecule&);
395 };
396 
397 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
398 
399 } // End namespace Foam
400 
401 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
402 
403 #include "moleculeI.H"
404 
405 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
406 
407 #endif
408 
409 // ************************ vim: set sw=4 sts=4 et: ************************ //