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

Comparing trunk/src/brains/Snapshot.cpp (file contents):
Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC vs.
Revision 1895 by gezelter, Mon Jul 1 21:09:37 2013 UTC

# Line 299 | Line 299 | namespace OpenMD {
299  
300    /** Wrap a vector according to periodic boundary conditions */
301    void Snapshot::wrapVector(Vector3d& pos) {
302    
303    Vector3d scaled = scaleVector(pos);
304    
305    for (int i = 0; i < 3; i++)
306      scaled[i] -= roundMe(scaled[i]);
302      
303 <    if( !frameData.orthoRhombic )
304 <      pos = frameData.hmat * scaled;    
305 <    else {
306 <      
303 >    if( !frameData.orthoRhombic ) {
304 >      Vector3d scaled = frameData.invHmat * pos;
305 >      for (int i = 0; i < 3; i++)
306 >        scaled[i] -= roundMe(scaled[i]);
307        // calc the wrapped real coordinates from the wrapped scaled coordinates
308 +      pos = frameData.hmat * scaled;
309 +    } else {
310 +      // calc the scaled coordinates.
311 +      RealType scaled;
312        for (int i=0; i<3; i++) {
313 <        pos[i] = scaled[i] * frameData.hmat(i, i);
314 <      }  
313 >        scaled = pos[i] * frameData.invHmat(i, i);
314 >        scaled -= roundMe(scaled);
315 >        pos[i] = scaled * frameData.hmat(i, i);
316 >      }
317      }
318    }
319  
320 +
321    /** Scaling a vector to multiples of the periodic box */
322    inline Vector3d Snapshot::scaleVector(Vector3d& pos) {  
323      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines