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-2024 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 "randomGenerator.H"
46 #include "standardNormal.H"
47 #include "fileName.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class moleculeCloud Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class moleculeCloud
59 :
60  public Cloud<molecule>
61 {
62  // Private Data
63 
64  const polyMesh& mesh_;
65 
66  const potential& pot_;
67 
68  List<DynamicList<molecule*>> cellOccupancy_;
69 
71 
73 
74  randomGenerator rndGen_;
75 
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& nLocateBoundaryHits,
118  label id,
119  bool tethered,
120  scalar temperature,
121  const vector& bulkVelocity
122  );
123 
124  label nSites() const;
125 
126  inline vector equipartitionLinearVelocity
127  (
128  scalar temperature,
129  scalar mass
130  );
131 
132  inline vector equipartitionAngularMomentum
133  (
134  scalar temperature,
136  );
137 
138 
139 public:
140 
141  //- Runtime type information
142  TypeName("moleculeCloud");
143 
144 
145  // Constructors
146 
147  //- Construct given mesh and potential references
149  (
150  const polyMesh& mesh,
151  const potential& pot,
152  bool readFields = true
153  );
154 
155  //- Construct given mesh, potential and mdInitialiseDict
157  (
158  const polyMesh& mesh,
159  const potential& pot,
160  const IOdictionary& mdInitialiseDict,
161  bool readFields = true
162  );
163 
164  //- Disallow default bitwise copy construction
165  moleculeCloud(const moleculeCloud&) = delete;
166 
167 
168  // Member Functions
169 
170  //- Evolve the molecules (move, calculate forces, control state etc)
171  void evolve();
172 
173  void calculateForce();
174 
176  (
177  const scalar targetTemperature,
178  const scalar measuredTemperature
179  );
180 
181 
182  // Access
183 
184  inline const polyMesh& mesh() const;
185 
186  inline const potential& pot() const;
187 
188  inline const List<DynamicList<molecule*>>& cellOccupancy() const;
189 
190  inline const InteractionLists<molecule>& il() const;
191 
192  inline const List<molecule::constantProperties> constProps() const;
193 
194  inline const molecule::constantProperties&
195  constProps(label id) const;
196 
197  inline randomGenerator& rndGen();
198 
200 
201 
202  // Member Functions
203 
204  //- Write molecule sites in XYZ format
205  void writeXYZ(const fileName& fName) const;
206 
207 
208  // Member Operators
209 
210  //- Disallow default bitwise assignment
211  void operator=(const moleculeCloud&) = delete;
212 };
213 
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 } // End namespace Foam
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #include "moleculeCloudI.H"
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
Base cloud calls templated on particle type.
Definition: Cloud.H:74
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Builds direct interaction list, specifying which local (real) cells are potentially in range of each ...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:60
Standard normal distribution. Not selectable.
A class for handling file names.
Definition: fileName.H:82
const potential & pot() const
const List< molecule::constantProperties > constProps() const
TypeName("moleculeCloud")
Runtime type information.
const List< DynamicList< molecule * > > & cellOccupancy() const
const polyMesh & mesh() const
void writeXYZ(const fileName &fName) const
Write molecule sites in XYZ format.
distributions::standardNormal & stdNormal()
const InteractionLists< molecule > & il() const
void operator=(const moleculeCloud &)=delete
Disallow default bitwise assignment.
randomGenerator & rndGen()
void evolve()
Evolve the molecules (move, calculate forces, control state etc)
void applyConstraintsAndThermostats(const scalar targetTemperature, const scalar measuredTemperature)
moleculeCloud(const polyMesh &mesh, const potential &pot, bool readFields=true)
Construct given mesh and potential references.
Class to hold molecule constant properties.
Definition: molecule.H:91
Foam::molecule.
Definition: molecule.H:68
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Random number generator.
Namespace for OpenFOAM.
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
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