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

Comparing branches/development/src/io/DumpWriter.cpp (file contents):
Revision 1764 by gezelter, Tue Jul 3 18:32:27 2012 UTC vs.
Revision 1769 by gezelter, Mon Jul 9 14:15:52 2012 UTC

# Line 44 | Line 44
44   #include "primitives/Molecule.hpp"
45   #include "utils/simError.h"
46   #include "io/basic_teebuf.hpp"
47 + #ifdef HAVE_ZLIB
48   #include "io/gzstream.hpp"
49 + #endif
50   #include "io/Globals.hpp"
51  
52 + #ifdef _MSC_VER
53 + #define isnan(x) _isnan((x))
54 + #define isinf(x) (!_finite(x) && !_isnan(x))
55 + #endif
56  
57   #ifdef IS_MPI
58   #include <mpi.h>
# Line 300 | Line 306 | namespace OpenMD {
306   #endif
307  
308      Molecule* mol;
309 <    StuntDouble* integrableObject;
309 >    StuntDouble* sd;
310      SimInfo::MoleculeIterator mi;
311      Molecule::IntegrableObjectIterator ii;
312      RigidBody::AtomIterator ai;
# Line 315 | Line 321 | namespace OpenMD {
321      for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) {
322  
323        
324 <      for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;  
325 <           integrableObject = mol->nextIntegrableObject(ii)) {  
326 <          os << prepareDumpLine(integrableObject);
324 >      for (sd = mol->beginIntegrableObject(ii); sd != NULL;  
325 >           sd = mol->nextIntegrableObject(ii)) {        
326 >          os << prepareDumpLine(sd);
327            
328        }
329      }    
# Line 327 | Line 333 | namespace OpenMD {
333        os << "    <SiteData>\n";
334        for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) {
335                
336 <        for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;  
337 <           integrableObject = mol->nextIntegrableObject(ii)) {  
336 >        for (sd = mol->beginIntegrableObject(ii); sd != NULL;  
337 >           sd = mol->nextIntegrableObject(ii)) {        
338  
339 <          int ioIndex = integrableObject->getGlobalIntegrableObjectIndex();
339 >          int ioIndex = sd->getGlobalIntegrableObjectIndex();
340            // do one for the IO itself
341 <          os << prepareSiteLine(integrableObject, ioIndex, 0);
341 >          os << prepareSiteLine(sd, ioIndex, 0);
342  
343 <          if (integrableObject->isRigidBody()) {
343 >          if (sd->isRigidBody()) {
344              
345 <            RigidBody* rb = static_cast<RigidBody*>(integrableObject);
345 >            RigidBody* rb = static_cast<RigidBody*>(sd);
346              int siteIndex = 0;
347              for (atom = rb->beginAtom(ai); atom != NULL;  
348                   atom = rb->nextAtom(ai)) {                                            
# Line 357 | Line 363 | namespace OpenMD {
363      for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) {
364  
365  
366 <      for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;
367 <           integrableObject = mol->nextIntegrableObject(ii)) {  
368 <          buffer += prepareDumpLine(integrableObject);
366 >      for (sd = mol->beginIntegrableObject(ii); sd != NULL;
367 >           sd = mol->nextIntegrableObject(ii)) {        
368 >          buffer += prepareDumpLine(sd);
369        }
370      }
371      
# Line 409 | Line 415 | namespace OpenMD {
415  
416    }
417  
418 <  std::string DumpWriter::prepareDumpLine(StuntDouble* integrableObject) {
418 >  std::string DumpWriter::prepareDumpLine(StuntDouble* sd) {
419          
420 <    int index = integrableObject->getGlobalIntegrableObjectIndex();
420 >    int index = sd->getGlobalIntegrableObjectIndex();
421      std::string type("pv");
422      std::string line;
423      char tempBuffer[4096];
424  
425      Vector3d pos;
426      Vector3d vel;
427 <    pos = integrableObject->getPos();
427 >    pos = sd->getPos();
428  
429      if (isinf(pos[0]) || isnan(pos[0]) ||
430          isinf(pos[1]) || isnan(pos[1]) ||
# Line 430 | Line 436 | namespace OpenMD {
436        simError();
437      }
438  
439 <    vel = integrableObject->getVel();          
439 >    vel = sd->getVel();        
440  
441      if (isinf(vel[0]) || isnan(vel[0]) ||
442          isinf(vel[1]) || isnan(vel[1]) ||
# Line 447 | Line 453 | namespace OpenMD {
453              vel[0], vel[1], vel[2]);                    
454      line += tempBuffer;
455  
456 <    if (integrableObject->isDirectional()) {
456 >    if (sd->isDirectional()) {
457        type += "qj";
458        Quat4d q;
459        Vector3d ji;
460 <      q = integrableObject->getQ();
460 >      q = sd->getQ();
461  
462        if (isinf(q[0]) || isnan(q[0]) ||
463            isinf(q[1]) || isnan(q[1]) ||
# Line 464 | Line 470 | namespace OpenMD {
470          simError();
471        }
472  
473 <      ji = integrableObject->getJ();
473 >      ji = sd->getJ();
474  
475        if (isinf(ji[0]) || isnan(ji[0]) ||
476            isinf(ji[1]) || isnan(ji[1]) ||
# Line 484 | Line 490 | namespace OpenMD {
490  
491      if (needForceVector_) {
492        type += "f";
493 <      Vector3d frc = integrableObject->getFrc();
493 >      Vector3d frc = sd->getFrc();
494        if (isinf(frc[0]) || isnan(frc[0]) ||
495            isinf(frc[1]) || isnan(frc[1]) ||
496            isinf(frc[2]) || isnan(frc[2]) ) {      
# Line 498 | Line 504 | namespace OpenMD {
504                frc[0], frc[1], frc[2]);
505        line += tempBuffer;
506        
507 <      if (integrableObject->isDirectional()) {
507 >      if (sd->isDirectional()) {
508          type += "t";
509 <        Vector3d trq = integrableObject->getTrq();        
509 >        Vector3d trq = sd->getTrq();        
510          if (isinf(trq[0]) || isnan(trq[0]) ||
511              isinf(trq[1]) || isnan(trq[1]) ||
512              isinf(trq[2]) || isnan(trq[2]) ) {      
# Line 520 | Line 526 | namespace OpenMD {
526      return std::string(tempBuffer);
527    }
528  
529 <  std::string DumpWriter::prepareSiteLine(StuntDouble* integrableObject, int ioIndex, int siteIndex) {
529 >  std::string DumpWriter::prepareSiteLine(StuntDouble* sd, int ioIndex, int siteIndex) {
530          
531  
532      std::string id;
# Line 528 | Line 534 | namespace OpenMD {
534      std::string line;
535      char tempBuffer[4096];
536  
537 <    if (integrableObject->isRigidBody()) {
537 >    if (sd->isRigidBody()) {
538        sprintf(tempBuffer, "%10d           ", ioIndex);
539        id = std::string(tempBuffer);
540      } else {
# Line 538 | Line 544 | namespace OpenMD {
544                
545      if (needFlucQ_) {
546        type += "cw";
547 <      RealType fqPos = integrableObject->getFlucQPos();
547 >      RealType fqPos = sd->getFlucQPos();
548        if (isinf(fqPos) || isnan(fqPos) ) {      
549          sprintf( painCave.errMsg,
550                   "DumpWriter detected a numerical error writing the"
# Line 549 | Line 555 | namespace OpenMD {
555        sprintf(tempBuffer, " %13e ", fqPos);
556        line += tempBuffer;
557      
558 <      RealType fqVel = integrableObject->getFlucQVel();
558 >      RealType fqVel = sd->getFlucQVel();
559        if (isinf(fqVel) || isnan(fqVel) ) {      
560          sprintf( painCave.errMsg,
561                   "DumpWriter detected a numerical error writing the"
# Line 562 | Line 568 | namespace OpenMD {
568  
569        if (needForceVector_) {
570          type += "g";
571 <        RealType fqFrc = integrableObject->getFlucQFrc();        
571 >        RealType fqFrc = sd->getFlucQFrc();        
572          if (isinf(fqFrc) || isnan(fqFrc) ) {      
573            sprintf( painCave.errMsg,
574                     "DumpWriter detected a numerical error writing the"
# Line 577 | Line 583 | namespace OpenMD {
583  
584      if (needElectricField_) {
585        type += "e";
586 <      Vector3d eField= integrableObject->getElectricField();
586 >      Vector3d eField= sd->getElectricField();
587        if (isinf(eField[0]) || isnan(eField[0]) ||
588            isinf(eField[1]) || isnan(eField[1]) ||
589            isinf(eField[2]) || isnan(eField[2]) ) {      
# Line 595 | Line 601 | namespace OpenMD {
601  
602      if (needParticlePot_) {
603        type += "u";
604 <      RealType particlePot = integrableObject->getParticlePot();
604 >      RealType particlePot = sd->getParticlePot();
605        if (isinf(particlePot) || isnan(particlePot)) {      
606          sprintf( painCave.errMsg,
607                   "DumpWriter detected a numerical error writing the particle "
# Line 679 | Line 685 | namespace OpenMD {
685    std::ostream* DumpWriter::createOStream(const std::string& filename) {
686  
687      std::ostream* newOStream;
688 < #ifdef HAVE_LIBZ
688 > #ifdef HAVE_ZLIB
689      if (needCompression_) {
690        newOStream = new ogzstream(filename.c_str());
691      } else {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines