1 |
< |
/* |
1 |
> |
/* |
2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
* |
4 |
|
* The University of Notre Dame grants you ("Licensee") a |
57 |
|
#include "brains/Exclude.hpp" |
58 |
|
#include "io/Globals.hpp" |
59 |
|
#include "math/Vector3.hpp" |
60 |
+ |
#include "math/SquareMatrix3.hpp" |
61 |
|
#include "types/MoleculeStamp.hpp" |
62 |
|
#include "UseTheForce/ForceField.hpp" |
63 |
|
#include "utils/PropertyMap.hpp" |
69 |
|
|
70 |
|
namespace oopse{ |
71 |
|
|
72 |
< |
//forward decalration |
73 |
< |
class SnapshotManager; |
74 |
< |
class Molecule; |
75 |
< |
class SelectionManager; |
76 |
< |
/** |
77 |
< |
* @class SimInfo SimInfo.hpp "brains/SimInfo.hpp" |
78 |
< |
* @brief As one of the heavy weight class of OOPSE, SimInfo |
79 |
< |
* One of the major changes in SimInfo class is the data struct. It only maintains a list of molecules. |
80 |
< |
* And the Molecule class will maintain all of the concrete objects (atoms, bond, bend, torsions, rigid bodies, |
81 |
< |
* cutoff groups, constrains). |
82 |
< |
* Another major change is the index. No matter single version or parallel version, atoms and |
83 |
< |
* rigid bodies have both global index and local index. Local index is not important to molecule as well as |
84 |
< |
* cutoff group. |
85 |
< |
*/ |
86 |
< |
class SimInfo { |
87 |
< |
public: |
88 |
< |
typedef std::map<int, Molecule*>::iterator MoleculeIterator; |
72 |
> |
//forward decalration |
73 |
> |
class SnapshotManager; |
74 |
> |
class Molecule; |
75 |
> |
class SelectionManager; |
76 |
> |
/** |
77 |
> |
* @class SimInfo SimInfo.hpp "brains/SimInfo.hpp" |
78 |
> |
* @brief As one of the heavy weight class of OOPSE, SimInfo |
79 |
> |
* One of the major changes in SimInfo class is the data struct. It only maintains a list of molecules. |
80 |
> |
* And the Molecule class will maintain all of the concrete objects (atoms, bond, bend, torsions, rigid bodies, |
81 |
> |
* cutoff groups, constrains). |
82 |
> |
* Another major change is the index. No matter single version or parallel version, atoms and |
83 |
> |
* rigid bodies have both global index and local index. Local index is not important to molecule as well as |
84 |
> |
* cutoff group. |
85 |
> |
*/ |
86 |
> |
class SimInfo { |
87 |
> |
public: |
88 |
> |
typedef std::map<int, Molecule*>::iterator MoleculeIterator; |
89 |
|
|
90 |
< |
/** |
91 |
< |
* Constructor of SimInfo |
92 |
< |
* @param molStampPairs MoleculeStamp Array. The first element of the pair is molecule stamp, the |
93 |
< |
* second element is the total number of molecules with the same molecule stamp in the system |
94 |
< |
* @param ff pointer of a concrete ForceField instance |
95 |
< |
* @param simParams |
96 |
< |
* @note |
97 |
< |
*/ |
98 |
< |
SimInfo(std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, ForceField* ff, Globals* simParams); |
99 |
< |
virtual ~SimInfo(); |
90 |
> |
/** |
91 |
> |
* Constructor of SimInfo |
92 |
> |
* @param molStampPairs MoleculeStamp Array. The first element of the pair is molecule stamp, the |
93 |
> |
* second element is the total number of molecules with the same molecule stamp in the system |
94 |
> |
* @param ff pointer of a concrete ForceField instance |
95 |
> |
* @param simParams |
96 |
> |
* @note |
97 |
> |
*/ |
98 |
> |
SimInfo(MakeStamps* stamps, std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, ForceField* ff, Globals* simParams); |
99 |
> |
virtual ~SimInfo(); |
100 |
|
|
101 |
< |
/** |
102 |
< |
* Adds a molecule |
103 |
< |
* @return return true if adding successfully, return false if the molecule is already in SimInfo |
104 |
< |
* @param mol molecule to be added |
105 |
< |
*/ |
106 |
< |
bool addMolecule(Molecule* mol); |
101 |
> |
/** |
102 |
> |
* Adds a molecule |
103 |
> |
* @return return true if adding successfully, return false if the molecule is already in SimInfo |
104 |
> |
* @param mol molecule to be added |
105 |
> |
*/ |
106 |
> |
bool addMolecule(Molecule* mol); |
107 |
|
|
108 |
< |
/** |
109 |
< |
* Removes a molecule from SimInfo |
110 |
< |
* @return true if removing successfully, return false if molecule is not in this SimInfo |
111 |
< |
*/ |
112 |
< |
bool removeMolecule(Molecule* mol); |
108 |
> |
/** |
109 |
> |
* Removes a molecule from SimInfo |
110 |
> |
* @return true if removing successfully, return false if molecule is not in this SimInfo |
111 |
> |
*/ |
112 |
> |
bool removeMolecule(Molecule* mol); |
113 |
|
|
114 |
< |
/** Returns the total number of molecules in the system. */ |
115 |
< |
int getNGlobalMolecules() { |
116 |
< |
return nGlobalMols_; |
117 |
< |
} |
114 |
> |
/** Returns the total number of molecules in the system. */ |
115 |
> |
int getNGlobalMolecules() { |
116 |
> |
return nGlobalMols_; |
117 |
> |
} |
118 |
|
|
119 |
< |
/** Returns the total number of atoms in the system. */ |
120 |
< |
int getNGlobalAtoms() { |
121 |
< |
return nGlobalAtoms_; |
122 |
< |
} |
119 |
> |
/** Returns the total number of atoms in the system. */ |
120 |
> |
int getNGlobalAtoms() { |
121 |
> |
return nGlobalAtoms_; |
122 |
> |
} |
123 |
|
|
124 |
< |
/** Returns the total number of cutoff groups in the system. */ |
125 |
< |
int getNGlobalCutoffGroups() { |
126 |
< |
return nGlobalCutoffGroups_; |
127 |
< |
} |
124 |
> |
/** Returns the total number of cutoff groups in the system. */ |
125 |
> |
int getNGlobalCutoffGroups() { |
126 |
> |
return nGlobalCutoffGroups_; |
127 |
> |
} |
128 |
|
|
129 |
< |
/** |
130 |
< |
* Returns the total number of integrable objects (total number of rigid bodies plus the total number |
131 |
< |
* of atoms which do not belong to the rigid bodies) in the system |
132 |
< |
*/ |
133 |
< |
int getNGlobalIntegrableObjects() { |
134 |
< |
return nGlobalIntegrableObjects_; |
135 |
< |
} |
129 |
> |
/** |
130 |
> |
* Returns the total number of integrable objects (total number of rigid bodies plus the total number |
131 |
> |
* of atoms which do not belong to the rigid bodies) in the system |
132 |
> |
*/ |
133 |
> |
int getNGlobalIntegrableObjects() { |
134 |
> |
return nGlobalIntegrableObjects_; |
135 |
> |
} |
136 |
|
|
137 |
< |
/** |
138 |
< |
* Returns the total number of integrable objects (total number of rigid bodies plus the total number |
139 |
< |
* of atoms which do not belong to the rigid bodies) in the system |
140 |
< |
*/ |
141 |
< |
int getNGlobalRigidBodies() { |
142 |
< |
return nGlobalRigidBodies_; |
143 |
< |
} |
137 |
> |
/** |
138 |
> |
* Returns the total number of integrable objects (total number of rigid bodies plus the total number |
139 |
> |
* of atoms which do not belong to the rigid bodies) in the system |
140 |
> |
*/ |
141 |
> |
int getNGlobalRigidBodies() { |
142 |
> |
return nGlobalRigidBodies_; |
143 |
> |
} |
144 |
|
|
145 |
< |
int getNGlobalConstraints(); |
146 |
< |
/** |
147 |
< |
* Returns the number of local molecules. |
148 |
< |
* @return the number of local molecules |
149 |
< |
*/ |
150 |
< |
int getNMolecules() { |
151 |
< |
return molecules_.size(); |
152 |
< |
} |
145 |
> |
int getNGlobalConstraints(); |
146 |
> |
/** |
147 |
> |
* Returns the number of local molecules. |
148 |
> |
* @return the number of local molecules |
149 |
> |
*/ |
150 |
> |
int getNMolecules() { |
151 |
> |
return molecules_.size(); |
152 |
> |
} |
153 |
|
|
154 |
< |
/** Returns the number of local atoms */ |
155 |
< |
unsigned int getNAtoms() { |
156 |
< |
return nAtoms_; |
157 |
< |
} |
154 |
> |
/** Returns the number of local atoms */ |
155 |
> |
unsigned int getNAtoms() { |
156 |
> |
return nAtoms_; |
157 |
> |
} |
158 |
|
|
159 |
< |
/** Returns the number of local bonds */ |
160 |
< |
unsigned int getNBonds(){ |
161 |
< |
return nBonds_; |
162 |
< |
} |
159 |
> |
/** Returns the number of local bonds */ |
160 |
> |
unsigned int getNBonds(){ |
161 |
> |
return nBonds_; |
162 |
> |
} |
163 |
|
|
164 |
< |
/** Returns the number of local bends */ |
165 |
< |
unsigned int getNBends() { |
166 |
< |
return nBends_; |
167 |
< |
} |
164 |
> |
/** Returns the number of local bends */ |
165 |
> |
unsigned int getNBends() { |
166 |
> |
return nBends_; |
167 |
> |
} |
168 |
|
|
169 |
< |
/** Returns the number of local torsions */ |
170 |
< |
unsigned int getNTorsions() { |
171 |
< |
return nTorsions_; |
172 |
< |
} |
169 |
> |
/** Returns the number of local torsions */ |
170 |
> |
unsigned int getNTorsions() { |
171 |
> |
return nTorsions_; |
172 |
> |
} |
173 |
|
|
174 |
< |
/** Returns the number of local rigid bodies */ |
175 |
< |
unsigned int getNRigidBodies() { |
176 |
< |
return nRigidBodies_; |
177 |
< |
} |
174 |
> |
/** Returns the number of local rigid bodies */ |
175 |
> |
unsigned int getNRigidBodies() { |
176 |
> |
return nRigidBodies_; |
177 |
> |
} |
178 |
|
|
179 |
< |
/** Returns the number of local integrable objects */ |
180 |
< |
unsigned int getNIntegrableObjects() { |
181 |
< |
return nIntegrableObjects_; |
182 |
< |
} |
179 |
> |
/** Returns the number of local integrable objects */ |
180 |
> |
unsigned int getNIntegrableObjects() { |
181 |
> |
return nIntegrableObjects_; |
182 |
> |
} |
183 |
|
|
184 |
< |
/** Returns the number of local cutoff groups */ |
185 |
< |
unsigned int getNCutoffGroups() { |
186 |
< |
return nCutoffGroups_; |
187 |
< |
} |
184 |
> |
/** Returns the number of local cutoff groups */ |
185 |
> |
unsigned int getNCutoffGroups() { |
186 |
> |
return nCutoffGroups_; |
187 |
> |
} |
188 |
|
|
189 |
< |
/** Returns the total number of constraints in this SimInfo */ |
190 |
< |
unsigned int getNConstraints() { |
191 |
< |
return nConstraints_; |
192 |
< |
} |
189 |
> |
/** Returns the total number of constraints in this SimInfo */ |
190 |
> |
unsigned int getNConstraints() { |
191 |
> |
return nConstraints_; |
192 |
> |
} |
193 |
|
|
194 |
< |
/** |
195 |
< |
* Returns the first molecule in this SimInfo and intialize the iterator. |
196 |
< |
* @return the first molecule, return NULL if there is not molecule in this SimInfo |
197 |
< |
* @param i the iterator of molecule array (user shouldn't change it) |
198 |
< |
*/ |
199 |
< |
Molecule* beginMolecule(MoleculeIterator& i); |
194 |
> |
/** |
195 |
> |
* Returns the first molecule in this SimInfo and intialize the iterator. |
196 |
> |
* @return the first molecule, return NULL if there is not molecule in this SimInfo |
197 |
> |
* @param i the iterator of molecule array (user shouldn't change it) |
198 |
> |
*/ |
199 |
> |
Molecule* beginMolecule(MoleculeIterator& i); |
200 |
|
|
201 |
< |
/** |
202 |
< |
* Returns the next avaliable Molecule based on the iterator. |
203 |
< |
* @return the next avaliable molecule, return NULL if reaching the end of the array |
204 |
< |
* @param i the iterator of molecule array |
205 |
< |
*/ |
206 |
< |
Molecule* nextMolecule(MoleculeIterator& i); |
201 |
> |
/** |
202 |
> |
* Returns the next avaliable Molecule based on the iterator. |
203 |
> |
* @return the next avaliable molecule, return NULL if reaching the end of the array |
204 |
> |
* @param i the iterator of molecule array |
205 |
> |
*/ |
206 |
> |
Molecule* nextMolecule(MoleculeIterator& i); |
207 |
|
|
208 |
< |
/** Returns the number of degrees of freedom */ |
209 |
< |
int getNdf() { |
210 |
< |
return ndf_; |
211 |
< |
} |
211 |
< |
|
212 |
< |
/** Returns the number of raw degrees of freedom */ |
213 |
< |
int getNdfRaw() { |
214 |
< |
return ndfRaw_; |
215 |
< |
} |
208 |
> |
/** Returns the number of degrees of freedom */ |
209 |
> |
int getNdf() { |
210 |
> |
return ndf_; |
211 |
> |
} |
212 |
|
|
213 |
< |
/** Returns the number of translational degrees of freedom */ |
214 |
< |
int getNdfTrans() { |
215 |
< |
return ndfTrans_; |
216 |
< |
} |
213 |
> |
/** Returns the number of raw degrees of freedom */ |
214 |
> |
int getNdfRaw() { |
215 |
> |
return ndfRaw_; |
216 |
> |
} |
217 |
|
|
218 |
< |
//getNZconstraint and setNZconstraint ruin the coherent of SimInfo class, need refactorying |
218 |
> |
/** Returns the number of translational degrees of freedom */ |
219 |
> |
int getNdfTrans() { |
220 |
> |
return ndfTrans_; |
221 |
> |
} |
222 |
> |
|
223 |
> |
//getNZconstraint and setNZconstraint ruin the coherent of SimInfo class, need refactorying |
224 |
|
|
225 |
< |
/** Returns the total number of z-constraint molecules in the system */ |
226 |
< |
int getNZconstraint() { |
227 |
< |
return nZconstraint_; |
228 |
< |
} |
225 |
> |
/** Returns the total number of z-constraint molecules in the system */ |
226 |
> |
int getNZconstraint() { |
227 |
> |
return nZconstraint_; |
228 |
> |
} |
229 |
|
|
230 |
< |
/** |
231 |
< |
* Sets the number of z-constraint molecules in the system. |
232 |
< |
*/ |
233 |
< |
void setNZconstraint(int nZconstraint) { |
234 |
< |
nZconstraint_ = nZconstraint; |
235 |
< |
} |
230 |
> |
/** |
231 |
> |
* Sets the number of z-constraint molecules in the system. |
232 |
> |
*/ |
233 |
> |
void setNZconstraint(int nZconstraint) { |
234 |
> |
nZconstraint_ = nZconstraint; |
235 |
> |
} |
236 |
|
|
237 |
< |
/** Returns the snapshot manager. */ |
238 |
< |
SnapshotManager* getSnapshotManager() { |
239 |
< |
return sman_; |
240 |
< |
} |
237 |
> |
/** Returns the snapshot manager. */ |
238 |
> |
SnapshotManager* getSnapshotManager() { |
239 |
> |
return sman_; |
240 |
> |
} |
241 |
|
|
242 |
< |
/** Sets the snapshot manager. */ |
243 |
< |
void setSnapshotManager(SnapshotManager* sman); |
242 |
> |
/** Sets the snapshot manager. */ |
243 |
> |
void setSnapshotManager(SnapshotManager* sman); |
244 |
|
|
245 |
< |
/** Returns the force field */ |
246 |
< |
ForceField* getForceField() { |
247 |
< |
return forceField_; |
248 |
< |
} |
245 |
> |
/** Returns the force field */ |
246 |
> |
ForceField* getForceField() { |
247 |
> |
return forceField_; |
248 |
> |
} |
249 |
|
|
250 |
< |
Globals* getSimParams() { |
251 |
< |
return simParams_; |
252 |
< |
} |
250 |
> |
Globals* getSimParams() { |
251 |
> |
return simParams_; |
252 |
> |
} |
253 |
|
|
254 |
< |
/** Returns the velocity of center of mass of the whole system.*/ |
255 |
< |
Vector3d getComVel(); |
254 |
> |
/** Returns the velocity of center of mass of the whole system.*/ |
255 |
> |
Vector3d getComVel(); |
256 |
|
|
257 |
< |
/** Returns the center of the mass of the whole system.*/ |
258 |
< |
Vector3d getCom(); |
257 |
> |
/** Returns the center of the mass of the whole system.*/ |
258 |
> |
Vector3d getCom(); |
259 |
> |
/** Returns the center of the mass and Center of Mass velocity of the whole system.*/ |
260 |
> |
void getComAll(Vector3d& com,Vector3d& comVel); |
261 |
|
|
262 |
< |
/** Returns the seed (used for random number generator) */ |
263 |
< |
int getSeed() { |
264 |
< |
return seed_; |
265 |
< |
} |
262 |
> |
/** Returns intertia tensor for the entire system and system Angular Momentum.*/ |
263 |
> |
void getInertiaTensor(Mat3x3d &intertiaTensor,Vector3d &angularMomentum); |
264 |
> |
|
265 |
> |
/** Returns system angular momentum */ |
266 |
> |
Vector3d getAngularMomentum(); |
267 |
|
|
268 |
< |
/** Sets the seed*/ |
269 |
< |
void setSeed(int seed) { |
266 |
< |
seed_ = seed; |
267 |
< |
} |
268 |
> |
/** main driver function to interact with fortran during the initialization and molecule migration */ |
269 |
> |
void update(); |
270 |
|
|
271 |
< |
/** main driver function to interact with fortran during the initialization and molecule migration */ |
272 |
< |
void update(); |
271 |
> |
/** Returns the local index manager */ |
272 |
> |
LocalIndexManager* getLocalIndexManager() { |
273 |
> |
return &localIndexMan_; |
274 |
> |
} |
275 |
|
|
276 |
< |
/** Returns the local index manager */ |
277 |
< |
LocalIndexManager* getLocalIndexManager() { |
278 |
< |
return &localIndexMan_; |
279 |
< |
} |
276 |
> |
int getMoleculeStampId(int globalIndex) { |
277 |
> |
//assert(globalIndex < molStampIds_.size()) |
278 |
> |
return molStampIds_[globalIndex]; |
279 |
> |
} |
280 |
|
|
281 |
< |
int getMoleculeStampId(int globalIndex) { |
282 |
< |
//assert(globalIndex < molStampIds_.size()) |
283 |
< |
return molStampIds_[globalIndex]; |
284 |
< |
} |
281 |
> |
/** Returns the molecule stamp */ |
282 |
> |
MoleculeStamp* getMoleculeStamp(int id) { |
283 |
> |
return moleculeStamps_[id]; |
284 |
> |
} |
285 |
|
|
286 |
< |
/** Returns the molecule stamp */ |
287 |
< |
MoleculeStamp* getMoleculeStamp(int id) { |
288 |
< |
return moleculeStamps_[id]; |
289 |
< |
} |
286 |
> |
/** Return the total number of the molecule stamps */ |
287 |
> |
int getNMoleculeStamp() { |
288 |
> |
return moleculeStamps_.size(); |
289 |
> |
} |
290 |
> |
/** |
291 |
> |
* Finds a molecule with a specified global index |
292 |
> |
* @return a pointer point to found molecule |
293 |
> |
* @param index |
294 |
> |
*/ |
295 |
> |
Molecule* getMoleculeByGlobalIndex(int index) { |
296 |
> |
MoleculeIterator i; |
297 |
> |
i = molecules_.find(index); |
298 |
|
|
299 |
< |
/** Return the total number of the molecule stamps */ |
300 |
< |
int getNMoleculeStamp() { |
289 |
< |
return moleculeStamps_.size(); |
290 |
< |
} |
291 |
< |
/** |
292 |
< |
* Finds a molecule with a specified global index |
293 |
< |
* @return a pointer point to found molecule |
294 |
< |
* @param index |
295 |
< |
*/ |
296 |
< |
Molecule* getMoleculeByGlobalIndex(int index) { |
297 |
< |
MoleculeIterator i; |
298 |
< |
i = molecules_.find(index); |
299 |
> |
return i != molecules_.end() ? i->second : NULL; |
300 |
> |
} |
301 |
|
|
302 |
< |
return i != molecules_.end() ? i->second : NULL; |
303 |
< |
} |
302 |
> |
/** Calculate the maximum cutoff radius based on the atom types */ |
303 |
> |
double calcMaxCutoffRadius(); |
304 |
|
|
305 |
< |
/** Calculate the maximum cutoff radius based on the atom types */ |
306 |
< |
double calcMaxCutoffRadius(); |
305 |
> |
double getRcut() { |
306 |
> |
return rcut_; |
307 |
> |
} |
308 |
|
|
309 |
< |
double getRcut() { |
310 |
< |
return rcut_; |
311 |
< |
} |
309 |
< |
|
310 |
< |
double getRsw() { |
311 |
< |
return rsw_; |
312 |
< |
} |
309 |
> |
double getRsw() { |
310 |
> |
return rsw_; |
311 |
> |
} |
312 |
|
|
313 |
< |
std::string getFinalConfigFileName() { |
314 |
< |
return finalConfigFileName_; |
315 |
< |
} |
313 |
> |
std::string getFinalConfigFileName() { |
314 |
> |
return finalConfigFileName_; |
315 |
> |
} |
316 |
|
|
317 |
< |
void setFinalConfigFileName(const std::string& fileName) { |
318 |
< |
finalConfigFileName_ = fileName; |
319 |
< |
} |
317 |
> |
void setFinalConfigFileName(const std::string& fileName) { |
318 |
> |
finalConfigFileName_ = fileName; |
319 |
> |
} |
320 |
|
|
321 |
< |
std::string getDumpFileName() { |
322 |
< |
return dumpFileName_; |
323 |
< |
} |
321 |
> |
std::string getDumpFileName() { |
322 |
> |
return dumpFileName_; |
323 |
> |
} |
324 |
|
|
325 |
< |
void setDumpFileName(const std::string& fileName) { |
326 |
< |
dumpFileName_ = fileName; |
327 |
< |
} |
325 |
> |
void setDumpFileName(const std::string& fileName) { |
326 |
> |
dumpFileName_ = fileName; |
327 |
> |
} |
328 |
|
|
329 |
< |
std::string getStatFileName() { |
330 |
< |
return statFileName_; |
331 |
< |
} |
329 |
> |
std::string getStatFileName() { |
330 |
> |
return statFileName_; |
331 |
> |
} |
332 |
|
|
333 |
< |
void setStatFileName(const std::string& fileName) { |
334 |
< |
statFileName_ = fileName; |
335 |
< |
} |
333 |
> |
void setStatFileName(const std::string& fileName) { |
334 |
> |
statFileName_ = fileName; |
335 |
> |
} |
336 |
> |
|
337 |
> |
std::string getRestFileName() { |
338 |
> |
return restFileName_; |
339 |
> |
} |
340 |
> |
|
341 |
> |
void setRestFileName(const std::string& fileName) { |
342 |
> |
restFileName_ = fileName; |
343 |
> |
} |
344 |
|
|
345 |
< |
/** |
346 |
< |
* Sets GlobalGroupMembership |
347 |
< |
* @see #SimCreator::setGlobalIndex |
348 |
< |
*/ |
349 |
< |
void setGlobalGroupMembership(const std::vector<int>& globalGroupMembership) { |
350 |
< |
assert(globalGroupMembership.size() == nGlobalAtoms_); |
351 |
< |
globalGroupMembership_ = globalGroupMembership; |
352 |
< |
} |
345 |
> |
/** |
346 |
> |
* Sets GlobalGroupMembership |
347 |
> |
* @see #SimCreator::setGlobalIndex |
348 |
> |
*/ |
349 |
> |
void setGlobalGroupMembership(const std::vector<int>& globalGroupMembership) { |
350 |
> |
assert(globalGroupMembership.size() == nGlobalAtoms_); |
351 |
> |
globalGroupMembership_ = globalGroupMembership; |
352 |
> |
} |
353 |
|
|
354 |
< |
/** |
355 |
< |
* Sets GlobalMolMembership |
356 |
< |
* @see #SimCreator::setGlobalIndex |
357 |
< |
*/ |
358 |
< |
void setGlobalMolMembership(const std::vector<int>& globalMolMembership) { |
359 |
< |
assert(globalMolMembership.size() == nGlobalAtoms_); |
360 |
< |
globalMolMembership_ = globalMolMembership; |
361 |
< |
} |
354 |
> |
/** |
355 |
> |
* Sets GlobalMolMembership |
356 |
> |
* @see #SimCreator::setGlobalIndex |
357 |
> |
*/ |
358 |
> |
void setGlobalMolMembership(const std::vector<int>& globalMolMembership) { |
359 |
> |
assert(globalMolMembership.size() == nGlobalAtoms_); |
360 |
> |
globalMolMembership_ = globalMolMembership; |
361 |
> |
} |
362 |
|
|
363 |
|
|
364 |
< |
bool isFortranInitialized() { |
365 |
< |
return fortranInitialized_; |
366 |
< |
} |
364 |
> |
bool isFortranInitialized() { |
365 |
> |
return fortranInitialized_; |
366 |
> |
} |
367 |
|
|
368 |
< |
//below functions are just forward functions |
369 |
< |
//To compose or to inherit is always a hot debate. In general, is-a relation need subclassing, in the |
370 |
< |
//the other hand, has-a relation need composing. |
371 |
< |
/** |
372 |
< |
* Adds property into property map |
373 |
< |
* @param genData GenericData to be added into PropertyMap |
374 |
< |
*/ |
375 |
< |
void addProperty(GenericData* genData); |
368 |
> |
//below functions are just forward functions |
369 |
> |
//To compose or to inherit is always a hot debate. In general, is-a relation need subclassing, in the |
370 |
> |
//the other hand, has-a relation need composing. |
371 |
> |
/** |
372 |
> |
* Adds property into property map |
373 |
> |
* @param genData GenericData to be added into PropertyMap |
374 |
> |
*/ |
375 |
> |
void addProperty(GenericData* genData); |
376 |
|
|
377 |
< |
/** |
378 |
< |
* Removes property from PropertyMap by name |
379 |
< |
* @param propName the name of property to be removed |
380 |
< |
*/ |
381 |
< |
void removeProperty(const std::string& propName); |
377 |
> |
/** |
378 |
> |
* Removes property from PropertyMap by name |
379 |
> |
* @param propName the name of property to be removed |
380 |
> |
*/ |
381 |
> |
void removeProperty(const std::string& propName); |
382 |
|
|
383 |
< |
/** |
384 |
< |
* clear all of the properties |
385 |
< |
*/ |
386 |
< |
void clearProperties(); |
383 |
> |
/** |
384 |
> |
* clear all of the properties |
385 |
> |
*/ |
386 |
> |
void clearProperties(); |
387 |
|
|
388 |
< |
/** |
389 |
< |
* Returns all names of properties |
390 |
< |
* @return all names of properties |
391 |
< |
*/ |
392 |
< |
std::vector<std::string> getPropertyNames(); |
388 |
> |
/** |
389 |
> |
* Returns all names of properties |
390 |
> |
* @return all names of properties |
391 |
> |
*/ |
392 |
> |
std::vector<std::string> getPropertyNames(); |
393 |
|
|
394 |
< |
/** |
395 |
< |
* Returns all of the properties in PropertyMap |
396 |
< |
* @return all of the properties in PropertyMap |
397 |
< |
*/ |
398 |
< |
std::vector<GenericData*> getProperties(); |
394 |
> |
/** |
395 |
> |
* Returns all of the properties in PropertyMap |
396 |
> |
* @return all of the properties in PropertyMap |
397 |
> |
*/ |
398 |
> |
std::vector<GenericData*> getProperties(); |
399 |
|
|
400 |
< |
/** |
401 |
< |
* Returns property |
402 |
< |
* @param propName name of property |
403 |
< |
* @return a pointer point to property with propName. If no property named propName |
404 |
< |
* exists, return NULL |
405 |
< |
*/ |
406 |
< |
GenericData* getPropertyByName(const std::string& propName); |
400 |
> |
/** |
401 |
> |
* Returns property |
402 |
> |
* @param propName name of property |
403 |
> |
* @return a pointer point to property with propName. If no property named propName |
404 |
> |
* exists, return NULL |
405 |
> |
*/ |
406 |
> |
GenericData* getPropertyByName(const std::string& propName); |
407 |
|
|
408 |
< |
/** |
409 |
< |
* add all exclude pairs of a molecule into exclude list. |
410 |
< |
*/ |
411 |
< |
void addExcludePairs(Molecule* mol); |
408 |
> |
/** |
409 |
> |
* add all exclude pairs of a molecule into exclude list. |
410 |
> |
*/ |
411 |
> |
void addExcludePairs(Molecule* mol); |
412 |
|
|
413 |
< |
/** |
414 |
< |
* remove all exclude pairs which belong to a molecule from exclude list |
415 |
< |
*/ |
413 |
> |
/** |
414 |
> |
* remove all exclude pairs which belong to a molecule from exclude list |
415 |
> |
*/ |
416 |
|
|
417 |
< |
void removeExcludePairs(Molecule* mol); |
417 |
> |
void removeExcludePairs(Molecule* mol); |
418 |
|
|
419 |
|
|
420 |
< |
SelectionManager* getSelectionManager() { |
421 |
< |
return selectMan_; |
415 |
< |
} |
416 |
< |
|
417 |
< |
/** Returns the unique atom types of local processor in an array */ |
418 |
< |
std::set<AtomType*> getUniqueAtomTypes(); |
420 |
> |
/** Returns the unique atom types of local processor in an array */ |
421 |
> |
std::set<AtomType*> getUniqueAtomTypes(); |
422 |
|
|
423 |
< |
friend std::ostream& operator <<(std::ostream& o, SimInfo& info); |
423 |
> |
friend std::ostream& operator <<(std::ostream& o, SimInfo& info); |
424 |
|
|
425 |
< |
void getCutoff(double& rcut, double& rsw); |
425 |
> |
void getCutoff(double& rcut, double& rsw); |
426 |
|
|
427 |
< |
private: |
427 |
> |
private: |
428 |
|
|
429 |
< |
/** fill up the simtype struct*/ |
430 |
< |
void setupSimType(); |
429 |
> |
/** fill up the simtype struct*/ |
430 |
> |
void setupSimType(); |
431 |
|
|
432 |
< |
/** |
433 |
< |
* Setup Fortran Simulation |
434 |
< |
* @see #setupFortranParallel |
435 |
< |
*/ |
436 |
< |
void setupFortranSim(); |
432 |
> |
/** |
433 |
> |
* Setup Fortran Simulation |
434 |
> |
* @see #setupFortranParallel |
435 |
> |
*/ |
436 |
> |
void setupFortranSim(); |
437 |
|
|
438 |
< |
/** Figure out the radius of cutoff, radius of switching function and pass them to fortran */ |
439 |
< |
void setupCutoff(); |
438 |
> |
/** Figure out the radius of cutoff, radius of switching function and pass them to fortran */ |
439 |
> |
void setupCutoff(); |
440 |
|
|
441 |
< |
/** Calculates the number of degress of freedom in the whole system */ |
442 |
< |
void calcNdf(); |
440 |
< |
void calcNdfRaw(); |
441 |
< |
void calcNdfTrans(); |
441 |
> |
/** Figure out which coulombic correction method to use and pass to fortran */ |
442 |
> |
void setupElectrostaticSummationMethod( int isError ); |
443 |
|
|
444 |
< |
/** |
445 |
< |
* Adds molecule stamp and the total number of the molecule with same molecule stamp in the whole |
445 |
< |
* system. |
446 |
< |
*/ |
447 |
< |
void addMoleculeStamp(MoleculeStamp* molStamp, int nmol); |
444 |
> |
/** Figure out which polynomial type to use for the switching function */ |
445 |
> |
void setupSwitchingFunction(); |
446 |
|
|
447 |
< |
ForceField* forceField_; |
448 |
< |
Globals* simParams_; |
447 |
> |
/** Calculates the number of degress of freedom in the whole system */ |
448 |
> |
void calcNdf(); |
449 |
> |
void calcNdfRaw(); |
450 |
> |
void calcNdfTrans(); |
451 |
|
|
452 |
< |
std::map<int, Molecule*> molecules_; /**< Molecule array */ |
452 |
> |
/** |
453 |
> |
* Adds molecule stamp and the total number of the molecule with same molecule stamp in the whole |
454 |
> |
* system. |
455 |
> |
*/ |
456 |
> |
void addMoleculeStamp(MoleculeStamp* molStamp, int nmol); |
457 |
> |
|
458 |
> |
MakeStamps* stamps_; |
459 |
> |
ForceField* forceField_; |
460 |
> |
Globals* simParams_; |
461 |
> |
|
462 |
> |
std::map<int, Molecule*> molecules_; /**< Molecule array */ |
463 |
|
|
464 |
< |
//degress of freedom |
465 |
< |
int ndf_; /**< number of degress of freedom (excludes constraints), ndf_ is local */ |
466 |
< |
int ndfRaw_; /**< number of degress of freedom (includes constraints), ndfRaw_ is local */ |
467 |
< |
int ndfTrans_; /**< number of translation degress of freedom, ndfTrans_ is local */ |
468 |
< |
int nZconstraint_; /** number of z-constraint molecules, nZconstraint_ is global */ |
464 |
> |
//degress of freedom |
465 |
> |
int ndf_; /**< number of degress of freedom (excludes constraints), ndf_ is local */ |
466 |
> |
int ndfRaw_; /**< number of degress of freedom (includes constraints), ndfRaw_ is local */ |
467 |
> |
int ndfTrans_; /**< number of translation degress of freedom, ndfTrans_ is local */ |
468 |
> |
int nZconstraint_; /** number of z-constraint molecules, nZconstraint_ is global */ |
469 |
|
|
470 |
< |
//number of global objects |
471 |
< |
int nGlobalMols_; /**< number of molecules in the system */ |
472 |
< |
int nGlobalAtoms_; /**< number of atoms in the system */ |
473 |
< |
int nGlobalCutoffGroups_; /**< number of cutoff groups in this system */ |
474 |
< |
int nGlobalIntegrableObjects_; /**< number of integrable objects in this system */ |
475 |
< |
int nGlobalRigidBodies_; /**< number of rigid bodies in this system */ |
476 |
< |
/** |
477 |
< |
* the size of globalGroupMembership_ is nGlobalAtoms. Its index is global index of an atom, and the |
478 |
< |
* corresponding content is the global index of cutoff group this atom belong to. |
479 |
< |
* It is filled by SimCreator once and only once, since it never changed during the simulation. |
480 |
< |
*/ |
481 |
< |
std::vector<int> globalGroupMembership_; |
470 |
> |
//number of global objects |
471 |
> |
int nGlobalMols_; /**< number of molecules in the system */ |
472 |
> |
int nGlobalAtoms_; /**< number of atoms in the system */ |
473 |
> |
int nGlobalCutoffGroups_; /**< number of cutoff groups in this system */ |
474 |
> |
int nGlobalIntegrableObjects_; /**< number of integrable objects in this system */ |
475 |
> |
int nGlobalRigidBodies_; /**< number of rigid bodies in this system */ |
476 |
> |
/** |
477 |
> |
* the size of globalGroupMembership_ is nGlobalAtoms. Its index is global index of an atom, and the |
478 |
> |
* corresponding content is the global index of cutoff group this atom belong to. |
479 |
> |
* It is filled by SimCreator once and only once, since it never changed during the simulation. |
480 |
> |
*/ |
481 |
> |
std::vector<int> globalGroupMembership_; |
482 |
|
|
483 |
< |
/** |
484 |
< |
* the size of globalGroupMembership_ is nGlobalAtoms. Its index is global index of an atom, and the |
485 |
< |
* corresponding content is the global index of molecule this atom belong to. |
486 |
< |
* It is filled by SimCreator once and only once, since it is never changed during the simulation. |
487 |
< |
*/ |
488 |
< |
std::vector<int> globalMolMembership_; |
483 |
> |
/** |
484 |
> |
* the size of globalGroupMembership_ is nGlobalAtoms. Its index is global index of an atom, and the |
485 |
> |
* corresponding content is the global index of molecule this atom belong to. |
486 |
> |
* It is filled by SimCreator once and only once, since it is never changed during the simulation. |
487 |
> |
*/ |
488 |
> |
std::vector<int> globalMolMembership_; |
489 |
|
|
490 |
|
|
491 |
< |
std::vector<int> molStampIds_; /**< stamp id array of all molecules in the system */ |
492 |
< |
std::vector<MoleculeStamp*> moleculeStamps_; /**< molecule stamps array */ |
491 |
> |
std::vector<int> molStampIds_; /**< stamp id array of all molecules in the system */ |
492 |
> |
std::vector<MoleculeStamp*> moleculeStamps_; /**< molecule stamps array */ |
493 |
|
|
494 |
< |
//number of local objects |
495 |
< |
int nAtoms_; /**< number of atoms in local processor */ |
496 |
< |
int nBonds_; /**< number of bonds in local processor */ |
497 |
< |
int nBends_; /**< number of bends in local processor */ |
498 |
< |
int nTorsions_; /**< number of torsions in local processor */ |
499 |
< |
int nRigidBodies_; /**< number of rigid bodies in local processor */ |
500 |
< |
int nIntegrableObjects_; /**< number of integrable objects in local processor */ |
501 |
< |
int nCutoffGroups_; /**< number of cutoff groups in local processor */ |
502 |
< |
int nConstraints_; /**< number of constraints in local processors */ |
494 |
> |
//number of local objects |
495 |
> |
int nAtoms_; /**< number of atoms in local processor */ |
496 |
> |
int nBonds_; /**< number of bonds in local processor */ |
497 |
> |
int nBends_; /**< number of bends in local processor */ |
498 |
> |
int nTorsions_; /**< number of torsions in local processor */ |
499 |
> |
int nRigidBodies_; /**< number of rigid bodies in local processor */ |
500 |
> |
int nIntegrableObjects_; /**< number of integrable objects in local processor */ |
501 |
> |
int nCutoffGroups_; /**< number of cutoff groups in local processor */ |
502 |
> |
int nConstraints_; /**< number of constraints in local processors */ |
503 |
|
|
504 |
< |
simtype fInfo_; /**< A dual struct shared by c++/fortran which indicates the atom types in simulation*/ |
505 |
< |
Exclude exclude_; |
506 |
< |
PropertyMap properties_; /**< Generic Property */ |
507 |
< |
SnapshotManager* sman_; /**< SnapshotManager */ |
504 |
> |
simtype fInfo_; /**< A dual struct shared by c++/fortran which indicates the atom types in simulation*/ |
505 |
> |
Exclude exclude_; |
506 |
> |
PropertyMap properties_; /**< Generic Property */ |
507 |
> |
SnapshotManager* sman_; /**< SnapshotManager */ |
508 |
|
|
509 |
< |
int seed_; /**< seed for random number generator */ |
509 |
> |
/** |
510 |
> |
* The reason to have a local index manager is that when molecule is migrating to other processors, |
511 |
> |
* the atoms and the rigid-bodies will release their local indices to LocalIndexManager. Combining the |
512 |
> |
* information of molecule migrating to current processor, Migrator class can query the LocalIndexManager |
513 |
> |
* to make a efficient data moving plan. |
514 |
> |
*/ |
515 |
> |
LocalIndexManager localIndexMan_; |
516 |
|
|
517 |
< |
/** |
518 |
< |
* The reason to have a local index manager is that when molecule is migrating to other processors, |
519 |
< |
* the atoms and the rigid-bodies will release their local indices to LocalIndexManager. Combining the |
520 |
< |
* information of molecule migrating to current processor, Migrator class can query the LocalIndexManager |
521 |
< |
* to make a efficient data moving plan. |
522 |
< |
*/ |
523 |
< |
LocalIndexManager localIndexMan_; |
517 |
> |
//file names |
518 |
> |
std::string finalConfigFileName_; |
519 |
> |
std::string dumpFileName_; |
520 |
> |
std::string statFileName_; |
521 |
> |
std::string restFileName_; |
522 |
> |
|
523 |
> |
double rcut_; /**< cutoff radius*/ |
524 |
> |
double rsw_; /**< radius of switching function*/ |
525 |
|
|
526 |
< |
//file names |
510 |
< |
std::string finalConfigFileName_; |
511 |
< |
std::string dumpFileName_; |
512 |
< |
std::string statFileName_; |
526 |
> |
bool fortranInitialized_; /**< flag indicate whether fortran side is initialized */ |
527 |
|
|
514 |
– |
double rcut_; /**< cutoff radius*/ |
515 |
– |
double rsw_; /**< radius of switching function*/ |
516 |
– |
|
517 |
– |
bool fortranInitialized_; /**< flag indicate whether fortran side is initialized */ |
518 |
– |
|
519 |
– |
SelectionManager* selectMan_; |
528 |
|
#ifdef IS_MPI |
529 |
|
//in Parallel version, we need MolToProc |
530 |
< |
public: |
530 |
> |
public: |
531 |
|
|
532 |
< |
/** |
533 |
< |
* Finds the processor where a molecule resides |
534 |
< |
* @return the id of the processor which contains the molecule |
535 |
< |
* @param globalIndex global Index of the molecule |
536 |
< |
*/ |
537 |
< |
int getMolToProc(int globalIndex) { |
538 |
< |
//assert(globalIndex < molToProcMap_.size()); |
539 |
< |
return molToProcMap_[globalIndex]; |
540 |
< |
} |
532 |
> |
/** |
533 |
> |
* Finds the processor where a molecule resides |
534 |
> |
* @return the id of the processor which contains the molecule |
535 |
> |
* @param globalIndex global Index of the molecule |
536 |
> |
*/ |
537 |
> |
int getMolToProc(int globalIndex) { |
538 |
> |
//assert(globalIndex < molToProcMap_.size()); |
539 |
> |
return molToProcMap_[globalIndex]; |
540 |
> |
} |
541 |
|
|
542 |
< |
/** |
543 |
< |
* Set MolToProcMap array |
544 |
< |
* @see #SimCreator::divideMolecules |
545 |
< |
*/ |
546 |
< |
void setMolToProcMap(const std::vector<int>& molToProcMap) { |
547 |
< |
molToProcMap_ = molToProcMap; |
548 |
< |
} |
542 |
> |
/** |
543 |
> |
* Set MolToProcMap array |
544 |
> |
* @see #SimCreator::divideMolecules |
545 |
> |
*/ |
546 |
> |
void setMolToProcMap(const std::vector<int>& molToProcMap) { |
547 |
> |
molToProcMap_ = molToProcMap; |
548 |
> |
} |
549 |
|
|
550 |
< |
private: |
550 |
> |
private: |
551 |
|
|
552 |
< |
void setupFortranParallel(); |
552 |
> |
void setupFortranParallel(); |
553 |
|
|
554 |
< |
/** |
555 |
< |
* The size of molToProcMap_ is equal to total number of molecules in the system. |
556 |
< |
* It maps a molecule to the processor on which it resides. it is filled by SimCreator once and only |
557 |
< |
* once. |
558 |
< |
*/ |
559 |
< |
std::vector<int> molToProcMap_; |
554 |
> |
/** |
555 |
> |
* The size of molToProcMap_ is equal to total number of molecules in the system. |
556 |
> |
* It maps a molecule to the processor on which it resides. it is filled by SimCreator once and only |
557 |
> |
* once. |
558 |
> |
*/ |
559 |
> |
std::vector<int> molToProcMap_; |
560 |
|
|
561 |
|
#endif |
562 |
|
|
563 |
< |
}; |
563 |
> |
}; |
564 |
|
|
565 |
|
} //namespace oopse |
566 |
|
#endif //BRAINS_SIMMODEL_HPP |