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 1896 by gezelter, Tue Jul 2 20:02:31 2013 UTC

# Line 297 | Line 297 | namespace OpenMD {
297      frameData.volume = vol;
298    }
299  
300 +
301    /** Wrap a vector according to periodic boundary conditions */
302    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]);
303      
304 <    if( !frameData.orthoRhombic )
305 <      pos = frameData.hmat * scaled;    
306 <    else {
307 <      
304 >    if( !frameData.orthoRhombic ) {
305 >      Vector3d scaled = frameData.invHmat * pos;
306 >      for (int i = 0; i < 3; i++) {
307 >        scaled[i] -= roundMe( scaled[i] );        
308 >      }
309        // calc the wrapped real coordinates from the wrapped scaled coordinates
310 <      for (int i=0; i<3; i++) {
311 <        pos[i] = scaled[i] * frameData.hmat(i, i);
312 <      }  
310 >      pos = frameData.hmat * scaled;
311 >    } else {
312 >      RealType scaled;
313 >      for (int i=0; i<3; i++) {      
314 >        scaled = pos[i] * frameData.invHmat(i,i);
315 >        scaled -= roundMe( scaled );
316 >        pos[i] = scaled * frameData.hmat(i,i);
317 >      }
318      }
319    }
320  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines