--- trunk/OOPSE/libmdtools/InitializeFromFile.cpp 2003/07/21 16:23:10 641 +++ trunk/OOPSE/libmdtools/InitializeFromFile.cpp 2003/08/07 21:47:18 670 @@ -83,6 +83,7 @@ void InitializeFromFile :: readInit( SimInfo* the_simn char *eof_test; // ptr to see when we reach the end of the file char *parseErr; int procIndex; + double currTime; double boxMat[9]; double theBoxMat3[3][3]; @@ -123,7 +124,7 @@ void InitializeFromFile :: readInit( SimInfo* the_simn simError(); } - parseErr = parseBoxLine( read_buffer, boxMat ); + parseErr = parseBoxLine( read_buffer, boxMat, currTime ); if( parseErr != NULL ){ strcpy( painCave.errMsg, parseErr ); painCave.isFatal = 1; @@ -134,6 +135,7 @@ void InitializeFromFile :: readInit( SimInfo* the_simn for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; simnfo->setBoxM( theBoxMat3 ); + simnfo->setTime( currTime ); for( i=0; i < n_atoms; i++){ @@ -210,7 +212,7 @@ void InitializeFromFile :: readInit( SimInfo* the_simn simError(); } - parseErr = parseBoxLine( read_buffer, boxMat ); + parseErr = parseBoxLine( read_buffer, boxMat, currTime ); if( parseErr != NULL ){ strcpy( painCave.errMsg, parseErr ); haveError = 1; @@ -218,6 +220,7 @@ void InitializeFromFile :: readInit( SimInfo* the_simn } MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD ); + MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD ); if(haveError) nodeZeroError(); @@ -272,6 +275,7 @@ void InitializeFromFile :: readInit( SimInfo* the_simn } else { MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD); + MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); done = 0; while (!done) { @@ -309,6 +313,7 @@ void InitializeFromFile :: readInit( SimInfo* the_simn for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; simnfo->setBoxM( theBoxMat3 ); + simnfo->setTime( currTime ); #endif @@ -318,8 +323,8 @@ char* InitializeFromFile::parseDumpLine(char* readLine char *foo; // the pointer to the current string token - double rx, ry, rz; // position place holders - double vx, vy, vz; // velocity placeholders + double pos[3]; // position place holders + double vel[3]; // velocity placeholders double q[4]; // the quaternions double jx, jy, jz; // angular velocity placeholders; double qSqr, qLength; // needed to normalize the quaternion vector. @@ -372,7 +377,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - rx = atof( foo ); + pos[0] = atof( foo ); foo = strtok(NULL, " ,;\t"); if(foo == NULL){ @@ -382,7 +387,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - ry = atof( foo ); + pos[1] = atof( foo ); foo = strtok(NULL, " ,;\t"); if(foo == NULL){ @@ -392,7 +397,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - rz = atof( foo ); + pos[2] = atof( foo ); // get the velocities @@ -405,7 +410,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - vx = atof( foo ); + vel[0] = atof( foo ); foo = strtok(NULL, " ,;\t"); if(foo == NULL){ @@ -415,7 +420,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - vy = atof( foo ); + vel[1] = atof( foo ); foo = strtok(NULL, " ,;\t"); if(foo == NULL){ @@ -425,7 +430,7 @@ char* InitializeFromFile::parseDumpLine(char* readLine c_in_name, n_atoms, atomIndex ); return strdup( painCave.errMsg ); } - vz = atof( foo ); + vel[2] = atof( foo ); // get the quaternions @@ -527,19 +532,15 @@ char* InitializeFromFile::parseDumpLine(char* readLine // add the positions and velocities to the atom - atoms[atomIndex]->setX( rx ); - atoms[atomIndex]->setY( ry ); - atoms[atomIndex]->setZ( rz ); - - atoms[atomIndex]->set_vx( vx ); - atoms[atomIndex]->set_vy( vy ); - atoms[atomIndex]->set_vz( vz ); + atoms[atomIndex]->setPos( pos ); + atoms[atomIndex]->setVel( vel ); return NULL; } -char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9]){ +char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9], + double &time ){ char *foo; // the pointer to the current string token int j; @@ -555,7 +556,7 @@ char* InitializeFromFile::parseBoxLine(char* readLine, c_in_name ); return strdup( painCave.errMsg ); } - simnfo->currentTime = atof( foo ); + time = atof( foo ); // get the Hx vector