| 1 | 
+ | 
#define _FILE_OFFSET_BITS 64 | 
| 2 | 
+ | 
 | 
| 3 | 
  | 
#include <cstring> | 
| 4 | 
  | 
#include <iostream> | 
| 5 | 
  | 
#include <fstream> | 
| 29 | 
  | 
  if(worldRank == 0 ){ | 
| 30 | 
  | 
#endif // is_mpi | 
| 31 | 
  | 
     | 
| 30 | 
– | 
  | 
| 31 | 
– | 
     | 
| 32 | 
  | 
    strcpy( outName, entry_plug->sampleName ); | 
| 33 | 
  | 
     | 
| 34 | 
  | 
    outFile.open(outName, ios::out | ios::trunc ); | 
| 41 | 
  | 
      painCave.isFatal = 1; | 
| 42 | 
  | 
      simError(); | 
| 43 | 
  | 
    } | 
| 44 | 
< | 
   | 
| 44 | 
> | 
 | 
| 45 | 
  | 
    //outFile.setf( ios::scientific ); | 
| 46 | 
  | 
 | 
| 47 | 
  | 
#ifdef IS_MPI | 
| 72 | 
  | 
  char tempBuffer[BUFFERSIZE]; | 
| 73 | 
  | 
  char writeLine[BUFFERSIZE]; | 
| 74 | 
  | 
 | 
| 75 | 
< | 
  int i, j, which_node, done, game_over, which_atom, local_index; | 
| 75 | 
> | 
  int i, j, which_node, done, which_atom, local_index; | 
| 76 | 
  | 
  double q[4]; | 
| 77 | 
  | 
  DirectionalAtom* dAtom; | 
| 78 | 
  | 
  int nAtoms = entry_plug->n_atoms; | 
| 79 | 
  | 
  Atom** atoms = entry_plug->atoms; | 
| 80 | 
+ | 
 | 
| 81 | 
+ | 
  double pos[3], vel[3]; | 
| 82 | 
  | 
     | 
| 83 | 
  | 
 | 
| 84 | 
  | 
#ifndef IS_MPI | 
| 85 | 
  | 
     | 
| 86 | 
  | 
  outFile << nAtoms << "\n"; | 
| 87 | 
  | 
     | 
| 88 | 
< | 
  outFile << currentTime << "\t"  | 
| 89 | 
< | 
          << entry_plug->box_x << "\t" | 
| 90 | 
< | 
          << entry_plug->box_y << "\t" | 
| 91 | 
< | 
          << entry_plug->box_z << "\n"; | 
| 88 | 
> | 
  outFile << currentTime << ";\t"  | 
| 89 | 
> | 
          << entry_plug->Hmat[0][0] << "\t" | 
| 90 | 
> | 
          << entry_plug->Hmat[1][0] << "\t" | 
| 91 | 
> | 
          << entry_plug->Hmat[2][0] << ";\t" | 
| 92 | 
> | 
 | 
| 93 | 
> | 
          << entry_plug->Hmat[0][1] << "\t" | 
| 94 | 
> | 
          << entry_plug->Hmat[1][1] << "\t" | 
| 95 | 
> | 
          << entry_plug->Hmat[2][1] << ";\t" | 
| 96 | 
> | 
 | 
| 97 | 
> | 
          << entry_plug->Hmat[0][2] << "\t" | 
| 98 | 
> | 
          << entry_plug->Hmat[1][2] << "\t" | 
| 99 | 
> | 
          << entry_plug->Hmat[2][2] << ";\n"; | 
| 100 | 
  | 
     | 
| 101 | 
  | 
  for( i=0; i<nAtoms; i++ ){ | 
| 102 | 
  | 
       | 
| 103 | 
+ | 
    atoms[i]->getPos(pos); | 
| 104 | 
+ | 
    atoms[i]->getVel(vel); | 
| 105 | 
  | 
 | 
| 106 | 
  | 
    sprintf( tempBuffer, | 
| 107 | 
  | 
             "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 108 | 
  | 
             atoms[i]->getType(), | 
| 109 | 
< | 
             atoms[i]->getX(), | 
| 110 | 
< | 
             atoms[i]->getY(), | 
| 111 | 
< | 
             atoms[i]->getZ(), | 
| 112 | 
< | 
             atoms[i]->get_vx(), | 
| 113 | 
< | 
             atoms[i]->get_vy(), | 
| 114 | 
< | 
             atoms[i]->get_vz()); | 
| 109 | 
> | 
             pos[0], | 
| 110 | 
> | 
             pos[1], | 
| 111 | 
> | 
             pos[2], | 
| 112 | 
> | 
             vel[0], | 
| 113 | 
> | 
             vel[1], | 
| 114 | 
> | 
             vel[2]); | 
