moleculeCloud.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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  // Private Data
62 
63  const polyMesh& mesh_;
64 
65  const potential& pot_;
66 
67  List<DynamicList<molecule*>> cellOccupancy_;
68 
70 
72 
73  Random rndGen_;
74 
75 
76  // Private Member Functions
77 
78  void buildConstProps();
79 
80  void setSiteSizesAndPositions();
81 
82  //- Determine which molecules are in which cells
83  void buildCellOccupancy();
84 
85  void calculatePairForce();
86 
87  inline void evaluatePair
88  (
89  molecule& molI,
90  molecule& molJ
91  );
92 
93  inline bool evaluatePotentialLimit
94  (
95  molecule& molI,
96  molecule& molJ
97  ) const;
98 
99  void calculateTetherForce();
100 
101  void calculateExternalForce();
102 
103  void removeHighEnergyOverlaps();
104 
105  void initialiseMolecules
106  (
107  const IOdictionary& mdInitialiseDict
108  );
109 
110  void createMolecule
111  (
112  const point& position,
113  label cell,
114  label id,
115  bool tethered,
116  scalar temperature,
117  const vector& bulkVelocity
118  );
119 
120  label nSites() const;
121 
122  inline vector equipartitionLinearVelocity
123  (
124  scalar temperature,
125  scalar mass
126  );
127 
128  inline vector equipartitionAngularMomentum
129  (
130  scalar temperature,
132  );
133 
134 
135 public:
136 
137  // Constructors
138 
139  //- Construct given mesh and potential references
141  (
142  const polyMesh& mesh,
143  const potential& pot,
144  bool readFields = true
145  );
146 
147  //- Construct given mesh, potential and mdInitialiseDict
149  (
150  const polyMesh& mesh,
151  const potential& pot,
152  const IOdictionary& mdInitialiseDict,
153  bool readFields = true
154  );
155 
156  //- Disallow default bitwise copy construction
157  moleculeCloud(const moleculeCloud&) = delete;
158 
159 
160  // Member Functions
161 
162  //- Evolve the molecules (move, calculate forces, control state etc)
163  void evolve();
164 
165  void calculateForce();
166 
168  (
169  const scalar targetTemperature,
170  const scalar measuredTemperature
171  );
172 
173 
174  // Access
175 
176  inline const polyMesh& mesh() const;
177 
178  inline const potential& pot() const;
179 
180  inline const List<DynamicList<molecule*>>& cellOccupancy() const;
181 
182  inline const InteractionLists<molecule>& il() const;
183 
184  inline const List<molecule::constantProperties> constProps() const;
185 
186  inline const molecule::constantProperties&
187  constProps(label id) const;
188 
189  inline Random& rndGen();
190 
191 
192  // Member Functions
193 
194  //- Write molecule sites in XYZ format
195  void writeXYZ(const fileName& fName) const;
196 
197 
198  // Member Operators
199 
200  //- Disallow default bitwise assignment
201  void operator=(const moleculeCloud&) = delete;
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:79
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:59
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)
void operator=(const moleculeCloud &)=delete
Disallow default bitwise assignment.
Random number generator.
Definition: Random.H:57
Base cloud calls templated on particle type.
Definition: Cloud.H:52
moleculeCloud(const polyMesh &mesh, const potential &pot, bool readFields=true)
Construct given mesh and potential references.
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.