ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/primitives/CutoffGroup.hpp
(Generate patch)

Comparing:
trunk/src/primitives/CutoffGroup.hpp (file contents), Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/development/src/primitives/CutoffGroup.hpp (file contents), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 36 | Line 36
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).                        
39 > * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 > * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   #ifndef PRIMITIVES_CUTOFFGROUP_HPP
# Line 50 | Line 51 | namespace OpenMD {
51    class CutoffGroup {
52    public:
53      
54 <    CutoffGroup() {
54 >    CutoffGroup() :  snapshotMan_(NULL) {
55 >
56 >      storage_ = &Snapshot::cgData;
57        haveTotalMass = false;
58        totalMass = 0.0;
59      }
60      
61 +    /**
62 +     * Sets the Snapshot Manager of this cutoffGroup
63 +     */
64 +    void setSnapshotManager(SnapshotManager* sman) {
65 +      snapshotMan_ = sman;
66 +    }
67 +
68 +
69      void addAtom(Atom *atom) {
70        cutoffAtomList.push_back(atom);
71      }
# Line 89 | Line 100 | namespace OpenMD {
100        return totalMass;
101      }
102      
103 <    void getCOM(Vector3d & com) {
103 >    void updateCOM() {
104        std::vector<Atom *>::iterator i;
105        Atom * atom;
106 <      Vector3d pos;
107 <      RealType mass;
108 <      
98 <      com[0] = 0;
99 <      com[1] = 0;
100 <      com[2] = 0;
106 >
107 >      DataStorage&  data = snapshotMan_->getCurrentSnapshot()->*storage_;
108 >    
109        totalMass = getMass();
110        
111        if (cutoffAtomList.size() == 1) {
112 <        com = beginAtom(i)->getPos();
112 >        data.position[localIndex_] = beginAtom(i)->getPos();
113        } else {
114 +        data.position[localIndex_] = V3Zero;
115          for(atom = beginAtom(i); atom != NULL; atom = nextAtom(i)) {
116 <          mass = atom->getMass();
117 <          pos = atom->getPos();
118 <          com += pos * mass;
110 <        }
111 <        
112 <        com /= totalMass;
116 >          data.position[localIndex_] += atom->getMass() * atom->getPos();
117 >        }        
118 >        data.position[localIndex_] /= totalMass;
119        }
120      }
121 +
122 +
123 +    Vector3d getPos() {
124 +      return ((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_];      
125 +    }
126      
127      int getNumAtom() {
128        return cutoffAtomList.size();
# Line 124 | Line 135 | namespace OpenMD {
135      void setGlobalIndex(int id) {
136        this->globalIndex = id;
137      }
138 +
139 +    /**
140 +     * Returns the local index of this cutoffGroup
141 +     * @return the local index of this cutoffGroup
142 +     */
143 +    int getLocalIndex() {
144 +      return localIndex_;
145 +    }
146 +
147 +    /**
148 +     * Sets the local index of this cutoffGroup
149 +     * @param index new index to be set
150 +     */        
151 +    void setLocalIndex(int index) {
152 +      localIndex_ = index;
153 +    }
154      
155    private:
156      
157      std::vector<Atom *>cutoffAtomList;
158      bool haveTotalMass;
159      RealType totalMass;
160 <    int globalIndex;
160 >    int globalIndex;    
161 >
162 >    int localIndex_;
163 >    DataStoragePointer storage_;
164 >    SnapshotManager* snapshotMan_;
165 >
166    };  
167   } //end namespace OpenMD
168   #endif //PRIMITIVES_CUTOFFGROUP_HPP  

Comparing:
trunk/src/primitives/CutoffGroup.hpp (property svn:keywords), Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/development/src/primitives/CutoffGroup.hpp (property svn:keywords), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines