55 CutoffGroup() : globalIndex(-1), localIndex_(-1), snapshotMan_(NULL) {
56 storage_ = &Snapshot::cgData;
57 haveTotalMass =
false;
66 void addAtom(
Atom* atom) { cutoffAtomList.push_back(atom); }
68 Atom* beginAtom(std::vector<Atom*>::iterator& i) {
69 i = cutoffAtomList.begin();
70 return i != cutoffAtomList.end() ? *i : NULL;
73 Atom* nextAtom(std::vector<Atom*>::iterator& i) {
75 return i != cutoffAtomList.end() ? *i : NULL;
78 std::vector<Atom*> getAtoms() {
return cutoffAtomList; }
83 std::vector<Atom*>::iterator i;
84 for (Atom* atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) {
85 RealType mass = atom->
getMass();
97 bool needsVel =
false;
98 if (data.getStorageLayout() & DataStorage::dslVelocity) needsVel =
true;
100 if (cutoffAtomList.size() == 1) {
101 data.position[localIndex_] = cutoffAtomList[0]->getPos();
102 if (needsVel) data.velocity[localIndex_] = cutoffAtomList[0]->getVel();
104 std::vector<Atom*>::iterator i;
106 RealType totalMass = getMass();
107 data.position[localIndex_] = V3Zero;
108 if (needsVel) data.velocity[localIndex_] = V3Zero;
110 for (atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) {
111 data.position[localIndex_] += atom->getMass() * atom->getPos();
113 data.velocity[localIndex_] += atom->getMass() * atom->getVel();
115 data.position[localIndex_] /= totalMass;
116 if (needsVel) data.velocity[localIndex_] /= totalMass;
122 .position[localIndex_];
126 .velocity[localIndex_];
129 size_t getNumAtom() {
return cutoffAtomList.size(); }
131 int getGlobalIndex() {
return globalIndex; }
133 void setGlobalIndex(
int id) { this->globalIndex = id; }
148 std::vector<Atom*> cutoffAtomList;
154 DataStoragePointer storage_;