| 59 |
|
|
| 60 |
|
int i; // loop counter |
| 61 |
|
|
| 62 |
+ |
const int BUFFERSIZE = 2000; // size of the read buffer |
| 63 |
|
int n_atoms; // the number of atoms |
| 64 |
< |
char read_buffer[2000]; //the line buffer for reading |
| 64 |
> |
char read_buffer[BUFFERSIZE]; //the line buffer for reading |
| 65 |
|
#ifdef IS_MPI |
| 66 |
< |
char send_buffer[2000]; |
| 66 |
> |
char send_buffer[BUFFERSIZE]; |
| 67 |
|
#endif |
| 68 |
|
|
| 69 |
|
char *eof_test; // ptr to see when we reach the end of the file |
| 70 |
< |
char *foo; // the pointer to the current string token |
| 70 |
> |
char *parseErr; |
| 71 |
|
|
| 71 |
– |
double rx, ry, rz; // position place holders |
| 72 |
– |
double vx, vy, vz; // velocity placeholders |
| 73 |
– |
double q[4]; // the quaternions |
| 74 |
– |
double jx, jy, jz; // angular velocity placeholders; |
| 75 |
– |
double qSqr, qLength; // needed to normalize the quaternion vector. |
| 72 |
|
|
| 73 |
|
entry_plug = the_entry_plug |
| 74 |
|
|
| 76 |
|
#ifndef IS_MPI |
| 77 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 78 |
|
if( eof_test == NULL ){ |
| 79 |
< |
std::cerr << "error reading 1st line of" << c_in_name << "\n"; |
| 79 |
> |
sprintf( painCave.errMsg, |
| 80 |
> |
"InitializeFromFile error: error reading 1st line of \"%s\"\n", |
| 81 |
> |
c_in_name ); |
| 82 |
> |
painCave.isFatal = 1; |
| 83 |
> |
simError(); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
< |
(void)sscanf(read_buffer, "%d", &n_atoms); |
| 86 |
> |
n_atoms = atoi( read_buffer ); |
| 87 |
|
|
| 88 |
|
Atom **atoms = entry_plug->atoms; |
| 89 |
|
DirectionalAtom* dAtom; |
| 120 |
|
simError(); |
| 121 |
|
} |
| 122 |
|
|
| 123 |
– |
foo = strtok(read_buffer, " ,;\t"); |
| 123 |
|
|
| 124 |
< |
// check the atom name to the current atom |
| 125 |
< |
|
| 126 |
< |
if( strcmp( foo, atoms[i]->getType() ) ){ |
| 128 |
< |
sprintf( painCave.errMsg, |
| 129 |
< |
"Initialize from file error. Atom %s at index %d " |
| 130 |
< |
"in file %s does not" |
| 131 |
< |
" match the BASS atom %s.\n", |
| 132 |
< |
foo, i, c_in_name, atoms[i]->getType() ); |
| 124 |
> |
parseErr = parseDumpLine( read_buffer, i ); |
| 125 |
> |
if( parseErr != NULL ){ |
| 126 |
> |
strcpy( painCave.errMsg, parseErr ); |
| 127 |
|
painCave.isFatal = 1; |
| 128 |
|
simError(); |
| 129 |
< |
} |
| 136 |
< |
|
| 137 |
< |
// get the positions |
| 138 |
< |
|
| 139 |
< |
foo = strtok(NULL, " ,;\t"); |
| 140 |
< |
if(foo == NULL){ |
| 141 |
< |
sprintf( painCave.errMsg, |
| 142 |
< |
"error in reading postition x from %s\n" |
| 143 |
< |
"natoms = %d, index = %d\n", |
| 144 |
< |
c_in_name, n_atoms, i ); |
| 145 |
< |
painCave.isFatal = 1; |
| 146 |
< |
simError(); |
| 147 |
< |
} |
| 148 |
< |
(void)sscanf( foo, "%lf", &rx ); |
| 149 |
< |
|
| 150 |
< |
foo = strtok(NULL, " ,;\t"); |
| 151 |
< |
if(foo == NULL){ |
| 152 |
< |
sprintf( painCave.errMsg, |
| 153 |
< |
"error in reading postition y from %s\n" |
| 154 |
< |
"natoms = %d, index = %d\n", |
| 155 |
< |
c_in_name, n_atoms, i ); |
| 156 |
< |
painCave.isFatal = 1; |
| 157 |
< |
simError(); |
| 158 |
< |
} |
| 159 |
< |
(void)sscanf( foo, "%lf", &ry ); |
| 160 |
< |
|
| 161 |
< |
foo = strtok(NULL, " ,;\t"); |
| 162 |
< |
if(foo == NULL){ |
| 163 |
< |
sprintf( painCave.errMsg, |
| 164 |
< |
"error in reading postition z from %s\n" |
| 165 |
< |
"natoms = %d, index = %d\n", |
| 166 |
< |
c_in_name, n_atoms, i ); |
| 167 |
< |
painCave.isFatal = 1; |
| 168 |
< |
simError(); |
| 169 |
< |
} |
| 170 |
< |
(void)sscanf( foo, "%lf", &rz ); |
| 171 |
< |
|
| 172 |
< |
// get the velocities |
| 173 |
< |
|
| 174 |
< |
foo = strtok(NULL, " ,;\t"); |
| 175 |
< |
if(foo == NULL){ |
| 176 |
< |
sprintf( painCave.errMsg, |
| 177 |
< |
"error in reading velocity x from %s\n" |
| 178 |
< |
"natoms = %d, index = %d\n", |
| 179 |
< |
c_in_name, n_atoms, i ); |
| 180 |
< |
painCave.isFatal = 1; |
| 181 |
< |
simError(); |
| 182 |
< |
} |
| 183 |
< |
(void)sscanf( foo, "%lf", &vx ); |
| 184 |
< |
|
| 185 |
< |
foo = strtok(NULL, " ,;\t"); |
| 186 |
< |
if(foo == NULL){ |
| 187 |
< |
sprintf( painCave.errMsg, |
| 188 |
< |
"error in reading velocity y from %s\n" |
| 189 |
< |
"natoms = %d, index = %d\n", |
| 190 |
< |
c_in_name, n_atoms, i ); |
| 191 |
< |
painCave.isFatal = 1; |
| 192 |
< |
simError(); |
| 193 |
< |
} |
| 194 |
< |
(void)sscanf( foo, "%lf", &vy ); |
| 195 |
< |
|
| 196 |
< |
foo = strtok(NULL, " ,;\t"); |
| 197 |
< |
if(foo == NULL){ |
| 198 |
< |
sprintf( painCave.errMsg, |
| 199 |
< |
"error in reading velocity z from %s\n" |
| 200 |
< |
"natoms = %d, index = %d\n", |
| 201 |
< |
c_in_name, n_atoms, i ); |
| 202 |
< |
painCave.isFatal = 1; |
| 203 |
< |
simError(); |
| 204 |
< |
} |
| 205 |
< |
(void)sscanf( foo, "%lf", &vz ); |
| 206 |
< |
|
| 207 |
< |
|
| 208 |
< |
// get the quaternions |
| 209 |
< |
|
| 210 |
< |
if( atoms[i]->isDirectional() ){ |
| 211 |
< |
|
| 212 |
< |
foo = strtok(NULL, " ,;\t"); |
| 213 |
< |
if(foo == NULL){ |
| 214 |
< |
sprintf(painCave.errMsg, |
| 215 |
< |
"error in reading quaternion 0 from %s\n" |
| 216 |
< |
"natoms = %d, index = %d\n", |
| 217 |
< |
c_in_name, n_atoms, i ); |
| 218 |
< |
painCave.isFatal = 1; |
| 219 |
< |
simError(); |
| 220 |
< |
} |
| 221 |
< |
(void)sscanf( foo, "%lf", &q[0] ); |
| 222 |
< |
|
| 223 |
< |
foo = strtok(NULL, " ,;\t"); |
| 224 |
< |
if(foo == NULL){ |
| 225 |
< |
sprintf( painCave.errMsg, |
| 226 |
< |
"error in reading quaternion 1 from %s\n" |
| 227 |
< |
"natoms = %d, index = %d\n", |
| 228 |
< |
c_in_name, n_atoms, i ); |
| 229 |
< |
painCave.isFatal = 1; |
| 230 |
< |
simError(); |
| 231 |
< |
} |
| 232 |
< |
(void)sscanf( foo, "%lf", &q[1] ); |
| 233 |
< |
|
| 234 |
< |
foo = strtok(NULL, " ,;\t"); |
| 235 |
< |
if(foo == NULL){ |
| 236 |
< |
sprintf( painCave.errMsg, |
| 237 |
< |
"error in reading quaternion 2 from %s\n" |
| 238 |
< |
"natoms = %d, index = %d\n", |
| 239 |
< |
c_in_name, n_atoms, i ); |
| 240 |
< |
painCave.isFatal = 1; |
| 241 |
< |
simError(); |
| 242 |
< |
} |
| 243 |
< |
(void)sscanf( foo, "%lf", &q[2] ); |
| 244 |
< |
|
| 245 |
< |
foo = strtok(NULL, " ,;\t"); |
| 246 |
< |
if(foo == NULL){ |
| 247 |
< |
sprintf( painCave.errMsg, |
| 248 |
< |
"error in reading quaternion 3 from %s\n" |
| 249 |
< |
"natoms = %d, index = %d\n", |
| 250 |
< |
c_in_name, n_atoms, i ); |
| 251 |
< |
painCave.isFatal = 1; |
| 252 |
< |
simError(); |
| 253 |
< |
} |
| 254 |
< |
(void)sscanf( foo, "%lf", &q[3] ); |
| 255 |
< |
|
| 256 |
< |
// get the angular velocities |
| 257 |
< |
|
| 258 |
< |
foo = strtok(NULL, " ,;\t"); |
| 259 |
< |
if(foo == NULL){ |
| 260 |
< |
sprintf( painCave.errMsg, |
| 261 |
< |
"error in reading angular momentum jx from %s\n" |
| 262 |
< |
"natoms = %d, index = %d\n", |
| 263 |
< |
c_in_name, n_atoms, i ); |
| 264 |
< |
painCave.isFatal = 1; |
| 265 |
< |
simError(); |
| 266 |
< |
} |
| 267 |
< |
(void)sscanf( foo, "%lf", &jx ); |
| 268 |
< |
|
| 269 |
< |
foo = strtok(NULL, " ,;\t"); |
| 270 |
< |
if(foo == NULL){ |
| 271 |
< |
sprintf( painCave.errMsg, |
| 272 |
< |
"error in reading angular momentum jy from %s\n" |
| 273 |
< |
"natoms = %d, index = %d\n", |
| 274 |
< |
c_in_name, n_atoms, i ); |
| 275 |
< |
painCave.isFatal = 1; |
| 276 |
< |
simError(); |
| 277 |
< |
} |
| 278 |
< |
(void)sscanf( foo, "%lf", &jy ); |
| 279 |
< |
|
| 280 |
< |
foo = strtok(NULL, " ,;\t"); |
| 281 |
< |
if(foo == NULL){ |
| 282 |
< |
sprintf( painCave.errMsg, |
| 283 |
< |
"error in reading angular momentum jz from %s\n" |
| 284 |
< |
"natoms = %d, index = %d\n", |
| 285 |
< |
c_in_name, n_atoms, i ); |
| 286 |
< |
painCave.isFatal = 1; |
| 287 |
< |
simError(); |
| 288 |
< |
} |
| 289 |
< |
(void)sscanf( foo, "%lf", &jz ); |
| 290 |
< |
|
| 291 |
< |
dAtom = ( DirectionalAtom* )atoms[i]; |
| 292 |
< |
|
| 293 |
< |
// check that the quaternion vector is normalized |
| 294 |
< |
|
| 295 |
< |
qSqr = (q[0] * q[0]) + (q[1] * q[1]) + (q[2] * q[2]) + (q[3] * q[3]); |
| 296 |
< |
|
| 297 |
< |
qLength = sqrt( qSqr ); |
| 298 |
< |
q[0] = q[0] / qLength; |
| 299 |
< |
q[1] = q[1] / qLength; |
| 300 |
< |
q[2] = q[2] / qLength; |
| 301 |
< |
q[3] = q[3] / qLength; |
| 302 |
< |
|
| 303 |
< |
dAtom->setQ( q ); |
| 304 |
< |
|
| 305 |
< |
// add the angular velocities |
| 306 |
< |
|
| 307 |
< |
dAtom->setJx( jx ); |
| 308 |
< |
dAtom->setJy( jy ); |
| 309 |
< |
dAtom->setJz( jz ); |
| 310 |
< |
} |
| 311 |
< |
|
| 312 |
< |
// add the positions and velocities to the atom |
| 313 |
< |
|
| 314 |
< |
atoms[i]->setX( rx ); |
| 315 |
< |
atoms[i]->setY( ry ); |
| 316 |
< |
atoms[i]->setZ( rz ); |
| 317 |
< |
|
| 318 |
< |
atoms[i]->set_vx( vx ); |
| 319 |
< |
atoms[i]->set_vy( vy ); |
| 320 |
< |
atoms[i]->set_vz( vz ); |
| 321 |
< |
|
| 129 |
> |
} |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
|
| 145 |
|
simError(); |
| 146 |
|
} |
| 147 |
|
|
| 148 |
< |
(void)sscanf(read_buffer, "%d", &n_atoms); |
| 148 |
> |
n_atoms = atoi( read_buffer ); |
| 149 |
|
|
| 150 |
|
Atom **atoms = entry_plug->atoms; |
| 151 |
|
DirectionalAtom* dAtom; |
| 152 |
|
|
| 153 |
< |
if( n_atoms != entry_plug->n_atoms ){ |
| 153 |
> |
if( n_atoms != entry_plug->mpiSim->getTotAtoms() ){ |
| 154 |
|
sprintf( painCave.errMsg, |
| 155 |
|
"Initialize from File error. %s n_atoms, %d, " |
| 156 |
|
"does not match the BASS file's n_atoms, %d.\n", |
| 169 |
|
simError(); |
| 170 |
|
} |
| 171 |
|
} |
| 172 |
+ |
|
| 173 |
|
for( i=0; i < n_atoms; i++){ |
| 174 |
|
|
| 175 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 182 |
|
painCave.isFatal = 1; |
| 183 |
|
simError(); |
| 184 |
|
} |
| 376 |
– |
|
| 377 |
– |
foo = strtok(read_buffer, " ,;\t"); |
| 185 |
|
|
| 186 |
< |
// check the atom name to the current atom |
| 187 |
< |
|
| 188 |
< |
if( strcmp( foo, atoms[i]->getType() ) ){ |
| 382 |
< |
sprintf( painCave.errMsg, |
| 383 |
< |
"Initialize from file error. Atom %s at index %d " |
| 384 |
< |
"in file %s does not" |
| 385 |
< |
" match the BASS atom %s.\n", |
| 386 |
< |
foo, i, c_in_name, atoms[i]->getType() ); |
| 186 |
> |
parseErr = parseDumpLine( read_buffer, i ); |
| 187 |
> |
if( parseErr != NULL ){ |
| 188 |
> |
strcpy( painCave.errMsg, parseErr ); |
| 189 |
|
painCave.isFatal = 1; |
| 190 |
|
simError(); |
| 191 |
< |
} |
| 191 |
> |
} |
| 192 |
> |
} |
| 193 |
> |
#endif |
| 194 |
> |
} |
| 195 |
> |
|
| 196 |
> |
|
| 197 |
> |
char* IntitializeFromFile::parseDumpLine(char* readLine, int atomIndex){ |
| 198 |
> |
|
| 199 |
> |
char *foo; // the pointer to the current string token |
| 200 |
> |
|
| 201 |
> |
double rx, ry, rz; // position place holders |
| 202 |
> |
double vx, vy, vz; // velocity placeholders |
| 203 |
> |
double q[4]; // the quaternions |
| 204 |
> |
double jx, jy, jz; // angular velocity placeholders; |
| 205 |
> |
double qSqr, qLength; // needed to normalize the quaternion vector. |
| 206 |
> |
|
| 207 |
> |
Atom **atoms = entry_plug->atoms; |
| 208 |
> |
DirectionalAtom* dAtom; |
| 209 |
> |
|
| 210 |
> |
int n_atoms; |
| 211 |
> |
|
| 212 |
> |
#ifdef IS_MPI |
| 213 |
> |
n_atoms = entry_plug->mpiSim->getTotAtoms(); |
| 214 |
> |
#else |
| 215 |
> |
n_atoms = entry_plug->n_atoms; |
| 216 |
> |
#endi // is_mpi |
| 217 |
> |
|
| 218 |
> |
|
| 219 |
> |
// set the string tokenizer |
| 220 |
> |
|
| 221 |
> |
foo = strtok(readLine, " ,;\t"); |
| 222 |
> |
|
| 223 |
> |
// check the atom name to the current atom |
| 224 |
> |
|
| 225 |
> |
if( strcmp( foo, atoms[atomIndex]->getType() ) ){ |
| 226 |
> |
sprintf( painCave.errMsg, |
| 227 |
> |
"Initialize from file error. Atom %s at index %d " |
| 228 |
> |
"in file %s does not" |
| 229 |
> |
" match the BASS atom %s.\n", |
| 230 |
> |
foo, atomIndex, c_in_name, atoms[atomIndex]->getType() ); |
| 231 |
> |
return strdup( painCave.errMsg ); |
| 232 |
> |
} |
| 233 |
|
|
| 234 |
< |
// get the positions |
| 234 |
> |
// get the positions |
| 235 |
> |
|
| 236 |
> |
foo = strtok(NULL, " ,;\t"); |
| 237 |
> |
if(foo == NULL){ |
| 238 |
> |
sprintf( painCave.errMsg, |
| 239 |
> |
"error in reading postition x from %s\n" |
| 240 |
> |
"natoms = %d, index = %d\n", |
| 241 |
> |
c_in_name, n_atoms, atomIndex ); |
| 242 |
> |
return strdup( painCave.errMsg ); |
| 243 |
> |
} |
| 244 |
> |
rx = atof( foo ); |
| 245 |
> |
|
| 246 |
> |
foo = strtok(NULL, " ,;\t"); |
| 247 |
> |
if(foo == NULL){ |
| 248 |
> |
sprintf( painCave.errMsg, |
| 249 |
> |
"error in reading postition y from %s\n" |
| 250 |
> |
"natoms = %d, index = %d\n", |
| 251 |
> |
c_in_name, n_atoms, atomIndex ); |
| 252 |
> |
return strdup( painCave.errMsg ); |
| 253 |
> |
} |
| 254 |
> |
ry = atof( foo ); |
| 255 |
> |
|
| 256 |
> |
foo = strtok(NULL, " ,;\t"); |
| 257 |
> |
if(foo == NULL){ |
| 258 |
> |
sprintf( painCave.errMsg, |
| 259 |
> |
"error in reading postition z from %s\n" |
| 260 |
> |
"natoms = %d, index = %d\n", |
| 261 |
> |
c_in_name, n_atoms, atomIndex ); |
| 262 |
> |
return strdup( painCave.errMsg ); |
| 263 |
> |
} |
| 264 |
> |
rz = atof( foo ); |
| 265 |
|
|
| 266 |
+ |
|
| 267 |
+ |
// get the velocities |
| 268 |
+ |
|
| 269 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 270 |
+ |
if(foo == NULL){ |
| 271 |
+ |
sprintf( painCave.errMsg, |
| 272 |
+ |
"error in reading velocity x from %s\n" |
| 273 |
+ |
"natoms = %d, index = %d\n", |
| 274 |
+ |
c_in_name, n_atoms, atomIndex ); |
| 275 |
+ |
return strdup( painCave.errMsg ); |
| 276 |
+ |
} |
| 277 |
+ |
vx = atof( foo ); |
| 278 |
+ |
|
| 279 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 280 |
+ |
if(foo == NULL){ |
| 281 |
+ |
sprintf( painCave.errMsg, |
| 282 |
+ |
"error in reading velocity y from %s\n" |
| 283 |
+ |
"natoms = %d, index = %d\n", |
| 284 |
+ |
c_in_name, n_atoms, atomIndex ); |
| 285 |
+ |
return strdup( painCave.errMsg ); |
| 286 |
+ |
} |
| 287 |
+ |
vy = atof( foo ); |
| 288 |
+ |
|
| 289 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 290 |
+ |
if(foo == NULL){ |
| 291 |
+ |
sprintf( painCave.errMsg, |
| 292 |
+ |
"error in reading velocity z from %s\n" |
| 293 |
+ |
"natoms = %d, index = %d\n", |
| 294 |
+ |
c_in_name, n_atoms, atomIndex ); |
| 295 |
+ |
return strdup( painCave.errMsg ); |
| 296 |
+ |
} |
| 297 |
+ |
vz = atof( foo ); |
| 298 |
+ |
|
| 299 |
+ |
|
| 300 |
+ |
// get the quaternions |
| 301 |
+ |
|
| 302 |
+ |
if( atoms[atomIndex]->isDirectional() ){ |
| 303 |
+ |
|
| 304 |
|
foo = strtok(NULL, " ,;\t"); |
| 305 |
|
if(foo == NULL){ |
| 306 |
+ |
sprintf(painCave.errMsg, |
| 307 |
+ |
"error in reading quaternion 0 from %s\n" |
| 308 |
+ |
"natoms = %d, index = %d\n", |
| 309 |
+ |
c_in_name, n_atoms, atomIndex ); |
| 310 |
+ |
return strdup( painCave.errMsg ); |
| 311 |
+ |
} |
| 312 |
+ |
q[0] = atof( foo ); |
| 313 |
+ |
|
| 314 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 315 |
+ |
if(foo == NULL){ |
| 316 |
|
sprintf( painCave.errMsg, |
| 317 |
< |
"error in reading postition x from %s\n" |
| 317 |
> |
"error in reading quaternion 1 from %s\n" |
| 318 |
|
"natoms = %d, index = %d\n", |
| 319 |
< |
c_in_name, n_atoms, i ); |
| 320 |
< |
painCave.isFatal = 1; |
| 400 |
< |
simError(); |
| 319 |
> |
c_in_name, n_atoms, atomIndex ); |
| 320 |
> |
return strdup( painCave.errMsg ); |
| 321 |
|
} |
| 322 |
< |
(void)sscanf( foo, "%lf", &rx ); |
| 323 |
< |
|
| 322 |
> |
q[1] = atof( foo ); |
| 323 |
> |
|
| 324 |
|
foo = strtok(NULL, " ,;\t"); |
| 325 |
|
if(foo == NULL){ |
| 326 |
|
sprintf( painCave.errMsg, |
| 327 |
< |
"error in reading postition y from %s\n" |
| 327 |
> |
"error in reading quaternion 2 from %s\n" |
| 328 |
|
"natoms = %d, index = %d\n", |
| 329 |
< |
c_in_name, n_atoms, i ); |
| 330 |
< |
painCave.isFatal = 1; |
| 411 |
< |
simError(); |
| 329 |
> |
c_in_name, n_atoms, atomIndex ); |
| 330 |
> |
return strdup( painCave.errMsg ); |
| 331 |
|
} |
| 332 |
< |
(void)sscanf( foo, "%lf", &ry ); |
| 333 |
< |
|
| 332 |
> |
q[2] = atof( foo ); |
| 333 |
> |
|
| 334 |
|
foo = strtok(NULL, " ,;\t"); |
| 335 |
|
if(foo == NULL){ |
| 336 |
|
sprintf( painCave.errMsg, |
| 337 |
< |
"error in reading postition z from %s\n" |
| 337 |
> |
"error in reading quaternion 3 from %s\n" |
| 338 |
|
"natoms = %d, index = %d\n", |
| 339 |
< |
c_in_name, n_atoms, i ); |
| 340 |
< |
painCave.isFatal = 1; |
| 422 |
< |
simError(); |
| 339 |
> |
c_in_name, n_atoms, atomIndex ); |
| 340 |
> |
return strdup( painCave.errMsg ); |
| 341 |
|
} |
| 342 |
< |
(void)sscanf( foo, "%lf", &rz ); |
| 343 |
< |
|
| 344 |
< |
// get the velocities |
| 345 |
< |
|
| 342 |
> |
q[3] = atof( foo ); |
| 343 |
> |
|
| 344 |
> |
// get the angular velocities |
| 345 |
> |
|
| 346 |
|
foo = strtok(NULL, " ,;\t"); |
| 347 |
|
if(foo == NULL){ |
| 348 |
|
sprintf( painCave.errMsg, |
| 349 |
< |
"error in reading velocity x from %s\n" |
| 349 |
> |
"error in reading angular momentum jx from %s\n" |
| 350 |
|
"natoms = %d, index = %d\n", |
| 351 |
< |
c_in_name, n_atoms, i ); |
| 352 |
< |
painCave.isFatal = 1; |
| 435 |
< |
simError(); |
| 351 |
> |
c_in_name, n_atoms, atomIndex ); |
| 352 |
> |
return strdup( painCave.errMsg ); |
| 353 |
|
} |
| 354 |
< |
(void)sscanf( foo, "%lf", &vx ); |
| 355 |
< |
|
| 354 |
> |
jx = atof( foo ); |
| 355 |
> |
|
| 356 |
|
foo = strtok(NULL, " ,;\t"); |
| 357 |
|
if(foo == NULL){ |
| 358 |
|
sprintf( painCave.errMsg, |
| 359 |
< |
"error in reading velocity y from %s\n" |
| 359 |
> |
"error in reading angular momentum jy from %s\n" |
| 360 |
|
"natoms = %d, index = %d\n", |
| 361 |
< |
c_in_name, n_atoms, i ); |
| 362 |
< |
painCave.isFatal = 1; |
| 446 |
< |
simError(); |
| 361 |
> |
c_in_name, n_atoms, atomIndex ); |
| 362 |
> |
return strdup( painCave.errMsg ); |
| 363 |
|
} |
| 364 |
< |
(void)sscanf( foo, "%lf", &vy ); |
| 365 |
< |
|
| 364 |
> |
jy = atof(foo ); |
| 365 |
> |
|
| 366 |
|
foo = strtok(NULL, " ,;\t"); |
| 367 |
|
if(foo == NULL){ |
| 368 |
|
sprintf( painCave.errMsg, |
| 369 |
< |
"error in reading velocity z from %s\n" |
| 369 |
> |
"error in reading angular momentum jz from %s\n" |
| 370 |
|
"natoms = %d, index = %d\n", |
| 371 |
< |
c_in_name, n_atoms, i ); |
| 372 |
< |
painCave.isFatal = 1; |
| 457 |
< |
simError(); |
| 371 |
> |
c_in_name, n_atoms, atomIndex ); |
| 372 |
> |
return strdup( painCave.errMsg ); |
| 373 |
|
} |
| 374 |
< |
(void)sscanf( foo, "%lf", &vz ); |
| 460 |
< |
|
| 461 |
< |
|
| 462 |
< |
// get the quaternions |
| 463 |
< |
|
| 464 |
< |
if( atoms[i]->isDirectional() ){ |
| 374 |
> |
jz = atof( foo ); |
| 375 |
|
|
| 376 |
< |
foo = strtok(NULL, " ,;\t"); |
| 467 |
< |
if(foo == NULL){ |
| 468 |
< |
sprintf(painCave.errMsg, |
| 469 |
< |
"error in reading quaternion 0 from %s\n" |
| 470 |
< |
"natoms = %d, index = %d\n", |
| 471 |
< |
c_in_name, n_atoms, i ); |
| 472 |
< |
painCave.isFatal = 1; |
| 473 |
< |
simError(); |
| 474 |
< |
} |
| 475 |
< |
(void)sscanf( foo, "%lf", &q[0] ); |
| 476 |
< |
|
| 477 |
< |
foo = strtok(NULL, " ,;\t"); |
| 478 |
< |
if(foo == NULL){ |
| 479 |
< |
sprintf( painCave.errMsg, |
| 480 |
< |
"error in reading quaternion 1 from %s\n" |
| 481 |
< |
"natoms = %d, index = %d\n", |
| 482 |
< |
c_in_name, n_atoms, i ); |
| 483 |
< |
painCave.isFatal = 1; |
| 484 |
< |
simError(); |
| 485 |
< |
} |
| 486 |
< |
(void)sscanf( foo, "%lf", &q[1] ); |
| 487 |
< |
|
| 488 |
< |
foo = strtok(NULL, " ,;\t"); |
| 489 |
< |
if(foo == NULL){ |
| 490 |
< |
sprintf( painCave.errMsg, |
| 491 |
< |
"error in reading quaternion 2 from %s\n" |
| 492 |
< |
"natoms = %d, index = %d\n", |
| 493 |
< |
c_in_name, n_atoms, i ); |
| 494 |
< |
painCave.isFatal = 1; |
| 495 |
< |
simError(); |
| 496 |
< |
} |
| 497 |
< |
(void)sscanf( foo, "%lf", &q[2] ); |
| 498 |
< |
|
| 499 |
< |
foo = strtok(NULL, " ,;\t"); |
| 500 |
< |
if(foo == NULL){ |
| 501 |
< |
sprintf( painCave.errMsg, |
| 502 |
< |
"error in reading quaternion 3 from %s\n" |
| 503 |
< |
"natoms = %d, index = %d\n", |
| 504 |
< |
c_in_name, n_atoms, i ); |
| 505 |
< |
painCave.isFatal = 1; |
| 506 |
< |
simError(); |
| 507 |
< |
} |
| 508 |
< |
(void)sscanf( foo, "%lf", &q[3] ); |
| 509 |
< |
|
| 510 |
< |
// get the angular velocities |
| 511 |
< |
|
| 512 |
< |
foo = strtok(NULL, " ,;\t"); |
| 513 |
< |
if(foo == NULL){ |
| 514 |
< |
sprintf( painCave.errMsg, |
| 515 |
< |
"error in reading angular momentum jx from %s\n" |
| 516 |
< |
"natoms = %d, index = %d\n", |
| 517 |
< |
c_in_name, n_atoms, i ); |
| 518 |
< |
painCave.isFatal = 1; |
| 519 |
< |
simError(); |
| 520 |
< |
} |
| 521 |
< |
(void)sscanf( foo, "%lf", &jx ); |
| 522 |
< |
|
| 523 |
< |
foo = strtok(NULL, " ,;\t"); |
| 524 |
< |
if(foo == NULL){ |
| 525 |
< |
sprintf( painCave.errMsg, |
| 526 |
< |
"error in reading angular momentum jy from %s\n" |
| 527 |
< |
"natoms = %d, index = %d\n", |
| 528 |
< |
c_in_name, n_atoms, i ); |
| 529 |
< |
painCave.isFatal = 1; |
| 530 |
< |
simError(); |
| 531 |
< |
} |
| 532 |
< |
(void)sscanf( foo, "%lf", &jy ); |
| 533 |
< |
|
| 534 |
< |
foo = strtok(NULL, " ,;\t"); |
| 535 |
< |
if(foo == NULL){ |
| 536 |
< |
sprintf( painCave.errMsg, |
| 537 |
< |
"error in reading angular momentum jz from %s\n" |
| 538 |
< |
"natoms = %d, index = %d\n", |
| 539 |
< |
c_in_name, n_atoms, i ); |
| 540 |
< |
painCave.isFatal = 1; |
| 541 |
< |
simError(); |
| 542 |
< |
} |
| 543 |
< |
(void)sscanf( foo, "%lf", &jz ); |
| 544 |
< |
|
| 545 |
< |
dAtom = ( DirectionalAtom* )atoms[i]; |
| 376 |
> |
dAtom = ( DirectionalAtom* )atoms[atomIndex]; |
| 377 |
|
|
| 378 |
< |
// check that the quaternion vector is normalized |
| 378 |
> |
// check that the quaternion vector is normalized |
| 379 |
|
|
| 380 |
< |
qSqr = (q[0] * q[0]) + (q[1] * q[1]) + (q[2] * q[2]) + (q[3] * q[3]); |
| 380 |
> |
qSqr = (q[0] * q[0]) + (q[1] * q[1]) + (q[2] * q[2]) + (q[3] * q[3]); |
| 381 |
|
|
| 382 |
< |
qLength = sqrt( qSqr ); |
| 383 |
< |
q[0] = q[0] / qLength; |
| 384 |
< |
q[1] = q[1] / qLength; |
| 385 |
< |
q[2] = q[2] / qLength; |
| 386 |
< |
q[3] = q[3] / qLength; |
| 382 |
> |
qLength = sqrt( qSqr ); |
| 383 |
> |
q[0] = q[0] / qLength; |
| 384 |
> |
q[1] = q[1] / qLength; |
| 385 |
> |
q[2] = q[2] / qLength; |
| 386 |
> |
q[3] = q[3] / qLength; |
| 387 |
|
|
| 388 |
< |
dAtom->setQ( q ); |
| 388 |
> |
dAtom->setQ( q ); |
| 389 |
|
|
| 390 |
< |
// add the angular velocities |
| 390 |
> |
// add the angular velocities |
| 391 |
|
|
| 392 |
< |
dAtom->setJx( jx ); |
| 393 |
< |
dAtom->setJy( jy ); |
| 394 |
< |
dAtom->setJz( jz ); |
| 395 |
< |
} |
| 392 |
> |
dAtom->setJx( jx ); |
| 393 |
> |
dAtom->setJy( jy ); |
| 394 |
> |
dAtom->setJz( jz ); |
| 395 |
> |
} |
| 396 |
|
|
| 397 |
< |
// add the positions and velocities to the atom |
| 397 |
> |
// add the positions and velocities to the atom |
| 398 |
|
|
| 399 |
< |
atoms[i]->setX( rx ); |
| 400 |
< |
atoms[i]->setY( ry ); |
| 401 |
< |
atoms[i]->setZ( rz ); |
| 399 |
> |
atoms[atomIndex]->setX( rx ); |
| 400 |
> |
atoms[atomIndex]->setY( ry ); |
| 401 |
> |
atoms[atomIndex]->setZ( rz ); |
| 402 |
|
|
| 403 |
< |
atoms[i]->set_vx( vx ); |
| 404 |
< |
atoms[i]->set_vy( vy ); |
| 405 |
< |
atoms[i]->set_vz( vz ); |
| 575 |
< |
|
| 576 |
< |
} |
| 577 |
< |
#endif |
| 578 |
< |
} |
| 403 |
> |
atoms[atomIndex]->set_vx( vx ); |
| 404 |
> |
atoms[atomIndex]->set_vy( vy ); |
| 405 |
> |
atoms[atomIndex]->set_vz( vz ); |
| 406 |
|
|
| 407 |
< |
char* IntitializeFromFile::parseDumpLine(char* readLine); |
| 407 |
> |
return NULL; |
| 408 |
> |
} |