Output.h

Go to the documentation of this file.
00001 
00007 /*
00008    This object outputs the data collected on the master  node
00009 */
00010 
00011 #ifndef OUTPUT_H
00012 #define OUTPUT_H
00013 
00014 #include "common.h"
00015 #include <string>
00016 #include <map>
00017 
00018 class Vector;
00019 class FloatVector;
00020 class Lattice;
00021 class ReplicaDcdInitMsg;
00022 class ReplicaDcdDataMsg;
00023 
00024 // semaphore "steps", must be negative
00025 #define FILE_OUTPUT -1
00026 #define END_OF_RUN -2
00027 #define EVAL_MEASURE -3
00028 #define FORCE_OUTPUT -4
00029 
00030 #define OUTPUT_SINGLE_FILE 1
00031 #define OUTPUT_MAGIC_NUMBER 123456
00032 #define OUTPUT_FILE_VERSION 1.00
00033 
00034 enum OUTPUTFILETYPE {
00035         dcdType,
00036         forcedcdType,
00037         veldcdType,
00038         coorType,
00039         forceType,
00040         velType
00041 };
00042 
00043 class Output 
00044 {
00045 
00046 private:
00047 
00048 friend class SimParameters;
00049 
00050    //  output coords to dcd file
00051    //  Pass non-NULL Lattice to include unit cell in the timesteps.
00052    int output_dcdfile(int, int, FloatVector *, const Lattice *); 
00053    void output_veldcdfile(int, int, Vector *);  //  output velocities to
00054                                                 //  dcd file
00055    void output_forcedcdfile(int, int, Vector *); //  output forces to
00056                                                 //  dcd file
00057 
00058    void output_restart_coordinates(Vector *, int, int);
00059                                                 //  output coords to 
00060                                                 //  restart file
00061    void output_restart_velocities(int, int, Vector *);
00062                                                 //  output velocities to 
00063                                                 //  restart file
00064    void output_final_coordinates(Vector *, int, int);//  output final coordinates
00065    void output_final_velocities(int, int, Vector *);    //  output final coordinates
00066    void output_forces(int, int, Vector *);      //  output forces
00067 
00068    void scale_vels(Vector *, int, Real);        //  scale velocity vectors before output
00069    void write_binary_file(char *, int, Vector *); // Write a binary restart file with
00070                                                 //  coordinates or velocities
00071 
00072    struct replicaDcdFile {
00073      std::string filename;
00074      int fileid;
00075      replicaDcdFile() : fileid(0) { ; }
00076    };
00077    std::map<int,replicaDcdFile> replicaDcdFiles;
00078    int replicaDcdActive;
00079    int replicaDcdIndex;
00080 
00081 public :
00082    Output();                                    //  Constructor
00083    ~Output();                                   //  Destructor
00084    void energy(int, BigReal *);                 //  Output energies
00085 
00086    static int coordinateNeeded(int);
00087    void coordinate(int, int, Vector *, FloatVector *, Lattice &);
00088                                                 //  Produce appropriate 
00089                                                 //  coordinate output for 
00090                                                 //  the current timestep
00091    static int velocityNeeded(int);
00092    void velocity(int, int, Vector *);           //  Produce appropriate velocity
00093                                                 //  output for the current 
00094                                                 //  timestep
00095    static int forceNeeded(int);
00096    void force(int, int, Vector *);              //  Produce appropriate force
00097                                                 //  output for the current 
00098                                                 //  timestep
00099 
00100   void replicaDcdOff() { replicaDcdActive = 0; }
00101   void setReplicaDcdIndex(int index);
00102   void replicaDcdInit(int index, const char *filename);
00103   void recvReplicaDcdInit(ReplicaDcdInitMsg *msg);
00104   void recvReplicaDcdData(ReplicaDcdDataMsg *msg);
00105 };
00106 
00107 #ifdef MEM_OPT_VERSION
00108 class ParOutput{
00109 private:
00110     void output_veldcdfile_master(int timestep, int n);
00111     void output_veldcdfile_slave(int timestep, int fID, int tID, Vector *vecs);
00112     void output_restart_velocities_master(int timestep, int n);
00113     void output_restart_velocities_slave(int timestep, int fID, int tID, Vector *vecs, int64 offset);
00114     void output_final_velocities_master(int n);
00115     void output_final_velocities_slave(int fID, int tID, Vector *vecs, int64 offset);
00116 
00117     void output_forcedcdfile_master(int timestep, int n);
00118     void output_forcedcdfile_slave(int timestep, int fID, int tID, Vector *vecs);
00119     void output_forces_master(int n);
00120     void output_forces_slave(int fID, int tID, Vector *vecs, int64 offset);
00121 
00122     void output_dcdfile_master(int timestep, int n, const Lattice *lat);
00123     void output_dcdfile_slave(int timestep, int fID, int tID, FloatVector *fvecs);
00124     void output_restart_coordinates_master(int timestep, int n);
00125     void output_restart_coordinates_slave(int timestep, int fID, int tID, Vector *vecs, int64 offset);
00126     void output_final_coordinates_master(int n);
00127     void output_final_coordinates_slave(int fID, int tID, Vector *vecs, int64 offset);
00128 
00129     void write_binary_file_master(char *fname, int n);
00130     void write_binary_file_slave(char *fname, int fID, int tID, Vector *vecs, int64 offset);
00131 
00132         #if !OUTPUT_SINGLE_FILE
00133         char *buildFileName(OUTPUTFILETYPE type, int timestep=-9999);
00134         #endif
00135 
00136     int dcdFileID;
00137     Bool dcdFirst;
00138     float *dcdX, *dcdY, *dcdZ;
00139 
00140     int veldcdFileID;
00141     Bool veldcdFirst;    
00142     float *veldcdX, *veldcdY, *veldcdZ;
00143 
00144     int forcedcdFileID;
00145     Bool forcedcdFirst;    
00146     float *forcedcdX, *forcedcdY, *forcedcdZ;
00147 
00148         int outputID; //the sequence of this output
00149 
00150 public:
00151     ParOutput(int oid=-1){
00152         dcdFileID=veldcdFileID=-99999;
00153         forcedcdFileID=-99999;
00154         dcdFirst=veldcdFirst=TRUE;
00155         forcedcdFirst=TRUE;
00156         dcdX=dcdY=dcdZ=veldcdX=veldcdY=veldcdZ=NULL;
00157         forcedcdX=forcedcdY=forcedcdZ=NULL;
00158                 outputID=oid;
00159     }
00160     ~ParOutput() {}
00161 
00162     void velocityMaster(int timestep, int n);
00163     void velocitySlave(int timestep, int fID, int tID, Vector *vecs);
00164 
00165     void forceMaster(int timestep, int n);
00166     void forceSlave(int timestep, int fID, int tID, Vector *vecs);
00167 
00168     void coordinateMaster(int timestep, int n, Lattice &lat);
00169     void coordinateSlave(int timestep, int fID, int tID, Vector *vecs, FloatVector *fvecs);
00170 };
00171 #endif
00172 
00173 #endif
00174 

Generated on Tue Sep 19 01:17:13 2017 for NAMD by  doxygen 1.4.7