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

Comparing:
trunk/src/brains/Snapshot.cpp (file contents), Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/development/src/brains/Snapshot.cpp (file contents), Revision 1568 by gezelter, Wed May 25 16:20:37 2011 UTC

# Line 51 | Line 51
51   #include "utils/NumericConstant.hpp"
52   #include "utils/simError.h"
53   #include "utils/Utility.hpp"
54 + #include <cstdio>
55 +
56   namespace OpenMD {
57  
58    void  Snapshot::setHmat(const Mat3x3d& m) {
59      hmat_ = m;
60      invHmat_ = hmat_.inverse();
61      
60
62      //prepare fortran Hmat
63      RealType fortranHmat[9];
64      RealType fortranInvHmat[9];
# Line 113 | Line 114 | namespace OpenMD {
114      }    
115  
116      //notify fortran simulation box has changed
117 <    setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_);
117 >    // setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_);
118    }
119  
120  
121    void Snapshot::wrapVector(Vector3d& pos) {
122 +    
123 +    Vector3d scaled = scaleVector(pos);
124 +    
125 +    for (int i = 0; i < 3; i++)
126 +      scaled[i] -= roundMe(scaled[i]);
127  
128 <    int i;
129 <    Vector3d scaled;
128 >    if( !orthoRhombic_ )
129 >      pos = hmat_ * scaled;    
130 >    else {
131  
125    if( !orthoRhombic_ ){
126
127      // calc the scaled coordinates.
128      scaled = invHmat_* pos;
129
130      // wrap the scaled coordinates
131      for (i = 0; i < 3; ++i) {
132        scaled[i] -= roundMe(scaled[i]);
133      }
134
132        // calc the wrapped real coordinates from the wrapped scaled coordinates
133 <      pos = hmat_ * scaled;    
133 >      for (int i=0; i<3; i++) {
134 >        pos[i] = scaled[i] * hmat_(i, i);
135 >      }  
136 >    }
137 >  }
138  
139 <    } else {//if it is orthoRhombic, we could improve efficiency by only caculating the diagonal element
139 >  inline Vector3d Snapshot::scaleVector(Vector3d& pos) {  
140      
141 <      // calc the scaled coordinates.
141 <      for (i=0; i<3; i++) {
142 <        scaled[i] = pos[i] * invHmat_(i, i);
143 <      }
144 <        
145 <      // wrap the scaled coordinates
146 <      for (i = 0; i < 3; ++i) {
147 <        scaled[i] -= roundMe(scaled[i]);
148 <      }
141 >    Vector3d scaled;
142  
143 <      // calc the wrapped real coordinates from the wrapped scaled coordinates
144 <      for (i=0; i<3; i++) {
145 <        pos[i] = scaled[i] * hmat_(i, i);
146 <      }
147 <        
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 <
153 >  
154    Vector3d Snapshot::getCOM() {
155      if( !hasCOM_ ) {
156        sprintf( painCave.errMsg, "COM was requested before COM was computed!\n");
# Line 182 | Line 177 | namespace OpenMD {
177      }
178      return COMw_;
179    }
185
180   }
181    

Comparing:
trunk/src/brains/Snapshot.cpp (property svn:keywords), Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/development/src/brains/Snapshot.cpp (property svn:keywords), Revision 1568 by gezelter, Wed May 25 16:20:37 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines