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

Comparing trunk/src/applications/staticProps/TetrahedralityParamXYZ.cpp (file contents):
Revision 2015 by gezelter, Wed Aug 13 20:42:43 2014 UTC vs.
Revision 2016 by plouden, Thu Aug 14 19:04:30 2014 UTC

# Line 125 | Line 125 | namespace OpenMD {
125      for (int istep = 0; istep < nFrames; istep += step_) {
126        reader.readFrame(istep);
127  
128 +      currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
129 +      Mat3x3d hmat = currentSnapshot_->getHmat();
130 +      Vector3d halfBox = Vector3d(hmat(0,0), hmat(1,1), hmat(2,2)) / 2.0;
131 +
132        if (evaluator1_.isDynamic()) {
133          seleMan1_.setSelectionSet(evaluator1_.evaluate());
134        }
# Line 220 | Line 224 | namespace OpenMD {
224        for (int i = 0; i < nBins_(0); ++i) {
225          for(int j = 0; j < nBins_(1); ++j) {
226            for(int k = 0; k < nBins_(2); ++k) {
227 <            Vector3d pos = Vector3d(i, j, k) * voxelSize_;
227 >            Vector3d pos = Vector3d(i, j, k) * voxelSize_ - halfBox;
228              for(qiter = qvals.begin(); qiter != qvals.end(); ++qiter) {
229                Vector3d d = pos - (*qiter).first;
230 +              currentSnapshot_->wrapVector(d);
231                RealType denom = pow(2.0 * sqrt(M_PI) * gaussWidth_, 3);
232                RealType exponent = -dot(d,d) / pow(2.0*gaussWidth_, 2);
233                RealType weight = exp(exponent) / denom;
# Line 237 | Line 242 | namespace OpenMD {
242    }
243    
244    void TetrahedralityParamXYZ::writeQxyz() {
245 +
246 +    Mat3x3d hmat = info_->getSnapshotManager()->getCurrentSnapshot()->getHmat();
247 +
248      // normalize by total weight in voxel:
249      for (unsigned int i = 0; i < hist_.size(); ++i) {
250        for(unsigned int j = 0; j < hist_[i].size(); ++j) {
251          for(unsigned int k = 0;k < hist_[i][j].size(); ++k) {
252 <          hist_[i][j][k] /= count_[i][j][k];
252 >          hist_[i][j][k] = hist_[i][j][k] / count_[i][j][k];
253          }
254        }
255      }
256  
257      std::ofstream qXYZstream(outputFilename_.c_str());
258      if (qXYZstream.is_open()) {
259 +      qXYZstream <<  "# AmiraMesh ASCII 1.0\n\n";
260 +      qXYZstream <<  "# Dimensions in x-, y-, and z-direction\n";
261 +      qXYZstream <<  "  define Lattice " << hist_.size() << " " << hist_[0].size() << " " << hist_[0][0].size() << "\n";
262 +      
263 +      qXYZstream <<  "Parameters {\n";
264 +      qXYZstream <<  "    CoordType \"uniform\",\n";
265 +      qXYZstream <<  "    # BoundingBox is xmin xmax ymin ymax zmin zmax\n";
266 +      qXYZstream <<  "    BoundingBox 0.0 " << hmat(0,0) <<
267 +        " 0.0 " << hmat(1,1) <<
268 +        " 0.0 " << hmat(2,2) << "\n";
269 +      qXYZstream <<  "}\n";
270 +      
271 +      qXYZstream <<  "Lattice { double ScalarField } = @1\n";
272 +      
273 +      qXYZstream <<  "@1\n";
274  
275 <      for (unsigned int i = 0; i < hist_.size(); ++i) {
276 <        for(unsigned int j = 0; j < hist_[i].size(); ++j) {
277 <          for(unsigned int k = 0;k < hist_[i][j].size(); ++k) {
278 <            qXYZstream.write(reinterpret_cast<char *>( &hist_[i][j][k] ),
279 <                             sizeof( hist_[i][j][k] ));
275 >      int xsize = hist_.size();
276 >      int ysize = hist_[0].size();
277 >      int zsize = hist_[0][0].size();
278 >      
279 >      for (unsigned int k = 0; k < zsize; ++k) {
280 >        for(unsigned int j = 0; j < ysize; ++j) {
281 >          for(unsigned int i = 0; i < xsize; ++i) {
282 >            qXYZstream << hist_[i][j][k] << " ";
283 >
284 >            //qXYZstream.write(reinterpret_cast<char *>( &hist_[i][j][k] ),
285 >            // sizeof( hist_[i][j][k] ));
286            }
287          }
288        }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines