DumpBench.C

Go to the documentation of this file.
00001 
00002 #include <stdio.h>
00003 #include "InfoStream.h"
00004 #include "DumpBench.h"
00005 #include "SimParameters.h"
00006 #include "ComputeNonbondedUtil.h"
00007 #include "LJTable.h"
00008 #include "Molecule.h"
00009 #include "Node.h"
00010 #include "PatchMap.h"
00011 #include "HomePatch.h"
00012 #include "NamdState.h"
00013 #include "ComputeMap.h"
00014 
00015 inline void dump_param(FILE *file, const char *name, int value) {
00016   fprintf(file,"%s %d\n",name,value);
00017 }
00018 
00019 inline void dump_param(FILE *file, const char *name, double value) {
00020   fprintf(file,"%s %g\n",name,value);
00021 }
00022 
00023 inline void dump_param(FILE *file, const char *name, Vector value) {
00024   fprintf(file,"%s %f %f %f\n",name,value.x,value.y,value.z);
00025 }
00026 
00027 int dumpbench(FILE *file) {
00028 
00029   Node *node = Node::Object();
00030 
00031   fprintf(file,"SIMPARAMETERS_BEGIN\n");
00032 
00033   SimParameters *simParams = node->simParameters;
00034 
00035 #define SIMPARAM(T,N,V) dump_param(file,#N,simParams->N)
00036 #include "DumpBenchParams.h"
00037 #undef SIMPARAM
00038 
00039   fprintf(file,"SIMPARAMETERS_END\n");
00040 
00041   fprintf(file,"LJTABLE_BEGIN\n");
00042 
00043   const LJTable *ljTable = ComputeNonbondedUtil::ljTable;
00044 
00045   int table_dim = ljTable->get_table_dim();
00046   fprintf(file,"%d\n",table_dim);
00047 
00048   const LJTable::TableEntry *table = ljTable->get_table();
00049   int i,j;
00050   for ( i=0; i < table_dim; ++i) {
00051     for ( j=i; j < table_dim; ++j)
00052     {
00053       const LJTable::TableEntry *curij = &(table[2*(i*table_dim+j)]);
00054       fprintf(file,"%g %g %g %g\n",curij->A,curij->B,
00055                                 (curij+1)->A,(curij+1)->B);
00056     }
00057   }
00058 
00059   fprintf(file,"LJTABLE_END\n");
00060 
00061   fprintf(file,"MOLECULE_BEGIN\n");
00062 
00063   const Molecule *mol = node->molecule;
00064 
00065   fprintf(file,"%d %d\n",mol->numAtoms,mol->numCalcExclusions);
00066  
00067   for ( i=0; i<mol->numAtoms; ++i) {
00068     int vdw = mol->atomvdwtype(i);
00069     #ifdef MEM_OPT_VERSION
00070     Index exclIdx = mol->getAtomExclSigId(i);
00071     const ExclusionCheck *excl = mol->get_excl_check_for_idx(exclIdx);
00072     //if(excl->flags==NULL || excl->flags == (char *)-1){
00073     //    fprintf(file,"%d: %d ====\n",i, vdw);
00074     //    continue;
00075     //}
00076     int min = i+excl->min;
00077     int max = i+excl->max;
00078     #else
00079     const ExclusionCheck *excl = mol->get_excl_check_for_atom(i);
00080     //if(excl->flags==NULL || excl->flags == (char *)-1){
00081     //    fprintf(file,"%d: %d ====\n",i, vdw);
00082     //    continue;
00083     //}
00084     int min = excl->min;
00085     int max = excl->max;
00086     #endif
00087     // fprintf(file,"%d: %d %d %d |",i,vdw,min,max);
00088     fprintf(file,"%d %d %d",vdw,min,max);
00089     if ( min <= max ) {
00090       int s = max - min + 1;
00091       const char *f = excl->flags;
00092       for ( int k=0; k<s; ++k ) {
00093         int fk = f[k];
00094         fprintf(file," %d",fk);
00095       }
00096     }
00097     fprintf(file,"\n");
00098   }
00099 
00100   fprintf(file,"MOLECULE_END\n");
00101 
00102 #if 0
00103   fprintf(file, "BONDS_BEGIN\n");
00104   fprintf(file, "%d %d\n", mol->numBonds, mol->numCalcBonds);
00105 #ifdef MEM_OPT_VERSION
00106   for(i=0; i<mol->numAtoms; i++){
00107       int sigId = node->molecule->getAtomSigId(i);
00108       AtomSignature *sig = &(mol->atomSigPool[sigId]);
00109       if(sig->bondCnt==0){
00110           fprintf(file, "%d: ===\n", i);
00111           continue;
00112       }
00113       fprintf(file, "%d:", i);
00114       for(j=0; j<sig->bondCnt; j++){
00115           fprintf(file, " (%d | %d)", (sig->bondSigs[j]).offset[0], sig->bondSigs[j].tupleParamType);
00116       }
00117       fprintf(file, "\n");
00118   }
00119 #else
00120   for(i=0; i<mol->numAtoms; i++){      
00121       int *p = node->molecule->get_bonds_for_atom(i);      
00122       if(*p==-1){
00123           fprintf(file, "%d: ===\n", i);
00124           continue;
00125       }
00126       fprintf(file, "%d:", i);
00127       for(; *p!=-1;p++){
00128           Bond *t = mol->get_bond(*p);
00129           fprintf(file, " (%d | %d)", t->atom2-i, t->bond_type);
00130       }
00131       fprintf(file, "\n");
00132   }
00133 #endif
00134   fprintf(file, "BONDS_END\n");
00135 
00136   fprintf(file, "ANGLES_BEGIN\n");
00137   fprintf(file, "%d %d\n", mol->numAngles, mol->numCalcAngles);
00138 #ifdef MEM_OPT_VERSION
00139   for(i=0; i<mol->numAtoms; i++){
00140       int sigId = node->molecule->getAtomSigId(i);
00141       AtomSignature *sig = &(mol->atomSigPool[sigId]);
00142       if(sig->angleCnt==0){
00143           fprintf(file, "%d: ===\n", i);
00144           continue;
00145       }
00146       fprintf(file, "%d:", i);
00147       for(j=0; j<sig->angleCnt; j++){
00148           int offset0 = (sig->angleSigs[j]).offset[0];
00149           int offset1 = (sig->angleSigs[j]).offset[1];
00150           fprintf(file, " (%d, %d | %d)", offset0, offset1, sig->angleSigs[j].tupleParamType);
00151       }
00152       fprintf(file, "\n");
00153   }
00154 #else
00155   for(i=0; i<mol->numAtoms; i++){      
00156       int *p = node->molecule->get_angles_for_atom(i);      
00157       if(*p==-1){
00158           fprintf(file, "%d: ===\n", i);
00159           continue;
00160       }
00161       fprintf(file, "%d:", i);
00162       for(; *p!=-1;p++){
00163           Angle *t = mol->get_angle(*p);
00164           int offset0 = t->atom2 - i;
00165           int offset1 = t->atom3 - i;
00166           fprintf(file, " (%d, %d | %d)", offset0, offset1, t->angle_type);
00167       }
00168       fprintf(file, "\n");
00169   }
00170 #endif
00171   fprintf(file, "ANGLES_END\n");
00172 
00173   fprintf(file, "DIHEDRALS_BEGIN\n");
00174   fprintf(file, "%d %d\n", mol->numDihedrals, mol->numCalcDihedrals);
00175 #ifdef MEM_OPT_VERSION
00176   for(i=0; i<mol->numAtoms; i++){
00177       int sigId = node->molecule->getAtomSigId(i);
00178       AtomSignature *sig = &(mol->atomSigPool[sigId]);
00179       if(sig->dihedralCnt==0){
00180           fprintf(file, "%d: ===\n", i);
00181           continue;
00182       }
00183       fprintf(file, "%d:", i);
00184       for(j=0; j<sig->dihedralCnt; j++){
00185           int offset0 = (sig->dihedralSigs[j]).offset[0];
00186           int offset1 = (sig->dihedralSigs[j]).offset[1];
00187           int offset2 = (sig->dihedralSigs[j]).offset[2];
00188           fprintf(file, " (%d, %d, %d | %d)", offset0, offset1, offset2, sig->dihedralSigs[j].tupleParamType);
00189       }
00190       fprintf(file, "\n");
00191   }
00192 #else
00193   for(i=0; i<mol->numAtoms; i++){      
00194       int *p = node->molecule->get_dihedrals_for_atom(i);      
00195       if(*p==-1){
00196           fprintf(file, "%d: ===\n", i);
00197           continue;
00198       }
00199       fprintf(file, "%d:", i);
00200       for(; *p!=-1;p++){
00201           Dihedral *t = mol->get_dihedral(*p);
00202           int offset0 = t->atom2 - i;
00203           int offset1 = t->atom3 - i;
00204           int offset2 = t->atom4 - i;
00205           fprintf(file, " (%d, %d, %d | %d)", offset0, offset1, offset2, t->dihedral_type);
00206       }
00207       fprintf(file, "\n");
00208   }
00209 #endif
00210   fprintf(file, "DIHEDRALS_END\n");
00211 
00212   fprintf(file, "IMPROPERS_BEGIN\n");
00213   fprintf(file, "%d %d\n", mol->numImpropers, mol->numCalcImpropers);
00214 #ifdef MEM_OPT_VERSION
00215   for(i=0; i<mol->numAtoms; i++){
00216       int sigId = node->molecule->getAtomSigId(i);
00217       AtomSignature *sig = &(mol->atomSigPool[sigId]);
00218       if(sig->improperCnt==0){
00219           fprintf(file, "%d: ===\n", i);
00220           continue;
00221       }
00222       fprintf(file, "%d:", i);
00223       for(j=0; j<sig->improperCnt; j++){
00224           int offset0 = (sig->improperSigs[j]).offset[0];
00225           int offset1 = (sig->improperSigs[j]).offset[1];
00226           int offset2 = (sig->improperSigs[j]).offset[2];
00227           fprintf(file, " (%d, %d, %d | %d)", offset0, offset1, offset2, sig->improperSigs[j].tupleParamType);
00228       }
00229       fprintf(file, "\n");
00230   }
00231 #else
00232   for(i=0; i<mol->numAtoms; i++){      
00233       int *p = node->molecule->get_impropers_for_atom(i);      
00234       if(*p==-1){
00235           fprintf(file, "%d: ===\n", i);
00236           continue;
00237       }
00238       fprintf(file, "%d:", i);
00239       for(; *p!=-1;p++){
00240           Improper *t = mol->get_improper(*p);
00241           int offset0 = t->atom2 - i;
00242           int offset1 = t->atom3 - i;
00243           int offset2 = t->atom4 - i;
00244           fprintf(file, " (%d, %d, %d | %d)", offset0, offset1, offset2, t->improper_type);
00245       }
00246       fprintf(file, "\n");
00247   }
00248 #endif
00249   fprintf(file, "IMPROPERS_END\n");
00250 #endif
00251 
00252   fprintf(file,"PATCHLIST_BEGIN\n");
00253 
00254   PatchMap *patchMap = PatchMap::Object();
00255   int numPatches = patchMap->numPatches();
00256   fprintf(file,"%d\n",numPatches);
00257 
00258   for ( i=0; i<numPatches; ++i) {
00259     HomePatch *patch = patchMap->homePatch(i);
00260     fprintf(file,"PATCH_BEGIN\n");
00261     int numAtoms = patch->getNumAtoms();
00262     fprintf(file,"%d\n",numAtoms);
00263     FullAtomList &atoms = patch->getAtomList();
00264     for ( j=0; j<numAtoms; ++j) {
00265       FullAtom &a = atoms[j];
00266       double x,y,z,q;
00267       int id,hgs,ngia,af,gf,part;
00268       x = a.position.x;
00269       y = a.position.y;
00270       z = a.position.z;
00271       q = a.charge;
00272       id = a.id;
00273       hgs = a.hydrogenGroupSize;
00274       ngia = ( hgs != 1 && a.nonbondedGroupSize == 1 ) ? 1 : 0;
00275       af = a.atomFixed;
00276       gf = a.groupFixed;
00277       part = a.partition;
00278       fprintf(file,"%f %f %f %f %d %d %d %d %d %d\n",
00279         x,y,z,q,id,hgs,ngia,af,gf,part);
00280     }
00281     fprintf(file,"PATCH_END\n");
00282   }
00283 
00284   fprintf(file,"PATCHLIST_END\n");
00285 
00286   fprintf(file,"COMPUTEPAIR_BEGIN\n");
00287 
00288   ComputeMap *computeMap = ComputeMap::Object();
00289   int numComputes = computeMap->numComputes();
00290   int numPairComputes = 0;
00291   for ( i=0; i<numComputes; ++i) {
00292     if ( computeMap->type(i) == computeNonbondedPairType
00293          && computeMap->partition(i) == 0 ) ++numPairComputes;
00294   }
00295   fprintf(file,"%d\n",numPairComputes);
00296   for ( i=0; i<numComputes; ++i) {
00297     if ( computeMap->type(i) == computeNonbondedPairType
00298          && computeMap->partition(i) == 0 ) {
00299       int pid1 = computeMap->pid(i,0);
00300       int trans1 = computeMap->trans(i,0);
00301       int pid2 = computeMap->pid(i,1);
00302       int trans2 = computeMap->trans(i,1);
00303       fprintf(file,"%d %d %d %d\n",pid1,trans1,pid2,trans2);
00304     }
00305   }
00306 
00307   fprintf(file,"COMPUTEPAIR_END\n");
00308 
00309   return 0;
00310 }
00311 

Generated on Mon Nov 20 01:17:12 2017 for NAMD by  doxygen 1.4.7