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-2025 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 lagrangian::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 meshSearch& searchEngine,
116  const point& position,
117  label cell,
118  label& nLocateBoundaryHits,
119  label id,
120  bool tethered,
121  scalar temperature,
122  const vector& bulkVelocity
123  );
124 
125  label nSites() const;
126 
127  inline vector equipartitionLinearVelocity
128  (
129  scalar temperature,
130  scalar mass
131  );
132 
133  inline vector equipartitionAngularMomentum
134  (
135  scalar temperature,
137  );
138 
139 
140 public:
141 
142  //- Runtime type information
143  TypeName("moleculeCloud");
144 
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  //- Disallow default bitwise copy construction
166  moleculeCloud(const moleculeCloud&) = delete;
167 
168 
169  // Member Functions
170 
171  //- Evolve the molecules (move, calculate forces, control state etc)
172  void evolve();
173 
174  void calculateForce();
175 
177  (
178  const scalar targetTemperature,
179  const scalar measuredTemperature
180  );
181 
182 
183  // Access
184 
185  inline const polyMesh& mesh() const;
186 
187  inline const potential& pot() const;
188 
189  inline const List<DynamicList<molecule*>>& cellOccupancy() const;
190 
191  inline const InteractionLists<molecule>& il() const;
192 
193  inline const List<molecule::constantProperties> constProps() const;
194 
195  inline const molecule::constantProperties&
196  constProps(label id) const;
197 
198  inline randomGenerator& rndGen();
199 
201 
202 
203  // Member Functions
204 
205  //- Write molecule sites in XYZ format
206  void writeXYZ(const fileName& fName) const;
207 
208 
209  // Member Operators
210 
211  //- Disallow default bitwise assignment
212  void operator=(const moleculeCloud&) = delete;
213 };
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 } // End namespace Foam
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #include "moleculeCloudI.H"
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
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
Mesh object that implements searches within the local cells and faces.
Definition: meshSearch.H:59
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:78
Random number generator.
const dimensionSet temperature
const dimensionSet mass
point position(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label facei, const label faceTrii, const scalar stepFraction)
Return the position given the coordinates and tet topology.
Definition: trackingI.H:224
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