| 50 |
|
class CutoffGroup { |
| 51 |
|
public: |
| 52 |
|
|
| 53 |
< |
CutoffGroup() { |
| 53 |
> |
CutoffGroup() : snapshotMan_(NULL) { |
| 54 |
> |
|
| 55 |
> |
storage_ = &Snapshot::cgData; |
| 56 |
|
haveTotalMass = false; |
| 57 |
|
totalMass = 0.0; |
| 58 |
|
} |
| 59 |
|
|
| 60 |
+ |
/** |
| 61 |
+ |
* Sets the Snapshot Manager of this cutoffGroup |
| 62 |
+ |
*/ |
| 63 |
+ |
void setSnapshotManager(SnapshotManager* sman) { |
| 64 |
+ |
snapshotMan_ = sman; |
| 65 |
+ |
} |
| 66 |
+ |
|
| 67 |
+ |
|
| 68 |
|
void addAtom(Atom *atom) { |
| 69 |
|
cutoffAtomList.push_back(atom); |
| 70 |
|
} |
| 99 |
|
return totalMass; |
| 100 |
|
} |
| 101 |
|
|
| 102 |
< |
void getCOM(Vector3d & com) { |
| 102 |
> |
void updateCOM() { |
| 103 |
|
std::vector<Atom *>::iterator i; |
| 104 |
|
Atom * atom; |
| 105 |
< |
Vector3d pos; |
| 106 |
< |
RealType mass; |
| 107 |
< |
|
| 98 |
< |
com[0] = 0; |
| 99 |
< |
com[1] = 0; |
| 100 |
< |
com[2] = 0; |
| 105 |
> |
|
| 106 |
> |
DataStorage& data = snapshotMan_->getCurrentSnapshot()->*storage_; |
| 107 |
> |
|
| 108 |
|
totalMass = getMass(); |
| 109 |
|
|
| 110 |
|
if (cutoffAtomList.size() == 1) { |
| 111 |
< |
com = beginAtom(i)->getPos(); |
| 111 |
> |
std::cerr << "YO!\n"; |
| 112 |
> |
std::cerr << "atipos = " << beginAtom(i)->getPos() << "\n"; |
| 113 |
> |
std::cerr << "lI = " << localIndex_ << "\n"; |
| 114 |
> |
|
| 115 |
> |
data.position[localIndex_] = beginAtom(i)->getPos(); |
| 116 |
> |
std::cerr << "YOYO!\n"; |
| 117 |
|
} else { |
| 118 |
+ |
data.position[localIndex_] = V3Zero; |
| 119 |
|
for(atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) { |
| 120 |
< |
mass = atom->getMass(); |
| 121 |
< |
pos = atom->getPos(); |
| 122 |
< |
com += pos * mass; |
| 110 |
< |
} |
| 111 |
< |
|
| 112 |
< |
com /= totalMass; |
| 120 |
> |
data.position[localIndex_] += atom->getMass() * atom->getPos(); |
| 121 |
> |
} |
| 122 |
> |
data.position[localIndex_] /= totalMass; |
| 123 |
|
} |
| 124 |
|
} |
| 125 |
+ |
|
| 126 |
+ |
|
| 127 |
+ |
Vector3d getPos() { |
| 128 |
+ |
return ((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_]; |
| 129 |
+ |
} |
| 130 |
|
|
| 131 |
|
int getNumAtom() { |
| 132 |
|
return cutoffAtomList.size(); |
| 139 |
|
void setGlobalIndex(int id) { |
| 140 |
|
this->globalIndex = id; |
| 141 |
|
} |
| 142 |
+ |
|
| 143 |
+ |
/** |
| 144 |
+ |
* Returns the local index of this cutoffGroup |
| 145 |
+ |
* @return the local index of this cutoffGroup |
| 146 |
+ |
*/ |
| 147 |
+ |
int getLocalIndex() { |
| 148 |
+ |
return localIndex_; |
| 149 |
+ |
} |
| 150 |
+ |
|
| 151 |
+ |
/** |
| 152 |
+ |
* Sets the local index of this cutoffGroup |
| 153 |
+ |
* @param index new index to be set |
| 154 |
+ |
*/ |
| 155 |
+ |
void setLocalIndex(int index) { |
| 156 |
+ |
localIndex_ = index; |
| 157 |
+ |
} |
| 158 |
|
|
| 159 |
|
private: |
| 160 |
|
|
| 161 |
|
std::vector<Atom *>cutoffAtomList; |
| 162 |
|
bool haveTotalMass; |
| 163 |
|
RealType totalMass; |
| 164 |
< |
int globalIndex; |
| 164 |
> |
int globalIndex; |
| 165 |
> |
|
| 166 |
> |
int localIndex_; |
| 167 |
> |
DataStoragePointer storage_; |
| 168 |
> |
SnapshotManager* snapshotMan_; |
| 169 |
> |
|
| 170 |
|
}; |
| 171 |
|
} //end namespace OpenMD |
| 172 |
|
#endif //PRIMITIVES_CUTOFFGROUP_HPP |