| 115 | 
  | 
    strcpy( writeLine, tempBuffer ); | 
| 116 | 
  | 
 | 
| 117 | 
  | 
    if( atoms[i]->isDirectional() ){ | 
| 152 | 
  | 
   | 
| 153 | 
  | 
  if( worldRank == 0 ){ | 
| 154 | 
  | 
    outFile << mpiSim->getTotAtoms() << "\n"; | 
| 155 | 
+ | 
   | 
| 156 | 
+ | 
    outFile << currentTime << ";\t"  | 
| 157 | 
+ | 
            << entry_plug->Hmat[0][0] << "\t" | 
| 158 | 
+ | 
            << entry_plug->Hmat[1][0] << "\t" | 
| 159 | 
+ | 
            << entry_plug->Hmat[2][0] << ";\t" | 
| 160 | 
+ | 
       | 
| 161 | 
+ | 
            << entry_plug->Hmat[0][1] << "\t" | 
| 162 | 
+ | 
            << entry_plug->Hmat[1][1] << "\t" | 
| 163 | 
+ | 
            << entry_plug->Hmat[2][1] << ";\t" | 
| 164 | 
+ | 
       | 
| 165 | 
+ | 
            << entry_plug->Hmat[0][2] << "\t" | 
| 166 | 
+ | 
            << entry_plug->Hmat[1][2] << "\t" | 
| 167 | 
+ | 
            << entry_plug->Hmat[2][2] << ";\n"; | 
| 168 | 
  | 
     | 
| 144 | 
– | 
    outFile << currentTime << "\t"  | 
| 145 | 
– | 
            << entry_plug->box_x << "\t" | 
| 146 | 
– | 
            << entry_plug->box_y << "\t" | 
| 147 | 
– | 
            << entry_plug->box_z << "\n"; | 
| 169 | 
  | 
    outFile.flush(); | 
| 170 | 
  | 
    for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { | 
| 171 | 
  | 
      // Get the Node number which has this atom; | 
| 182 | 
  | 
        } | 
| 183 | 
  | 
        if (local_index != -1) { | 
| 184 | 
  | 
          //format the line | 
| 185 | 
+ | 
           | 
| 186 | 
+ | 
          atoms[local_index]->getPos(pos); | 
| 187 | 
+ | 
          atoms[local_index]->getVel(vel); | 
| 188 | 
+ | 
 | 
| 189 | 
  | 
          sprintf( tempBuffer, | 
| 190 | 
  | 
                   "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 191 | 
  | 
                   atoms[local_index]->getType(), | 
| 192 | 
< | 
                   atoms[local_index]->getX(), | 
| 193 | 
< | 
                   atoms[local_index]->getY(), | 
| 194 | 
< | 
                   atoms[local_index]->getZ(), | 
| 195 | 
< | 
                   atoms[local_index]->get_vx(), | 
| 196 | 
< | 
                   atoms[local_index]->get_vy(), | 
| 197 | 
< | 
                   atoms[local_index]->get_vz()); // check here. | 
| 192 | 
> | 
                   pos[0], | 
| 193 | 
> | 
                   pos[1], | 
| 194 | 
> | 
                   pos[2], | 
| 195 | 
> | 
                   vel[0], | 
| 196 | 
> | 
                   vel[1], | 
| 197 | 
> | 
                   vel[2]); // check here. | 
| 198 | 
  | 
          strcpy( writeLine, tempBuffer ); | 
| 199 | 
  | 
           | 
| 200 | 
  | 
          if( atoms[local_index]->isDirectional() ){ | 
| 276 | 
  | 
      } | 
| 277 | 
  | 
      if (local_index != -1) { | 
| 278 | 
  | 
        //format the line | 
| 279 | 
+ | 
 | 
| 280 | 
+ | 
        atoms[local_index]->getPos(pos); | 
| 281 | 
+ | 
        atoms[local_index]->getVel(vel); | 
| 282 | 
+ | 
 | 
| 283 | 
  | 
        sprintf( tempBuffer, | 
| 284 | 
  | 
                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 285 | 
  | 
                 atoms[local_index]->getType(), | 
| 286 | 
< | 
                 atoms[local_index]->getX(), | 
| 287 | 
< | 
                 atoms[local_index]->getY(), | 
| 288 | 
< | 
                 atoms[local_index]->getZ(), | 
| 289 | 
< | 
                 atoms[local_index]->get_vx(), | 
| 290 | 
< | 
                 atoms[local_index]->get_vy(), | 
| 291 | 
< | 
                 atoms[local_index]->get_vz()); // check here. | 
| 286 | 
> | 
                 pos[0], | 
| 287 | 
> | 
                 pos[1], | 
| 288 | 
> | 
                 pos[2], | 
| 289 | 
> | 
                 vel[0], | 
| 290 | 
> | 
                 vel[1], | 
| 291 | 
> | 
                 vel[2]); // check here. | 
| 292 | 
  | 
        strcpy( writeLine, tempBuffer ); | 
| 293 | 
  | 
         | 
| 294 | 
  | 
        if( atoms[local_index]->isDirectional() ){ | 
| 338 | 
  | 
#endif // is_mpi | 
| 339 | 
  | 
} | 
| 340 | 
  | 
 | 
| 341 | 
< | 
void DumpWriter::writeFinal(){ | 
| 341 | 
> | 
void DumpWriter::writeFinal(double finalTime){ | 
| 342 | 
  | 
 | 
| 343 | 
  | 
  char finalName[500]; | 
| 344 | 
  | 
  ofstream finalOut; | 
| 353 | 
  | 
  Atom** atoms = entry_plug->atoms; | 
| 354 | 
  | 
  int i, j, which_node, done, game_over, which_atom, local_index; | 
| 355 | 
  | 
   | 
| 356 | 
+ | 
  double pos[3], vel[3]; | 
| 357 | 
  | 
   | 
| 358 | 
  | 
#ifdef IS_MPI | 
| 359 | 
  | 
  if(worldRank == 0 ){ | 
| 385 | 
  | 
     | 
| 386 | 
  | 
  finalOut << nAtoms << "\n"; | 
| 387 | 
  | 
     | 
| 388 | 
< | 
  finalOut << entry_plug->box_x << "\t" | 
| 389 | 
< | 
           << entry_plug->box_y << "\t" | 
| 390 | 
< | 
           << entry_plug->box_z << "\n"; | 
| 388 | 
> | 
  finalOut << finalTime << ";\t" | 
| 389 | 
> | 
           << entry_plug->Hmat[0][0] << "\t" | 
| 390 | 
> | 
           << entry_plug->Hmat[1][0] << "\t" | 
| 391 | 
> | 
           << entry_plug->Hmat[2][0] << ";\t" | 
| 392 | 
> | 
     | 
| 393 | 
> | 
           << entry_plug->Hmat[0][1] << "\t" | 
| 394 | 
> | 
           << entry_plug->Hmat[1][1] << "\t" | 
| 395 | 
> | 
           << entry_plug->Hmat[2][1] << ";\t" | 
| 396 | 
> | 
     | 
| 397 | 
> | 
           << entry_plug->Hmat[0][2] << "\t" | 
| 398 | 
> | 
           << entry_plug->Hmat[1][2] << "\t" | 
| 399 | 
> | 
           << entry_plug->Hmat[2][2] << ";\n"; | 
| 400 | 
  | 
   | 
| 401 | 
  | 
  for( i=0; i<nAtoms; i++ ){ | 
| 402 | 
  | 
       | 
| 403 | 
+ | 
    atoms[i]->getPos(pos); | 
| 404 | 
+ | 
    atoms[i]->getVel(vel); | 
| 405 | 
+ | 
     | 
| 406 | 
  | 
    sprintf( tempBuffer, | 
| 407 | 
  | 
             "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 408 | 
  | 
             atoms[i]->getType(), | 
| 409 | 
< | 
             atoms[i]->getX(), | 
| 410 | 
< | 
             atoms[i]->getY(), | 
| 411 | 
< | 
             atoms[i]->getZ(), | 
| 412 | 
< | 
             atoms[i]->get_vx(), | 
| 413 | 
< | 
             atoms[i]->get_vy(), | 
| 414 | 
< | 
             atoms[i]->get_vz()); | 
| 409 | 
> | 
             pos[0], | 
| 410 | 
> | 
             pos[1], | 
| 411 | 
> | 
             pos[2], | 
| 412 | 
> | 
             vel[0], | 
| 413 | 
> | 
             vel[1], | 
| 414 | 
> | 
             vel[2]); | 
| 415 | 
  | 
    strcpy( writeLine, tempBuffer ); | 
| 416 | 
  | 
 | 
| 417 | 
  | 
    if( atoms[i]->isDirectional() ){ | 
| 455 | 
  | 
  if( worldRank == 0 ){ | 
| 456 | 
  | 
    finalOut << mpiSim->getTotAtoms() << "\n"; | 
| 457 | 
  | 
     | 
| 458 | 
< | 
    finalOut << entry_plug->box_x << "\t" | 
| 459 | 
< | 
            << entry_plug->box_y << "\t" | 
| 460 | 
< | 
            << entry_plug->box_z << "\n"; | 
| 458 | 
> | 
    finalOut << finalTime << ";\t" | 
| 459 | 
> | 
             << entry_plug->Hmat[0][0] << "\t" | 
| 460 | 
> | 
             << entry_plug->Hmat[1][0] << "\t" | 
| 461 | 
> | 
             << entry_plug->Hmat[2][0] << ";\t" | 
| 462 | 
> | 
       | 
| 463 | 
> | 
             << entry_plug->Hmat[0][1] << "\t" | 
| 464 | 
> | 
             << entry_plug->Hmat[1][1] << "\t" | 
| 465 | 
> | 
             << entry_plug->Hmat[2][1] << ";\t" | 
| 466 | 
> | 
       | 
| 467 | 
> | 
             << entry_plug->Hmat[0][2] << "\t" | 
| 468 | 
> | 
             << entry_plug->Hmat[1][2] << "\t" | 
| 469 | 
> | 
             << entry_plug->Hmat[2][2] << ";\n"; | 
| 470 | 
  | 
     | 
| 471 | 
  | 
    for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { | 
| 472 | 
  | 
      // Get the Node number which has this molecule: | 
| 480 | 
  | 
        for (j=0; (j<mpiSim->getMyNlocal()) && (local_index < 0); j++) { | 
| 481 | 
  | 
          if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; | 
| 482 | 
  | 
        } | 
| 483 | 
< | 
        if (local_index != -1) {         | 
| 483 | 
> | 
        if (local_index != -1) {     | 
| 484 | 
> | 
 | 
| 485 | 
> | 
          atoms[local_index]->getPos(pos); | 
| 486 | 
> | 
          atoms[local_index]->getVel(vel); | 
| 487 | 
> | 
           | 
| 488 | 
  | 
          sprintf( tempBuffer, | 
| 489 | 
  | 
                   "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 490 | 
  | 
                   atoms[local_index]->getType(), | 
| 491 | 
< | 
                   atoms[local_index]->getX(), | 
| 492 | 
< | 
                   atoms[local_index]->getY(), | 
| 493 | 
< | 
                   atoms[local_index]->getZ(), | 
| 494 | 
< | 
                   atoms[local_index]->get_vx(), | 
| 495 | 
< | 
                   atoms[local_index]->get_vy(), | 
| 496 | 
< | 
                   atoms[local_index]->get_vz()); | 
| 491 | 
> | 
                   pos[0], | 
| 492 | 
> | 
                   pos[1], | 
| 493 | 
> | 
                   pos[2], | 
| 494 | 
> | 
                   vel[0], | 
| 495 | 
> | 
                   vel[1], | 
| 496 | 
> | 
                   vel[2]); | 
| 497 | 
  | 
          strcpy( writeLine, tempBuffer ); | 
| 498 | 
  | 
           | 
| 499 | 
  | 
          if( atoms[local_index]->isDirectional() ){ | 
| 573 | 
  | 
      } | 
| 574 | 
  | 
      if (local_index != -1) { | 
| 575 | 
  | 
 | 
| 576 | 
+ | 
        atoms[local_index]->getPos(pos); | 
| 577 | 
+ | 
        atoms[local_index]->getVel(vel); | 
| 578 | 
+ | 
 | 
| 579 | 
  | 
        //format the line | 
| 580 | 
  | 
        sprintf( tempBuffer, | 
| 581 | 
  | 
                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 582 | 
  | 
                 atoms[local_index]->getType(), | 
| 583 | 
< | 
                 atoms[local_index]->getX(), | 
| 584 | 
< | 
                 atoms[local_index]->getY(), | 
| 585 | 
< | 
                 atoms[local_index]->getZ(), | 
| 586 | 
< | 
                 atoms[local_index]->get_vx(), | 
| 587 | 
< | 
                 atoms[local_index]->get_vy(), | 
| 588 | 
< | 
                 atoms[local_index]->get_vz()); // check here. | 
| 583 | 
> | 
                 pos[0], | 
| 584 | 
> | 
                 pos[1], | 
| 585 | 
> | 
                 pos[2], | 
| 586 | 
> | 
                 vel[0], | 
| 587 | 
> | 
                 vel[1], | 
| 588 | 
> | 
                 vel[2]); // check here. | 
| 589 | 
  | 
        strcpy( writeLine, tempBuffer ); | 
| 590 | 
  | 
         | 
| 591 | 
  | 
        if( atoms[local_index]->isDirectional() ){ |