# | Line 65 | Line 65 | namespace OpenMD { | |
---|---|---|
65 | needFlucQ_ = simParams->getOutputFluctuatingCharges(); | |
66 | needElectricField_ = simParams->getOutputElectricField(); | |
67 | ||
68 | + | if (needParticlePot_ || needFlucQ_ || needElectricField_) { |
69 | + | doSiteData_ = true; |
70 | + | } else { |
71 | + | doSiteData_ = false; |
72 | + | } |
73 | + | |
74 | createDumpFile_ = true; | |
75 | #ifdef HAVE_LIBZ | |
76 | if (needCompression_) { | |
# | Line 108 | Line 114 | namespace OpenMD { | |
114 | needFlucQ_ = simParams->getOutputFluctuatingCharges(); | |
115 | needElectricField_ = simParams->getOutputElectricField(); | |
116 | ||
117 | + | if (needParticlePot_ || needFlucQ_ || needElectricField_) { |
118 | + | doSiteData_ = true; |
119 | + | } else { |
120 | + | doSiteData_ = false; |
121 | + | } |
122 | + | |
123 | createDumpFile_ = true; | |
124 | #ifdef HAVE_LIBZ | |
125 | if (needCompression_) { | |
# | Line 150 | Line 162 | namespace OpenMD { | |
162 | needParticlePot_ = simParams->getOutputParticlePotential(); | |
163 | needFlucQ_ = simParams->getOutputFluctuatingCharges(); | |
164 | needElectricField_ = simParams->getOutputElectricField(); | |
165 | + | |
166 | + | if (needParticlePot_ || needFlucQ_ || needElectricField_) { |
167 | + | doSiteData_ = true; |
168 | + | } else { |
169 | + | doSiteData_ = false; |
170 | + | } |
171 | ||
172 | #ifdef HAVE_LIBZ | |
173 | if (needCompression_) { | |
# | Line 284 | Line 302 | namespace OpenMD { | |
302 | StuntDouble* integrableObject; | |
303 | SimInfo::MoleculeIterator mi; | |
304 | Molecule::IntegrableObjectIterator ii; | |
305 | + | RigidBody::AtomIterator ai; |
306 | + | Atom* atom; |
307 | ||
308 | #ifndef IS_MPI | |
309 | os << " <Snapshot>\n"; | |
# | Line 301 | Line 321 | namespace OpenMD { | |
321 | } | |
322 | } | |
323 | os << " </StuntDoubles>\n"; | |
324 | < | |
324 | > | |
325 | > | if (doSiteData_) { |
326 | > | os << " <SiteData>\n"; |
327 | > | for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
328 | > | |
329 | > | for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL; |
330 | > | integrableObject = mol->nextIntegrableObject(ii)) { |
331 | > | |
332 | > | int ioIndex = integrableObject->getGlobalIntegrableObjectIndex(); |
333 | > | // do one for the IO itself |
334 | > | os << prepareSiteLine(integrableObject, ioIndex, 0); |
335 | > | |
336 | > | if (integrableObject->isRigidBody()) { |
337 | > | |
338 | > | RigidBody* rb = static_cast<RigidBody*>(integrableObject); |
339 | > | int siteIndex = 0; |
340 | > | for (atom = rb->beginAtom(ai); atom != NULL; |
341 | > | atom = rb->nextAtom(ai)) { |
342 | > | os << prepareSiteLine(atom, ioIndex, siteIndex); |
343 | > | siteIndex++; |
344 | > | } |
345 | > | } |
346 | > | } |
347 | > | } |
348 | > | os << " </SiteData>\n"; |
349 | > | } |
350 | os << " </Snapshot>\n"; | |
351 | ||
352 | os.flush(); | |
# | Line 470 | Line 515 | namespace OpenMD { | |
515 | } | |
516 | } | |
517 | ||
518 | < | if (needParticlePot_) { |
519 | < | type += "u"; |
520 | < | RealType particlePot = integrableObject->getParticlePot(); |
521 | < | if (isinf(particlePot) || isnan(particlePot)) { |
522 | < | sprintf( painCave.errMsg, |
523 | < | "DumpWriter detected a numerical error writing the particle " |
524 | < | " potential for object %d", index); |
525 | < | painCave.isFatal = 1; |
526 | < | simError(); |
527 | < | } |
528 | < | sprintf(tempBuffer, " %13e", particlePot); |
529 | < | line += tempBuffer; |
518 | > | sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str()); |
519 | > | return std::string(tempBuffer); |
520 | > | } |
521 | > | |
522 | > | std::string DumpWriter::prepareSiteLine(StuntDouble* integrableObject, int ioIndex, int siteIndex) { |
523 | > | |
524 | > | |
525 | > | std::string id; |
526 | > | std::string type; |
527 | > | std::string line; |
528 | > | char tempBuffer[4096]; |
529 | > | |
530 | > | if (integrableObject->isRigidBody()) { |
531 | > | sprintf(tempBuffer, "%10d ", ioIndex); |
532 | > | id = std::string(tempBuffer); |
533 | > | } else { |
534 | > | sprintf(tempBuffer, "%10d %10d", ioIndex, siteIndex); |
535 | > | id = std::string(tempBuffer); |
536 | } | |
537 | < | |
537 | > | |
538 | if (needFlucQ_) { | |
539 | type += "cw"; | |
540 | RealType fqPos = integrableObject->getFlucQPos(); | |
541 | if (isinf(fqPos) || isnan(fqPos) ) { | |
542 | sprintf( painCave.errMsg, | |
543 | "DumpWriter detected a numerical error writing the" | |
544 | < | " fluctuating charge for object %d", index); |
544 | > | " fluctuating charge for object %s", id.c_str()); |
545 | painCave.isFatal = 1; | |
546 | simError(); | |
547 | } | |
# | Line 501 | Line 552 | namespace OpenMD { | |
552 | if (isinf(fqVel) || isnan(fqVel) ) { | |
553 | sprintf( painCave.errMsg, | |
554 | "DumpWriter detected a numerical error writing the" | |
555 | < | " fluctuating charge velocity for object %d", index); |
555 | > | " fluctuating charge velocity for object %s", id.c_str()); |
556 | painCave.isFatal = 1; | |
557 | simError(); | |
558 | } | |
# | Line 514 | Line 565 | namespace OpenMD { | |
565 | if (isinf(fqFrc) || isnan(fqFrc) ) { | |
566 | sprintf( painCave.errMsg, | |
567 | "DumpWriter detected a numerical error writing the" | |
568 | < | " fluctuating charge force for object %d", index); |
568 | > | " fluctuating charge force for object %s", id.c_str()); |
569 | painCave.isFatal = 1; | |
570 | simError(); | |
571 | } | |
# | Line 531 | Line 582 | namespace OpenMD { | |
582 | isinf(eField[2]) || isnan(eField[2]) ) { | |
583 | sprintf( painCave.errMsg, | |
584 | "DumpWriter detected a numerical error writing the electric" | |
585 | < | " field for object %d", index); |
585 | > | " field for object %s", id.c_str()); |
586 | painCave.isFatal = 1; | |
587 | simError(); | |
588 | } | |
# | Line 540 | Line 591 | namespace OpenMD { | |
591 | line += tempBuffer; | |
592 | } | |
593 | ||
594 | < | sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str()); |
594 | > | |
595 | > | if (needParticlePot_) { |
596 | > | type += "u"; |
597 | > | RealType particlePot = integrableObject->getParticlePot(); |
598 | > | if (isinf(particlePot) || isnan(particlePot)) { |
599 | > | sprintf( painCave.errMsg, |
600 | > | "DumpWriter detected a numerical error writing the particle " |
601 | > | " potential for object %s", id.c_str()); |
602 | > | painCave.isFatal = 1; |
603 | > | simError(); |
604 | > | } |
605 | > | sprintf(tempBuffer, " %13e", particlePot); |
606 | > | line += tempBuffer; |
607 | > | } |
608 | > | |
609 | > | |
610 | > | sprintf(tempBuffer, "%s %7s %s\n", id.c_str(), type.c_str(), line.c_str()); |
611 | return std::string(tempBuffer); | |
612 | } | |
613 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |