Output Class Reference

#include <Output.h>

List of all members.

Classes

struct  replicaDcdFile

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

Detailed Description

Definition at line 43 of file Output.h.


Constructor & Destructor Documentation

Output::Output (  ) 

Definition at line 168 of file Output.C.

00168 : replicaDcdActive(0) { }

Output::~Output (  ) 

Definition at line 178 of file Output.C.

00178 { }


Member Function Documentation

void Output::coordinate ( int  timestep,
int  n,
Vector coor,
FloatVector fcoor,
Lattice lattice 
)

Definition at line 277 of file Output.C.

References SimParameters::dcdFrequency, SimParameters::dcdUnitCell, END_OF_RUN, endi(), EVAL_MEASURE, FILE_OUTPUT, SimParameters::firstTimestep, IMDOutput::gather_coordinates(), Node::getScript(), Node::imd, SimParameters::IMDfreq, SimParameters::IMDon, iout, ScriptTcl::measure(), SimParameters::N, Node::Object(), SimParameters::restartFrequency, Node::simParameters, simParams, and wrap_coor().

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

int Output::coordinateNeeded ( int  timestep  )  [static]

Definition at line 198 of file Output.C.

References SimParameters::benchTimestep, SimParameters::dcdFrequency, END_OF_RUN, EVAL_MEASURE, FILE_OUTPUT, SimParameters::firstTimestep, SimParameters::IMDfreq, SimParameters::IMDon, Node::Object(), SimParameters::restartFrequency, Node::simParameters, and simParams.

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

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

void Output::energy ( int  ,
BigReal  
)
void Output::force ( int  timestep,
int  n,
Vector frc 
)

Definition at line 486 of file Output.C.

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

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

int Output::forceNeeded ( int  timestep  )  [static]

Definition at line 460 of file Output.C.

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

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

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

void Output::recvReplicaDcdData ( ReplicaDcdDataMsg msg  ) 

Definition at line 700 of file Output.C.

References ReplicaDcdDataMsg::data, DCD_FILEEXISTS, ReplicaDcdDataMsg::dcdIndex, ReplicaDcdDataMsg::DELTA, 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().

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

void Output::recvReplicaDcdInit ( ReplicaDcdInitMsg msg  ) 

Definition at line 689 of file Output.C.

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

Referenced by recvReplicaDcdInit().

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

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

Definition at line 678 of file Output.C.

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

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

void Output::replicaDcdOff (  )  [inline]

Definition at line 100 of file Output.h.

00100 { replicaDcdActive = 0; }

void Output::setReplicaDcdIndex ( int  index  ) 

Definition at line 673 of file Output.C.

00673                                          {
00674   replicaDcdActive = 1;
00675   replicaDcdIndex = index;
00676 }

void Output::velocity ( int  timestep,
int  n,
Vector vel 
)

Definition at line 396 of file Output.C.

References END_OF_RUN, endi(), FILE_OUTPUT, SimParameters::firstTimestep, SimParameters::forceDcdFrequency, iout, SimParameters::N, Node::Object(), SimParameters::restartFrequency, Node::simParameters, simParams, and SimParameters::velDcdFrequency.

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

int Output::velocityNeeded ( int  timestep  )  [static]

Definition at line 365 of file Output.C.

References SimParameters::benchTimestep, END_OF_RUN, FILE_OUTPUT, Node::Object(), SimParameters::restartFrequency, Node::simParameters, simParams, and SimParameters::velDcdFrequency.

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

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


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 20 Oct 2019 for NAMD by  doxygen 1.6.1