--- trunk/src/io/DumpWriter.cpp 2005/09/21 20:59:31 619 +++ trunk/src/io/DumpWriter.cpp 2006/05/17 21:51:42 963 @@ -57,7 +57,8 @@ namespace oopse { Globals* simParams = info->getSimParams(); needCompression_ = simParams->getCompressDumpFile(); - + needForceVector_ = simParams->getOutputForceVector(); + createDumpFile_ = true; #ifdef HAVE_LIBZ if (needCompression_) { filename_ += ".gz"; @@ -70,7 +71,7 @@ namespace oopse { if (worldRank == 0) { #endif // is_mpi - + dumpFile_ = createOStream(filename_); if (!dumpFile_) { @@ -99,7 +100,8 @@ namespace oopse { eorFilename_ = filename_.substr(0, filename_.rfind(".")) + ".eor"; needCompression_ = simParams->getCompressDumpFile(); - + needForceVector_ = simParams->getOutputForceVector(); + createDumpFile_ = true; #ifdef HAVE_LIBZ if (needCompression_) { filename_ += ".gz"; @@ -112,7 +114,7 @@ namespace oopse { if (worldRank == 0) { #endif // is_mpi - + dumpFile_ = createOStream(filename_); if (!dumpFile_) { @@ -132,6 +134,54 @@ namespace oopse { #endif // is_mpi } + + DumpWriter::DumpWriter(SimInfo* info, const std::string& filename, bool writeDumpFile) + : info_(info), filename_(filename){ + + Globals* simParams = info->getSimParams(); + eorFilename_ = filename_.substr(0, filename_.rfind(".")) + ".eor"; + + needCompression_ = simParams->getCompressDumpFile(); + needForceVector_ = simParams->getOutputForceVector(); + +#ifdef HAVE_LIBZ + if (needCompression_) { + filename_ += ".gz"; + eorFilename_ += ".gz"; + } +#endif + +#ifdef IS_MPI + + if (worldRank == 0) { +#endif // is_mpi + + createDumpFile_ = writeDumpFile; + if (createDumpFile_) { + dumpFile_ = createOStream(filename_); + + if (!dumpFile_) { + sprintf(painCave.errMsg, "Could not open \"%s\" for dump output.\n", + filename_.c_str()); + painCave.isFatal = 1; + simError(); + } + } +#ifdef IS_MPI + + } + + sprintf(checkPointMsg, "Sucessfully opened output file for dumping.\n"); + MPIcheckPoint(); + +#endif // is_mpi + + } + + + + + DumpWriter::~DumpWriter() { @@ -139,9 +189,9 @@ namespace oopse { if (worldRank == 0) { #endif // is_mpi - - delete dumpFile_; - + if (createDumpFile_){ + delete dumpFile_; + } #ifdef IS_MPI } @@ -152,10 +202,10 @@ namespace oopse { void DumpWriter::writeCommentLine(std::ostream& os, Snapshot* s) { - double currentTime; + RealType currentTime; Mat3x3d hmat; - double chi; - double integralOfChiDt; + RealType chi; + RealType integralOfChiDt; Mat3x3d eta; currentTime = s->getTime(); @@ -171,7 +221,7 @@ namespace oopse { //write out additional parameters, such as chi and eta - os << chi << "\t" << integralOfChiDt << "\t;"; + os << chi << "\t" << integralOfChiDt << ";\t"; os << eta(0, 0) << "\t" << eta(1, 0) << "\t" << eta(2, 0) << ";\t" << eta(0, 1) << "\t" << eta(1, 1) << "\t" << eta(2, 1) << ";\t" @@ -191,6 +241,8 @@ namespace oopse { Vector3d ji; Vector3d pos; Vector3d vel; + Vector3d frc; + Vector3d trq; Molecule* mol; StuntDouble* integrableObject; @@ -227,14 +279,25 @@ namespace oopse { q = integrableObject->getQ(); ji = integrableObject->getJ(); - sprintf(tempBuffer, "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", + sprintf(tempBuffer, "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf", q[0], q[1], q[2], q[3], ji[0], ji[1], ji[2]); strcat(writeLine, tempBuffer); } else { - strcat(writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n"); + strcat(writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0"); } + if (needForceVector_) { + frc = integrableObject->getFrc(); + trq = integrableObject->getTrq(); + + sprintf(tempBuffer, "\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf", + frc[0], frc[1], frc[2], + trq[0], trq[1], trq[2]); + strcat(writeLine, tempBuffer); + } + + strcat(writeLine, "\n"); os << writeLine; } @@ -284,7 +347,7 @@ namespace oopse { int myPotato; int nProc; int which_node; - double atomData[13]; + RealType atomData[19]; int isDirectional; char MPIatomTypeString[MINIBUFFERSIZE]; int msgLen; // the length of message actually recieved at master nodes @@ -359,13 +422,13 @@ namespace oopse { myPotato++; - MPI_Recv(atomData, 13, MPI_DOUBLE, which_node, myPotato, + MPI_Recv(atomData, 19, MPI_REALTYPE, which_node, myPotato, MPI_COMM_WORLD, &istatus); myPotato++; - MPI_Get_count(&istatus, MPI_DOUBLE, &msgLen); + MPI_Get_count(&istatus, MPI_REALTYPE, &msgLen); - if (msgLen == 13) + if (msgLen == 13 || msgLen == 19) isDirectional = 1; else isDirectional = 0; @@ -380,10 +443,10 @@ namespace oopse { atomData[5]); strcat(writeLine, - "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n"); + "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0"); } else { sprintf(writeLine, - "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", + "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf", MPIatomTypeString, atomData[0], atomData[1], @@ -399,7 +462,28 @@ namespace oopse { atomData[11], atomData[12]); } + + if (needForceVector_) { + if (!isDirectional) { + sprintf(writeLine, "\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf", + atomData[6], + atomData[7], + atomData[8], + atomData[9], + atomData[10], + atomData[11]); + } else { + sprintf(writeLine, "\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf", + atomData[13], + atomData[14], + atomData[15], + atomData[16], + atomData[17], + atomData[18]); + } + } + sprintf(writeLine, "\n"); os << writeLine; } // end for(int l =0) @@ -451,6 +535,27 @@ namespace oopse { atomData[12] = ji[2]; } + if (needForceVector_) { + frc = integrableObject->getFrc(); + trq = integrableObject->getTrq(); + + if (!isDirectional) { + atomData[6] = frc[0]; + atomData[7] = frc[1]; + atomData[8] = frc[2]; + atomData[9] = trq[0]; + atomData[10] = trq[1]; + atomData[11] = trq[2]; + } else { + atomData[13] = frc[0]; + atomData[14] = frc[1]; + atomData[15] = frc[2]; + atomData[16] = trq[0]; + atomData[17] = trq[1]; + atomData[18] = trq[2]; + } + } + // If we've survived to here, format the line: if (!isDirectional) { @@ -461,10 +566,10 @@ namespace oopse { atomData[5]); strcat(writeLine, - "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n"); + "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0"); } else { sprintf(writeLine, - "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", + "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf", integrableObject->getType().c_str(), atomData[0], atomData[1], @@ -481,7 +586,27 @@ namespace oopse { atomData[12]); } + if (needForceVector_) { + if (!isDirectional) { + sprintf(writeLine, "\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf", + atomData[6], + atomData[7], + atomData[8], + atomData[9], + atomData[10], + atomData[11]); + } else { + sprintf(writeLine, "\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf", + atomData[13], + atomData[14], + atomData[15], + atomData[16], + atomData[17], + atomData[18]); + } + } + sprintf(writeLine, "\n"); os << writeLine; } //end for(iter = integrableObject.begin()) @@ -567,6 +692,29 @@ namespace oopse { atomData[12] = ji[2]; } + if (needForceVector_) { + frc = integrableObject->getFrc(); + trq = integrableObject->getTrq(); + + if (!isDirectional) { + atomData[6] = frc[0]; + atomData[7] = frc[1]; + atomData[8] = frc[2]; + + atomData[9] = trq[0]; + atomData[10] = trq[1]; + atomData[11] = trq[2]; + } else { + atomData[13] = frc[0]; + atomData[14] = frc[1]; + atomData[15] = frc[2]; + + atomData[16] = trq[0]; + atomData[17] = trq[1]; + atomData[18] = trq[2]; + } + } + strncpy(MPIatomTypeString, integrableObject->getType().c_str(), MINIBUFFERSIZE); // null terminate the std::string before sending (just in case): @@ -577,11 +725,17 @@ namespace oopse { myPotato++; - if (isDirectional) { - MPI_Send(atomData, 13, MPI_DOUBLE, 0, myPotato, + if (isDirectional && needForceVector_) { + MPI_Send(atomData, 19, MPI_REALTYPE, 0, myPotato, MPI_COMM_WORLD); + } else if (isDirectional) { + MPI_Send(atomData, 13, MPI_REALTYPE, 0, myPotato, + MPI_COMM_WORLD); + } else if (needForceVector_) { + MPI_Send(atomData, 12, MPI_REALTYPE, 0, myPotato, + MPI_COMM_WORLD); } else { - MPI_Send(atomData, 6, MPI_DOUBLE, 0, myPotato, + MPI_Send(atomData, 6, MPI_REALTYPE, 0, myPotato, MPI_COMM_WORLD); }