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) 2011-2017 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::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 "Cloud.H"
40 #include "molecule.H"
41 #include "IOdictionary.H"
42 #include "potential.H"
43 #include "InteractionLists.H"
44 #include "labelVector.H"
45 #include "Random.H"
46 #include "fileName.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class moleculeCloud Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class moleculeCloud
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 
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 bool evaluatePotentialLimit
97  (
98  molecule& molI,
99  molecule& molJ
100  ) const;
101 
102  void calculateTetherForce();
103 
104  void calculateExternalForce();
105 
106  void removeHighEnergyOverlaps();
107 
108  void initialiseMolecules
109  (
110  const IOdictionary& mdInitialiseDict
111  );
112 
113  void createMolecule
114  (
115  const point& position,
116  label cell,
117  label id,
118  bool tethered,
119  scalar temperature,
120  const vector& bulkVelocity
121  );
122 
123  label nSites() const;
124 
125  inline vector equipartitionLinearVelocity
126  (
127  scalar temperature,
128  scalar mass
129  );
130 
131  inline vector equipartitionAngularMomentum
132  (
133  scalar temperature,
135  );
136 
137  //- Disallow default bitwise copy construct
139 
140  //- Disallow default bitwise assignment
141  void operator=(const moleculeCloud&);
142 
143 
144 public:
145 
146  // Constructors
147 
148  //- Construct given mesh and potential references
150  (
151  const polyMesh& mesh,
152  const potential& pot,
153  bool readFields = true
154  );
155 
156  //- Construct given mesh, potential and mdInitialiseDict
158  (
159  const polyMesh& mesh,
160  const potential& pot,
161  const IOdictionary& mdInitialiseDict,
162  bool readFields = true
163  );
164 
165 
166  // Member Functions
167 
168  //- Evolve the molecules (move, calculate forces, control state etc)
169  void evolve();
170 
171  void calculateForce();
172 
174  (
175  const scalar targetTemperature,
176  const scalar measuredTemperature
177  );
178 
179 
180  // Access
181 
182  inline const polyMesh& mesh() const;
183 
184  inline const potential& pot() const;
185 
186  inline const List<DynamicList<molecule*>>& cellOccupancy() const;
187 
188  inline const InteractionLists<molecule>& il() const;
189 
190  inline const List<molecule::constantProperties> constProps() const;
191 
192  inline const molecule::constantProperties&
193  constProps(label id) const;
194 
195  inline Random& rndGen();
196 
197 
198  // Member Operators
199 
200  //- Write molecule sites in XYZ format
201  void writeXYZ(const fileName& fName) const;
202 };
203 
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 } // End namespace Foam
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #include "moleculeCloudI.H"
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #endif
216 
217 // ************************************************************************* //
void writeXYZ(const fileName &fName) const
Write molecule sites in XYZ format.
const InteractionLists< molecule > & il() const
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
A class for handling file names.
Definition: fileName.H:69
Builds direct interaction list, specifying which local (real) cells are potentially in range of each ...
Class to hold molecule constant properties.
Definition: molecule.H:89
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject *> &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
void evolve()
Evolve the molecules (move, calculate forces, control state etc)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:52
const List< DynamicList< molecule * > > & cellOccupancy() const
void applyConstraintsAndThermostats(const scalar targetTemperature, const scalar measuredTemperature)
Simple random number generator.
Definition: Random.H:49
Base cloud calls templated on particle type.
Definition: Cloud.H:52
const potential & pot() const
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:56
const List< molecule::constantProperties > constProps() const
Foam::molecule.
Definition: molecule.H:64
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const polyMesh & mesh() const
Namespace for OpenFOAM.