ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/Snapshot.cpp
(Generate patch)

Comparing branches/development/src/brains/Snapshot.cpp (file contents):
Revision 1550 by gezelter, Wed Apr 27 21:49:59 2011 UTC vs.
Revision 1562 by gezelter, Thu May 12 17:00:14 2011 UTC

# Line 118 | Line 118 | namespace OpenMD {
118    }
119  
120  
121 <  void Snapshot::wrapVector(Vector3d& pos) {
121 >  inline void Snapshot::wrapVector(Vector3d& pos) {
122 >    
123 >    Vector3d scaled = scaleVector(pos);
124  
125 <    int i;
126 <    Vector3d scaled;
125 >    for (int i = 0; i < 3; i++)
126 >      scaled[i] -= roundMe(scaled[i]);
127  
128 <    if( !orthoRhombic_ ){
127 <
128 <      // calc the scaled coordinates.
129 <      scaled = invHmat_* pos;
130 <
131 <      // wrap the scaled coordinates
132 <      for (i = 0; i < 3; ++i) {
133 <        scaled[i] -= roundMe(scaled[i]);
134 <      }
135 <
136 <      // calc the wrapped real coordinates from the wrapped scaled coordinates
128 >    if( !orthoRhombic_ )
129        pos = hmat_ * scaled;    
130 +    else {
131  
139    } else {
140
141      // if it is orthoRhombic, we could improve efficiency by only
142      // caculating the diagonal element
143    
144      // calc the scaled coordinates.
145      for (i=0; i<3; i++) {
146        scaled[i] = pos[i] * invHmat_(i, i);
147      }
148        
149      // wrap the scaled coordinates
150      for (i = 0; i < 3; ++i) {
151        scaled[i] -= roundMe(scaled[i]);
152      }
153
132        // calc the wrapped real coordinates from the wrapped scaled coordinates
133 <      for (i=0; i<3; i++) {
133 >      for (int i=0; i<3; i++) {
134          pos[i] = scaled[i] * hmat_(i, i);
135        }  
136      }
137    }
138  
139 +  inline Vector3d Snapshot::scaleVector(Vector3d& pos) {  
140 +    
141 +    Vector3d scaled;
142 +
143 +    if( !orthoRhombic_ )
144 +      scaled = invHmat_* pos;
145 +    else {
146 +      // calc the scaled coordinates.
147 +      for (int i=0; i<3; i++)
148 +        scaled[i] = pos[i] * invHmat_(i, i);
149 +    }
150 +
151 +    return scaled;
152 +  }
153 +  
154    Vector3d Snapshot::getCOM() {
155      if( !hasCOM_ ) {
156        sprintf( painCave.errMsg, "COM was requested before COM was computed!\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines