ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/headers/Atom.hpp
(Generate patch)

Comparing trunk/mdtools/headers/Atom.hpp (file contents):
Revision 184 by mmeineke, Thu Nov 21 20:33:06 2002 UTC vs.
Revision 189 by mmeineke, Tue Nov 26 21:04:43 2002 UTC

# Line 12 | Line 12 | class Atom{ (public)
12      is_VDW = 0;
13      is_LJ = 0;
14      index = theIndex;
15 +    offset = 3 * index;
16    }
17    virtual ~Atom() {}
18  
# Line 28 | Line 29 | class Atom{ (public)
29      delete[] trq;
30    }
31    
32 <  double getX() const {return pos[3*index];}
33 <  double getY() const {return pos[3*index+1];}
34 <  double getZ() const {return pos[3*index+2];}
35 <  void setX(double x) {pos[3*index]   = x;}
36 <  void setY(double y) {pos[3*index+1] = y;}
37 <  void setZ(double z) {pos[3*index+2] = z;}
32 >  double getX() const {return pos[offset];}
33 >  double getY() const {return pos[offset+1];}
34 >  double getZ() const {return pos[offset+2];}
35 >  void setX(double x) {pos[offset]   = x;}
36 >  void setY(double y) {pos[offset+1] = y;}
37 >  void setZ(double z) {pos[offset+2] = z;}
38    
39 <  double get_vx() const  {return vel[3*index];}
40 <  double get_vy() const  {return vel[3*index+1];}
41 <  double get_vz() const  {return vel[3*index+2];}
42 <  void set_vx(double vx) {vel[3*index]   = vx;}
43 <  void set_vy(double vy) {vel[3*index+1] = vy;}
44 <  void set_vz(double vz) {vel[3*index+2] = vz;}
39 >  double get_vx() const  {return vel[offset];}
40 >  double get_vy() const  {return vel[offset+1];}
41 >  double get_vz() const  {return vel[offset+2];}
42 >  void set_vx(double vx) {vel[offset]   = vx;}
43 >  void set_vy(double vy) {vel[offset+1] = vy;}
44 >  void set_vz(double vz) {vel[offset+2] = vz;}
45    
46 <  double getFx() const   {return frc[3*index];}
47 <  double getFy() const   {return frc[3*index+1];}
48 <  double getFz() const   {return frc[3*index+2];}
49 <  void addFx(double add) {frc[3*index]   += add;}
50 <  void addFy(double add) {frc[3*index+1] += add;}
51 <  void addFz(double add) {frc[3*index+2] += add;}
46 >  double getFx() const   {return frc[offset];}
47 >  double getFy() const   {return frc[offset+1];}
48 >  double getFz() const   {return frc[offset+2];}
49 >  void addFx(double add) {frc[offset]   += add;}
50 >  void addFy(double add) {frc[offset+1] += add;}
51 >  void addFz(double add) {frc[offset+2] += add;}
52    virtual void zeroForces() = 0;
53  
54    double getMass() const {return c_mass;}
# Line 63 | Line 64 | class Atom{ (public)
64    void setCovalent(double covalent) {c_covalent = covalent;}
65    
66    int getIndex() const {return index;}
67 <  void setIndex(int theIndex) {index = theIndex;}
67 >  void setIndex(int theIndex) {index = theIndex; offset = index*3;}
68    
69    char *getType() {return c_name;}
70    void setType(char * name) {strcpy(c_name,name);}
# Line 95 | Line 96 | class Atom{ (public)
96    double c_covalent; // The covalent radius of the atom.
97  
98    int index; /* set the atom's index */
99 +  int offset; // the atom's offset in the storage array
100  
101    char c_name[100]; /* it's name */
102  
# Line 116 | Line 118 | class GeneralAtom : public Atom{ (public)
118  
119    int isDirectional( void ){ return 0; }
120    void zeroForces() {
121 <    frc[3*index]   = 0.0;
122 <    frc[3*index+1] = 0.0;
123 <    frc[3*index+2] = 0.0;
121 >    frc[offset]   = 0.0;
122 >    frc[offset+1] = 0.0;
123 >    frc[offset+2] = 0.0;
124    }
125   };
126  
# Line 159 | Line 161 | class DirectionalAtom : public Atom { (public)
161    void setJy( double the_jy ) { jy = the_jy; }
162    void setJz( double the_jz ) { jz = the_jz; }
163      
164 <  void addTx( double the_tx ) { trq[3*index]   += the_tx;}
165 <  void addTy( double the_ty ) { trq[3*index+1] += the_ty;}
166 <  void addTz( double the_tz ) { trq[3*index+2] += the_tz;}
164 >  void addTx( double the_tx ) { trq[offset]   += the_tx;}
165 >  void addTy( double the_ty ) { trq[offset+1] += the_ty;}
166 >  void addTz( double the_tz ) { trq[offset+2] += the_tz;}
167  
168    void setMu( double the_mu ) { mu = the_mu; }
169  
170    void zeroForces() {
171 <    frc[3*index]   = 0.0;
172 <    frc[3*index+1] = 0.0;
173 <    frc[3*index+2] = 0.0;
171 >    frc[offset]   = 0.0;
172 >    frc[offset+1] = 0.0;
173 >    frc[offset+2] = 0.0;
174  
175 <    trq[3*index]   = 0.0;
176 <    trq[3*index+1] = 0.0;
177 <    trq[3*index+2] = 0.0;
175 >    trq[offset]   = 0.0;
176 >    trq[offset+1] = 0.0;
177 >    trq[offset+2] = 0.0;
178    }
179  
180    double getAxx( void ) { return Axx; }
# Line 200 | Line 202 | class DirectionalAtom : public Atom { (public)
202    double getJy( void ) { return jy; }
203    double getJz( void ) { return jz; }
204  
205 <  double getTx( void ) { return trq[3*index];}
206 <  double getTy( void ) { return trq[3*index+1]; }
207 <  double getTz( void ) { return trq[3*index+2]; }
205 >  double getTx( void ) { return trq[offset];}
206 >  double getTy( void ) { return trq[offset+1]; }
207 >  double getTz( void ) { return trq[offset+2]; }
208  
209    double getIxx( void ) { return Ixx; }
210    double getIxy( void ) { return Ixy; }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines