Output Class Reference

#include <Output.h>

List of all members.

Public Member Functions

 Output ()
 ~Output ()
void energy (int, BigReal *)
void coordinate (int, int, Vector *, FloatVector *, Lattice &)
void velocity (int, int, Vector *)
void force (int, int, Vector *)
void replicaDcdOff ()
void setReplicaDcdIndex (int index)
void replicaDcdInit (int index, const char *filename)
void recvReplicaDcdInit (ReplicaDcdInitMsg *msg)
void recvReplicaDcdData (ReplicaDcdDataMsg *msg)

Static Public Member Functions

static int coordinateNeeded (int)
static int velocityNeeded (int)
static int forceNeeded (int)

Friends

class SimParameters

Classes

struct  replicaDcdFile


Detailed Description

Definition at line 43 of file Output.h.


Constructor & Destructor Documentation

Output::Output (  ) 

Definition at line 164 of file Output.C.

00164 : replicaDcdActive(0) { }

Output::~Output (  ) 

Definition at line 174 of file Output.C.

00174 { }


Member Function Documentation

void Output::coordinate ( int  ,
int  ,
Vector ,
FloatVector ,
Lattice  
)

Definition at line 273 of file Output.C.

References END_OF_RUN, endi(), EVAL_MEASURE, FILE_OUTPUT, IMDOutput::gather_coordinates(), Node::getScript(), Node::imd, iout, ScriptTcl::measure(), Node::Object(), Node::simParameters, simParams, and wrap_coor().

Referenced by CollectionMaster::disposePositions().

00275 {
00276   SimParameters *simParams = Node::Object()->simParameters;
00277   double coor_wrapped = 0;
00278   float fcoor_wrapped = 0;
00279 
00280   if ( timestep >= 0 ) {
00281 
00282     //  Output a DCD trajectory 
00283     if ( simParams->dcdFrequency &&
00284        ((timestep % simParams->dcdFrequency) == 0) )
00285     {
00286       wrap_coor(fcoor,lattice,&fcoor_wrapped);
00287       output_dcdfile(timestep, n, fcoor, 
00288           simParams->dcdUnitCell ? &lattice : NULL);
00289     }
00290 
00291     //  Output a restart file
00292     if ( simParams->restartFrequency &&
00293        ((timestep % simParams->restartFrequency) == 0) )
00294     {
00295       iout << "WRITING COORDINATES TO RESTART FILE AT STEP "
00296                                 << timestep << "\n" << endi;
00297       wrap_coor(coor,lattice,&coor_wrapped);
00298       output_restart_coordinates(coor, n, timestep);
00299       iout << "FINISHED WRITING RESTART COORDINATES\n" <<endi;
00300       fflush(stdout);
00301     }
00302 
00303     //  Interactive MD
00304     if ( simParams->IMDon &&
00305        ( ((timestep % simParams->IMDfreq) == 0) ||
00306          (timestep == simParams->firstTimestep) ) )
00307     {
00308       IMDOutput *imd = Node::Object()->imd;
00309       wrap_coor(fcoor,lattice,&fcoor_wrapped);
00310       if (imd != NULL) imd->gather_coordinates(timestep, n, fcoor);
00311     }
00312 
00313   }
00314 
00315   if (timestep == EVAL_MEASURE)
00316   {
00317 #ifdef NAMD_TCL
00318     wrap_coor(coor,lattice,&coor_wrapped);
00319     Node::Object()->getScript()->measure(coor);
00320 #endif
00321   }
00322 
00323   //  Output final coordinates
00324   if (timestep == FILE_OUTPUT || timestep == END_OF_RUN)
00325   {
00326     int realstep = ( timestep == FILE_OUTPUT ?
00327           simParams->firstTimestep : simParams->N );
00328     iout << "WRITING COORDINATES TO OUTPUT FILE AT STEP "
00329                                 << realstep << "\n" << endi;
00330     fflush(stdout);
00331     wrap_coor(coor,lattice,&coor_wrapped);
00332     output_final_coordinates(coor, n, realstep);
00333   }
00334 
00335   //  Close trajectory files
00336   if (timestep == END_OF_RUN)
00337   {
00338     if (simParams->dcdFrequency) output_dcdfile(END_OF_RUN,0,0, 
00339         simParams->dcdUnitCell ? &lattice : NULL);
00340   }
00341 
00342 }

int Output::coordinateNeeded ( int   )  [static]

Definition at line 194 of file Output.C.

References END_OF_RUN, EVAL_MEASURE, FILE_OUTPUT, Node::Object(), Node::simParameters, and simParams.

Referenced by Controller::enqueueCollections(), and Sequencer::submitCollections().

00195 {
00196   SimParameters *simParams = Node::Object()->simParameters;
00197 
00198   if(simParams->benchTimestep) return 0;
00199 
00200   int positionsNeeded = 0;
00201 
00202   if ( timestep >= 0 ) {
00203 
00204     //  Output a DCD trajectory 
00205     if ( simParams->dcdFrequency &&
00206        ((timestep % simParams->dcdFrequency) == 0) )
00207     { positionsNeeded |= 1; }
00208 
00209     //  Output a restart file
00210     if ( simParams->restartFrequency &&
00211        ((timestep % simParams->restartFrequency) == 0) )
00212     { positionsNeeded |= 2; }
00213 
00214     //  Iteractive MD
00215     if ( simParams->IMDon &&
00216        ( ((timestep % simParams->IMDfreq) == 0) ||
00217          (timestep == simParams->firstTimestep) ) )
00218       { positionsNeeded |= 1; }
00219 
00220   }
00221 
00222   //  Output final coordinates
00223   if (timestep == FILE_OUTPUT || timestep == END_OF_RUN ||
00224                                         timestep == EVAL_MEASURE)
00225   {
00226     positionsNeeded |= 2;
00227   }
00228 
00229   return positionsNeeded;
00230 }

void Output::energy ( int  ,
BigReal  
)

void Output::force ( int  ,
int  ,
Vector  
)

Definition at line 482 of file Output.C.

References endi(), FORCE_OUTPUT, iout, Node::Object(), Node::simParameters, and simParams.

Referenced by CollectionMaster::disposeForces().

00483 {
00484   SimParameters *simParams = Node::Object()->simParameters;
00485 
00486   if ( timestep >= 0 ) {
00487 
00488     //  Output force DCD trajectory
00489     if ( simParams->forceDcdFrequency &&
00490        ((timestep % simParams->forceDcdFrequency) == 0) )
00491     {
00492       output_forcedcdfile(timestep, n, frc);
00493     }
00494 
00495   }
00496 
00497   //  Output forces
00498   if (timestep == FORCE_OUTPUT)
00499   {
00500     int realstep = simParams->firstTimestep;
00501     iout << "WRITING FORCES TO OUTPUT FILE AT STEP "
00502                                 << realstep << "\n" << endi;
00503     fflush(stdout);
00504     output_forces(realstep, n, frc);
00505   }
00506 
00507   //  Trajectory file closed by velocity() above
00508 
00509 }

int Output::forceNeeded ( int   )  [static]

Definition at line 456 of file Output.C.

References FORCE_OUTPUT, Node::Object(), Node::simParameters, and simParams.

Referenced by Controller::enqueueCollections(), and Sequencer::submitCollections().

00457 {
00458   SimParameters *simParams = Node::Object()->simParameters;
00459 
00460   if(simParams->benchTimestep) return 0;
00461 
00462   int forcesNeeded = 0;
00463 
00464   if ( timestep >= 0 ) {
00465 
00466     //  Output a force DCD trajectory
00467     if ( simParams->forceDcdFrequency &&
00468        ((timestep % simParams->forceDcdFrequency) == 0) )
00469       { forcesNeeded |= 1; }
00470 
00471   }
00472 
00473   //  Output forces
00474   if (timestep == FORCE_OUTPUT)
00475   {
00476     forcesNeeded |= 2;
00477   }
00478 
00479   return forcesNeeded;
00480 }

void Output::recvReplicaDcdData ( ReplicaDcdDataMsg msg  ) 

Definition at line 696 of file Output.C.

References ReplicaDcdDataMsg::data, DCD_FILEEXISTS, ReplicaDcdDataMsg::dcdIndex, ReplicaDcdDataMsg::DELTA, f, iout, NAMD_bug(), NAMD_die(), NAMD_err(), ReplicaDcdDataMsg::NFILE, ReplicaDcdDataMsg::NPRIV, ReplicaDcdDataMsg::NSAVC, ReplicaDcdDataMsg::NSTEP, ReplicaDcdDataMsg::numAtoms, open_dcd_write(), sendReplicaDcdAck(), ReplicaDcdDataMsg::srcPart, ReplicaDcdDataMsg::unitcell, ReplicaDcdDataMsg::with_unitcell, write_dcdheader(), and write_dcdstep().

Referenced by recvReplicaDcdData().

00696                                                       {
00697   if ( ! replicaDcdFiles.count(msg->dcdIndex) ) {
00698     char err_msg[257];
00699     sprintf(err_msg, "Unknown replicaDcdFile identifier %d\n", msg->dcdIndex);
00700     NAMD_die(err_msg);
00701   }
00702   replicaDcdFile &f = replicaDcdFiles[msg->dcdIndex];
00703 
00704   if ( ! f.fileid ) {
00705     //  Open the DCD file
00706     iout << "OPENING REPLICA DCD FILE " << msg->dcdIndex << " " << f.filename.c_str() << "\n" << endi;
00707 
00708     f.fileid=open_dcd_write(f.filename.c_str());
00709 
00710     if (f.fileid == DCD_FILEEXISTS) {
00711       char err_msg[257];
00712       sprintf(err_msg, "DCD file %s already exists!!", f.filename.c_str());
00713       NAMD_err(err_msg);
00714     } else if (f.fileid < 0) {
00715       char err_msg[257];
00716       sprintf(err_msg, "Couldn't open DCD file %s", f.filename.c_str());
00717       NAMD_err(err_msg);
00718     } else if (! f.fileid) {
00719       NAMD_bug("Output::recvReplicaDcdData open_dcd_write returned fileid of zero");
00720     }
00721 
00722     //  Write out the header
00723     int ret_code = write_dcdheader(f.fileid, f.filename.c_str(),
00724         msg->numAtoms, msg->NFILE, msg->NPRIV, msg->NSAVC, msg->NSTEP,
00725         msg->DELTA, msg->with_unitcell);
00726 
00727     if (ret_code<0) {
00728       NAMD_err("Writing of DCD header failed!!");
00729     }
00730   }
00731 
00732   //  Write out the values for this timestep
00733   iout << "WRITING TO REPLICA DCD FILE " << msg->dcdIndex << " " << f.filename.c_str() << "\n" << endi;
00734   float *msgx = (float*) msg->data;
00735   float *msgy = msgx + msg->numAtoms;
00736   float *msgz = msgy + msg->numAtoms;
00737   int ret_code = write_dcdstep(f.fileid, msg->numAtoms, msgx, msgy, msgz,
00738                                    msg->with_unitcell ? msg->unitcell : 0);
00739   if (ret_code < 0) NAMD_err("Writing of DCD step failed!!");
00740 
00741   sendReplicaDcdAck(msg->srcPart, (ReplicaDcdAckMsg*) CmiAlloc(sizeof(ReplicaDcdAckMsg)));
00742 }

void Output::recvReplicaDcdInit ( ReplicaDcdInitMsg msg  ) 

Definition at line 685 of file Output.C.

References close_dcd_write(), ReplicaDcdInitMsg::data, ReplicaDcdInitMsg::dcdIndex, f, iout, sendReplicaDcdAck(), and ReplicaDcdInitMsg::srcPart.

Referenced by recvReplicaDcdInit().

00685                                                       {
00686   replicaDcdFile &f = replicaDcdFiles[msg->dcdIndex];
00687   if ( f.fileid ) {
00688     iout << "CLOSING REPLICA DCD FILE " << msg->dcdIndex << " " << f.filename.c_str() << "\n" << endi;
00689     close_dcd_write(f.fileid);
00690     f.fileid = 0;
00691   }
00692   f.filename = (const char*) msg->data;
00693   sendReplicaDcdAck(msg->srcPart, (ReplicaDcdAckMsg*) CmiAlloc(sizeof(ReplicaDcdAckMsg)));
00694 }

void Output::replicaDcdInit ( int  index,
const char *  filename 
)

Definition at line 674 of file Output.C.

References ReplicaDcdInitMsg::data, ReplicaDcdInitMsg::dcdIndex, sendReplicaDcdInit(), and ReplicaDcdInitMsg::srcPart.

