1 |
/* |
2 |
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
* |
4 |
* The University of Notre Dame grants you ("Licensee") a |
5 |
* non-exclusive, royalty free, license to use, modify and |
6 |
* redistribute this software in source and binary code form, provided |
7 |
* that the following conditions are met: |
8 |
* |
9 |
* 1. Redistributions of source code must retain the above copyright |
10 |
* notice, this list of conditions and the following disclaimer. |
11 |
* |
12 |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
* notice, this list of conditions and the following disclaimer in the |
14 |
* documentation and/or other materials provided with the |
15 |
* distribution. |
16 |
* |
17 |
* This software is provided "AS IS," without a warranty of any |
18 |
* kind. All express or implied conditions, representations and |
19 |
* warranties, including any implied warranty of merchantability, |
20 |
* fitness for a particular purpose or non-infringement, are hereby |
21 |
* excluded. The University of Notre Dame and its licensors shall not |
22 |
* be liable for any damages suffered by licensee as a result of |
23 |
* using, modifying or distributing the software or its |
24 |
* derivatives. In no event will the University of Notre Dame or its |
25 |
* licensors be liable for any lost revenue, profit or data, or for |
26 |
* direct, indirect, special, consequential, incidental or punitive |
27 |
* damages, however caused and regardless of the theory of liability, |
28 |
* arising out of the use of or inability to use software, even if the |
29 |
* University of Notre Dame has been advised of the possibility of |
30 |
* such damages. |
31 |
* |
32 |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
* research, please cite the appropriate papers when you publish your |
34 |
* work. Good starting points are: |
35 |
* |
36 |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
* [4] Vardeman & Gezelter, in progress (2009). |
40 |
*/ |
41 |
|
42 |
/** |
43 |
* @file SimInfo.hpp |
44 |
* @author tlin |
45 |
* @date 11/02/2004 |
46 |
* @version 1.0 |
47 |
*/ |
48 |
|
49 |
#ifndef BRAINS_SIMMODEL_HPP |
50 |
#define BRAINS_SIMMODEL_HPP |
51 |
|
52 |
#include <iostream> |
53 |
#include <set> |
54 |
#include <utility> |
55 |
#include <vector> |
56 |
|
57 |
#include "brains/PairList.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" |
64 |
#include "utils/LocalIndexManager.hpp" |
65 |
#include "nonbonded/Electrostatic.hpp" |
66 |
|
67 |
//another nonsense macro declaration |
68 |
#define __OPENMD_C |
69 |
#include "brains/fSimulation.h" |
70 |
|
71 |
namespace OpenMD{ |
72 |
|
73 |
//forward decalration |
74 |
class SnapshotManager; |
75 |
class Molecule; |
76 |
class SelectionManager; |
77 |
class StuntDouble; |
78 |
class Electrostatic; |
79 |
/** |
80 |
* @class SimInfo SimInfo.hpp "brains/SimInfo.hpp" |
81 |
* @brief One of the heavy weight classes of OpenMD, SimInfo maintains a list of molecules. |
82 |
* The Molecule class maintains all of the concrete objects |
83 |
* (atoms, bond, bend, torsions, inversions, rigid bodies, cutoff groups, |
84 |
* constraints). In both the single and parallel versions, atoms and |
85 |
* rigid bodies have both global and local indices. The local index is |
86 |
* not relevant to molecules or cutoff groups. |
87 |
*/ |
88 |
class SimInfo { |
89 |
public: |
90 |
typedef std::map<int, Molecule*>::iterator MoleculeIterator; |
91 |
|
92 |
/** |
93 |
* Constructor of SimInfo |
94 |
* @param molStampPairs MoleculeStamp Array. The first element of the pair is molecule stamp, the |
95 |
* second element is the total number of molecules with the same molecule stamp in the system |
96 |
* @param ff pointer of a concrete ForceField instance |
97 |
* @param simParams |
98 |
* @note |
99 |
*/ |
100 |
SimInfo(ForceField* ff, Globals* simParams); |
101 |
virtual ~SimInfo(); |
102 |
|
103 |
/** |
104 |
* Adds a molecule |
105 |
* @return return true if adding successfully, return false if the molecule is already in SimInfo |
106 |
* @param mol molecule to be added |
107 |
*/ |
108 |
bool addMolecule(Molecule* mol); |
109 |
|
110 |
/** |
111 |
* Removes a molecule from SimInfo |
112 |
* @return true if removing successfully, return false if molecule is not in this SimInfo |
113 |
*/ |
114 |
bool removeMolecule(Molecule* mol); |
115 |
|
116 |
/** Returns the total number of molecules in the system. */ |
117 |
int getNGlobalMolecules() { |
118 |
return nGlobalMols_; |
119 |
} |
120 |
|
121 |
/** Returns the total number of atoms in the system. */ |
122 |
int getNGlobalAtoms() { |
123 |
return nGlobalAtoms_; |
124 |
} |
125 |
|
126 |
/** Returns the total number of cutoff groups in the system. */ |
127 |
int getNGlobalCutoffGroups() { |
128 |
return nGlobalCutoffGroups_; |
129 |
} |
130 |
|
131 |
/** |
132 |
* Returns the total number of integrable objects (total number of rigid bodies plus the total number |
133 |
* of atoms which do not belong to the rigid bodies) in the system |
134 |
*/ |
135 |
int getNGlobalIntegrableObjects() { |
136 |
return nGlobalIntegrableObjects_; |
137 |
} |
138 |
|
139 |
/** |
140 |
* Returns the total number of integrable objects (total number of rigid bodies plus the total number |
141 |
* of atoms which do not belong to the rigid bodies) in the system |
142 |
*/ |
143 |
int getNGlobalRigidBodies() { |
144 |
return nGlobalRigidBodies_; |
145 |
} |
146 |
|
147 |
int getNGlobalConstraints(); |
148 |
/** |
149 |
* Returns the number of local molecules. |
150 |
* @return the number of local molecules |
151 |
*/ |
152 |
int getNMolecules() { |
153 |
return molecules_.size(); |
154 |
} |
155 |
|
156 |
/** Returns the number of local atoms */ |
157 |
unsigned int getNAtoms() { |
158 |
return nAtoms_; |
159 |
} |
160 |
|
161 |
/** Returns the number of local bonds */ |
162 |
unsigned int getNBonds(){ |
163 |
return nBonds_; |
164 |
} |
165 |
|
166 |
/** Returns the number of local bends */ |
167 |
unsigned int getNBends() { |
168 |
return nBends_; |
169 |
} |
170 |
|
171 |
/** Returns the number of local torsions */ |
172 |
unsigned int getNTorsions() { |
173 |
return nTorsions_; |
174 |
} |
175 |
|
176 |
/** Returns the number of local torsions */ |
177 |
unsigned int getNInversions() { |
178 |
return nInversions_; |
179 |
} |
180 |
/** Returns the number of local rigid bodies */ |
181 |
unsigned int getNRigidBodies() { |
182 |
return nRigidBodies_; |
183 |
} |
184 |
|
185 |
/** Returns the number of local integrable objects */ |
186 |
unsigned int getNIntegrableObjects() { |
187 |
return nIntegrableObjects_; |
188 |
} |
189 |
|
190 |
/** Returns the number of local cutoff groups */ |
191 |
unsigned int getNCutoffGroups() { |
192 |
return nCutoffGroups_; |
193 |
} |
194 |
|
195 |
/** Returns the total number of constraints in this SimInfo */ |
196 |
unsigned int getNConstraints() { |
197 |
return nConstraints_; |
198 |
} |
199 |
|
200 |
/** |
201 |
* Returns the first molecule in this SimInfo and intialize the iterator. |
202 |
* @return the first molecule, return NULL if there is not molecule in this SimInfo |
203 |
* @param i the iterator of molecule array (user shouldn't change it) |
204 |
*/ |
205 |
Molecule* beginMolecule(MoleculeIterator& i); |
206 |
|
207 |
/** |
208 |
* Returns the next avaliable Molecule based on the iterator. |
209 |
* @return the next avaliable molecule, return NULL if reaching the end of the array |
210 |
* @param i the iterator of molecule array |
211 |
*/ |
212 |
Molecule* nextMolecule(MoleculeIterator& i); |
213 |
|
214 |
/** Returns the number of degrees of freedom */ |
215 |
int getNdf() { |
216 |
return ndf_ - getFdf(); |
217 |
} |
218 |
|
219 |
/** Returns the number of raw degrees of freedom */ |
220 |
int getNdfRaw() { |
221 |
return ndfRaw_; |
222 |
} |
223 |
|
224 |
/** Returns the number of translational degrees of freedom */ |
225 |
int getNdfTrans() { |
226 |
return ndfTrans_; |
227 |
} |
228 |
|
229 |
/** sets the current number of frozen degrees of freedom */ |
230 |
void setFdf(int fdf) { |
231 |
fdf_local = fdf; |
232 |
} |
233 |
|
234 |
int getFdf(); |
235 |
|
236 |
//getNZconstraint and setNZconstraint ruin the coherent of SimInfo class, need refactorying |
237 |
|
238 |
/** Returns the total number of z-constraint molecules in the system */ |
239 |
int getNZconstraint() { |
240 |
return nZconstraint_; |
241 |
} |
242 |
|
243 |
/** |
244 |
* Sets the number of z-constraint molecules in the system. |
245 |
*/ |
246 |
void setNZconstraint(int nZconstraint) { |
247 |
nZconstraint_ = nZconstraint; |
248 |
} |
249 |
|
250 |
/** Returns the snapshot manager. */ |
251 |
SnapshotManager* getSnapshotManager() { |
252 |
return sman_; |
253 |
} |
254 |
|
255 |
/** Sets the snapshot manager. */ |
256 |
void setSnapshotManager(SnapshotManager* sman); |
257 |
|
258 |
/** Returns the force field */ |
259 |
ForceField* getForceField() { |
260 |
return forceField_; |
261 |
} |
262 |
|
263 |
Globals* getSimParams() { |
264 |
return simParams_; |
265 |
} |
266 |
|
267 |
/** Returns the velocity of center of mass of the whole system.*/ |
268 |
Vector3d getComVel(); |
269 |
|
270 |
/** Returns the center of the mass of the whole system.*/ |
271 |
Vector3d getCom(); |
272 |
/** Returns the center of the mass and Center of Mass velocity of the whole system.*/ |
273 |
void getComAll(Vector3d& com,Vector3d& comVel); |
274 |
|
275 |
/** Returns intertia tensor for the entire system and system Angular Momentum.*/ |
276 |
void getInertiaTensor(Mat3x3d &intertiaTensor,Vector3d &angularMomentum); |
277 |
|
278 |
/** Returns system angular momentum */ |
279 |
Vector3d getAngularMomentum(); |
280 |
|
281 |
/** Returns volume of system as estimated by an ellipsoid defined by the radii of gyration*/ |
282 |
void getGyrationalVolume(RealType &vol); |
283 |
/** Overloaded version of gyrational volume that also returns det(I) so dV/dr can be calculated*/ |
284 |
void getGyrationalVolume(RealType &vol, RealType &detI); |
285 |
/** main driver function to interact with fortran during the initialization and molecule migration */ |
286 |
void update(); |
287 |
|
288 |
/** Returns the local index manager */ |
289 |
LocalIndexManager* getLocalIndexManager() { |
290 |
return &localIndexMan_; |
291 |
} |
292 |
|
293 |
int getMoleculeStampId(int globalIndex) { |
294 |
//assert(globalIndex < molStampIds_.size()) |
295 |
return molStampIds_[globalIndex]; |
296 |
} |
297 |
|
298 |
/** Returns the molecule stamp */ |
299 |
MoleculeStamp* getMoleculeStamp(int id) { |
300 |
return moleculeStamps_[id]; |
301 |
} |
302 |
|
303 |
/** Return the total number of the molecule stamps */ |
304 |
int getNMoleculeStamp() { |
305 |
return moleculeStamps_.size(); |
306 |
} |
307 |
/** |
308 |
* Finds a molecule with a specified global index |
309 |
* @return a pointer point to found molecule |
310 |
* @param index |
311 |
*/ |
312 |
Molecule* getMoleculeByGlobalIndex(int index) { |
313 |
MoleculeIterator i; |
314 |
i = molecules_.find(index); |
315 |
|
316 |
return i != molecules_.end() ? i->second : NULL; |
317 |
} |
318 |
|
319 |
int getGlobalMolMembership(int id){ |
320 |
return globalMolMembership_[id]; |
321 |
} |
322 |
|
323 |
RealType getRcut() { |
324 |
return rcut_; |
325 |
} |
326 |
|
327 |
RealType getRsw() { |
328 |
return rsw_; |
329 |
} |
330 |
|
331 |
RealType getList() { |
332 |
return rlist_; |
333 |
} |
334 |
|
335 |
std::string getFinalConfigFileName() { |
336 |
return finalConfigFileName_; |
337 |
} |
338 |
|
339 |
void setFinalConfigFileName(const std::string& fileName) { |
340 |
finalConfigFileName_ = fileName; |
341 |
} |
342 |
|
343 |
std::string getRawMetaData() { |
344 |
return rawMetaData_; |
345 |
} |
346 |
void setRawMetaData(const std::string& rawMetaData) { |
347 |
rawMetaData_ = rawMetaData; |
348 |
} |
349 |
|
350 |
std::string getDumpFileName() { |
351 |
return dumpFileName_; |
352 |
} |
353 |
|
354 |
void setDumpFileName(const std::string& fileName) { |
355 |
dumpFileName_ = fileName; |
356 |
} |
357 |
|
358 |
std::string getStatFileName() { |
359 |
return statFileName_; |
360 |
} |
361 |
|
362 |
void setStatFileName(const std::string& fileName) { |
363 |
statFileName_ = fileName; |
364 |
} |
365 |
|
366 |
std::string getRestFileName() { |
367 |
return restFileName_; |
368 |
} |
369 |
|
370 |
void setRestFileName(const std::string& fileName) { |
371 |
restFileName_ = fileName; |
372 |
} |
373 |
|
374 |
/** |
375 |
* Sets GlobalGroupMembership |
376 |
* @see #SimCreator::setGlobalIndex |
377 |
*/ |
378 |
void setGlobalGroupMembership(const std::vector<int>& globalGroupMembership) { |
379 |
assert(globalGroupMembership.size() == static_cast<size_t>(nGlobalAtoms_)); |
380 |
globalGroupMembership_ = globalGroupMembership; |
381 |
} |
382 |
|
383 |
/** |
384 |
* Sets GlobalMolMembership |
385 |
* @see #SimCreator::setGlobalIndex |
386 |
*/ |
387 |
void setGlobalMolMembership(const std::vector<int>& globalMolMembership) { |
388 |
assert(globalMolMembership.size() == static_cast<size_t>(nGlobalAtoms_)); |
389 |
globalMolMembership_ = globalMolMembership; |
390 |
} |
391 |
|
392 |
|
393 |
bool isFortranInitialized() { |
394 |
return fortranInitialized_; |
395 |
} |
396 |
|
397 |
bool getCalcBoxDipole() { |
398 |
return calcBoxDipole_; |
399 |
} |
400 |
|
401 |
bool getUseAtomicVirial() { |
402 |
return useAtomicVirial_; |
403 |
} |
404 |
|
405 |
//below functions are just forward functions |
406 |
//To compose or to inherit is always a hot debate. In general, is-a relation need subclassing, in the |
407 |
//the other hand, has-a relation need composing. |
408 |
/** |
409 |
* Adds property into property map |
410 |
* @param genData GenericData to be added into PropertyMap |
411 |
*/ |
412 |
void addProperty(GenericData* genData); |
413 |
|
414 |
/** |
415 |
* Removes property from PropertyMap by name |
416 |
* @param propName the name of property to be removed |
417 |
*/ |
418 |
void removeProperty(const std::string& propName); |
419 |
|
420 |
/** |
421 |
* clear all of the properties |
422 |
*/ |
423 |
void clearProperties(); |
424 |
|
425 |
/** |
426 |
* Returns all names of properties |
427 |
* @return all names of properties |
428 |
*/ |
429 |
std::vector<std::string> getPropertyNames(); |
430 |
|
431 |
/** |
432 |
* Returns all of the properties in PropertyMap |
433 |
* @return all of the properties in PropertyMap |
434 |
*/ |
435 |
std::vector<GenericData*> getProperties(); |
436 |
|
437 |
/** |
438 |
* Returns property |
439 |
* @param propName name of property |
440 |
* @return a pointer point to property with propName. If no property named propName |
441 |
* exists, return NULL |
442 |
*/ |
443 |
GenericData* getPropertyByName(const std::string& propName); |
444 |
|
445 |
/** |
446 |
* add all special interaction pairs (including excluded |
447 |
* interactions) in a molecule into the appropriate lists. |
448 |
*/ |
449 |
void addInteractionPairs(Molecule* mol); |
450 |
|
451 |
/** |
452 |
* remove all special interaction pairs which belong to a molecule |
453 |
* from the appropriate lists. |
454 |
*/ |
455 |
void removeInteractionPairs(Molecule* mol); |
456 |
|
457 |
|
458 |
/** Returns the unique atom types of local processor in an array */ |
459 |
std::set<AtomType*> getUniqueAtomTypes(); |
460 |
|
461 |
friend std::ostream& operator <<(std::ostream& o, SimInfo& info); |
462 |
|
463 |
void getCutoff(RealType& rcut, RealType& rsw); |
464 |
|
465 |
private: |
466 |
|
467 |
/** fill up the simtype struct*/ |
468 |
void setupSimType(); |
469 |
|
470 |
/** |
471 |
* Setup Fortran Simulation |
472 |
* @see #setupFortranParallel |
473 |
*/ |
474 |
void setupFortranSim(); |
475 |
|
476 |
/** Figure out the radius of cutoff, radius of switching function and pass them to fortran */ |
477 |
void setupCutoff(); |
478 |
|
479 |
/** Figure out which coulombic correction method to use and pass to fortran */ |
480 |
void setupElectrostaticSummationMethod( int isError ); |
481 |
|
482 |
/** Figure out which polynomial type to use for the switching function */ |
483 |
void setupSwitchingFunction(); |
484 |
|
485 |
/** Determine if we need to accumulate the simulation box dipole */ |
486 |
void setupAccumulateBoxDipole(); |
487 |
|
488 |
/** Calculates the number of degress of freedom in the whole system */ |
489 |
void calcNdf(); |
490 |
void calcNdfRaw(); |
491 |
void calcNdfTrans(); |
492 |
|
493 |
ForceField* forceField_; |
494 |
Globals* simParams_; |
495 |
|
496 |
std::map<int, Molecule*> molecules_; /**< Molecule array */ |
497 |
|
498 |
/** |
499 |
* Adds molecule stamp and the total number of the molecule with same molecule stamp in the whole |
500 |
* system. |
501 |
*/ |
502 |
void addMoleculeStamp(MoleculeStamp* molStamp, int nmol); |
503 |
|
504 |
//degress of freedom |
505 |
int ndf_; /**< number of degress of freedom (excludes constraints), ndf_ is local */ |
506 |
int fdf_local; /**< number of frozen degrees of freedom */ |
507 |
int fdf_; /**< number of frozen degrees of freedom */ |
508 |
int ndfRaw_; /**< number of degress of freedom (includes constraints), ndfRaw_ is local */ |
509 |
int ndfTrans_; /**< number of translation degress of freedom, ndfTrans_ is local */ |
510 |
int nZconstraint_; /** number of z-constraint molecules, nZconstraint_ is global */ |
511 |
|
512 |
//number of global objects |
513 |
int nGlobalMols_; /**< number of molecules in the system */ |
514 |
int nGlobalAtoms_; /**< number of atoms in the system */ |
515 |
int nGlobalCutoffGroups_; /**< number of cutoff groups in this system */ |
516 |
int nGlobalIntegrableObjects_; /**< number of integrable objects in this system */ |
517 |
int nGlobalRigidBodies_; /**< number of rigid bodies in this system */ |
518 |
/** |
519 |
* the size of globalGroupMembership_ is nGlobalAtoms. Its index is global index of an atom, and the |
520 |
* corresponding content is the global index of cutoff group this atom belong to. |
521 |
* It is filled by SimCreator once and only once, since it never changed during the simulation. |
522 |
*/ |
523 |
std::vector<int> globalGroupMembership_; |
524 |
|
525 |
/** |
526 |
* the size of globalMolMembership_ is nGlobalAtoms. Its index is global index of an atom, and the |
527 |
* corresponding content is the global index of molecule this atom belong to. |
528 |
* It is filled by SimCreator once and only once, since it is never changed during the simulation. |
529 |
*/ |
530 |
std::vector<int> globalMolMembership_; |
531 |
|
532 |
|
533 |
std::vector<int> molStampIds_; /**< stamp id array of all molecules in the system */ |
534 |
std::vector<MoleculeStamp*> moleculeStamps_; /**< molecule stamps array */ |
535 |
|
536 |
//number of local objects |
537 |
int nAtoms_; /**< number of atoms in local processor */ |
538 |
int nBonds_; /**< number of bonds in local processor */ |
539 |
int nBends_; /**< number of bends in local processor */ |
540 |
int nTorsions_; /**< number of torsions in local processor */ |
541 |
int nInversions_; /**< number of inversions in local processor */ |
542 |
int nRigidBodies_; /**< number of rigid bodies in local processor */ |
543 |
int nIntegrableObjects_; /**< number of integrable objects in local processor */ |
544 |
int nCutoffGroups_; /**< number of cutoff groups in local processor */ |
545 |
int nConstraints_; /**< number of constraints in local processors */ |
546 |
|
547 |
simtype fInfo_; /**< A dual struct shared by c++/fortran which indicates the atom types in simulation*/ |
548 |
PairList excludedInteractions_; |
549 |
PairList oneTwoInteractions_; |
550 |
PairList oneThreeInteractions_; |
551 |
PairList oneFourInteractions_; |
552 |
PropertyMap properties_; /**< Generic Property */ |
553 |
SnapshotManager* sman_; /**< SnapshotManager */ |
554 |
|
555 |
/** |
556 |
* The reason to have a local index manager is that when molecule is migrating to other processors, |
557 |
* the atoms and the rigid-bodies will release their local indices to LocalIndexManager. Combining the |
558 |
* information of molecule migrating to current processor, Migrator class can query the LocalIndexManager |
559 |
* to make a efficient data moving plan. |
560 |
*/ |
561 |
LocalIndexManager localIndexMan_; |
562 |
|
563 |
// unparsed MetaData block for storing in Dump and EOR files: |
564 |
std::string rawMetaData_; |
565 |
|
566 |
//file names |
567 |
std::string finalConfigFileName_; |
568 |
std::string dumpFileName_; |
569 |
std::string statFileName_; |
570 |
std::string restFileName_; |
571 |
|
572 |
RealType rcut_; /**< cutoff radius*/ |
573 |
RealType rsw_; /**< radius of switching function*/ |
574 |
RealType rlist_; /**< neighbor list radius */ |
575 |
|
576 |
int ljsp_; /**< use shifted potential for LJ*/ |
577 |
int ljsf_; /**< use shifted force for LJ*/ |
578 |
|
579 |
bool fortranInitialized_; /** flag to indicate whether the fortran side is initialized */ |
580 |
|
581 |
bool calcBoxDipole_; /**< flag to indicate whether or not we calculate |
582 |
the simulation box dipole moment */ |
583 |
|
584 |
bool useAtomicVirial_; /**< flag to indicate whether or not we use |
585 |
Atomic Virials to calculate the pressure */ |
586 |
|
587 |
public: |
588 |
/** |
589 |
* return an integral objects by its global index. In MPI version, if the StuntDouble with specified |
590 |
* global index does not belong to local processor, a NULL will be return. |
591 |
*/ |
592 |
StuntDouble* getIOIndexToIntegrableObject(int index); |
593 |
void setIOIndexToIntegrableObject(const std::vector<StuntDouble*>& v); |
594 |
private: |
595 |
std::vector<StuntDouble*> IOIndexToIntegrableObject; |
596 |
//public: |
597 |
//void setStuntDoubleFromGlobalIndex(std::vector<StuntDouble*> v); |
598 |
/** |
599 |
* return a StuntDouble by its global index. In MPI version, if the StuntDouble with specified |
600 |
* global index does not belong to local processor, a NULL will be return. |
601 |
*/ |
602 |
//StuntDouble* getStuntDoubleFromGlobalIndex(int index); |
603 |
//private: |
604 |
//std::vector<StuntDouble*> sdByGlobalIndex_; |
605 |
|
606 |
//in Parallel version, we need MolToProc |
607 |
public: |
608 |
|
609 |
/** |
610 |
* Finds the processor where a molecule resides |
611 |
* @return the id of the processor which contains the molecule |
612 |
* @param globalIndex global Index of the molecule |
613 |
*/ |
614 |
int getMolToProc(int globalIndex) { |
615 |
//assert(globalIndex < molToProcMap_.size()); |
616 |
return molToProcMap_[globalIndex]; |
617 |
} |
618 |
|
619 |
/** |
620 |
* Set MolToProcMap array |
621 |
* @see #SimCreator::divideMolecules |
622 |
*/ |
623 |
void setMolToProcMap(const std::vector<int>& molToProcMap) { |
624 |
molToProcMap_ = molToProcMap; |
625 |
} |
626 |
|
627 |
private: |
628 |
|
629 |
void setupFortranParallel(); |
630 |
|
631 |
/** |
632 |
* The size of molToProcMap_ is equal to total number of molecules |
633 |
* in the system. It maps a molecule to the processor on which it |
634 |
* resides. it is filled by SimCreator once and only once. |
635 |
*/ |
636 |
std::vector<int> molToProcMap_; |
637 |
|
638 |
|
639 |
}; |
640 |
|
641 |
} //namespace OpenMD |
642 |
#endif //BRAINS_SIMMODEL_HPP |
643 |
|