| 56 |
|
const std::string& filename, |
| 57 |
|
const std::string& sele1, |
| 58 |
|
const std::string& sele2, |
| 59 |
< |
RealType rCut, RealType voxelSize, |
| 59 |
> |
RealType rCut, |
| 60 |
> |
RealType voxelSize, |
| 61 |
|
RealType gaussWidth) |
| 62 |
|
: StaticAnalyser(info, filename), selectionScript1_(sele1), |
| 63 |
|
evaluator1_(info), seleMan1_(info), selectionScript2_(sele2), |
| 115 |
|
RealType cospsi; |
| 116 |
|
RealType Qk; |
| 117 |
|
std::vector<std::pair<RealType,StuntDouble*> > myNeighbors; |
| 118 |
< |
std::vector<std::pair<Vector3d, RealType> > qvals; |
| 119 |
< |
std::vector<std::pair<Vector3d, RealType> >::iterator qiter; |
| 118 |
> |
//std::vector<std::pair<Vector3d, RealType> > qvals; |
| 119 |
> |
//std::vector<std::pair<Vector3d, RealType> >::iterator qiter; |
| 120 |
|
int isd1; |
| 121 |
|
int isd2; |
| 122 |
|
|
| 123 |
+ |
|
| 124 |
+ |
int kMax = int(5.0 * gaussWidth_ / voxelSize_); |
| 125 |
+ |
int kSqLim = kMax*kMax; |
| 126 |
+ |
cerr << "gw = " << gaussWidth_ << " vS = " << voxelSize_ << " kMax = " << kMax << " kSqLim = " << kSqLim << "\n"; |
| 127 |
+ |
|
| 128 |
|
DumpReader reader(info_, dumpFilename_); |
| 129 |
|
int nFrames = reader.getNFrames(); |
| 130 |
|
|
| 131 |
|
for (int istep = 0; istep < nFrames; istep += step_) { |
| 132 |
|
reader.readFrame(istep); |
| 133 |
|
|
| 134 |
+ |
currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); |
| 135 |
+ |
Mat3x3d hmat = currentSnapshot_->getHmat(); |
| 136 |
+ |
Vector3d halfBox = Vector3d(hmat(0,0), hmat(1,1), hmat(2,2)) / 2.0; |
| 137 |
+ |
|
| 138 |
|
if (evaluator1_.isDynamic()) { |
| 139 |
|
seleMan1_.setSelectionSet(evaluator1_.evaluate()); |
| 140 |
|
} |
| 152 |
|
} |
| 153 |
|
} |
| 154 |
|
|
| 155 |
< |
qvals.clear(); |
| 155 |
> |
//qvals.clear(); |
| 156 |
|
|
| 157 |
|
// outer loop is over the selected StuntDoubles: |
| 158 |
|
for (sd = seleMan1_.beginSelected(isd1); sd != NULL; |
| 223 |
|
if (nang > 0) { |
| 224 |
|
if (usePeriodicBoundaryConditions_) |
| 225 |
|
currentSnapshot_->wrapVector(rk); |
| 226 |
< |
qvals.push_back(std::make_pair(rk, Qk)); |
| 227 |
< |
} |
| 228 |
< |
} |
| 226 |
> |
//qvals.push_back(std::make_pair(rk, Qk)); |
| 227 |
> |
|
| 228 |
> |
Vector3d pos = rk + halfBox; |
| 229 |
|
|
| 230 |
< |
for (int i = 0; i < nBins_(0); ++i) { |
| 231 |
< |
for(int j = 0; j < nBins_(1); ++j) { |
| 232 |
< |
for(int k = 0; k < nBins_(2); ++k) { |
| 233 |
< |
Vector3d pos = Vector3d(i, j, k) * voxelSize_; |
| 234 |
< |
for(qiter = qvals.begin(); qiter != qvals.end(); ++qiter) { |
| 235 |
< |
Vector3d d = pos - (*qiter).first; |
| 236 |
< |
RealType denom = pow(2.0 * sqrt(M_PI) * gaussWidth_, 3); |
| 237 |
< |
RealType exponent = -dot(d,d) / pow(2.0*gaussWidth_, 2); |
| 238 |
< |
RealType weight = exp(exponent) / denom; |
| 239 |
< |
count_[i][j][k] += weight; |
| 240 |
< |
hist_[i][j][k] += weight * (*qiter).second; |
| 230 |
> |
|
| 231 |
> |
Vector3i whichVoxel(int(pos[0] / voxelSize_), |
| 232 |
> |
int(pos[1] / voxelSize_), |
| 233 |
> |
int(pos[2] / voxelSize_)); |
| 234 |
> |
|
| 235 |
> |
for (int l = -kMax; l <= kMax; l++) { |
| 236 |
> |
for (int m = -kMax; m <= kMax; m++) { |
| 237 |
> |
for (int n = -kMax; n <= kMax; n++) { |
| 238 |
> |
int kk = l*l + m*m + n*n; |
| 239 |
> |
if(kk <= kSqLim) { |
| 240 |
> |
|
| 241 |
> |
int ll = (whichVoxel[0] + l) % nBins_(0); |
| 242 |
> |
ll = ll < 0 ? nBins_(0) + ll : ll; |
| 243 |
> |
int mm = (whichVoxel[1] + m) % nBins_(1); |
| 244 |
> |
mm = mm < 0 ? nBins_(1) + mm : mm; |
| 245 |
> |
int nn = (whichVoxel[2] + n) % nBins_(2); |
| 246 |
> |
nn = nn < 0 ? nBins_(2) + nn : nn; |
| 247 |
> |
|
| 248 |
> |
Vector3d bPos = Vector3d(ll,mm,nn) * voxelSize_ - halfBox; |
| 249 |
> |
Vector3d d = bPos - rk; |
| 250 |
> |
currentSnapshot_->wrapVector(d); |
| 251 |
> |
RealType denom = pow(2.0 * sqrt(M_PI) * gaussWidth_, 3); |
| 252 |
> |
RealType exponent = -dot(d,d) / pow(2.0*gaussWidth_, 2); |
| 253 |
> |
RealType weight = exp(exponent) / denom; |
| 254 |
> |
count_[ll][mm][nn] += weight; |
| 255 |
> |
hist_[ll][mm][nn] += weight * Qk; |
| 256 |
> |
} |
| 257 |
> |
} |
| 258 |
|
} |
| 259 |
|
} |
| 260 |
|
} |
| 261 |
|
} |
| 262 |
+ |
|
| 263 |
+ |
// for (int i = 0; i < nBins_(0); ++i) { |
| 264 |
+ |
// for(int j = 0; j < nBins_(1); ++j) { |
| 265 |
+ |
// for(int k = 0; k < nBins_(2); ++k) { |
| 266 |
+ |
// Vector3d pos = Vector3d(i, j, k) * voxelSize_ - halfBox; |
| 267 |
+ |
// for(qiter = qvals.begin(); qiter != qvals.end(); ++qiter) { |
| 268 |
+ |
// Vector3d d = pos - (*qiter).first; |
| 269 |
+ |
// currentSnapshot_->wrapVector(d); |
| 270 |
+ |
// RealType denom = pow(2.0 * sqrt(M_PI) * gaussWidth_, 3); |
| 271 |
+ |
// RealType exponent = -dot(d,d) / pow(2.0*gaussWidth_, 2); |
| 272 |
+ |
// RealType weight = exp(exponent) / denom; |
| 273 |
+ |
// count_[i][j][k] += weight; |
| 274 |
+ |
// hist_[i][j][k] += weight * (*qiter).second; |
| 275 |
+ |
// } |
| 276 |
+ |
// } |
| 277 |
+ |
// } |
| 278 |
+ |
// } |
| 279 |
|
} |
| 280 |
|
writeQxyz(); |
| 281 |
|
} |
| 282 |
|
|
| 283 |
|
void TetrahedralityParamXYZ::writeQxyz() { |
| 284 |
+ |
|
| 285 |
+ |
Mat3x3d hmat = info_->getSnapshotManager()->getCurrentSnapshot()->getHmat(); |
| 286 |
+ |
|
| 287 |
|
// normalize by total weight in voxel: |
| 288 |
|
for (unsigned int i = 0; i < hist_.size(); ++i) { |
| 289 |
|
for(unsigned int j = 0; j < hist_[i].size(); ++j) { |
| 290 |
|
for(unsigned int k = 0;k < hist_[i][j].size(); ++k) { |
| 291 |
< |
hist_[i][j][k] /= count_[i][j][k]; |
| 291 |
> |
hist_[i][j][k] = hist_[i][j][k] / count_[i][j][k]; |
| 292 |
|
} |
| 293 |
|
} |
| 294 |
|
} |
| 295 |
|
|
| 296 |
|
std::ofstream qXYZstream(outputFilename_.c_str()); |
| 297 |
|
if (qXYZstream.is_open()) { |
| 298 |
+ |
qXYZstream << "# AmiraMesh ASCII 1.0\n\n"; |
| 299 |
+ |
qXYZstream << "# Dimensions in x-, y-, and z-direction\n"; |
| 300 |
+ |
qXYZstream << " define Lattice " << hist_.size() << " " << hist_[0].size() << " " << hist_[0][0].size() << "\n"; |
| 301 |
+ |
|
| 302 |
+ |
qXYZstream << "Parameters {\n"; |
| 303 |
+ |
qXYZstream << " CoordType \"uniform\",\n"; |
| 304 |
+ |
qXYZstream << " # BoundingBox is xmin xmax ymin ymax zmin zmax\n"; |
| 305 |
+ |
qXYZstream << " BoundingBox 0.0 " << hmat(0,0) << |
| 306 |
+ |
" 0.0 " << hmat(1,1) << |
| 307 |
+ |
" 0.0 " << hmat(2,2) << "\n"; |
| 308 |
+ |
qXYZstream << "}\n"; |
| 309 |
+ |
|
| 310 |
+ |
qXYZstream << "Lattice { double ScalarField } = @1\n"; |
| 311 |
+ |
|
| 312 |
+ |
qXYZstream << "@1\n"; |
| 313 |
|
|
| 314 |
< |
for (unsigned int i = 0; i < hist_.size(); ++i) { |
| 315 |
< |
for(unsigned int j = 0; j < hist_[i].size(); ++j) { |
| 316 |
< |
for(unsigned int k = 0;k < hist_[i][j].size(); ++k) { |
| 317 |
< |
qXYZstream.write(reinterpret_cast<char *>( &hist_[i][j][k] ), |
| 318 |
< |
sizeof( hist_[i][j][k] )); |
| 314 |
> |
int xsize = hist_.size(); |
| 315 |
> |
int ysize = hist_[0].size(); |
| 316 |
> |
int zsize = hist_[0][0].size(); |
| 317 |
> |
|
| 318 |
> |
for (unsigned int k = 0; k < zsize; ++k) { |
| 319 |
> |
for(unsigned int j = 0; j < ysize; ++j) { |
| 320 |
> |
for(unsigned int i = 0; i < xsize; ++i) { |
| 321 |
> |
qXYZstream << hist_[i][j][k] << " "; |
| 322 |
> |
|
| 323 |
> |
//qXYZstream.write(reinterpret_cast<char *>( &hist_[i][j][k] ), |
| 324 |
> |
// sizeof( hist_[i][j][k] )); |
| 325 |
|
} |
| 326 |
|
} |
| 327 |
|
} |