NAMD
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
Output Class Reference

#include <Output.h>

Public Member Functions

 Output ()
 
 ~Output ()
 
void energy (int, BigReal *)
 
void coordinate (int timestep, int n, Vector *coor, FloatVector *fcoor, Lattice &lattice)
 Produce appropriate coordinate output for the current timestep. More...
 
void velocity (int timestep, int n, Vector *vel, FloatVector *fvel)
 Produce appropriate velocity for the current timestep. More...
 
void force (int timestep, int n, Vector *frc, FloatVector *ffrc)
 Produce appropriate force for the current timestep. More...
 
void replicaDcdOff ()
 
void setReplicaDcdIndex (int index)
 
void replicaDcdInit (int index, const char *filename)
 
void replicaDcdSelectInit (int index, const char *tag, const char *filename)
 
void recvReplicaDcdInit (ReplicaDcdInitMsg *msg)
 
void recvReplicaDcdData (ReplicaDcdDataMsg *msg)
 

Static Public Member Functions

static std::pair< int, int > coordinateNeeded (int timestep)
 Check if the step requires to output the coordinates. More...
 
static int velocityNeeded (int timestep)
 Check if the step requires to output the velocities. More...
 
static int forceNeeded (int timestep)
 Check if the step requires to output the forces. More...
 

Friends

class SimParameters
 

Detailed Description

Definition at line 35 of file Output.h.

Constructor & Destructor Documentation

◆ Output()

Output::Output ( )

Definition at line 171 of file Output.C.

171 : replicaDcdActive(0) { }

◆ ~Output()

Output::~Output ( )

Definition at line 181 of file Output.C.

181 { }

Member Function Documentation

◆ coordinate()

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

Produce appropriate coordinate output for the current timestep.

Parameters
timestepTimestep coordinates were accumulated for
nThe number of coordinates accumulated
coorArray of Vectors containing the coordinates in double precision. If the second bit of the first bitmask of coordinateNeeded is 1, then this parameter shouldn't be nullptr or NULL.
fcoorArray of Vectors containing the coordinates in single precision. If the first bit of the first bitmask of coordinateNeeded is 1, then this parameter shouldn't be nullptr or NULL.
latticeThe PBC box for wrapping the output coordinates

Definition at line 350 of file Output.C.

References Lattice::a(), Lattice::b(), Lattice::c(), Molecule::dcdSelectionParams, END_OF_RUN, endi(), EVAL_MEASURE, FILE_OUTPUT, dcd_params::frequency, IMDOutput::gather_box(), IMDOutput::gather_coordinates(), Molecule::get_dcd_selection_index_from_atom_id(), Molecule::get_dcd_selection_size(), Node::getScript(), Node::imd, IMDv2, IMDv3, iout, ScriptTcl::measure(), Node::molecule, Node::Object(), Node::simParameters, simParams, dcd_params::size, dcd_params::tag, wrap_coor(), wrap_coor_dcd_selection(), Vector::x, Vector::y, and Vector::z.

Referenced by CollectionMaster::disposePositions().

352 {
354  Molecule *molecule = Node::Object()->molecule;
355  double coor_wrapped = 0;
356  float fcoor_wrapped = 0;
357 
358  if ( timestep >= 0 ) {
359 
360  // Output a DCD trajectory
361  if ( simParams->dcdFrequency &&
362  ((timestep % simParams->dcdFrequency) == 0) )
363  {
364  wrap_coor(fcoor,lattice,&fcoor_wrapped);
365  output_dcdfile(timestep, n, fcoor,
366  simParams->dcdUnitCell ? &lattice : NULL, 0);
367  }
368 
369  // Output any DCD selection trajectories that this timestep mods
370  if ( simParams->dcdSelectionOn)
371  {
372  bool needCleanup = false;
373 
374  for(int index=0; index<16;++index)
375  {
376  int frequency=molecule->dcdSelectionParams[index].frequency;
377  uint16 tag=molecule->dcdSelectionParams[index].tag;
378  int size=molecule->dcdSelectionParams[index].size;
379  if(frequency>0 && (timestep % frequency) == 0)
380  {
381  FloatVector *dcdSelectionFcoor = fcoor;
382  int dcdSelectionNpoints = n;
383  if(dcdSelectionNpoints != molecule->get_dcd_selection_size(index))
384  {
385  // on intervals when some other output is also happening, we have
386  // to filter out a copy of the selection from the full
387  // collected output then wrap and output accordingly
388  dcdSelectionNpoints = size;
389  dcdSelectionFcoor = new FloatVector[dcdSelectionNpoints];
390  needCleanup = true;
391  for(int i=0; i<n ;i++)
392  {
393  int offset = molecule->get_dcd_selection_index_from_atom_id(index, i);
394  if(offset >= 0)
395  dcdSelectionFcoor[offset] = fcoor[i];
396  }
397  }
398  else
399  {
400  dcdSelectionFcoor = fcoor;
401  }
402  wrap_coor_dcd_selection(dcdSelectionFcoor, lattice, &fcoor_wrapped, index);
403  output_dcdfile(timestep, dcdSelectionNpoints, dcdSelectionFcoor,
404  simParams->dcdUnitCell ? &lattice : NULL, tag);
405  if(needCleanup)
406  delete [] dcdSelectionFcoor;
407  }
408 
409  }
410  }
411 
412  // Output a restart file
413  if ( simParams->restartFrequency &&
414  ((timestep % simParams->restartFrequency) == 0) )
415  {
416  iout << "WRITING COORDINATES TO RESTART FILE AT STEP "
417  << timestep << "\n" << endi;
418  wrap_coor(coor,lattice,&coor_wrapped);
419  output_restart_coordinates(coor, n, timestep);
420  iout << "FINISHED WRITING RESTART COORDINATES\n" <<endi;
421  fflush(stdout);
422  }
423 
424  // Interactive MD
425  if ( simParams->IMDon &&
426  ( ((timestep % simParams->IMDfreq) == 0) ||
427  (timestep == simParams->firstTimestep) ) )
428  {
429 
430  if ((simParams->IMDversion == IMDversion_t::IMDv2) || ((simParams->IMDversion == IMDversion_t::IMDv3)
431  && ((simParams->IMDsendsettings.box_switch == 1) || (simParams->IMDsendsettings.fcoords_switch == 1))))
432  {
433  IMDOutput *imd = NULL;
434 #ifdef NODEGROUP_FORCE_REGISTER
435  if (simParams->CUDASOAintegrate) {
436  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
437  imd = cpdata.ckLocalBranch()->imd;
438  }
439  else
440 #endif
441  {
442  imd = Node::Object()->imd;
443  }
444 
445  if ((imd != NULL) && ((simParams->IMDversion == IMDversion_t::IMDv3)
446  && (simParams->IMDsendsettings.box_switch == 1))) {
447  IMDBox box = {(float)lattice.a().x, (float)lattice.a().y, (float)lattice.a().z,
448  (float)lattice.b().x, (float)lattice.b().y, (float)lattice.b().z,
449  (float)lattice.c().x, (float)lattice.c().y, (float)lattice.c().z};
450 
451  if (imd != NULL) imd->gather_box(timestep, &box);
452  }
453 
454 
455  if ((imd != NULL) && ((simParams->IMDversion == IMDversion_t::IMDv2) || ((simParams->IMDversion == IMDversion_t::IMDv3)
456  && (simParams->IMDsendsettings.fcoords_switch == 1)))) {
457  if ((simParams->IMDversion == IMDversion_t::IMDv2) || ((simParams->IMDversion == IMDversion_t::IMDv3)
458  && (simParams->IMDsendsettings.wrap_switch == 1)))
459  wrap_coor(fcoor,lattice,&fcoor_wrapped);
460  if (imd != NULL) imd->gather_coordinates(timestep, n, fcoor);
461  }
462 
463  }
464  }
465 
466  }
467 
468  if (timestep == EVAL_MEASURE)
469  {
470 #ifdef NAMD_TCL
471  wrap_coor(coor,lattice,&coor_wrapped);
472  Node::Object()->getScript()->measure(coor);
473 #endif
474  }
475 
476  // Output final coordinates
477  if (timestep == FILE_OUTPUT || timestep == END_OF_RUN)
478  {
479  int realstep = ( timestep == FILE_OUTPUT ?
480  simParams->firstTimestep : simParams->N );
481  iout << "WRITING COORDINATES TO OUTPUT FILE AT STEP "
482  << realstep << "\n" << endi;
483  fflush(stdout);
484  wrap_coor(coor,lattice,&coor_wrapped);
485  output_final_coordinates(coor, n, realstep);
486  }
487 
488  // Close trajectory files
489  if (timestep == END_OF_RUN)
490  {
491  if (simParams->dcdFrequency) output_dcdfile(END_OF_RUN,0,0,
492  simParams->dcdUnitCell
493  ? &lattice : NULL, 0);
494  if ( simParams->dcdSelectionOn)
495  {
496  for(int dcdSelectionIndex=0; dcdSelectionIndex<16;++dcdSelectionIndex)
497  {
498  int dcdSelectionFrequency = molecule->dcdSelectionParams[dcdSelectionIndex].frequency;
499  int dcdSelectionTag = molecule->dcdSelectionParams[dcdSelectionIndex].tag;
500  if(dcdSelectionFrequency)
501  output_dcdfile(END_OF_RUN,0,0,
502  simParams->dcdUnitCell
503  ? &lattice : NULL, dcdSelectionTag);
504  }
505  }
506  }
507 
508 }
static Node * Object()
Definition: Node.h:86
DCDParams dcdSelectionParams[16]
Definition: Molecule.h:482
int frequency
Definition: common.h:255
NAMD_HOST_DEVICE Vector c() const
Definition: Lattice.h:270
Definition: common.h:275
#define FILE_OUTPUT
Definition: Output.h:25
IMDOutput * imd
Definition: Node.h:186
uint16 tag
Definition: common.h:252
#define EVAL_MEASURE
Definition: Output.h:27
SimParameters * simParameters
Definition: Node.h:181
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
BigReal z
Definition: Vector.h:74
void gather_coordinates(int timestep, int N, FloatVector *coords)
Definition: IMDOutput.C:44
#define iout
Definition: InfoStream.h:51
Molecule stores the structural information for the system.
Definition: Molecule.h:174
uint16_t uint16
Definition: common.h:41
const int get_dcd_selection_size(const int index)
Definition: Molecule.h:893
void wrap_coor(Vector *coor, Lattice &lattice, double *done)
Definition: Output.C:342
Definition: imd.h:55
int get_dcd_selection_index_from_atom_id(const int index, const int atomIndex)
Definition: Molecule.h:888
void wrap_coor_dcd_selection(Vector *coor, Lattice &lattice, double *done, int index)
Definition: Output.C:334
BigReal x
Definition: Vector.h:74
#define END_OF_RUN
Definition: Output.h:26
NAMD_HOST_DEVICE Vector b() const
Definition: Lattice.h:269
void gather_box(int timestep, IMDBox *box)
Definition: IMDOutput.C:71
#define simParams
Definition: Output.C:131
int size
Definition: common.h:259
BigReal y
Definition: Vector.h:74
ScriptTcl * getScript()
Definition: Node.C:1656
Definition: common.h:275
NAMD_HOST_DEVICE Vector a() const
Definition: Lattice.h:268
void measure(Vector *)
Definition: ScriptTcl.C:1400
Molecule * molecule
Definition: Node.h:179

◆ coordinateNeeded()

std::pair< int, int > Output::coordinateNeeded ( int  timestep)
static

Check if the step requires to output the coordinates.

Parameters
timestepThe current step number
Returns
A pair of bitmasks. The first bitmask indicates whether the step requires to output the velocities. If the first returned bitmask is 0, then the coordinates are not required for output. If its first bit is 1, then the single-precision coordinates are required. If its second bit is 1, then the double-precision coordinates are required. If both the first and the second bit are 1, then both precisions are required. XXX TODO: Document the second bitmask (also known as dcdSelectionTag)

Definition at line 185 of file Output.C.

References Molecule::dcdSelectionParams, END_OF_RUN, EVAL_MEASURE, FILE_OUTPUT, dcd_params::frequency, IMDOutput::get_imd_packet(), Node::imd, IMDv2, IMDv3, Node::molecule, Node::Object(), Node::simParameters, simParams, and dcd_params::tag.

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

186 {
188 
189  if(simParams->benchTimestep) return std::make_pair(0,0);
190 
191  int positionsNeeded = 0;
192  uint16 dcdSelectionTag = 0;
193  if ( timestep >= 0 ) {
194 
195  // Output a DCD trajectory
196  if ( simParams->dcdFrequency &&
197  ((timestep % simParams->dcdFrequency) == 0) )
198  { positionsNeeded |= 1; }
199 
200  // Output a DCD Selection trajectory
201 
202  if (simParams->dcdSelectionOn)
203  {
204  Molecule *mol = Node::Object()->molecule;
205  int tagCount=0;
206  for(int index=0; index<16;++index)
207  {
208  int frequency=mol->dcdSelectionParams[index].frequency;
209  uint16 tag=mol->dcdSelectionParams[index].tag;
210  if(frequency && (timestep % frequency) == 0)
211  {
212  if(++tagCount>1)
213  positionsNeeded |=1; //multi selection means all positions
214  positionsNeeded |= 4; dcdSelectionTag = tag;
215  }
216  }
217  }
218  // Output a restart file
219  if ( simParams->restartFrequency &&
220  ((timestep % simParams->restartFrequency) == 0) )
221  { positionsNeeded |= 2; }
222 
223  // Iteractive MD
224  if ( simParams->IMDon ) {
225  if ((simParams->IMDversion == IMDversion_t::IMDv3) &&
226  (simParams->IMDsendsettings.time_switch == 0) && (simParams->IMDsendsettings.energies_switch == 0)) {
227  IMDOutput *imd = NULL;
228 #ifdef NODEGROUP_FORCE_REGISTER
229  if (simParams->CUDASOAintegrate) {
230  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
231  imd = cpdata.ckLocalBranch()->imd;
232  }
233  else
234 #endif
235  {
236  imd = Node::Object()->imd;
237  }
238  if (imd != NULL) imd->get_imd_packet();
239  }
240  if ( (((timestep % simParams->IMDfreq) == 0) ||
241  (timestep == simParams->firstTimestep) ) &&
242  ((simParams->IMDversion == IMDversion_t::IMDv2) || ((simParams->IMDversion == IMDversion_t::IMDv3)
243  && ((simParams->IMDsendsettings.box_switch == 1) || (simParams->IMDsendsettings.fcoords_switch == 1)))) )
244  { positionsNeeded |= 1; }
245  }
246 
247  }
248 
249  // Output final coordinates
250  if (timestep == FILE_OUTPUT || timestep == END_OF_RUN ||
251  timestep == EVAL_MEASURE)
252  {
253  positionsNeeded |= 2;
254  }
255  return std::make_pair(positionsNeeded,dcdSelectionTag);
256 }
static Node * Object()
Definition: Node.h:86
DCDParams dcdSelectionParams[16]
Definition: Molecule.h:482
int frequency
Definition: common.h:255
Definition: common.h:275
#define FILE_OUTPUT
Definition: Output.h:25
IMDOutput * imd
Definition: Node.h:186
uint16 tag
Definition: common.h:252
#define EVAL_MEASURE
Definition: Output.h:27
SimParameters * simParameters
Definition: Node.h:181
Molecule stores the structural information for the system.
Definition: Molecule.h:174
uint16_t uint16
Definition: common.h:41
#define END_OF_RUN
Definition: Output.h:26
#define simParams
Definition: Output.C:131
Definition: common.h:275
Molecule * molecule
Definition: Node.h:179
void get_imd_packet()
Definition: IMDOutput.C:33

◆ energy()

void Output::energy ( int  ,
BigReal  
)

◆ force()

void Output::force ( int  timestep,
int  n,
Vector frc,
FloatVector ffrc 
)

Produce appropriate force for the current timestep.

This function receives the forces accumulated for a given timestep from the Collect object and calls the appropriate output functions. ALL routines used to output force information should be called from here.

Parameters
timestepTimestep forces were accumulated for
nThe number of forces accumulated
frcArray of Vectors containing the forces in double precision. If the second bit of forceNeeded is 1, then this parameter shouldn't be nullptr or NULL.
ffrcArray of Vectors containing the forces in single precision. If the first bit of forceNeeded is 1, then this parameter shouldn't be nullptr or NULL.

Definition at line 653 of file Output.C.

References endi(), FORCE_OUTPUT, IMDOutput::gather_forces(), Node::imd, IMDv3, iout, Node::Object(), Node::simParameters, and simParams.

Referenced by CollectionMaster::disposeForces().

654 {
656 
657  if ( timestep >= 0 ) {
658 
659  // Output force DCD trajectory
660  if ( simParams->forceDcdFrequency &&
661  ((timestep % simParams->forceDcdFrequency) == 0) )
662  {
663  output_forcedcdfile(timestep, n, ffrc);
664  }
665 
666  // Interactive MD
667  if ( simParams->IMDon && (simParams->IMDversion == IMDversion_t::IMDv3) &&
668  ( ((timestep % simParams->IMDfreq) == 0) ||
669  (timestep == simParams->firstTimestep) ) &&
670  ((simParams->IMDsendsettings.forces_switch == 1)) )
671  {
672  IMDOutput *imd = NULL;
673 #ifdef NODEGROUP_FORCE_REGISTER
674  if (simParams->CUDASOAintegrate) {
675  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
676  imd = cpdata.ckLocalBranch()->imd;
677  }
678  else
679 #endif
680  {
681  imd = Node::Object()->imd;
682  }
683  if (imd != NULL) imd->gather_forces(timestep, n, ffrc);
684  }
685 
686  }
687 
688  // Output forces
689  if (timestep == FORCE_OUTPUT)
690  {
691  int realstep = simParams->firstTimestep;
692  iout << "WRITING FORCES TO OUTPUT FILE AT STEP "
693  << realstep << "\n" << endi;
694  fflush(stdout);
695  output_forces(realstep, n, frc);
696  }
697 
698  // Trajectory file closed by velocity() above
699 
700 }
static Node * Object()
Definition: Node.h:86
Definition: common.h:275
IMDOutput * imd
Definition: Node.h:186
SimParameters * simParameters
Definition: Node.h:181
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
#define simParams
Definition: Output.C:131
void gather_forces(int timestep, int N, FloatVector *forces)
Definition: IMDOutput.C:62
#define FORCE_OUTPUT
Definition: Output.h:28

◆ forceNeeded()

int Output::forceNeeded ( int  timestep)
static

Check if the step requires to output the forces.

Parameters
timestepThe current step number
Returns
A bitmask indicates whether the step requires to output the forces. If the return value is 0, then forces are not required for output. If the first bit of the return value is 1, then the single-precision forces is required. If the second bit is 1, then the double- precision forces is required. If both the first and the second bit are 1, then both precisions are required.

Definition at line 619 of file Output.C.

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

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

620 {
622 
623  if(simParams->benchTimestep) return 0;
624 
625  int forcesNeeded = 0;
626 
627  if ( timestep >= 0 ) {
628 
629  // Output a force DCD trajectory
630  if ( simParams->forceDcdFrequency &&
631  ((timestep % simParams->forceDcdFrequency) == 0) )
632  { forcesNeeded |= 1; }
633 
634  // Iteractive MD
635  if ( simParams->IMDon &&
636  ( ((timestep % simParams->IMDfreq) == 0) ||
637  (timestep == simParams->firstTimestep) ) &&
638  ((simParams->IMDversion == IMDversion_t::IMDv2) || ((simParams->IMDversion == IMDversion_t::IMDv3)
639  && (simParams->IMDsendsettings.forces_switch == 1))) )
640  { forcesNeeded |= 1; }
641 
642  }
643 
644  // Output forces
645  if (timestep == FORCE_OUTPUT)
646  {
647  forcesNeeded |= 2;
648  }
649 
650  return forcesNeeded;
651 }
static Node * Object()
Definition: Node.h:86
Definition: common.h:275
SimParameters * simParameters
Definition: Node.h:181
#define simParams
Definition: Output.C:131
Definition: common.h:275
#define FORCE_OUTPUT
Definition: Output.h:28

◆ recvReplicaDcdData()

void Output::recvReplicaDcdData ( ReplicaDcdDataMsg msg)

Definition at line 931 of file Output.C.

References ReplicaDcdDataMsg::data, DCD_FILEEXISTS, ReplicaDcdDataMsg::dcdIndex, ReplicaDcdDataMsg::dcdSelectIndex, ReplicaDcdDataMsg::DELTA, endi(), iout, NAMD_bug(), NAMD_die(), NAMD_err(), namdMyNode, 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().

931  {
932  Molecule *molecule = namdMyNode->molecule;
933  if ( msg->dcdSelectIndex>=16 && ! replicaDcdFiles.count(msg->dcdIndex) ||
934  ( ! replicaDcdFiles.count(msg->dcdIndex) )) {
935  char err_msg[257];
936  sprintf(err_msg, "Unknown replicaDcdFile identifier %d\n", msg->dcdIndex);
937  NAMD_die(err_msg);
938  }
939  replicaDcdFile &f = (msg->dcdSelectIndex<16) ? replicaDcdSelectFiles[std::make_pair(msg->dcdIndex,msg->dcdSelectIndex)]: replicaDcdFiles[msg->dcdIndex];
940 
941  if ( ! f.fileid ) {
942  // Open the DCD file
943  iout << "OPENING REPLICA DCD FILE " << msg->dcdIndex << " " << f.filename.c_str() << "\n" << endi;
944 
945  f.fileid=open_dcd_write(f.filename.c_str());
946 
947  if (f.fileid == DCD_FILEEXISTS) {
948  char err_msg[257];
949  sprintf(err_msg, "DCD file %s already exists!!", f.filename.c_str());
950  NAMD_err(err_msg);
951  } else if (f.fileid < 0) {
952  char err_msg[257];
953  if(msg->dcdSelectIndex<16)
954  sprintf(err_msg, "Couldn't open DCD Index %d Select Index %d file %s", msg->dcdIndex, msg->dcdSelectIndex, f.filename.c_str());
955  else
956  sprintf(err_msg, "Couldn't open DCD Index %d file %s", msg->dcdIndex, f.filename.c_str());
957  NAMD_err(err_msg);
958  } else if (! f.fileid) {
959  NAMD_bug("Output::recvReplicaDcdData open_dcd_write returned fileid of zero");
960  }
961 
962  // Write out the header
963  int ret_code = write_dcdheader(f.fileid, f.filename.c_str(),
964  msg->numAtoms, msg->NFILE, msg->NPRIV, msg->NSAVC, msg->NSTEP,
965  msg->DELTA, msg->with_unitcell);
966 
967  if (ret_code<0) {
968  NAMD_err("Writing of DCD header failed!!");
969  }
970  }
971 
972  // Write out the values for this timestep
973  iout << "WRITING TO REPLICA DCD FILE " << msg->dcdIndex << " " << f.filename.c_str() << "\n" << endi;
974  float *msgx = (float*) msg->data;
975  float *msgy = msgx + msg->numAtoms;
976  float *msgz = msgy + msg->numAtoms;
977  int ret_code = write_dcdstep(f.fileid, msg->numAtoms, msgx, msgy, msgz,
978  msg->with_unitcell ? msg->unitcell : 0);
979  if (ret_code < 0) NAMD_err("Writing of DCD step failed!!");
980 
981  sendReplicaDcdAck(msg->srcPart, (ReplicaDcdAckMsg*) CmiAlloc(sizeof(ReplicaDcdAckMsg)));
982 }
void NAMD_err(const char *err_msg)
Definition: common.C:170
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
Molecule stores the structural information for the system.
Definition: Molecule.h:174
int open_dcd_write(const char *dcdname)
Definition: dcdlib.C:662
#define DCD_FILEEXISTS
Definition: dcdlib.h:52
void NAMD_bug(const char *err_msg)
Definition: common.C:195
#define namdMyNode
Definition: Output.C:130
int write_dcdstep(int fd, int N, float *X, float *Y, float *Z, double *cell)
Definition: dcdlib.C:736
void NAMD_die(const char *err_msg)
Definition: common.C:147
int write_dcdheader(int fd, const char *filename, int N, int NFILE, int NPRIV, int NSAVC, int NSTEP, double DELTA, int with_unitcell)
Definition: dcdlib.C:915
void sendReplicaDcdAck(int dstPart, ReplicaDcdAckMsg *msg)
Definition: DataExchanger.C:67
uint16_t dcdSelectIndex
Definition: DataExchanger.h:48
double unitcell[6]
Definition: DataExchanger.h:51

◆ recvReplicaDcdInit()

void Output::recvReplicaDcdInit ( ReplicaDcdInitMsg msg)

Definition at line 920 of file Output.C.

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

Referenced by recvReplicaDcdInit().

920  {
921  replicaDcdFile &f = (msg->dcdSelectIndex<16) ? replicaDcdSelectFiles[std::make_pair(msg->dcdIndex,msg->dcdSelectIndex)]: replicaDcdFiles[msg->dcdIndex];
922  if ( f.fileid ) {
923  iout << "CLOSING REPLICA DCD FILE " << msg->dcdIndex << " " << f.filename.c_str() << "\n" << endi;
924  close_dcd_write(f.fileid);
925  f.fileid = 0;
926  }
927  f.filename = (const char*) msg->data;
928  sendReplicaDcdAck(msg->srcPart, (ReplicaDcdAckMsg*) CmiAlloc(sizeof(ReplicaDcdAckMsg)));
929 }
uint16_t dcdSelectIndex
Definition: DataExchanger.h:39
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
void sendReplicaDcdAck(int dstPart, ReplicaDcdAckMsg *msg)
Definition: DataExchanger.C:67
void close_dcd_write(int fd)
Definition: dcdlib.C:1063

