--- branches/development/src/applications/staticProps/SpatialStatistics.cpp 2013/04/17 18:24:08 1865 +++ trunk/src/applications/staticProps/SpatialStatistics.cpp 2013/06/18 17:48:52 1887 @@ -43,6 +43,10 @@ #include "applications/staticProps/SpatialStatistics.hpp" #include "io/DumpReader.hpp" #include "primitives/Molecule.hpp" +#ifdef _MSC_VER +#define isnan(x) _isnan((x)) +#define isinf(x) (!_finite(x) && !_isnan(x)) +#endif namespace OpenMD { @@ -137,7 +141,7 @@ namespace OpenMD { processStuntDouble( sd, bin ); dynamic_cast(counts_->accumulator[bin])->add(1); - } + } } @@ -221,15 +225,13 @@ namespace OpenMD { int n = dat->accumulator[bin]->count(); if (n == 0) return; - RealType r; - Vector3d v; - if( dat->dataType == odtReal ) { + RealType r; dynamic_cast(dat->accumulator[bin])->getAverage(r); if (isinf(r) || isnan(r) ) { sprintf( painCave.errMsg, "SpatialStatistics detected a numerical error writing:\n" - "\t%s for bin %d", + "\t%s for bin %u", dat->title.c_str(), bin); painCave.isFatal = 1; simError(); @@ -238,13 +240,14 @@ namespace OpenMD { os << "\t" << r; } else if ( dat->dataType == odtVector3 ) { + Vector3d v; dynamic_cast(dat->accumulator[bin])->getAverage(v); if (isinf(v[0]) || isnan(v[0]) || isinf(v[1]) || isnan(v[1]) || isinf(v[2]) || isnan(v[2]) ) { sprintf( painCave.errMsg, "SpatialStatistics detected a numerical error writing:\n" - "\t%s for bin %d", + "\t%s for bin %u", dat->title.c_str(), bin); painCave.isFatal = 1; simError(); @@ -260,15 +263,13 @@ namespace OpenMD { int n = dat->accumulator[bin]->count(); if (n == 0) return; - RealType r; - Vector3d v; - if( dat->dataType == odtReal ) { + RealType r; dynamic_cast(dat->accumulator[bin])->getStdDev(r); if (isinf(r) || isnan(r) ) { sprintf( painCave.errMsg, "SpatialStatistics detected a numerical error writing:\n" - "\tstandard deviation of %s for bin %d", + "\tstandard deviation of %s for bin %u", dat->title.c_str(), bin); painCave.isFatal = 1; simError(); @@ -277,13 +278,14 @@ namespace OpenMD { os << "\t" << r; } else if ( dat->dataType == odtVector3 ) { + Vector3d v; dynamic_cast(dat->accumulator[bin])->getStdDev(v); if (isinf(v[0]) || isnan(v[0]) || isinf(v[1]) || isnan(v[1]) || isinf(v[2]) || isnan(v[2]) ) { sprintf( painCave.errMsg, "SpatialStatistics detected a numerical error writing:\n" - "\tstandard deviation of %s for bin %d", + "\tstandard deviation of %s for bin %u", dat->title.c_str(), bin); painCave.isFatal = 1; simError(); @@ -320,8 +322,13 @@ namespace OpenMD { data_.push_back(z_); } + SlabStatistics::~SlabStatistics() { + } + + void SlabStatistics::processFrame(int istep) { RealType z; + hmat_ = currentSnapshot_->getHmat(); for (int i = 0; i < nBins_; i++) { z = (((RealType)i + 0.5) / (RealType)nBins_) * hmat_(2,2); @@ -342,14 +349,12 @@ namespace OpenMD { return int(nBins_ * (pos.z() / hmat_(2,2) + 0.5)) % nBins_; } - ShellStatistics::ShellStatistics(SimInfo* info, const string& filename, const string& sele, int nbins) : - SpatialStatistics(info, filename, sele, nbins){ + SpatialStatistics(info, filename, sele, nbins), coordinateOrigin_(V3Zero) { - coordinateOrigin_ = V3Zero; binWidth_ = 1.0; - + r_ = new OutputData; r_->units = "Angstroms"; r_->title = "R"; @@ -366,6 +371,9 @@ namespace OpenMD { } } + ShellStatistics::~ShellStatistics() { + } + int ShellStatistics::getBin(Vector3d pos) { Vector3d rPos = pos - coordinateOrigin_; return int(rPos.length() / binWidth_);