26 |
|
|
27 |
|
#endif // is_mpi |
28 |
|
|
29 |
< |
InitializeFromFile :: InitializeFromFile( char *in_name ){ |
29 |
> |
InitializeFromFile::InitializeFromFile( char *in_name ){ |
30 |
> |
|
31 |
> |
std::cerr << "Hello from Initialize from file.\n"; |
32 |
> |
|
33 |
|
#ifdef IS_MPI |
34 |
|
if (worldRank == 0) { |
35 |
|
#endif |
51 |
|
return; |
52 |
|
} |
53 |
|
|
54 |
< |
InitializeFromFile :: ~InitializeFromFile( ){ |
54 |
> |
InitializeFromFile::~InitializeFromFile( ){ |
55 |
|
#ifdef IS_MPI |
56 |
|
if (worldRank == 0) { |
57 |
|
#endif |
86 |
|
char *eof_test; // ptr to see when we reach the end of the file |
87 |
|
char *parseErr; |
88 |
|
int procIndex; |
89 |
+ |
double currTime; |
90 |
|
double boxMat[9]; |
91 |
|
double theBoxMat3[3][3]; |
92 |
|
|
127 |
|
simError(); |
128 |
|
} |
129 |
|
|
130 |
< |
parseErr = parseBoxLine( read_buffer, boxMat ); |
130 |
> |
parseErr = parseBoxLine( read_buffer, boxMat, currTime ); |
131 |
|
if( parseErr != NULL ){ |
132 |
|
strcpy( painCave.errMsg, parseErr ); |
133 |
|
painCave.isFatal = 1; |
138 |
|
for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
139 |
|
|
140 |
|
simnfo->setBoxM( theBoxMat3 ); |
141 |
+ |
simnfo->setTime( currTime ); |
142 |
|
|
143 |
|
|
144 |
|
for( i=0; i < n_atoms; i++){ |
215 |
|
simError(); |
216 |
|
} |
217 |
|
|
218 |
< |
parseErr = parseBoxLine( read_buffer, boxMat ); |
218 |
> |
parseErr = parseBoxLine( read_buffer, boxMat, currTime ); |
219 |
|
if( parseErr != NULL ){ |
220 |
|
strcpy( painCave.errMsg, parseErr ); |
221 |
|
haveError = 1; |
223 |
|
} |
224 |
|
|
225 |
|
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
226 |
+ |
MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
227 |
|
|
228 |
|
if(haveError) nodeZeroError(); |
229 |
|
|
278 |
|
} else { |
279 |
|
|
280 |
|
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
281 |
+ |
MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
282 |
|
|
283 |
|
done = 0; |
284 |
|
while (!done) { |
316 |
|
for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
317 |
|
|
318 |
|
simnfo->setBoxM( theBoxMat3 ); |
319 |
+ |
simnfo->setTime( currTime ); |
320 |
|
|
321 |
|
|
322 |
|
#endif |
326 |
|
|
327 |
|
char *foo; // the pointer to the current string token |
328 |
|
|
329 |
< |
double rx, ry, rz; // position place holders |
330 |
< |
double vx, vy, vz; // velocity placeholders |
329 |
> |
double pos[3]; // position place holders |
330 |
> |
double vel[3]; // velocity placeholders |
331 |
|
double q[4]; // the quaternions |
332 |
|
double jx, jy, jz; // angular velocity placeholders; |
333 |
|
double qSqr, qLength; // needed to normalize the quaternion vector. |
380 |
|
c_in_name, n_atoms, atomIndex ); |
381 |
|
return strdup( painCave.errMsg ); |
382 |
|
} |
383 |
< |
rx = atof( foo ); |
383 |
> |
pos[0] = atof( foo ); |
384 |
|
|
385 |
|
foo = strtok(NULL, " ,;\t"); |
386 |
|
if(foo == NULL){ |
390 |
|
c_in_name, n_atoms, atomIndex ); |
391 |
|
return strdup( painCave.errMsg ); |
392 |
|
} |
393 |
< |
ry = atof( foo ); |
393 |
> |
pos[1] = atof( foo ); |
394 |
|
|
395 |
|
foo = strtok(NULL, " ,;\t"); |
396 |
|
if(foo == NULL){ |
400 |
|
c_in_name, n_atoms, atomIndex ); |
401 |
|
return strdup( painCave.errMsg ); |
402 |
|
} |
403 |
< |
rz = atof( foo ); |
403 |
> |
pos[2] = atof( foo ); |
404 |
|
|
405 |
|
|
406 |
|
// get the velocities |
413 |
|
c_in_name, n_atoms, atomIndex ); |
414 |
|
return strdup( painCave.errMsg ); |
415 |
|
} |
416 |
< |
vx = atof( foo ); |
416 |
> |
vel[0] = atof( foo ); |
417 |
|
|
418 |
|
foo = strtok(NULL, " ,;\t"); |
419 |
|
if(foo == NULL){ |
423 |
|
c_in_name, n_atoms, atomIndex ); |
424 |
|
return strdup( painCave.errMsg ); |
425 |
|
} |
426 |
< |
vy = atof( foo ); |
426 |
> |
vel[1] = atof( foo ); |
427 |
|
|
428 |
|
foo = strtok(NULL, " ,;\t"); |
429 |
|
if(foo == NULL){ |
433 |
|
c_in_name, n_atoms, atomIndex ); |
434 |
|
return strdup( painCave.errMsg ); |
435 |
|
} |
436 |
< |
vz = atof( foo ); |
436 |
> |
vel[2] = atof( foo ); |
437 |
|
|
438 |
|
|
439 |
|
// get the quaternions |
535 |
|
|
536 |
|
// add the positions and velocities to the atom |
537 |
|
|
538 |
< |
atoms[atomIndex]->setX( rx ); |
539 |
< |
atoms[atomIndex]->setY( ry ); |
532 |
< |
atoms[atomIndex]->setZ( rz ); |
533 |
< |
|
534 |
< |
atoms[atomIndex]->set_vx( vx ); |
535 |
< |
atoms[atomIndex]->set_vy( vy ); |
536 |
< |
atoms[atomIndex]->set_vz( vz ); |
538 |
> |
atoms[atomIndex]->setPos( pos ); |
539 |
> |
atoms[atomIndex]->setVel( vel ); |
540 |
|
|
541 |
|
return NULL; |
542 |
|
} |
543 |
|
|
544 |
|
|
545 |
< |
char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9]){ |
545 |
> |
char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9], |
546 |
> |
double &time ){ |
547 |
|
|
548 |
|
char *foo; // the pointer to the current string token |
549 |
|
int j; |
559 |
|
c_in_name ); |
560 |
|
return strdup( painCave.errMsg ); |
561 |
|
} |
562 |
< |
simnfo->currentTime = atof( foo ); |
562 |
> |
time = atof( foo ); |
563 |
|
|
564 |
|
// get the Hx vector |
565 |
|
|