00674                                                            {
00675   replicaDcdActive = 1;
00676   replicaDcdIndex = index;
00677   int msgsize = sizeof(ReplicaDcdInitMsg) + strlen(filename);
00678   ReplicaDcdInitMsg *msg = (ReplicaDcdInitMsg *) CmiAlloc(msgsize);
00679   msg->srcPart = CmiMyPartition();
00680   msg->dcdIndex = replicaDcdIndex;
00681   strcpy(msg->data, filename);
00682   sendReplicaDcdInit(abs(replicaDcdIndex) % CmiNumPartitions(), msg, msgsize);
00683 }

void Output::replicaDcdOff (  )  [inline]

Definition at line 100 of file Output.h.

00100 { replicaDcdActive = 0; }

void Output::setReplicaDcdIndex ( int  index  ) 

Definition at line 669 of file Output.C.

00669                                          {
00670   replicaDcdActive = 1;
00671   replicaDcdIndex = index;
00672 }

void Output::velocity ( int  ,
int  ,
Vector  
)

Definition at line 392 of file Output.C.

References END_OF_RUN, endi(), FILE_OUTPUT, iout, Node::Object(), Node::simParameters, and simParams.

Referenced by CollectionMaster::disposeVelocities().

00393 {
00394   SimParameters *simParams = Node::Object()->simParameters;
00395 
00396   if ( timestep >= 0 ) {
00397 
00398     //  Output velocity DCD trajectory
00399     if ( simParams->velDcdFrequency &&
00400        ((timestep % simParams->velDcdFrequency) == 0) )
00401     {
00402       output_veldcdfile(timestep, n, vel);
00403     }
00404 
00405   //  Output restart file
00406     if ( simParams->restartFrequency &&
00407        ((timestep % simParams->restartFrequency) == 0) )
00408     {
00409       iout << "WRITING VELOCITIES TO RESTART FILE AT STEP "
00410                                 << timestep << "\n" << endi;
00411       output_restart_velocities(timestep, n, vel);
00412       iout << "FINISHED WRITING RESTART VELOCITIES\n" <<endi;
00413       fflush(stdout);
00414     }
00415 
00416   }
00417 
00418   //  Output final velocities
00419   if (timestep == FILE_OUTPUT || timestep == END_OF_RUN)
00420   {
00421     int realstep = ( timestep == FILE_OUTPUT ?
00422           simParams->firstTimestep : simParams->N );
00423     iout << "WRITING VELOCITIES TO OUTPUT FILE AT STEP "
00424                                 << realstep << "\n" << endi;
00425     fflush(stdout);
00426     output_final_velocities(realstep, n, vel);
00427   }
00428 
00429   //  Close trajectory files
00430   if (timestep == END_OF_RUN)
00431   {
00432     if (simParams->velDcdFrequency) output_veldcdfile(END_OF_RUN,0,0);
00433     // close force dcd file here since no final force output below
00434     if (simParams->forceDcdFrequency) output_forcedcdfile(END_OF_RUN,0,0);
00435   }
00436 
00437 }

int Output::velocityNeeded ( int   )  [static]

Definition at line 361 of file Output.C.

References END_OF_RUN, FILE_OUTPUT, Node::Object(), Node::simParameters, and simParams.

Referenced by Controller::enqueueCollections(), and Sequencer::submitCollections().

00362 {
00363   SimParameters *simParams = Node::Object()->simParameters;
00364 
00365   if(simParams->benchTimestep) return 0;
00366 
00367   int velocitiesNeeded = 0;
00368 
00369   if ( timestep >= 0 ) {
00370 
00371     //  Output a velocity DCD trajectory
00372     if ( simParams->velDcdFrequency &&
00373        ((timestep % simParams->velDcdFrequency) == 0) )
00374       { velocitiesNeeded |= 1; }
00375 
00376     //  Output a restart file
00377     if ( simParams->restartFrequency &&
00378        ((timestep % simParams->restartFrequency) == 0) )
00379       { velocitiesNeeded |= 2; }
00380 
00381   }
00382 
00383   //  Output final velocities
00384   if (timestep == FILE_OUTPUT || timestep == END_OF_RUN)
00385   {
00386     velocitiesNeeded |= 2;
00387   }
00388 
00389   return velocitiesNeeded;
00390 }


Friends And Related Function Documentation

friend class SimParameters [friend]

Definition at line 48 of file Output.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 23 01:17:19 2017 for NAMD by  doxygen 1.4.7