16 |
|
#ifdef IS_MPI |
17 |
|
#include <mpi.h> |
18 |
|
#include "mpiSimulation.hpp" |
19 |
< |
#define TAKE_THIS_TAG_CHAR 0 |
20 |
< |
#define TAKE_THIS_TAG_INT 1 |
19 |
> |
#define TAKE_THIS_TAG_CHAR 3134 |
20 |
> |
#define TAKE_THIS_TAG_INT 3135 |
21 |
|
|
22 |
|
namespace initFile{ |
23 |
|
void nodeZeroError( void ); |
85 |
|
#endif //is_mpi |
86 |
|
|
87 |
|
const int BUFFERSIZE = 2000; // size of the read buffer |
88 |
< |
int n_atoms; // the number of atoms |
88 |
> |
int nTotObjs; // the number of atoms |
89 |
|
char read_buffer[BUFFERSIZE]; //the line buffer for reading |
90 |
|
|
91 |
|
char *eof_test; // ptr to see when we reach the end of the file |
92 |
|
char *parseErr; |
93 |
|
|
94 |
+ |
vector<StuntDouble*> integrableObjects; |
95 |
+ |
|
96 |
|
simnfo = the_simnfo; |
97 |
|
|
98 |
|
|
106 |
|
simError(); |
107 |
|
} |
108 |
|
|
109 |
< |
n_atoms = atoi( read_buffer ); |
109 |
> |
nTotObjs = atoi( read_buffer ); |
110 |
|
|
111 |
< |
if( n_atoms != simnfo->n_atoms ){ |
111 |
> |
if( nTotObjs != simnfo->getTotIntegrableObjects() ){ |
112 |
|
sprintf( painCave.errMsg, |
113 |
|
"Initialize from File error. %s n_atoms, %d, " |
114 |
|
"does not match the BASS file's n_atoms, %d.\n", |
115 |
< |
c_in_name, n_atoms, simnfo->n_atoms ); |
115 |
> |
c_in_name, nTotObjs, simnfo->getTotIntegrableObjects()); |
116 |
|
painCave.isFatal = 1; |
117 |
|
simError(); |
118 |
|
} |
127 |
|
simError(); |
128 |
|
} |
129 |
|
|
128 |
– |
|
129 |
– |
|
130 |
|
parseErr = parseCommentLine( read_buffer, simnfo); |
131 |
|
if( parseErr != NULL ){ |
132 |
|
strcpy( painCave.errMsg, parseErr ); |
136 |
|
|
137 |
|
//parse dump lines |
138 |
|
|
139 |
< |
for( i=0; i < n_atoms; i++){ |
139 |
> |
for( i=0; i < simnfo->n_mol; i++){ |
140 |
|
|
141 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
142 |
< |
if(eof_test == NULL){ |
143 |
< |
sprintf(painCave.errMsg, |
144 |
< |
"error in reading file %s\n" |
145 |
< |
"natoms = %d; index = %d\n" |
146 |
< |
"error reading the line from the file.\n", |
147 |
< |
c_in_name, n_atoms, i ); |
148 |
< |
painCave.isFatal = 1; |
149 |
< |
simError(); |
150 |
< |
} |
141 |
> |
integrableObjects = (simnfo->molecules[i]).getIntegrableObjects(); |
142 |
|
|
143 |
+ |
for(j = 0; j < integrableObjects.size(); j++){ |
144 |
|
|
145 |
< |
parseErr = parseDumpLine( read_buffer, i ); |
146 |
< |
if( parseErr != NULL ){ |
147 |
< |
strcpy( painCave.errMsg, parseErr ); |
148 |
< |
painCave.isFatal = 1; |
149 |
< |
simError(); |
145 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
146 |
> |
if(eof_test == NULL){ |
147 |
> |
sprintf(painCave.errMsg, |
148 |
> |
"error in reading file %s\n" |
149 |
> |
"natoms = %d; index = %d\n" |
150 |
> |
"error reading the line from the file.\n", |
151 |
> |
c_in_name, nTotObjs, i ); |
152 |
> |
painCave.isFatal = 1; |
153 |
> |
simError(); |
154 |
> |
} |
155 |
> |
|
156 |
> |
parseErr = parseDumpLine( read_buffer, integrableObjects[j]); |
157 |
> |
if( parseErr != NULL ){ |
158 |
> |
strcpy( painCave.errMsg, parseErr ); |
159 |
> |
painCave.isFatal = 1; |
160 |
> |
simError(); |
161 |
> |
} |
162 |
|
} |
163 |
|
} |
164 |
|
|
161 |
– |
|
165 |
|
// MPI Section of code.......... |
166 |
|
#else //IS_MPI |
167 |
|
|
172 |
|
int haveError; |
173 |
|
|
174 |
|
MPI_Status istatus; |
175 |
< |
int *AtomToProcMap = mpiSim->getAtomToProcMap(); |
175 |
> |
int *MolToProcMap = mpiSim->getMolToProcMap(); |
176 |
> |
int localIndex; |
177 |
> |
int nCurObj; |
178 |
> |
int nItems; |
179 |
|
|
180 |
< |
|
180 |
> |
nTotObjs = simnfo->getTotIntegrableObjects(); |
181 |
|
haveError = 0; |
182 |
|
if (worldRank == 0) { |
183 |
|
|
189 |
|
simError(); |
190 |
|
} |
191 |
|
|
192 |
< |
n_atoms = atoi( read_buffer ); |
192 |
> |
nItems = atoi( read_buffer ); |
193 |
|
|
194 |
< |
// Check to see that the number of atoms in the intial configuration file is the |
194 |
> |
// Check to see that the number of integrable objects in the intial configuration file is the |
195 |
|
// same as declared in simBass. |
196 |
|
|
197 |
< |
if( n_atoms != mpiSim->getTotAtoms() ){ |
197 |
> |
if( nTotObjs != nItems){ |
198 |
|
sprintf( painCave.errMsg, |
199 |
|
"Initialize from File error. %s n_atoms, %d, " |
200 |
|
"does not match the BASS file's n_atoms, %d.\n", |
201 |
< |
c_in_name, n_atoms, simnfo->n_atoms ); |
201 |
> |
c_in_name, nTotObjs, simnfo->getTotIntegrableObjects()); |
202 |
|
haveError= 1; |
203 |
|
simError(); |
204 |
|
} |
220 |
|
|
221 |
|
MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); |
222 |
|
|
223 |
+ |
cerr << "node " << worldRank << " finished MPI_Bcast" << endl; |
224 |
+ |
|
225 |
|
parseErr = parseCommentLine( read_buffer, simnfo); |
226 |
|
|
227 |
|
if( parseErr != NULL ){ |
230 |
|
simError(); |
231 |
|
} |
232 |
|
|
233 |
< |
for (i=0 ; i < mpiSim->getTotAtoms(); i++) { |
233 |
> |
for (i=0 ; i < mpiSim->getTotNmol(); i++) { |
234 |
> |
which_node = MolToProcMap[i]; |
235 |
> |
if(which_node == 0){ |
236 |
> |
//molecules belong to master node |
237 |
|
|
238 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
239 |
< |
if(eof_test == NULL){ |
240 |
< |
sprintf(painCave.errMsg, |
241 |
< |
"error in reading file %s\n" |
242 |
< |
"natoms = %d; index = %d\n" |
243 |
< |
"error reading the line from the file.\n", |
233 |
< |
c_in_name, n_atoms, i ); |
234 |
< |
haveError= 1; |
235 |
< |
simError(); |
238 |
> |
localIndex = mpiSim->getGlobalToLocalMol(i); |
239 |
> |
|
240 |
> |
if(localIndex == -1) { |
241 |
> |
strcpy(painCave.errMsg, "Molecule not found on node 0!"); |
242 |
> |
haveError = 1; |
243 |
> |
simError(); |
244 |
|
} |
245 |
|
|
246 |
< |
if(haveError) nodeZeroError(); |
246 |
> |
integrableObjects = (simnfo->molecules[localIndex]).getIntegrableObjects(); |
247 |
> |
for(j=0; j < integrableObjects.size(); j++){ |
248 |
> |
|
249 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
250 |
> |
if(eof_test == NULL){ |
251 |
> |
sprintf(painCave.errMsg, |
252 |
> |
"error in reading file %s\n" |
253 |
> |
"natoms = %d; index = %d\n" |
254 |
> |
"error reading the line from the file.\n", |
255 |
> |
c_in_name, nTotObjs, i ); |
256 |
> |
haveError= 1; |
257 |
> |
simError(); |
258 |
> |
} |
259 |
> |
|
260 |
> |
if(haveError) nodeZeroError(); |
261 |
|
|
262 |
< |
// Get the Node number which wants this atom: |
263 |
< |
which_node = AtomToProcMap[i]; |
264 |
< |
if (which_node == 0) { |
265 |
< |
parseErr = parseDumpLine( read_buffer, i ); |
266 |
< |
if( parseErr != NULL ){ |
245 |
< |
strcpy( painCave.errMsg, parseErr ); |
246 |
< |
haveError = 1; |
247 |
< |
simError(); |
248 |
< |
} |
249 |
< |
if(haveError) nodeZeroError(); |
262 |
> |
parseDumpLine(read_buffer, integrableObjects[j]); |
263 |
> |
|
264 |
> |
} |
265 |
> |
|
266 |
> |
|
267 |
|
} |
268 |
+ |
else{ |
269 |
+ |
//molecule belongs to slave nodes |
270 |
|
|
271 |
< |
else { |
271 |
> |
MPI_Recv(&nCurObj, 1, MPI_INT, which_node, |
272 |
> |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
273 |
> |
cerr << "node " << worldRank << " finished MPI_Send" << endl; |
274 |
> |
for(j=0; j < nCurObj; j++){ |
275 |
> |
|
276 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
277 |
> |
if(eof_test == NULL){ |
278 |
> |
sprintf(painCave.errMsg, |
279 |
> |
"error in reading file %s\n" |
280 |
> |
"natoms = %d; index = %d\n" |
281 |
> |
"error reading the line from the file.\n", |
282 |
> |
c_in_name, nTotObjs, i ); |
283 |
> |
haveError= 1; |
284 |
> |
simError(); |
285 |
> |
} |
286 |
> |
|
287 |
> |
if(haveError) nodeZeroError(); |
288 |
|
|
289 |
< |
myStatus = 1; |
290 |
< |
MPI_Send(&myStatus, 1, MPI_INT, which_node, |
291 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
292 |
< |
MPI_Send(read_buffer, BUFFERSIZE, MPI_CHAR, which_node, |
258 |
< |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); |
259 |
< |
MPI_Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
260 |
< |
MPI_COMM_WORLD); |
261 |
< |
MPI_Recv(&myStatus, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
262 |
< |
MPI_COMM_WORLD, &istatus); |
289 |
> |
MPI_Send(read_buffer, BUFFERSIZE, MPI_CHAR, which_node, |
290 |
> |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); |
291 |
> |
cerr << "node " << worldRank << " finished MPI_Send" << endl; |
292 |
> |
} |
293 |
|
|
264 |
– |
if(!myStatus) nodeZeroError(); |
294 |
|
} |
295 |
+ |
|
296 |
|
} |
297 |
< |
myStatus = -1; |
298 |
< |
for (j = 1; j < mpiSim->getNumberProcessors(); j++) { |
299 |
< |
MPI_Send( &myStatus, 1, MPI_INT, j, |
300 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
271 |
< |
} |
297 |
> |
|
298 |
> |
} |
299 |
> |
else{ |
300 |
> |
//actions taken at slave nodes |
301 |
|
|
273 |
– |
} else { |
274 |
– |
|
302 |
|
MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); |
303 |
|
|
304 |
+ |
cerr << "node " << worldRank << " finished MPI_Bcast" << endl; |
305 |
|
parseErr = parseCommentLine( read_buffer, simnfo); |
306 |
|
|
307 |
|
if( parseErr != NULL ){ |
309 |
|
haveError = 1; |
310 |
|
simError(); |
311 |
|
} |
312 |
+ |
|
313 |
+ |
for (i=0 ; i < mpiSim->getTotNmol(); i++) { |
314 |
+ |
which_node = MolToProcMap[i]; |
315 |
+ |
|
316 |
+ |
if(which_node == worldRank){ |
317 |
+ |
//molecule with global index i belongs to this processor |
318 |
+ |
|
319 |
+ |
localIndex = mpiSim->getGlobalToLocalMol(i); |
320 |
|
|
321 |
+ |
if(localIndex == -1) { |
322 |
+ |
sprintf(painCave.errMsg, "Molecule not found on node %d\n", worldRank); |
323 |
+ |
haveError = 1; |
324 |
+ |
simError(); |
325 |
+ |
} |
326 |
|
|
327 |
< |
done = 0; |
287 |
< |
while (!done) { |
327 |
> |
integrableObjects = (simnfo->molecules[localIndex]).getIntegrableObjects(); |
328 |
|
|
329 |
< |
MPI_Recv(&myStatus, 1, MPI_INT, 0, |
330 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
329 |
> |
nCurObj = integrableObjects.size(); |
330 |
> |
|
331 |
> |
MPI_Send(&nCurObj, 1, MPI_INT, 0, |
332 |
> |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
333 |
|
|
334 |
< |
if(!myStatus) anonymousNodeDie(); |
334 |
> |
cerr << "node " << worldRank << " finished MPI_Send" << endl; |
335 |
> |
for(j = 0; j < integrableObjects.size(); j++){ |
336 |
|
|
337 |
< |
if(myStatus < 0) break; |
337 |
> |
MPI_Recv(read_buffer, BUFFERSIZE, MPI_CHAR, 0, |
338 |
> |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); |
339 |
|
|
340 |
< |
MPI_Recv(read_buffer, BUFFERSIZE, MPI_CHAR, 0, |
341 |
< |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); |
298 |
< |
MPI_Recv(&which_atom, 1, MPI_INT, 0, |
299 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
340 |
> |
cerr << "node " << worldRank << " finished MPI_Recv" << endl; |
341 |
> |
parseErr = parseDumpLine(read_buffer, integrableObjects[j]); |
342 |
|
|
343 |
< |
myStatus = 1; |
344 |
< |
parseErr = parseDumpLine( read_buffer, which_atom ); |
345 |
< |
if( parseErr != NULL ){ |
346 |
< |
strcpy( painCave.errMsg, parseErr ); |
305 |
< |
myStatus = 0;; |
306 |
< |
simError(); |
307 |
< |
} |
343 |
> |
if( parseErr != NULL ){ |
344 |
> |
strcpy( painCave.errMsg, parseErr ); |
345 |
> |
simError(); |
346 |
> |
} |
347 |
|
|
348 |
< |
MPI_Send( &myStatus, 1, MPI_INT, 0, |
349 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
350 |
< |
|
348 |
> |
} |
349 |
> |
|
350 |
> |
} |
351 |
> |
|
352 |
|
} |
313 |
– |
} |
353 |
|
|
354 |
< |
// last thing last, enable fatalities. |
316 |
< |
painCave.isEventLoop = 0; |
317 |
< |
|
318 |
< |
|
319 |
< |
|
354 |
> |
} |
355 |
|
#endif |
356 |
|
} |
357 |
|
|
358 |
< |
char* InitializeFromFile::parseDumpLine(char* readLine, int globalIndex){ |
358 |
> |
char* InitializeFromFile::parseDumpLine(char* readLine, StuntDouble* sd){ |
359 |
|
|
360 |
|
char *foo; // the pointer to the current string token |
361 |
|
|
362 |
|
double pos[3]; // position place holders |
363 |
|
double vel[3]; // velocity placeholders |
364 |
|
double q[4]; // the quaternions |
365 |
< |
double jx, jy, jz; // angular velocity placeholders; |
365 |
> |
double ji[3]; // angular velocity placeholders; |
366 |
|
double qSqr, qLength; // needed to normalize the quaternion vector. |
367 |
|
|
333 |
– |
Atom **atoms = simnfo->atoms; |
334 |
– |
DirectionalAtom* dAtom; |
368 |
|
|
336 |
– |
int n_atoms, atomIndex; |
337 |
– |
|
338 |
– |
#ifdef IS_MPI |
339 |
– |
int j; |
340 |
– |
|
341 |
– |
n_atoms = mpiSim->getTotAtoms(); |
342 |
– |
atomIndex=-1; |
343 |
– |
for (j=0; j < mpiSim->getMyNlocal(); j++) { |
344 |
– |
if (atoms[j]->getGlobalIndex() == globalIndex) atomIndex = j; |
345 |
– |
} |
346 |
– |
if (atomIndex == -1) { |
347 |
– |
sprintf( painCave.errMsg, |
348 |
– |
"Initialize from file error. Atom at index %d " |
349 |
– |
"in file %s does not exist on processor %d .\n", |
350 |
– |
globalIndex, c_in_name, mpiSim->getMyNode() ); |
351 |
– |
return strdup( painCave.errMsg ); |
352 |
– |
} |
353 |
– |
#else |
354 |
– |
n_atoms = simnfo->n_atoms; |
355 |
– |
atomIndex = globalIndex; |
356 |
– |
#endif // is_mpi |
357 |
– |
|
369 |
|
// set the string tokenizer |
370 |
|
|
371 |
|
foo = strtok(readLine, " ,;\t"); |
372 |
|
|
373 |
|
// check the atom name to the current atom |
374 |
|
|
375 |
< |
if( strcmp( foo, atoms[atomIndex]->getType() ) ){ |
375 |
> |
if( strcmp( foo, sd->getType() ) ){ |
376 |
|
sprintf( painCave.errMsg, |
377 |
< |
"Initialize from file error. Atom %s at index %d " |
367 |
< |
"in file %s does not" |
377 |
> |
"Initialize from file error. Does not" |
378 |
|
" match the BASS atom %s.\n", |
379 |
< |
foo, atomIndex, c_in_name, atoms[atomIndex]->getType() ); |
379 |
> |
sd->getType() ); |
380 |
|
return strdup( painCave.errMsg ); |
381 |
|
} |
382 |
|
|
385 |
|
foo = strtok(NULL, " ,;\t"); |
386 |
|
if(foo == NULL){ |
387 |
|
sprintf( painCave.errMsg, |
388 |
< |
"error in reading postition x from %s\n" |
389 |
< |
"natoms = %d, index = %d\n", |
380 |
< |
c_in_name, n_atoms, atomIndex ); |
388 |
> |
"error in reading postition x from %s\n", |
389 |
> |
c_in_name); |
390 |
|
return strdup( painCave.errMsg ); |
391 |
|
} |
392 |
|
pos[0] = atof( foo ); |
394 |
|
foo = strtok(NULL, " ,;\t"); |
395 |
|
if(foo == NULL){ |
396 |
|
sprintf( painCave.errMsg, |
397 |
< |
"error in reading postition y from %s\n" |
398 |
< |
"natoms = %d, index = %d\n", |
390 |
< |
c_in_name, n_atoms, atomIndex ); |
397 |
> |
"error in reading postition y from %s\n", |
398 |
> |
c_in_name); |
399 |
|
return strdup( painCave.errMsg ); |
400 |
|
} |
401 |
|
pos[1] = atof( foo ); |
403 |
|
foo = strtok(NULL, " ,;\t"); |
404 |
|
if(foo == NULL){ |
405 |
|
sprintf( painCave.errMsg, |
406 |
< |
"error in reading postition z from %s\n" |
407 |
< |
"natoms = %d, index = %d\n", |
400 |
< |
c_in_name, n_atoms, atomIndex ); |
406 |
> |
"error in reading postition z from %s\n", |
407 |
> |
c_in_name); |
408 |
|
return strdup( painCave.errMsg ); |
409 |
|
} |
410 |
|
pos[2] = atof( foo ); |
415 |
|
foo = strtok(NULL, " ,;\t"); |
416 |
|
if(foo == NULL){ |
417 |
|
sprintf( painCave.errMsg, |
418 |
< |
"error in reading velocity x from %s\n" |
419 |
< |
"natoms = %d, index = %d\n", |
413 |
< |
c_in_name, n_atoms, atomIndex ); |
418 |
> |
"error in reading velocity x from %s\n", |
419 |
> |
c_in_name ); |
420 |
|
return strdup( painCave.errMsg ); |
421 |
|
} |
422 |
|
vel[0] = atof( foo ); |
424 |
|
foo = strtok(NULL, " ,;\t"); |
425 |
|
if(foo == NULL){ |
426 |
|
sprintf( painCave.errMsg, |
427 |
< |
"error in reading velocity y from %s\n" |
428 |
< |
"natoms = %d, index = %d\n", |
423 |
< |
c_in_name, n_atoms, atomIndex ); |
427 |
> |
"error in reading velocity x from %s\n", |
428 |
> |
c_in_name ); |
429 |
|
return strdup( painCave.errMsg ); |
430 |
|
} |
431 |
|
vel[1] = atof( foo ); |
433 |
|
foo = strtok(NULL, " ,;\t"); |
434 |
|
if(foo == NULL){ |
435 |
|
sprintf( painCave.errMsg, |
436 |
< |
"error in reading velocity z from %s\n" |
437 |
< |
"natoms = %d, index = %d\n", |
433 |
< |
c_in_name, n_atoms, atomIndex ); |
436 |
> |
"error in reading velocity x from %s\n", |
437 |
> |
c_in_name ); |
438 |
|
return strdup( painCave.errMsg ); |
439 |
|
} |
440 |
|
vel[2] = atof( foo ); |
441 |
|
|
442 |
|
|
443 |
+ |
// add the positions and velocities to the atom |
444 |
+ |
|
445 |
+ |
sd->setPos( pos ); |
446 |
+ |
sd->setVel( vel ); |
447 |
+ |
|
448 |
+ |
if (!sd->isDirectional()) |
449 |
+ |
return NULL; |
450 |
+ |
|
451 |
|
// get the quaternions |
452 |
|
|
453 |
< |
if( atoms[atomIndex]->isDirectional() ){ |
453 |
> |
if( sd->isDirectional() ){ |
454 |
|
|
455 |
|
foo = strtok(NULL, " ,;\t"); |
456 |
|
if(foo == NULL){ |
457 |
< |
sprintf(painCave.errMsg, |
458 |
< |
"error in reading quaternion 0 from %s\n" |
459 |
< |
"natoms = %d, index = %d\n", |
448 |
< |
c_in_name, n_atoms, atomIndex ); |
457 |
> |
sprintf( painCave.errMsg, |
458 |
> |
"error in reading velocity x from %s\n", |
459 |
> |
c_in_name ); |
460 |
|
return strdup( painCave.errMsg ); |
461 |
|
} |
462 |
|
q[0] = atof( foo ); |
464 |
|
foo = strtok(NULL, " ,;\t"); |
465 |
|
if(foo == NULL){ |
466 |
|
sprintf( painCave.errMsg, |
467 |
< |
"error in reading quaternion 1 from %s\n" |
468 |
< |
"natoms = %d, index = %d\n", |
458 |
< |
c_in_name, n_atoms, atomIndex ); |
467 |
> |
"error in reading velocity x from %s\n", |
468 |
> |
c_in_name ); |
469 |
|
return strdup( painCave.errMsg ); |
470 |
|
} |
471 |
|
q[1] = atof( foo ); |
473 |
|
foo = strtok(NULL, " ,;\t"); |
474 |
|
if(foo == NULL){ |
475 |
|
sprintf( painCave.errMsg, |
476 |
< |
"error in reading quaternion 2 from %s\n" |
477 |
< |
"natoms = %d, index = %d\n", |
468 |
< |
c_in_name, n_atoms, atomIndex ); |
476 |
> |
"error in reading velocity x from %s\n", |
477 |
> |
c_in_name ); |
478 |
|
return strdup( painCave.errMsg ); |
479 |
|
} |
480 |
|
q[2] = atof( foo ); |
482 |
|
foo = strtok(NULL, " ,;\t"); |
483 |
|
if(foo == NULL){ |
484 |
|
sprintf( painCave.errMsg, |
485 |
< |
"error in reading quaternion 3 from %s\n" |
486 |
< |
"natoms = %d, index = %d\n", |
478 |
< |
c_in_name, n_atoms, atomIndex ); |
485 |
> |
"error in reading velocity x from %s\n", |
486 |
> |
c_in_name ); |
487 |
|
return strdup( painCave.errMsg ); |
488 |
|
} |
489 |
|
q[3] = atof( foo ); |
493 |
|
foo = strtok(NULL, " ,;\t"); |
494 |
|
if(foo == NULL){ |
495 |
|
sprintf( painCave.errMsg, |
496 |
< |
"error in reading angular momentum jx from %s\n" |
497 |
< |
"natoms = %d, index = %d\n", |
490 |
< |
c_in_name, n_atoms, atomIndex ); |
496 |
> |
"error in reading velocity x from %s\n", |
497 |
> |
c_in_name ); |
498 |
|
return strdup( painCave.errMsg ); |
499 |
|
} |
500 |
< |
jx = atof( foo ); |
500 |
> |
ji[0] = atof( foo ); |
501 |
|
|
502 |
|
foo = strtok(NULL, " ,;\t"); |
503 |
|
if(foo == NULL){ |
504 |
|
sprintf( painCave.errMsg, |
505 |
< |
"error in reading angular momentum jy from %s\n" |
506 |
< |
"natoms = %d, index = %d\n", |
500 |
< |
c_in_name, n_atoms, atomIndex ); |
505 |
> |
"error in reading velocity x from %s\n", |
506 |
> |
c_in_name ); |
507 |
|
return strdup( painCave.errMsg ); |
508 |
|
} |
509 |
< |
jy = atof(foo ); |
509 |
> |
ji[1] = atof(foo ); |
510 |
|
|
511 |
|
foo = strtok(NULL, " ,;\t"); |
512 |
|
if(foo == NULL){ |
513 |
|
sprintf( painCave.errMsg, |
514 |
< |
"error in reading angular momentum jz from %s\n" |
515 |
< |
"natoms = %d, index = %d\n", |
510 |
< |
c_in_name, n_atoms, atomIndex ); |
514 |
> |
"error in reading velocity x from %s\n", |
515 |
> |
c_in_name ); |
516 |
|
return strdup( painCave.errMsg ); |
517 |
|
} |
518 |
< |
jz = atof( foo ); |
518 |
> |
ji[2] = atof( foo ); |
519 |
|
|
515 |
– |
dAtom = ( DirectionalAtom* )atoms[atomIndex]; |
520 |
|
|
521 |
|
// check that the quaternion vector is normalized |
522 |
|
|
528 |
|
q[2] = q[2] / qLength; |
529 |
|
q[3] = q[3] / qLength; |
530 |
|
|
531 |
< |
dAtom->setQ( q ); |
531 |
> |
// add quaternion and angular velocities |
532 |
|
|
533 |
< |
// add the angular velocities |
534 |
< |
|
531 |
< |
dAtom->setJx( jx ); |
532 |
< |
dAtom->setJy( jy ); |
533 |
< |
dAtom->setJz( jz ); |
533 |
> |
sd->setQ( q ); |
534 |
> |
sd->setJ( ji ); |
535 |
|
} |
536 |
|
|
536 |
– |
// add the positions and velocities to the atom |
537 |
|
|
538 |
– |
atoms[atomIndex]->setPos( pos ); |
539 |
– |
atoms[atomIndex]->setVel( vel ); |
538 |
|
|
539 |
|
return NULL; |
540 |
|
} |
616 |
|
return NULL; |
617 |
|
|
618 |
|
//get eta |
619 |
< |
for(int i = 0 ; i < 9; i++){ |
620 |
< |
foo = strtok(NULL, " ,;\t"); |
621 |
< |
if(foo == NULL){ |
622 |
< |
sprintf( painCave.errMsg, |
623 |
< |
"error in reading eta[%d] from %s\n", i, c_in_name ); |
624 |
< |
return strdup( painCave.errMsg ); |
619 |
> |
foo = strtok(NULL, " ,;\t\n"); |
620 |
> |
if(foo != NULL ){ |
621 |
> |
|
622 |
> |
for(int i = 0 ; i < 9; i++){ |
623 |
> |
|
624 |
> |
if(foo == NULL){ |
625 |
> |
sprintf( painCave.errMsg, |
626 |
> |
"error in reading eta[%d] from %s\n", i, c_in_name ); |
627 |
> |
return strdup( painCave.errMsg ); |
628 |
> |
} |
629 |
> |
eta[i] = atof( foo ); |
630 |
> |
foo = strtok(NULL, " ,;\t\n"); |
631 |
|
} |
628 |
– |
eta[i] = atof( foo ); |
632 |
|
} |
633 |
+ |
else |
634 |
+ |
return NULL; |
635 |
|
|
636 |
|
//push eta into SimInfo::properties which can be |
637 |
|
//retrieved by integrator later |
638 |
< |
//entry_plug->setBoxM( theBoxMat3 ); |
638 |
> |
|
639 |
|
DoubleArrayData* etaValue = new DoubleArrayData(); |
640 |
|
etaValue->setID(ETAVALUE_ID); |
641 |
|
etaValue->setData(eta, 9); |