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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::moleculeCloud
29 
30 Description
31 
32 SourceFiles
33  moleculeCloudI.H
34  moleculeCloud.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef moleculeCloud_H
39 #define moleculeCloud_H
40 
41 #include "Cloud.H"
42 #include "molecule.H"
43 #include "IOdictionary.H"
44 #include "potential.H"
45 #include "InteractionLists.H"
46 #include "labelVector.H"
47 #include "Random.H"
48 #include "fileName.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class moleculeCloud Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class moleculeCloud
60 :
61  public Cloud<molecule>
62 {
63  // Private Data
64 
65  const polyMesh& mesh_;
66 
67  const potential& pot_;
68 
69  List<DynamicList<molecule*>> cellOccupancy_;
70 
72 
74 
75  Random rndGen_;
76 
77 
78  // Private Member Functions
79 
80  void buildConstProps();
81 
82  void setSiteSizesAndPositions();
83 
84  //- Determine which molecules are in which cells
85  void buildCellOccupancy();
86 
87  void calculatePairForce();
88 
89  inline void evaluatePair
90  (
91  molecule& molI,
92  molecule& molJ
93  );
94 
95  inline bool evaluatePotentialLimit
96  (
97  molecule& molI,
98  molecule& molJ
99  ) const;
100 
101  void calculateTetherForce();
102 
103  void calculateExternalForce();
104 
105  void removeHighEnergyOverlaps();
106 
107  void initialiseMolecules
108  (
109  const IOdictionary& mdInitialiseDict
110  );
111 
112  void createMolecule
113  (
114  const point& position,
115  label cell,
116  label id,
117  bool tethered,
118  scalar temperature,
119  const vector& bulkVelocity
120  );
121 
122  label nSites() const;
123 
124  inline vector equipartitionLinearVelocity
125  (
126  scalar temperature,
127  scalar mass
128  );
129 
130  inline vector equipartitionAngularMomentum
131  (
132  scalar temperature,
134  );
135 
136  //- No copy construct
137  moleculeCloud(const moleculeCloud&) = delete;
138 
139  //- No copy assignment
140  void operator=(const moleculeCloud&) = delete;
141 
142 
143 public:
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 
165  // Member Functions
166 
167  //- Evolve the molecules (move, calculate forces, control state etc)
168  void evolve();
169 
170  void calculateForce();
171 
173  (
174  const scalar targetTemperature,
175  const scalar measuredTemperature
176  );
177 
178 
179  // Access
180 
181  inline const polyMesh& mesh() const;
182 
183  inline const potential& pot() const;
184 
185  inline const List<DynamicList<molecule*>>& cellOccupancy() const;
186 
187  inline const InteractionLists<molecule>& il() const;
188 
189  inline const List<molecule::constantProperties> constProps() const;
190 
191  inline const molecule::constantProperties& constProps(label id) const;
192 
193  inline Random& rndGen();
194 
195 
196  // Member Operators
197 
198  //- Write molecule sites in XYZ format
199  void writeXYZ(const fileName& fName) const;
200 };
201 
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 } // End namespace Foam
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 #include "moleculeCloudI.H"
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 #endif
214 
215 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::moleculeCloud::cellOccupancy
const List< DynamicList< molecule * > > & cellOccupancy() const
Definition: moleculeCloudI.H:356
Foam::Random
Random number generator.
Definition: Random.H:59
Foam::moleculeCloud::il
const InteractionLists< molecule > & il() const
Definition: moleculeCloudI.H:363
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
labelVector.H
Cloud.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::moleculeCloud::constProps
const List< molecule::constantProperties > constProps() const
Definition: moleculeCloudI.H:370
Foam::molecule
Foam::molecule.
Definition: molecule.H:67
Foam::InteractionLists
Builds direct interaction list, specifying which local (real) cells are potentially in range of each ...
Definition: InteractionLists.H:81
fileName.H
Foam::moleculeCloud::evolve
void evolve()
Evolve the molecules (move, calculate forces, control state etc)
Definition: moleculeCloud.C:1101
Foam::moleculeCloud::mesh
const polyMesh & mesh() const
Definition: moleculeCloudI.H:343
Foam::moleculeCloud::writeXYZ
void writeXYZ(const fileName &fName) const
Write molecule sites in XYZ format.
Definition: moleculeCloud.C:1170
Foam::moleculeCloud::rndGen
Random & rndGen()
Definition: moleculeCloudI.H:383
Foam::potential
Definition: potential.H:55
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Random.H
potential.H
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Definition: ReadFieldsTemplates.C:312
IOdictionary.H
Foam::moleculeCloud::pot
const potential & pot() const
Definition: moleculeCloudI.H:349
moleculeCloudI.H
Foam::moleculeCloud
Definition: moleculeCloud.H:58
InteractionLists.H
Foam::Vector< scalar >
Foam::moleculeCloud::applyConstraintsAndThermostats
void applyConstraintsAndThermostats(const scalar targetTemperature, const scalar measuredTemperature)
Definition: moleculeCloud.C:1142
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::Cloud
Base cloud calls templated on particle type.
Definition: Cloud.H:55
Foam::molecule::constantProperties
Class to hold molecule constant properties.
Definition: molecule.H:91
molecule.H
Foam::moleculeCloud::calculateForce
void calculateForce()
Definition: moleculeCloud.C:1119
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:54