FreeFOAM The Cross-Platform CFD Toolkit
moleculeCloud.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::moleculeCloud
26 
27 Description
28 
29 SourceFiles
30  moleculeCloudI.H
31  moleculeCloud.C
32 
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef moleculeCloud_H
37 #define moleculeCloud_H
38 
39 #include <lagrangian/Cloud.H>
40 #include <molecule/molecule.H>
41 #include <OpenFOAM/IOdictionary.H>
42 #include <potential/potential.H>
44 #include <OpenFOAM/labelVector.H>
45 #include <OpenFOAM/Random.H>
46 #include <OpenFOAM/fileName.H>
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class moleculeCloud Declaration
55 \*---------------------------------------------------------------------------*/
56 
58 :
59  public Cloud<molecule>
60 {
61 
62 private:
63 
64  // Private data
65 
66  const polyMesh& mesh_;
67 
68  const potential& pot_;
69 
70  List<DynamicList<molecule*> > cellOccupancy_;
71 
72  interactionLists il_;
73 
75 
76  Random rndGen_;
77 
78 
79  // Private Member Functions
80 
81  void buildConstProps();
82 
83  void setSiteSizesAndPositions();
84 
85  //- Determine which molecules are in which cells
86  void buildCellOccupancy();
87 
88  void calculatePairForce();
89 
90  inline void evaluatePair
91  (
92  molecule* molI,
93  molecule* molJ
94  );
95 
96  inline void evaluatePair
97  (
98  molecule* molReal,
99  referredMolecule* molRef
100  );
101 
102  inline bool evaluatePotentialLimit
103  (
104  molecule* molI,
105  molecule* molJ
106  ) const;
107 
108  inline bool evaluatePotentialLimit
109  (
110  molecule* molReal,
111  referredMolecule* molRef
112  ) const;
113 
114  void calculateTetherForce();
115 
116  void calculateExternalForce();
117 
118  void removeHighEnergyOverlaps();
119 
120  void initialiseMolecules
121  (
122  const IOdictionary& mdInitialiseDict
123  );
124 
125  void createMolecule
126  (
127  const point& position,
128  label cell,
129  label id,
130  bool tethered,
131  scalar temperature,
132  const vector& bulkVelocity
133  );
134 
135  label nSites() const;
136 
137  inline vector equipartitionLinearVelocity
138  (
139  scalar temperature,
140  scalar mass
141  );
142 
143  inline vector equipartitionAngularMomentum
144  (
145  scalar temperature,
147  );
148 
149  //- Disallow default bitwise copy construct
151 
152  //- Disallow default bitwise assignment
153  void operator=(const moleculeCloud&);
154 
155 
156 public:
157 
158  // Static data members
159 
160  static scalar kb;
161 
162  static scalar elementaryCharge;
163 
164  static scalar vacuumPermittivity;
165 
166 
167  // Constructors
168 
169  //- Construct given mesh and potential references
171  (
172  const polyMesh& mesh,
173  const potential& pot,
174  bool readFields = true
175  );
176 
177  //- Construct given mesh, potential and mdInitialiseDict
179  (
180  const polyMesh& mesh,
181  const potential& pot,
182  const IOdictionary& mdInitialiseDict,
183  bool readFields = true
184  );
185 
186 
187  // Member Functions
188 
189  //- Evolve the molecules (move, calculate forces, control state etc)
190  void evolve();
191 
192  void calculateForce();
193 
195  (
196  const scalar targetTemperature,
197  const scalar measuredTemperature
198  );
199 
200 
201  // Access
202 
203  inline const polyMesh& mesh() const;
204 
205  inline const potential& pot() const;
206 
207  inline const List<DynamicList<molecule*> >& cellOccupancy() const;
208 
209  inline const interactionLists& il() const;
210 
211  inline const List<molecule::constantProperties> constProps() const;
212 
213  inline const molecule::constantProperties&
214  constProps(label id) const;
215 
216  inline Random& rndGen();
217 
218 
219  // Member Operators
220 
221  //- Write molecule sites in XYZ format
222  void writeXYZ(const fileName& fName) const;
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #include "moleculeCloudI.H"
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #endif
237 
238 // ************************ vim: set sw=4 sts=4 et: ************************ //