| 1 |
+ |
#define _LARGEFILE_SOURCE64 |
| 2 |
|
#define _FILE_OFFSET_BITS 64 |
| 3 |
|
|
| 4 |
|
#include <sys/types.h> |
| 5 |
|
#include <sys/stat.h> |
| 6 |
|
|
| 7 |
|
#include <iostream> |
| 8 |
< |
#include <cmath> |
| 8 |
> |
#include <math.h> |
| 9 |
|
|
| 10 |
|
#include <stdio.h> |
| 11 |
|
#include <stdlib.h> |
| 34 |
|
using namespace dumpRead; |
| 35 |
|
|
| 36 |
|
|
| 37 |
< |
DumpReader :: DumpReader( char *in_name ){ |
| 37 |
> |
DumpReader :: DumpReader(const char *in_name ){ |
| 38 |
|
|
| 39 |
|
isScanned = false; |
| 40 |
|
headFP = new FilePos; |
| 222 |
|
double time; |
| 223 |
|
|
| 224 |
|
fpos_t *framePos; |
| 225 |
+ |
framePos = frameStart[whichFrame]->getPos(); |
| 226 |
|
|
| 227 |
|
#ifndef IS_MPI |
| 228 |
|
|
| 229 |
< |
framePos = frameStart[whichFrame]->getPos(); |
| 228 |
< |
|
| 229 |
> |
fsetpos(inFile, framePos); |
| 230 |
|
|
| 231 |
|
|
| 231 |
– |
|
| 232 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
| 233 |
|
if( eof_test == NULL ){ |
| 234 |
|
sprintf( painCave.errMsg, |
| 316 |
|
|
| 317 |
|
haveError = 0; |
| 318 |
|
if (worldRank == 0) { |
| 319 |
< |
|
| 319 |
> |
fsetpos(inFile, framePos); |
| 320 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
| 321 |
|
if( eof_test == NULL ){ |
| 322 |
|
sprintf( painCave.errMsg, |
| 465 |
|
|
| 466 |
|
char *foo; // the pointer to the current string token |
| 467 |
|
|
| 468 |
< |
double pos[3]; // position place holders |
| 469 |
< |
double vel[3]; // velocity placeholders |
| 470 |
< |
double q[4]; // the quaternions |
| 471 |
< |
double jx, jy, jz; // angular velocity placeholders; |
| 468 |
> |
double pos[3]; // position place holders |
| 469 |
> |
double vel[3]; // velocity placeholders |
| 470 |
> |
double q[4]; // the quaternions |
| 471 |
> |
double ji[3]; // angular velocity placeholders; |
| 472 |
|
double qSqr, qLength; // needed to normalize the quaternion vector. |
| 473 |
|
|
| 474 |
|
Atom **atoms = simnfo->atoms; |
| 497 |
|
// set the string tokenizer |
| 498 |
|
|
| 499 |
|
foo = strtok(readLine, " ,;\t"); |
| 500 |
< |
|
| 500 |
> |
atoms[atomIndex]->setType(foo); |
| 501 |
|
// check the atom name to the current atom |
| 502 |
|
|
| 503 |
< |
if( strcmp( foo, atoms[atomIndex]->getType() ) ){ |
| 504 |
< |
sprintf( painCave.errMsg, |
| 505 |
< |
"Initialize from file error. Atom %s at index %d " |
| 506 |
< |
"in file %s does not" |
| 507 |
< |
" match the BASS atom %s.\n", |
| 508 |
< |
foo, atomIndex, inName, atoms[atomIndex]->getType() ); |
| 509 |
< |
return strdup( painCave.errMsg ); |
| 510 |
< |
} |
| 503 |
> |
//if( strcmp( foo, atoms[atomIndex]->getType() ) ){ |
| 504 |
> |
// sprintf( painCave.errMsg, |
| 505 |
> |
// "Initialize from file error. Atom %s at index %d " |
| 506 |
> |
// "in file %s does not" |
| 507 |
> |
// " match the BASS atom %s.\n", |
| 508 |
> |
// foo, atomIndex, inName, atoms[atomIndex]->getType() ); |
| 509 |
> |
// return strdup( painCave.errMsg ); |
| 510 |
> |
//} |
| 511 |
|
|
| 512 |
|
// get the positions |
| 513 |
|
|
| 629 |
|
inName, n_atoms, atomIndex ); |
| 630 |
|
return strdup( painCave.errMsg ); |
| 631 |
|
} |
| 632 |
< |
jx = atof( foo ); |
| 632 |
> |
ji[0] = atof( foo ); |
| 633 |
|
|
| 634 |
|
foo = strtok(NULL, " ,;\t"); |
| 635 |
|
if(foo == NULL){ |
| 639 |
|
inName, n_atoms, atomIndex ); |
| 640 |
|
return strdup( painCave.errMsg ); |
| 641 |
|
} |
| 642 |
< |
jy = atof(foo ); |
| 642 |
> |
ji[1] = atof(foo ); |
| 643 |
|
|
| 644 |
|
foo = strtok(NULL, " ,;\t"); |
| 645 |
|
if(foo == NULL){ |
| 649 |
|
inName, n_atoms, atomIndex ); |
| 650 |
|
return strdup( painCave.errMsg ); |
| 651 |
|
} |
| 652 |
< |
jz = atof( foo ); |
| 652 |
> |
ji[2] = atof( foo ); |
| 653 |
|
|
| 654 |
|
dAtom = ( DirectionalAtom* )atoms[atomIndex]; |
| 655 |
|
|
| 667 |
|
|
| 668 |
|
// add the angular velocities |
| 669 |
|
|
| 670 |
< |
dAtom->setJx( jx ); |
| 671 |
< |
dAtom->setJy( jy ); |
| 672 |
< |
dAtom->setJz( jz ); |
| 670 |
> |
dAtom->setJ( ji ); |
| 671 |
|
} |
| 672 |
|
|
| 673 |
|
// add the positions and velocities to the atom |
| 684 |
|
|
| 685 |
|
char *foo; // the pointer to the current string token |
| 686 |
|
int j; |
| 687 |
+ |
double chi, integralOfChidt; |
| 688 |
+ |
double eta[9]; |
| 689 |
|
|
| 690 |
|
// set the string tokenizer |
| 691 |
|
|
| 784 |
|
return strdup( painCave.errMsg ); |
| 785 |
|
} |
| 786 |
|
boxMat[8] = atof( foo ); |
| 787 |
+ |
|
| 788 |
+ |
return NULL; |
| 789 |
|
|
| 790 |
+ |
//get chi and integralOfChidt, they should appear by pair |
| 791 |
+ |
foo = strtok(NULL, " ,;\t\n"); |
| 792 |
+ |
if(foo != NULL){ |
| 793 |
+ |
chi = atof(foo); |
| 794 |
+ |
|
| 795 |
+ |
foo = strtok(NULL, " ,;\t\n"); |
| 796 |
+ |
if(foo == NULL){ |
| 797 |
+ |
sprintf( painCave.errMsg, |
| 798 |
+ |
"chi and integralOfChidt should appear by pair in %s\n", inName ); |
| 799 |
+ |
return strdup( painCave.errMsg ); |
| 800 |
+ |
} |
| 801 |
+ |
integralOfChidt = atof( foo ); |
| 802 |
+ |
|
| 803 |
+ |
//push chi and integralOfChidt into SimInfo::properties which can be |
| 804 |
+ |
//retrieved by integrator later |
| 805 |
+ |
DoubleData* chiValue = new DoubleData(); |
| 806 |
+ |
chiValue->setID(CHIVALUE_ID); |
| 807 |
+ |
chiValue->setData(chi); |
| 808 |
+ |
simnfo->addProperty(chiValue); |
| 809 |
+ |
|
| 810 |
+ |
DoubleData* integralOfChidtValue = new DoubleData(); |
| 811 |
+ |
integralOfChidtValue->setID(INTEGRALOFCHIDT_ID); |
| 812 |
+ |
integralOfChidtValue->setData(integralOfChidt); |
| 813 |
+ |
simnfo->addProperty(integralOfChidtValue); |
| 814 |
+ |
|
| 815 |
+ |
} |
| 816 |
+ |
else |
| 817 |
+ |
return NULL; |
| 818 |
+ |
|
| 819 |
+ |
//get eta |
| 820 |
+ |
for(int i = 0 ; i < 9; i++){ |
| 821 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 822 |
+ |
if(foo == NULL){ |
| 823 |
+ |
sprintf( painCave.errMsg, |
| 824 |
+ |
"error in reading eta[%d] from %s\n", i, inName ); |
| 825 |
+ |
return strdup( painCave.errMsg ); |
| 826 |
+ |
} |
| 827 |
+ |
eta[i] = atof( foo ); |
| 828 |
+ |
} |
| 829 |
+ |
|
| 830 |
+ |
//push eta into SimInfo::properties which can be |
| 831 |
+ |
//retrieved by integrator later |
| 832 |
+ |
//simnfo->setBoxM( theBoxMat3 ); |
| 833 |
+ |
DoubleArrayData* etaValue = new DoubleArrayData(); |
| 834 |
+ |
etaValue->setID(ETAVALUE_ID); |
| 835 |
+ |
etaValue->setData(eta, 9); |
| 836 |
+ |
simnfo->addProperty(etaValue); |
| 837 |
+ |
|
| 838 |
+ |
|
| 839 |
|
return NULL; |
| 840 |
+ |
|
| 841 |
+ |
|
| 842 |
+ |
|
| 843 |
|
} |
| 844 |
|
|
| 845 |
|
|