| 82 |
|
|
| 83 |
|
std::vector<Atom*> getAtoms() { return cutoffAtomList; } |
| 84 |
|
RealType getMass() { |
| 85 |
– |
std::vector<Atom *>::iterator i; |
| 85 |
|
|
| 86 |
|
if (!haveTotalMass) { |
| 87 |
< |
totalMass = 0; |
| 87 |
> |
totalMass = 0.0; |
| 88 |
|
|
| 89 |
+ |
std::vector<Atom *>::iterator i; |
| 90 |
|
for(Atom* atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) { |
| 91 |
|
RealType mass = atom->getMass(); |
| 92 |
|
totalMass += mass; |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
void updateCOM() { |
| 102 |
– |
std::vector<Atom *>::iterator i; |
| 103 |
– |
Atom * atom; |
| 102 |
|
|
| 103 |
< |
DataStorage& data = snapshotMan_->getCurrentSnapshot()->*storage_; |
| 104 |
< |
int storageLayout = data.getStorageLayout(); |
| 105 |
< |
|
| 106 |
< |
totalMass = getMass(); |
| 109 |
< |
|
| 103 |
> |
DataStorage& data = snapshotMan_->getCurrentSnapshot()->*storage_; |
| 104 |
> |
bool needsVel = false; |
| 105 |
> |
if (data.getStorageLayout() & DataStorage::dslVelocity) needsVel = true; |
| 106 |
> |
|
| 107 |
|
if (cutoffAtomList.size() == 1) { |
| 108 |
< |
data.position[localIndex_] = beginAtom(i)->getPos(); |
| 108 |
> |
data.position[localIndex_] = cutoffAtomList[0]->getPos(); |
| 109 |
> |
if (needsVel) |
| 110 |
> |
data.velocity[localIndex_] = cutoffAtomList[0]->getVel(); |
| 111 |
|
} else { |
| 112 |
+ |
std::vector<Atom *>::iterator i; |
| 113 |
+ |
Atom * atom; |
| 114 |
+ |
RealType totalMass = getMass(); |
| 115 |
|
data.position[localIndex_] = V3Zero; |
| 116 |
+ |
if (needsVel) data.velocity[localIndex_] = V3Zero; |
| 117 |
+ |
|
| 118 |
|
for(atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) { |
| 119 |
|
data.position[localIndex_] += atom->getMass() * atom->getPos(); |
| 120 |
< |
} |
| 117 |
< |
data.position[localIndex_] /= totalMass; |
| 118 |
< |
} |
| 119 |
< |
|
| 120 |
< |
if (storageLayout & DataStorage::dslVelocity) { |
| 121 |
< |
if (cutoffAtomList.size() == 1) { |
| 122 |
< |
data.velocity[localIndex_] = beginAtom(i)->getVel(); |
| 123 |
< |
} else { |
| 124 |
< |
data.velocity[localIndex_] = V3Zero; |
| 125 |
< |
for(atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) { |
| 120 |
> |
if (needsVel) |
| 121 |
|
data.velocity[localIndex_] += atom->getMass() * atom->getVel(); |
| 122 |
< |
} |
| 123 |
< |
data.velocity[localIndex_] /= totalMass; |
| 124 |
< |
} |
| 125 |
< |
} |
| 122 |
> |
} |
| 123 |
> |
data.position[localIndex_] /= totalMass; |
| 124 |
> |
if (needsVel) data.velocity[localIndex_] /= totalMass; |
| 125 |
> |
} |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
|