Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

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

Generated on Fri May 25 04:07:16 2012 for NAMD by  doxygen 1.3.9.1