1 |
gezelter |
246 |
/* |
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. Acknowledgement of the program authors must be made in any |
10 |
|
|
* publication of scientific results based in part on use of the |
11 |
|
|
* program. An acceptable form of acknowledgement is citation of |
12 |
|
|
* the article in which the program was described (Matthew |
13 |
|
|
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
|
|
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
|
|
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
|
|
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
|
|
* |
18 |
|
|
* 2. Redistributions of source code must retain the above copyright |
19 |
|
|
* notice, this list of conditions and the following disclaimer. |
20 |
|
|
* |
21 |
|
|
* 3. Redistributions in binary form must reproduce the above copyright |
22 |
|
|
* notice, this list of conditions and the following disclaimer in the |
23 |
|
|
* documentation and/or other materials provided with the |
24 |
|
|
* distribution. |
25 |
|
|
* |
26 |
|
|
* This software is provided "AS IS," without a warranty of any |
27 |
|
|
* kind. All express or implied conditions, representations and |
28 |
|
|
* warranties, including any implied warranty of merchantability, |
29 |
|
|
* fitness for a particular purpose or non-infringement, are hereby |
30 |
|
|
* excluded. The University of Notre Dame and its licensors shall not |
31 |
|
|
* be liable for any damages suffered by licensee as a result of |
32 |
|
|
* using, modifying or distributing the software or its |
33 |
|
|
* derivatives. In no event will the University of Notre Dame or its |
34 |
|
|
* licensors be liable for any lost revenue, profit or data, or for |
35 |
|
|
* direct, indirect, special, consequential, incidental or punitive |
36 |
|
|
* damages, however caused and regardless of the theory of liability, |
37 |
|
|
* arising out of the use of or inability to use software, even if the |
38 |
|
|
* University of Notre Dame has been advised of the possibility of |
39 |
|
|
* such damages. |
40 |
|
|
*/ |
41 |
|
|
|
42 |
|
|
/** |
43 |
|
|
* @file SimInfo.cpp |
44 |
|
|
* @author tlin |
45 |
|
|
* @date 11/02/2004 |
46 |
|
|
* @version 1.0 |
47 |
|
|
*/ |
48 |
gezelter |
2 |
|
49 |
gezelter |
246 |
#include <algorithm> |
50 |
|
|
#include <set> |
51 |
gezelter |
2 |
|
52 |
tim |
3 |
#include "brains/SimInfo.hpp" |
53 |
gezelter |
246 |
#include "math/Vector3.hpp" |
54 |
|
|
#include "primitives/Molecule.hpp" |
55 |
|
|
#include "UseTheForce/doForces_interface.h" |
56 |
|
|
#include "UseTheForce/notifyCutoffs_interface.h" |
57 |
|
|
#include "utils/MemoryUtils.hpp" |
58 |
tim |
3 |
#include "utils/simError.h" |
59 |
tim |
316 |
#include "selection/SelectionManager.hpp" |
60 |
gezelter |
2 |
|
61 |
gezelter |
246 |
#ifdef IS_MPI |
62 |
|
|
#include "UseTheForce/mpiComponentPlan.h" |
63 |
|
|
#include "UseTheForce/DarkSide/simParallel_interface.h" |
64 |
|
|
#endif |
65 |
gezelter |
2 |
|
66 |
gezelter |
246 |
namespace oopse { |
67 |
gezelter |
2 |
|
68 |
gezelter |
246 |
SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, |
69 |
|
|
ForceField* ff, Globals* simParams) : |
70 |
|
|
forceField_(ff), simParams_(simParams), |
71 |
|
|
ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), |
72 |
|
|
nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), |
73 |
|
|
nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), |
74 |
|
|
nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nRigidBodies_(0), |
75 |
|
|
nIntegrableObjects_(0), nCutoffGroups_(0), nConstraints_(0), |
76 |
tim |
292 |
sman_(NULL), fortranInitialized_(false), selectMan_(NULL) { |
77 |
gezelter |
2 |
|
78 |
gezelter |
246 |
|
79 |
|
|
std::vector<std::pair<MoleculeStamp*, int> >::iterator i; |
80 |
|
|
MoleculeStamp* molStamp; |
81 |
|
|
int nMolWithSameStamp; |
82 |
|
|
int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
83 |
|
|
int nGroups = 0; //total cutoff groups defined in meta-data file |
84 |
|
|
CutoffGroupStamp* cgStamp; |
85 |
|
|
RigidBodyStamp* rbStamp; |
86 |
|
|
int nRigidAtoms = 0; |
87 |
|
|
|
88 |
|
|
for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) { |
89 |
|
|
molStamp = i->first; |
90 |
|
|
nMolWithSameStamp = i->second; |
91 |
|
|
|
92 |
|
|
addMoleculeStamp(molStamp, nMolWithSameStamp); |
93 |
gezelter |
2 |
|
94 |
gezelter |
246 |
//calculate atoms in molecules |
95 |
|
|
nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp; |
96 |
gezelter |
2 |
|
97 |
|
|
|
98 |
gezelter |
246 |
//calculate atoms in cutoff groups |
99 |
|
|
int nAtomsInGroups = 0; |
100 |
|
|
int nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); |
101 |
|
|
|
102 |
|
|
for (int j=0; j < nCutoffGroupsInStamp; j++) { |
103 |
|
|
cgStamp = molStamp->getCutoffGroup(j); |
104 |
|
|
nAtomsInGroups += cgStamp->getNMembers(); |
105 |
|
|
} |
106 |
gezelter |
2 |
|
107 |
gezelter |
246 |
nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; |
108 |
|
|
nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp; |
109 |
gezelter |
2 |
|
110 |
gezelter |
246 |
//calculate atoms in rigid bodies |
111 |
|
|
int nAtomsInRigidBodies = 0; |
112 |
tim |
274 |
int nRigidBodiesInStamp = molStamp->getNRigidBodies(); |
113 |
gezelter |
246 |
|
114 |
|
|
for (int j=0; j < nRigidBodiesInStamp; j++) { |
115 |
|
|
rbStamp = molStamp->getRigidBody(j); |
116 |
|
|
nAtomsInRigidBodies += rbStamp->getNMembers(); |
117 |
|
|
} |
118 |
gezelter |
2 |
|
119 |
gezelter |
246 |
nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp; |
120 |
|
|
nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp; |
121 |
|
|
|
122 |
|
|
} |
123 |
chrisfen |
143 |
|
124 |
gezelter |
246 |
//every free atom (atom does not belong to cutoff groups) is a cutoff group |
125 |
|
|
//therefore the total number of cutoff groups in the system is equal to |
126 |
|
|
//the total number of atoms minus number of atoms belong to cutoff group defined in meta-data |
127 |
|
|
//file plus the number of cutoff groups defined in meta-data file |
128 |
|
|
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
129 |
gezelter |
2 |
|
130 |
gezelter |
246 |
//every free atom (atom does not belong to rigid bodies) is an integrable object |
131 |
|
|
//therefore the total number of integrable objects in the system is equal to |
132 |
|
|
//the total number of atoms minus number of atoms belong to rigid body defined in meta-data |
133 |
|
|
//file plus the number of rigid bodies defined in meta-data file |
134 |
|
|
nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms + nGlobalRigidBodies_; |
135 |
gezelter |
2 |
|
136 |
gezelter |
246 |
nGlobalMols_ = molStampIds_.size(); |
137 |
gezelter |
2 |
|
138 |
gezelter |
246 |
#ifdef IS_MPI |
139 |
|
|
molToProcMap_.resize(nGlobalMols_); |
140 |
|
|
#endif |
141 |
tim |
292 |
|
142 |
tim |
316 |
selectMan_ = new SelectionManager(this); |
143 |
tim |
292 |
selectMan_->selectAll(); |
144 |
gezelter |
246 |
} |
145 |
gezelter |
2 |
|
146 |
gezelter |
246 |
SimInfo::~SimInfo() { |
147 |
tim |
398 |
std::map<int, Molecule*>::iterator i; |
148 |
|
|
for (i = molecules_.begin(); i != molecules_.end(); ++i) { |
149 |
|
|
delete i->second; |
150 |
|
|
} |
151 |
|
|
molecules_.clear(); |
152 |
gezelter |
246 |
|
153 |
tim |
398 |
MemoryUtils::deletePointers(moleculeStamps_); |
154 |
|
|
|
155 |
gezelter |
246 |
delete sman_; |
156 |
|
|
delete simParams_; |
157 |
|
|
delete forceField_; |
158 |
tim |
292 |
delete selectMan_; |
159 |
gezelter |
2 |
} |
160 |
|
|
|
161 |
gezelter |
246 |
int SimInfo::getNGlobalConstraints() { |
162 |
|
|
int nGlobalConstraints; |
163 |
|
|
#ifdef IS_MPI |
164 |
|
|
MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, |
165 |
|
|
MPI_COMM_WORLD); |
166 |
|
|
#else |
167 |
|
|
nGlobalConstraints = nConstraints_; |
168 |
|
|
#endif |
169 |
|
|
return nGlobalConstraints; |
170 |
|
|
} |
171 |
gezelter |
2 |
|
172 |
gezelter |
246 |
bool SimInfo::addMolecule(Molecule* mol) { |
173 |
|
|
MoleculeIterator i; |
174 |
gezelter |
2 |
|
175 |
gezelter |
246 |
i = molecules_.find(mol->getGlobalIndex()); |
176 |
|
|
if (i == molecules_.end() ) { |
177 |
gezelter |
2 |
|
178 |
gezelter |
246 |
molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol)); |
179 |
|
|
|
180 |
|
|
nAtoms_ += mol->getNAtoms(); |
181 |
|
|
nBonds_ += mol->getNBonds(); |
182 |
|
|
nBends_ += mol->getNBends(); |
183 |
|
|
nTorsions_ += mol->getNTorsions(); |
184 |
|
|
nRigidBodies_ += mol->getNRigidBodies(); |
185 |
|
|
nIntegrableObjects_ += mol->getNIntegrableObjects(); |
186 |
|
|
nCutoffGroups_ += mol->getNCutoffGroups(); |
187 |
|
|
nConstraints_ += mol->getNConstraintPairs(); |
188 |
gezelter |
2 |
|
189 |
gezelter |
246 |
addExcludePairs(mol); |
190 |
|
|
|
191 |
|
|
return true; |
192 |
|
|
} else { |
193 |
|
|
return false; |
194 |
|
|
} |
195 |
gezelter |
2 |
} |
196 |
|
|
|
197 |
gezelter |
246 |
bool SimInfo::removeMolecule(Molecule* mol) { |
198 |
|
|
MoleculeIterator i; |
199 |
|
|
i = molecules_.find(mol->getGlobalIndex()); |
200 |
gezelter |
2 |
|
201 |
gezelter |
246 |
if (i != molecules_.end() ) { |
202 |
gezelter |
2 |
|
203 |
gezelter |
246 |
assert(mol == i->second); |
204 |
|
|
|
205 |
|
|
nAtoms_ -= mol->getNAtoms(); |
206 |
|
|
nBonds_ -= mol->getNBonds(); |
207 |
|
|
nBends_ -= mol->getNBends(); |
208 |
|
|
nTorsions_ -= mol->getNTorsions(); |
209 |
|
|
nRigidBodies_ -= mol->getNRigidBodies(); |
210 |
|
|
nIntegrableObjects_ -= mol->getNIntegrableObjects(); |
211 |
|
|
nCutoffGroups_ -= mol->getNCutoffGroups(); |
212 |
|
|
nConstraints_ -= mol->getNConstraintPairs(); |
213 |
gezelter |
2 |
|
214 |
gezelter |
246 |
removeExcludePairs(mol); |
215 |
|
|
molecules_.erase(mol->getGlobalIndex()); |
216 |
gezelter |
2 |
|
217 |
gezelter |
246 |
delete mol; |
218 |
|
|
|
219 |
|
|
return true; |
220 |
|
|
} else { |
221 |
|
|
return false; |
222 |
|
|
} |
223 |
|
|
|
224 |
|
|
|
225 |
|
|
} |
226 |
|
|
|
227 |
|
|
|
228 |
|
|
Molecule* SimInfo::beginMolecule(MoleculeIterator& i) { |
229 |
|
|
i = molecules_.begin(); |
230 |
|
|
return i == molecules_.end() ? NULL : i->second; |
231 |
|
|
} |
232 |
|
|
|
233 |
|
|
Molecule* SimInfo::nextMolecule(MoleculeIterator& i) { |
234 |
|
|
++i; |
235 |
|
|
return i == molecules_.end() ? NULL : i->second; |
236 |
gezelter |
2 |
} |
237 |
|
|
|
238 |
|
|
|
239 |
gezelter |
246 |
void SimInfo::calcNdf() { |
240 |
|
|
int ndf_local; |
241 |
|
|
MoleculeIterator i; |
242 |
|
|
std::vector<StuntDouble*>::iterator j; |
243 |
|
|
Molecule* mol; |
244 |
|
|
StuntDouble* integrableObject; |
245 |
gezelter |
2 |
|
246 |
gezelter |
246 |
ndf_local = 0; |
247 |
|
|
|
248 |
|
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
249 |
|
|
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
250 |
|
|
integrableObject = mol->nextIntegrableObject(j)) { |
251 |
gezelter |
2 |
|
252 |
gezelter |
246 |
ndf_local += 3; |
253 |
gezelter |
2 |
|
254 |
gezelter |
246 |
if (integrableObject->isDirectional()) { |
255 |
|
|
if (integrableObject->isLinear()) { |
256 |
|
|
ndf_local += 2; |
257 |
|
|
} else { |
258 |
|
|
ndf_local += 3; |
259 |
|
|
} |
260 |
|
|
} |
261 |
|
|
|
262 |
|
|
}//end for (integrableObject) |
263 |
|
|
}// end for (mol) |
264 |
|
|
|
265 |
|
|
// n_constraints is local, so subtract them on each processor |
266 |
|
|
ndf_local -= nConstraints_; |
267 |
|
|
|
268 |
|
|
#ifdef IS_MPI |
269 |
|
|
MPI_Allreduce(&ndf_local,&ndf_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); |
270 |
|
|
#else |
271 |
|
|
ndf_ = ndf_local; |
272 |
|
|
#endif |
273 |
|
|
|
274 |
|
|
// nZconstraints_ is global, as are the 3 COM translations for the |
275 |
|
|
// entire system: |
276 |
|
|
ndf_ = ndf_ - 3 - nZconstraint_; |
277 |
|
|
|
278 |
gezelter |
2 |
} |
279 |
|
|
|
280 |
gezelter |
246 |
void SimInfo::calcNdfRaw() { |
281 |
|
|
int ndfRaw_local; |
282 |
gezelter |
2 |
|
283 |
gezelter |
246 |
MoleculeIterator i; |
284 |
|
|
std::vector<StuntDouble*>::iterator j; |
285 |
|
|
Molecule* mol; |
286 |
|
|
StuntDouble* integrableObject; |
287 |
|
|
|
288 |
|
|
// Raw degrees of freedom that we have to set |
289 |
|
|
ndfRaw_local = 0; |
290 |
|
|
|
291 |
|
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
292 |
|
|
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
293 |
|
|
integrableObject = mol->nextIntegrableObject(j)) { |
294 |
|
|
|
295 |
|
|
ndfRaw_local += 3; |
296 |
|
|
|
297 |
|
|
if (integrableObject->isDirectional()) { |
298 |
|
|
if (integrableObject->isLinear()) { |
299 |
|
|
ndfRaw_local += 2; |
300 |
|
|
} else { |
301 |
|
|
ndfRaw_local += 3; |
302 |
|
|
} |
303 |
|
|
} |
304 |
|
|
|
305 |
|
|
} |
306 |
|
|
} |
307 |
|
|
|
308 |
|
|
#ifdef IS_MPI |
309 |
|
|
MPI_Allreduce(&ndfRaw_local,&ndfRaw_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); |
310 |
|
|
#else |
311 |
|
|
ndfRaw_ = ndfRaw_local; |
312 |
|
|
#endif |
313 |
gezelter |
2 |
} |
314 |
|
|
|
315 |
gezelter |
246 |
void SimInfo::calcNdfTrans() { |
316 |
|
|
int ndfTrans_local; |
317 |
gezelter |
2 |
|
318 |
gezelter |
246 |
ndfTrans_local = 3 * nIntegrableObjects_ - nConstraints_; |
319 |
gezelter |
2 |
|
320 |
|
|
|
321 |
gezelter |
246 |
#ifdef IS_MPI |
322 |
|
|
MPI_Allreduce(&ndfTrans_local,&ndfTrans_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); |
323 |
|
|
#else |
324 |
|
|
ndfTrans_ = ndfTrans_local; |
325 |
|
|
#endif |
326 |
gezelter |
2 |
|
327 |
gezelter |
246 |
ndfTrans_ = ndfTrans_ - 3 - nZconstraint_; |
328 |
|
|
|
329 |
gezelter |
2 |
} |
330 |
|
|
|
331 |
gezelter |
246 |
void SimInfo::addExcludePairs(Molecule* mol) { |
332 |
|
|
std::vector<Bond*>::iterator bondIter; |
333 |
|
|
std::vector<Bend*>::iterator bendIter; |
334 |
|
|
std::vector<Torsion*>::iterator torsionIter; |
335 |
|
|
Bond* bond; |
336 |
|
|
Bend* bend; |
337 |
|
|
Torsion* torsion; |
338 |
|
|
int a; |
339 |
|
|
int b; |
340 |
|
|
int c; |
341 |
|
|
int d; |
342 |
|
|
|
343 |
|
|
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
344 |
|
|
a = bond->getAtomA()->getGlobalIndex(); |
345 |
|
|
b = bond->getAtomB()->getGlobalIndex(); |
346 |
|
|
exclude_.addPair(a, b); |
347 |
|
|
} |
348 |
gezelter |
2 |
|
349 |
gezelter |
246 |
for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { |
350 |
|
|
a = bend->getAtomA()->getGlobalIndex(); |
351 |
|
|
b = bend->getAtomB()->getGlobalIndex(); |
352 |
|
|
c = bend->getAtomC()->getGlobalIndex(); |
353 |
gezelter |
2 |
|
354 |
gezelter |
246 |
exclude_.addPair(a, b); |
355 |
|
|
exclude_.addPair(a, c); |
356 |
|
|
exclude_.addPair(b, c); |
357 |
|
|
} |
358 |
gezelter |
2 |
|
359 |
gezelter |
246 |
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
360 |
|
|
a = torsion->getAtomA()->getGlobalIndex(); |
361 |
|
|
b = torsion->getAtomB()->getGlobalIndex(); |
362 |
|
|
c = torsion->getAtomC()->getGlobalIndex(); |
363 |
|
|
d = torsion->getAtomD()->getGlobalIndex(); |
364 |
gezelter |
2 |
|
365 |
gezelter |
246 |
exclude_.addPair(a, b); |
366 |
|
|
exclude_.addPair(a, c); |
367 |
|
|
exclude_.addPair(a, d); |
368 |
|
|
exclude_.addPair(b, c); |
369 |
|
|
exclude_.addPair(b, d); |
370 |
|
|
exclude_.addPair(c, d); |
371 |
gezelter |
2 |
} |
372 |
|
|
|
373 |
|
|
|
374 |
gezelter |
246 |
} |
375 |
|
|
|
376 |
|
|
void SimInfo::removeExcludePairs(Molecule* mol) { |
377 |
|
|
std::vector<Bond*>::iterator bondIter; |
378 |
|
|
std::vector<Bend*>::iterator bendIter; |
379 |
|
|
std::vector<Torsion*>::iterator torsionIter; |
380 |
|
|
Bond* bond; |
381 |
|
|
Bend* bend; |
382 |
|
|
Torsion* torsion; |
383 |
|
|
int a; |
384 |
|
|
int b; |
385 |
|
|
int c; |
386 |
|
|
int d; |
387 |
|
|
|
388 |
|
|
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
389 |
|
|
a = bond->getAtomA()->getGlobalIndex(); |
390 |
|
|
b = bond->getAtomB()->getGlobalIndex(); |
391 |
|
|
exclude_.removePair(a, b); |
392 |
gezelter |
2 |
} |
393 |
gezelter |
246 |
|
394 |
|
|
for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { |
395 |
|
|
a = bend->getAtomA()->getGlobalIndex(); |
396 |
|
|
b = bend->getAtomB()->getGlobalIndex(); |
397 |
|
|
c = bend->getAtomC()->getGlobalIndex(); |
398 |
|
|
|
399 |
|
|
exclude_.removePair(a, b); |
400 |
|
|
exclude_.removePair(a, c); |
401 |
|
|
exclude_.removePair(b, c); |
402 |
gezelter |
2 |
} |
403 |
gezelter |
246 |
|
404 |
|
|
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
405 |
|
|
a = torsion->getAtomA()->getGlobalIndex(); |
406 |
|
|
b = torsion->getAtomB()->getGlobalIndex(); |
407 |
|
|
c = torsion->getAtomC()->getGlobalIndex(); |
408 |
|
|
d = torsion->getAtomD()->getGlobalIndex(); |
409 |
|
|
|
410 |
|
|
exclude_.removePair(a, b); |
411 |
|
|
exclude_.removePair(a, c); |
412 |
|
|
exclude_.removePair(a, d); |
413 |
|
|
exclude_.removePair(b, c); |
414 |
|
|
exclude_.removePair(b, d); |
415 |
|
|
exclude_.removePair(c, d); |
416 |
|
|
} |
417 |
|
|
|
418 |
gezelter |
2 |
} |
419 |
|
|
|
420 |
|
|
|
421 |
gezelter |
246 |
void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) { |
422 |
|
|
int curStampId; |
423 |
gezelter |
2 |
|
424 |
gezelter |
246 |
//index from 0 |
425 |
|
|
curStampId = moleculeStamps_.size(); |
426 |
gezelter |
2 |
|
427 |
gezelter |
246 |
moleculeStamps_.push_back(molStamp); |
428 |
|
|
molStampIds_.insert(molStampIds_.end(), nmol, curStampId); |
429 |
|
|
} |
430 |
gezelter |
2 |
|
431 |
gezelter |
246 |
void SimInfo::update() { |
432 |
gezelter |
2 |
|
433 |
gezelter |
246 |
setupSimType(); |
434 |
gezelter |
2 |
|
435 |
gezelter |
246 |
#ifdef IS_MPI |
436 |
|
|
setupFortranParallel(); |
437 |
|
|
#endif |
438 |
gezelter |
2 |
|
439 |
gezelter |
246 |
setupFortranSim(); |
440 |
gezelter |
2 |
|
441 |
gezelter |
246 |
//setup fortran force field |
442 |
|
|
/** @deprecate */ |
443 |
|
|
int isError = 0; |
444 |
|
|
initFortranFF( &fInfo_.SIM_uses_RF , &isError ); |
445 |
|
|
if(isError){ |
446 |
|
|
sprintf( painCave.errMsg, |
447 |
|
|
"ForceField error: There was an error initializing the forceField in fortran.\n" ); |
448 |
|
|
painCave.isFatal = 1; |
449 |
|
|
simError(); |
450 |
|
|
} |
451 |
gezelter |
2 |
|
452 |
gezelter |
246 |
|
453 |
|
|
setupCutoff(); |
454 |
gezelter |
2 |
|
455 |
gezelter |
246 |
calcNdf(); |
456 |
|
|
calcNdfRaw(); |
457 |
|
|
calcNdfTrans(); |
458 |
|
|
|
459 |
|
|
fortranInitialized_ = true; |
460 |
gezelter |
2 |
} |
461 |
|
|
|
462 |
gezelter |
246 |
std::set<AtomType*> SimInfo::getUniqueAtomTypes() { |
463 |
|
|
SimInfo::MoleculeIterator mi; |
464 |
|
|
Molecule* mol; |
465 |
|
|
Molecule::AtomIterator ai; |
466 |
|
|
Atom* atom; |
467 |
|
|
std::set<AtomType*> atomTypes; |
468 |
gezelter |
2 |
|
469 |
gezelter |
246 |
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
470 |
gezelter |
2 |
|
471 |
gezelter |
246 |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
472 |
|
|
atomTypes.insert(atom->getAtomType()); |
473 |
|
|
} |
474 |
|
|
|
475 |
|
|
} |
476 |
gezelter |
2 |
|
477 |
gezelter |
246 |
return atomTypes; |
478 |
|
|
} |
479 |
gezelter |
2 |
|
480 |
gezelter |
246 |
void SimInfo::setupSimType() { |
481 |
|
|
std::set<AtomType*>::iterator i; |
482 |
|
|
std::set<AtomType*> atomTypes; |
483 |
|
|
atomTypes = getUniqueAtomTypes(); |
484 |
gezelter |
2 |
|
485 |
gezelter |
246 |
int useLennardJones = 0; |
486 |
|
|
int useElectrostatic = 0; |
487 |
|
|
int useEAM = 0; |
488 |
|
|
int useCharge = 0; |
489 |
|
|
int useDirectional = 0; |
490 |
|
|
int useDipole = 0; |
491 |
|
|
int useGayBerne = 0; |
492 |
|
|
int useSticky = 0; |
493 |
|
|
int useShape = 0; |
494 |
|
|
int useFLARB = 0; //it is not in AtomType yet |
495 |
|
|
int useDirectionalAtom = 0; |
496 |
|
|
int useElectrostatics = 0; |
497 |
|
|
//usePBC and useRF are from simParams |
498 |
|
|
int usePBC = simParams_->getPBC(); |
499 |
|
|
int useRF = simParams_->getUseRF(); |
500 |
gezelter |
2 |
|
501 |
gezelter |
246 |
//loop over all of the atom types |
502 |
|
|
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
503 |
|
|
useLennardJones |= (*i)->isLennardJones(); |
504 |
|
|
useElectrostatic |= (*i)->isElectrostatic(); |
505 |
|
|
useEAM |= (*i)->isEAM(); |
506 |
|
|
useCharge |= (*i)->isCharge(); |
507 |
|
|
useDirectional |= (*i)->isDirectional(); |
508 |
|
|
useDipole |= (*i)->isDipole(); |
509 |
|
|
useGayBerne |= (*i)->isGayBerne(); |
510 |
|
|
useSticky |= (*i)->isSticky(); |
511 |
|
|
useShape |= (*i)->isShape(); |
512 |
|
|
} |
513 |
gezelter |
2 |
|
514 |
gezelter |
246 |
if (useSticky || useDipole || useGayBerne || useShape) { |
515 |
|
|
useDirectionalAtom = 1; |
516 |
|
|
} |
517 |
gezelter |
2 |
|
518 |
gezelter |
246 |
if (useCharge || useDipole) { |
519 |
|
|
useElectrostatics = 1; |
520 |
|
|
} |
521 |
gezelter |
2 |
|
522 |
gezelter |
246 |
#ifdef IS_MPI |
523 |
|
|
int temp; |
524 |
gezelter |
2 |
|
525 |
gezelter |
246 |
temp = usePBC; |
526 |
|
|
MPI_Allreduce(&temp, &usePBC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
527 |
gezelter |
2 |
|
528 |
gezelter |
246 |
temp = useDirectionalAtom; |
529 |
|
|
MPI_Allreduce(&temp, &useDirectionalAtom, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
530 |
gezelter |
2 |
|
531 |
gezelter |
246 |
temp = useLennardJones; |
532 |
|
|
MPI_Allreduce(&temp, &useLennardJones, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
533 |
gezelter |
2 |
|
534 |
gezelter |
246 |
temp = useElectrostatics; |
535 |
|
|
MPI_Allreduce(&temp, &useElectrostatics, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
536 |
gezelter |
2 |
|
537 |
gezelter |
246 |
temp = useCharge; |
538 |
|
|
MPI_Allreduce(&temp, &useCharge, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
539 |
gezelter |
2 |
|
540 |
gezelter |
246 |
temp = useDipole; |
541 |
|
|
MPI_Allreduce(&temp, &useDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
542 |
gezelter |
2 |
|
543 |
gezelter |
246 |
temp = useSticky; |
544 |
|
|
MPI_Allreduce(&temp, &useSticky, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
545 |
gezelter |
2 |
|
546 |
gezelter |
246 |
temp = useGayBerne; |
547 |
|
|
MPI_Allreduce(&temp, &useGayBerne, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
548 |
gezelter |
2 |
|
549 |
gezelter |
246 |
temp = useEAM; |
550 |
|
|
MPI_Allreduce(&temp, &useEAM, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
551 |
gezelter |
2 |
|
552 |
gezelter |
246 |
temp = useShape; |
553 |
|
|
MPI_Allreduce(&temp, &useShape, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
554 |
|
|
|
555 |
|
|
temp = useFLARB; |
556 |
|
|
MPI_Allreduce(&temp, &useFLARB, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
557 |
|
|
|
558 |
|
|
temp = useRF; |
559 |
|
|
MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
560 |
|
|
|
561 |
gezelter |
2 |
#endif |
562 |
|
|
|
563 |
gezelter |
246 |
fInfo_.SIM_uses_PBC = usePBC; |
564 |
|
|
fInfo_.SIM_uses_DirectionalAtoms = useDirectionalAtom; |
565 |
|
|
fInfo_.SIM_uses_LennardJones = useLennardJones; |
566 |
|
|
fInfo_.SIM_uses_Electrostatics = useElectrostatics; |
567 |
|
|
fInfo_.SIM_uses_Charges = useCharge; |
568 |
|
|
fInfo_.SIM_uses_Dipoles = useDipole; |
569 |
|
|
fInfo_.SIM_uses_Sticky = useSticky; |
570 |
|
|
fInfo_.SIM_uses_GayBerne = useGayBerne; |
571 |
|
|
fInfo_.SIM_uses_EAM = useEAM; |
572 |
|
|
fInfo_.SIM_uses_Shapes = useShape; |
573 |
|
|
fInfo_.SIM_uses_FLARB = useFLARB; |
574 |
|
|
fInfo_.SIM_uses_RF = useRF; |
575 |
gezelter |
2 |
|
576 |
gezelter |
246 |
if( fInfo_.SIM_uses_Dipoles && fInfo_.SIM_uses_RF) { |
577 |
gezelter |
2 |
|
578 |
gezelter |
246 |
if (simParams_->haveDielectric()) { |
579 |
|
|
fInfo_.dielect = simParams_->getDielectric(); |
580 |
|
|
} else { |
581 |
|
|
sprintf(painCave.errMsg, |
582 |
|
|
"SimSetup Error: No Dielectric constant was set.\n" |
583 |
|
|
"\tYou are trying to use Reaction Field without" |
584 |
|
|
"\tsetting a dielectric constant!\n"); |
585 |
|
|
painCave.isFatal = 1; |
586 |
|
|
simError(); |
587 |
|
|
} |
588 |
|
|
|
589 |
|
|
} else { |
590 |
|
|
fInfo_.dielect = 0.0; |
591 |
|
|
} |
592 |
|
|
|
593 |
gezelter |
2 |
} |
594 |
|
|
|
595 |
gezelter |
246 |
void SimInfo::setupFortranSim() { |
596 |
|
|
int isError; |
597 |
|
|
int nExclude; |
598 |
|
|
std::vector<int> fortranGlobalGroupMembership; |
599 |
|
|
|
600 |
|
|
nExclude = exclude_.getSize(); |
601 |
|
|
isError = 0; |
602 |
gezelter |
2 |
|
603 |
gezelter |
246 |
//globalGroupMembership_ is filled by SimCreator |
604 |
|
|
for (int i = 0; i < nGlobalAtoms_; i++) { |
605 |
|
|
fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); |
606 |
|
|
} |
607 |
gezelter |
2 |
|
608 |
gezelter |
246 |
//calculate mass ratio of cutoff group |
609 |
|
|
std::vector<double> mfact; |
610 |
|
|
SimInfo::MoleculeIterator mi; |
611 |
|
|
Molecule* mol; |
612 |
|
|
Molecule::CutoffGroupIterator ci; |
613 |
|
|
CutoffGroup* cg; |
614 |
|
|
Molecule::AtomIterator ai; |
615 |
|
|
Atom* atom; |
616 |
|
|
double totalMass; |
617 |
|
|
|
618 |
|
|
//to avoid memory reallocation, reserve enough space for mfact |
619 |
|
|
mfact.reserve(getNCutoffGroups()); |
620 |
gezelter |
2 |
|
621 |
gezelter |
246 |
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
622 |
|
|
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
623 |
gezelter |
2 |
|
624 |
gezelter |
246 |
totalMass = cg->getMass(); |
625 |
|
|
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
626 |
|
|
mfact.push_back(atom->getMass()/totalMass); |
627 |
|
|
} |
628 |
gezelter |
2 |
|
629 |
gezelter |
246 |
} |
630 |
|
|
} |
631 |
gezelter |
2 |
|
632 |
gezelter |
246 |
//fill ident array of local atoms (it is actually ident of AtomType, it is so confusing !!!) |
633 |
|
|
std::vector<int> identArray; |
634 |
gezelter |
2 |
|
635 |
gezelter |
246 |
//to avoid memory reallocation, reserve enough space identArray |
636 |
|
|
identArray.reserve(getNAtoms()); |
637 |
|
|
|
638 |
|
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
639 |
|
|
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
640 |
|
|
identArray.push_back(atom->getIdent()); |
641 |
|
|
} |
642 |
|
|
} |
643 |
gezelter |
2 |
|
644 |
gezelter |
246 |
//fill molMembershipArray |
645 |
|
|
//molMembershipArray is filled by SimCreator |
646 |
|
|
std::vector<int> molMembershipArray(nGlobalAtoms_); |
647 |
|
|
for (int i = 0; i < nGlobalAtoms_; i++) { |
648 |
|
|
molMembershipArray[i] = globalMolMembership_[i] + 1; |
649 |
|
|
} |
650 |
|
|
|
651 |
|
|
//setup fortran simulation |
652 |
|
|
//gloalExcludes and molMembershipArray should go away (They are never used) |
653 |
|
|
//why the hell fortran need to know molecule? |
654 |
|
|
//OOPSE = Object-Obfuscated Parallel Simulation Engine |
655 |
|
|
int nGlobalExcludes = 0; |
656 |
|
|
int* globalExcludes = NULL; |
657 |
|
|
int* excludeList = exclude_.getExcludeList(); |
658 |
|
|
setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], &nExclude, excludeList , |
659 |
|
|
&nGlobalExcludes, globalExcludes, &molMembershipArray[0], |
660 |
|
|
&mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); |
661 |
gezelter |
2 |
|
662 |
gezelter |
246 |
if( isError ){ |
663 |
gezelter |
2 |
|
664 |
gezelter |
246 |
sprintf( painCave.errMsg, |
665 |
|
|
"There was an error setting the simulation information in fortran.\n" ); |
666 |
|
|
painCave.isFatal = 1; |
667 |
|
|
painCave.severity = OOPSE_ERROR; |
668 |
|
|
simError(); |
669 |
|
|
} |
670 |
|
|
|
671 |
|
|
#ifdef IS_MPI |
672 |
|
|
sprintf( checkPointMsg, |
673 |
|
|
"succesfully sent the simulation information to fortran.\n"); |
674 |
|
|
MPIcheckPoint(); |
675 |
|
|
#endif // is_mpi |
676 |
gezelter |
2 |
} |
677 |
|
|
|
678 |
|
|
|
679 |
gezelter |
246 |
#ifdef IS_MPI |
680 |
|
|
void SimInfo::setupFortranParallel() { |
681 |
|
|
|
682 |
|
|
//SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex |
683 |
|
|
std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0); |
684 |
|
|
std::vector<int> localToGlobalCutoffGroupIndex; |
685 |
|
|
SimInfo::MoleculeIterator mi; |
686 |
|
|
Molecule::AtomIterator ai; |
687 |
|
|
Molecule::CutoffGroupIterator ci; |
688 |
|
|
Molecule* mol; |
689 |
|
|
Atom* atom; |
690 |
|
|
CutoffGroup* cg; |
691 |
|
|
mpiSimData parallelData; |
692 |
|
|
int isError; |
693 |
gezelter |
2 |
|
694 |
gezelter |
246 |
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
695 |
gezelter |
2 |
|
696 |
gezelter |
246 |
//local index(index in DataStorge) of atom is important |
697 |
|
|
for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
698 |
|
|
localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; |
699 |
|
|
} |
700 |
gezelter |
2 |
|
701 |
gezelter |
246 |
//local index of cutoff group is trivial, it only depends on the order of travesing |
702 |
|
|
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
703 |
|
|
localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); |
704 |
|
|
} |
705 |
|
|
|
706 |
|
|
} |
707 |
gezelter |
2 |
|
708 |
gezelter |
246 |
//fill up mpiSimData struct |
709 |
|
|
parallelData.nMolGlobal = getNGlobalMolecules(); |
710 |
|
|
parallelData.nMolLocal = getNMolecules(); |
711 |
|
|
parallelData.nAtomsGlobal = getNGlobalAtoms(); |
712 |
|
|
parallelData.nAtomsLocal = getNAtoms(); |
713 |
|
|
parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); |
714 |
|
|
parallelData.nGroupsLocal = getNCutoffGroups(); |
715 |
|
|
parallelData.myNode = worldRank; |
716 |
|
|
MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors)); |
717 |
gezelter |
2 |
|
718 |
gezelter |
246 |
//pass mpiSimData struct and index arrays to fortran |
719 |
|
|
setFsimParallel(¶llelData, &(parallelData.nAtomsLocal), |
720 |
|
|
&localToGlobalAtomIndex[0], &(parallelData.nGroupsLocal), |
721 |
|
|
&localToGlobalCutoffGroupIndex[0], &isError); |
722 |
gezelter |
2 |
|
723 |
gezelter |
246 |
if (isError) { |
724 |
|
|
sprintf(painCave.errMsg, |
725 |
|
|
"mpiRefresh errror: fortran didn't like something we gave it.\n"); |
726 |
|
|
painCave.isFatal = 1; |
727 |
|
|
simError(); |
728 |
|
|
} |
729 |
gezelter |
2 |
|
730 |
gezelter |
246 |
sprintf(checkPointMsg, " mpiRefresh successful.\n"); |
731 |
|
|
MPIcheckPoint(); |
732 |
gezelter |
2 |
|
733 |
|
|
|
734 |
gezelter |
246 |
} |
735 |
chrisfen |
143 |
|
736 |
gezelter |
246 |
#endif |
737 |
chrisfen |
143 |
|
738 |
gezelter |
246 |
double SimInfo::calcMaxCutoffRadius() { |
739 |
chrisfen |
143 |
|
740 |
|
|
|
741 |
gezelter |
246 |
std::set<AtomType*> atomTypes; |
742 |
|
|
std::set<AtomType*>::iterator i; |
743 |
|
|
std::vector<double> cutoffRadius; |
744 |
gezelter |
2 |
|
745 |
gezelter |
246 |
//get the unique atom types |
746 |
|
|
atomTypes = getUniqueAtomTypes(); |
747 |
|
|
|
748 |
|
|
//query the max cutoff radius among these atom types |
749 |
|
|
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
750 |
|
|
cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); |
751 |
|
|
} |
752 |
|
|
|
753 |
|
|
double maxCutoffRadius = *(std::max_element(cutoffRadius.begin(), cutoffRadius.end())); |
754 |
gezelter |
2 |
#ifdef IS_MPI |
755 |
gezelter |
246 |
//pick the max cutoff radius among the processors |
756 |
gezelter |
2 |
#endif |
757 |
|
|
|
758 |
gezelter |
246 |
return maxCutoffRadius; |
759 |
|
|
} |
760 |
|
|
|
761 |
tim |
326 |
void SimInfo::getCutoff(double& rcut, double& rsw) { |
762 |
gezelter |
2 |
|
763 |
gezelter |
246 |
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
764 |
|
|
|
765 |
|
|
if (!simParams_->haveRcut()){ |
766 |
|
|
sprintf(painCave.errMsg, |
767 |
|
|
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
768 |
|
|
"\tOOPSE will use a default value of 15.0 angstroms" |
769 |
|
|
"\tfor the cutoffRadius.\n"); |
770 |
|
|
painCave.isFatal = 0; |
771 |
|
|
simError(); |
772 |
tim |
328 |
rcut = 15.0; |
773 |
gezelter |
246 |
} else{ |
774 |
tim |
328 |
rcut = simParams_->getRcut(); |
775 |
gezelter |
246 |
} |
776 |
|
|
|
777 |
|
|
if (!simParams_->haveRsw()){ |
778 |
|
|
sprintf(painCave.errMsg, |
779 |
|
|
"SimCreator Warning: No value was set for switchingRadius.\n" |
780 |
|
|
"\tOOPSE will use a default value of\n" |
781 |
|
|
"\t0.95 * cutoffRadius for the switchingRadius\n"); |
782 |
|
|
painCave.isFatal = 0; |
783 |
|
|
simError(); |
784 |
tim |
328 |
rsw = 0.95 * rcut; |
785 |
gezelter |
246 |
} else{ |
786 |
tim |
328 |
rsw = simParams_->getRsw(); |
787 |
gezelter |
246 |
} |
788 |
|
|
|
789 |
|
|
} else { |
790 |
|
|
// if charge, dipole or reaction field is not used and the cutofff radius is not specified in |
791 |
|
|
//meta-data file, the maximum cutoff radius calculated from forcefiled will be used |
792 |
|
|
|
793 |
|
|
if (simParams_->haveRcut()) { |
794 |
tim |
328 |
rcut = simParams_->getRcut(); |
795 |
gezelter |
246 |
} else { |
796 |
|
|
//set cutoff radius to the maximum cutoff radius based on atom types in the whole system |
797 |
tim |
328 |
rcut = calcMaxCutoffRadius(); |
798 |
gezelter |
246 |
} |
799 |
|
|
|
800 |
|
|
if (simParams_->haveRsw()) { |
801 |
tim |
328 |
rsw = simParams_->getRsw(); |
802 |
gezelter |
246 |
} else { |
803 |
tim |
328 |
rsw = rcut; |
804 |
gezelter |
246 |
} |
805 |
|
|
|
806 |
|
|
} |
807 |
tim |
326 |
} |
808 |
|
|
|
809 |
|
|
void SimInfo::setupCutoff() { |
810 |
|
|
getCutoff(rcut_, rsw_); |
811 |
gezelter |
246 |
double rnblist = rcut_ + 1; // skin of neighbor list |
812 |
|
|
|
813 |
|
|
//Pass these cutoff radius etc. to fortran. This function should be called once and only once |
814 |
|
|
notifyFortranCutoffs(&rcut_, &rsw_, &rnblist); |
815 |
gezelter |
2 |
} |
816 |
|
|
|
817 |
gezelter |
246 |
void SimInfo::addProperty(GenericData* genData) { |
818 |
|
|
properties_.addProperty(genData); |
819 |
gezelter |
2 |
} |
820 |
|
|
|
821 |
gezelter |
246 |
void SimInfo::removeProperty(const std::string& propName) { |
822 |
|
|
properties_.removeProperty(propName); |
823 |
|
|
} |
824 |
gezelter |
2 |
|
825 |
gezelter |
246 |
void SimInfo::clearProperties() { |
826 |
|
|
properties_.clearProperties(); |
827 |
gezelter |
2 |
} |
828 |
|
|
|
829 |
gezelter |
246 |
std::vector<std::string> SimInfo::getPropertyNames() { |
830 |
|
|
return properties_.getPropertyNames(); |
831 |
|
|
} |
832 |
|
|
|
833 |
|
|
std::vector<GenericData*> SimInfo::getProperties() { |
834 |
|
|
return properties_.getProperties(); |
835 |
|
|
} |
836 |
gezelter |
2 |
|
837 |
gezelter |
246 |
GenericData* SimInfo::getPropertyByName(const std::string& propName) { |
838 |
|
|
return properties_.getPropertyByName(propName); |
839 |
gezelter |
2 |
} |
840 |
|
|
|
841 |
gezelter |
246 |
void SimInfo::setSnapshotManager(SnapshotManager* sman) { |
842 |
tim |
334 |
//if (sman_ == sman_) { |
843 |
|
|
// return; |
844 |
|
|
//} |
845 |
tim |
331 |
|
846 |
tim |
334 |
//delete sman_; |
847 |
gezelter |
246 |
sman_ = sman; |
848 |
gezelter |
2 |
|
849 |
gezelter |
246 |
Molecule* mol; |
850 |
|
|
RigidBody* rb; |
851 |
|
|
Atom* atom; |
852 |
|
|
SimInfo::MoleculeIterator mi; |
853 |
|
|
Molecule::RigidBodyIterator rbIter; |
854 |
|
|
Molecule::AtomIterator atomIter;; |
855 |
|
|
|
856 |
|
|
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
857 |
|
|
|
858 |
|
|
for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) { |
859 |
|
|
atom->setSnapshotManager(sman_); |
860 |
|
|
} |
861 |
|
|
|
862 |
|
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
863 |
|
|
rb->setSnapshotManager(sman_); |
864 |
|
|
} |
865 |
|
|
} |
866 |
gezelter |
2 |
|
867 |
gezelter |
246 |
} |
868 |
gezelter |
2 |
|
869 |
gezelter |
246 |
Vector3d SimInfo::getComVel(){ |
870 |
|
|
SimInfo::MoleculeIterator i; |
871 |
|
|
Molecule* mol; |
872 |
gezelter |
2 |
|
873 |
gezelter |
246 |
Vector3d comVel(0.0); |
874 |
|
|
double totalMass = 0.0; |
875 |
gezelter |
2 |
|
876 |
gezelter |
246 |
|
877 |
|
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
878 |
|
|
double mass = mol->getMass(); |
879 |
|
|
totalMass += mass; |
880 |
|
|
comVel += mass * mol->getComVel(); |
881 |
|
|
} |
882 |
gezelter |
2 |
|
883 |
gezelter |
246 |
#ifdef IS_MPI |
884 |
|
|
double tmpMass = totalMass; |
885 |
|
|
Vector3d tmpComVel(comVel); |
886 |
|
|
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
887 |
|
|
MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
888 |
|
|
#endif |
889 |
|
|
|
890 |
|
|
comVel /= totalMass; |
891 |
|
|
|
892 |
|
|
return comVel; |
893 |
gezelter |
2 |
} |
894 |
|
|
|
895 |
gezelter |
246 |
Vector3d SimInfo::getCom(){ |
896 |
|
|
SimInfo::MoleculeIterator i; |
897 |
|
|
Molecule* mol; |
898 |
gezelter |
2 |
|
899 |
gezelter |
246 |
Vector3d com(0.0); |
900 |
|
|
double totalMass = 0.0; |
901 |
|
|
|
902 |
|
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
903 |
|
|
double mass = mol->getMass(); |
904 |
|
|
totalMass += mass; |
905 |
|
|
com += mass * mol->getCom(); |
906 |
|
|
} |
907 |
gezelter |
2 |
|
908 |
|
|
#ifdef IS_MPI |
909 |
gezelter |
246 |
double tmpMass = totalMass; |
910 |
|
|
Vector3d tmpCom(com); |
911 |
|
|
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
912 |
|
|
MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
913 |
gezelter |
2 |
#endif |
914 |
|
|
|
915 |
gezelter |
246 |
com /= totalMass; |
916 |
gezelter |
2 |
|
917 |
gezelter |
246 |
return com; |
918 |
gezelter |
2 |
|
919 |
gezelter |
246 |
} |
920 |
|
|
|
921 |
|
|
std::ostream& operator <<(std::ostream& o, SimInfo& info) { |
922 |
|
|
|
923 |
|
|
return o; |
924 |
gezelter |
2 |
} |
925 |
gezelter |
246 |
|
926 |
|
|
}//end namespace oopse |
927 |
|
|
|