◆ replicaDcdInit()

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

Definition at line 894 of file Output.C.

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

894  {
895  replicaDcdActive = 1;
896  replicaDcdIndex = index;
897  int msgsize = sizeof(ReplicaDcdInitMsg) + strlen(filename);
898  ReplicaDcdInitMsg *msg = (ReplicaDcdInitMsg *) CmiAlloc(msgsize);
899  msg->srcPart = CmiMyPartition();
900  msg->dcdIndex = replicaDcdIndex;
901  msg->dcdSelectIndex = 16;
902  strcpy(msg->data, filename);
903  sendReplicaDcdInit(abs(replicaDcdIndex) % CmiNumPartitions(), msg, msgsize);
904 }
uint16_t dcdSelectIndex
Definition: DataExchanger.h:39
void sendReplicaDcdInit(int dstPart, ReplicaDcdInitMsg *msg, int msgsize)
Definition: DataExchanger.C:45

◆ replicaDcdOff()

void Output::replicaDcdOff ( )
inline

Definition at line 173 of file Output.h.

173 { replicaDcdActive = 0; }

◆ replicaDcdSelectInit()

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

Definition at line 906 of file Output.C.

References ReplicaDcdInitMsg::data, ReplicaDcdInitMsg::dcdIndex, ReplicaDcdInitMsg::dcdSelectIndex, Molecule::find_or_create_dcd_selection_index(), namdMyNode, sendReplicaDcdInit(), and ReplicaDcdInitMsg::srcPart.

906  {
907  replicaDcdActive = 1;
908  replicaDcdIndex = index;
909  int msgsize = sizeof(ReplicaDcdInitMsg) + strlen(filename);
910  ReplicaDcdInitMsg *msg = (ReplicaDcdInitMsg *) CmiAlloc(msgsize);
911  msg->srcPart = CmiMyPartition();
912  msg->dcdIndex = replicaDcdIndex;
913  Molecule *molecule = namdMyNode->molecule;
915  strcpy(msg->data, filename);
916  sendReplicaDcdInit(abs(replicaDcdIndex) % CmiNumPartitions(), msg, msgsize);
917 }
uint16_t dcdSelectIndex
Definition: DataExchanger.h:39
void sendReplicaDcdInit(int dstPart, ReplicaDcdInitMsg *msg, int msgsize)
Definition: DataExchanger.C:45
Molecule stores the structural information for the system.
Definition: Molecule.h:174
uint16_t find_or_create_dcd_selection_index(const char *keystr)
#define namdMyNode
Definition: Output.C:130

◆ setReplicaDcdIndex()

void Output::setReplicaDcdIndex ( int  index)

Definition at line 889 of file Output.C.

889  {
890  replicaDcdActive = 1;
891  replicaDcdIndex = index;
892 }

◆ velocity()

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

Produce appropriate velocity for the current timestep.

This function receives the velocities accumulated for a given timestep from the Collect object and calls the appropriate output functions. ALL routines used to output velocity information should be called from here.

Parameters
timestepTimestep velocities were accumulated for
nThe number of velocities accumulated
velArray of Vectors containing the velocities in double precision. If the second bit of velocityNeeded is 1, then this parameter shouldn't be nullptr or NULL.
fvelArray of Vectors containing the velocities in single precision. If the first bit of velocityNeeded is 1, then this parameter shouldn't be nullptr or NULL.

Definition at line 549 of file Output.C.

References END_OF_RUN, endi(), FILE_OUTPUT, IMDOutput::gather_velocities(), Node::imd, IMDv3, iout, Node::Object(), PDBVELFACTOR, Node::simParameters, and simParams.

Referenced by CollectionMaster::disposeVelocities().

550 {
552 
553  if ( timestep >= 0 ) {
554 
555  // Output velocity DCD trajectory
556  if ( simParams->velDcdFrequency &&
557  ((timestep % simParams->velDcdFrequency) == 0) )
558  {
559  output_veldcdfile(timestep, n, fvel);
560  }
561 
562  // Output restart file
563  if ( simParams->restartFrequency &&
564  ((timestep % simParams->restartFrequency) == 0) )
565  {
566  iout << "WRITING VELOCITIES TO RESTART FILE AT STEP "
567  << timestep << "\n" << endi;
568  output_restart_velocities(timestep, n, vel);
569  iout << "FINISHED WRITING RESTART VELOCITIES\n" <<endi;
570  fflush(stdout);
571  }
572 
573  // Interactive MD
574  if ( simParams->IMDon && (simParams->IMDversion == IMDversion_t::IMDv3) &&
575  ( ((timestep % simParams->IMDfreq) == 0) ||
576  (timestep == simParams->firstTimestep) ) &&
577  (simParams->IMDsendsettings.velocities_switch == 1) )
578  {
579  IMDOutput *imd = NULL;
580 #ifdef NODEGROUP_FORCE_REGISTER
581  if (simParams->CUDASOAintegrate) {
582  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
583  imd = cpdata.ckLocalBranch()->imd;
584  }
585  else
586 #endif
587  {
588  imd = Node::Object()->imd;
589  }
590  if (imd != NULL) {
591  scale_fvels(fvel, n, PDBVELFACTOR);
592  imd->gather_velocities(timestep, n, fvel);
593  }
594  }
595 
596  }
597 
598  // Output final velocities
599  if (timestep == FILE_OUTPUT || timestep == END_OF_RUN)
600  {
601  int realstep = ( timestep == FILE_OUTPUT ?
602  simParams->firstTimestep : simParams->N );
603  iout << "WRITING VELOCITIES TO OUTPUT FILE AT STEP "
604  << realstep << "\n" << endi;
605  fflush(stdout);
606  output_final_velocities(realstep, n, vel);
607  }
608 
609  // Close trajectory files
610  if (timestep == END_OF_RUN)
611  {
612  if (simParams->velDcdFrequency) output_veldcdfile(END_OF_RUN,0,0);
613  // close force dcd file here since no final force output below
614  if (simParams->forceDcdFrequency) output_forcedcdfile(END_OF_RUN,0,0);
615  }
616 
617 }
static Node * Object()
Definition: Node.h:86
void gather_velocities(int timestep, int N, FloatVector *velocities)
Definition: IMDOutput.C:53
Definition: common.h:275
#define FILE_OUTPUT
Definition: Output.h:25
IMDOutput * imd
Definition: Node.h:186
SimParameters * simParameters
Definition: Node.h:181
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
#define END_OF_RUN
Definition: Output.h:26
#define simParams
Definition: Output.C:131
#define PDBVELFACTOR
Definition: common.h:57

◆ velocityNeeded()

int Output::velocityNeeded ( int  timestep)
static

Check if the step requires to output the velocities.

Parameters
timestepThe current step number
Returns
A bitmask indicates whether the step requires to output the velocities. If the return value is 0, then velocities are not required for output. If the first bit of the return value is 1, then the single-precision velocities are required. If the second bit is 1, then the double- precision velocities are required. If both the first and the second bit are 1, then both precisions are required.

Definition at line 510 of file Output.C.

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

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

511 {
513 
514  if(simParams->benchTimestep) return 0;
515 
516  int velocitiesNeeded = 0;
517 
518  if ( timestep >= 0 ) {
519 
520  // Output a velocity DCD trajectory
521  if ( simParams->velDcdFrequency &&
522  ((timestep % simParams->velDcdFrequency) == 0) )
523  { velocitiesNeeded |= 1; }
524 
525  // Output a restart file
526  if ( simParams->restartFrequency &&
527  ((timestep % simParams->restartFrequency) == 0) )
528  { velocitiesNeeded |= 2; }
529 
530  // Interactive MD
531  if ( simParams->IMDon &&
532  ( ((timestep % simParams->IMDfreq) == 0) ||
533  (timestep == simParams->firstTimestep) ) &&
534  ((simParams->IMDversion == IMDversion_t::IMDv3)
535  && (simParams->IMDsendsettings.velocities_switch == 1)) )
536  { velocitiesNeeded |= 1; }
537 
538  }
539 
540  // Output final velocities
541  if (timestep == FILE_OUTPUT || timestep == END_OF_RUN)
542  {
543  velocitiesNeeded |= 2;
544  }
545 
546  return velocitiesNeeded;
547 }
static Node * Object()
Definition: Node.h:86
Definition: common.h:275
#define FILE_OUTPUT
Definition: Output.h:25
SimParameters * simParameters
Definition: Node.h:181
#define END_OF_RUN
Definition: Output.h:26
#define simParams
Definition: Output.C:131

Friends And Related Function Documentation

◆ SimParameters

friend class SimParameters
friend

Definition at line 40 of file Output.h.


The documentation for this class was generated from the following files: