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

ComputeNonbondedUtil.h

Go to the documentation of this file.
00001 
00007 /*
00008    Common operations for ComputeNonbonded classes
00009 */
00010 
00011 #ifndef COMPUTENONBONDEDUTIL_H
00012 #define COMPUTENONBONDEDUTIL_H
00013 
00014 #include "NamdTypes.h"
00015 #include "ReductionMgr.h"
00016 class LJTable;
00017 class Molecule;
00018 
00019 typedef unsigned short plint;
00020 
00021 class Pairlists {
00022   enum {initsize = 10};
00023   plint *data;
00024   int curpos;
00025   int size;
00026   Pairlists(const Pairlists&) { ; }
00027   Pairlists& operator=(const Pairlists&) { return *this; }
00028 public:
00029   Pairlists() : size(initsize) { data = new plint[initsize]; }
00030   ~Pairlists() { delete [] data; }
00031   plint *newlist(int max_size) {  // get a new list w/ room for max_size
00032     int reqnewsize = curpos + max_size + 1;
00033     int newsize = size;
00034     while ( newsize < reqnewsize ) { newsize += newsize >> 1; }
00035     if ( newsize > size ) {
00036       plint *newdata = new plint[newsize];
00037       CmiMemcpy(newdata,data,curpos*sizeof(plint));
00038       delete [] data;
00039       data = newdata;
00040       size = newsize;
00041     }
00042     return &data[curpos+1];
00043   }
00044   void newsize(int list_size) {  // set the size of the last list gotten
00045     data[curpos] = list_size;
00046     curpos += list_size + 1;
00047   }
00048   void reset() { curpos = 0; }  // go back to the beginning
00049   void nextlist(plint **list, int *list_size) {  // get next list and size
00050     *list = &data[curpos+1];
00051     curpos += ( *list_size = data[curpos] ) + 1;
00052   }
00053 };
00054 
00055 #define NBWORKARRAYSINIT(ARRAYS) \
00056   ComputeNonbondedWorkArrays* const computeNonbondedWorkArrays = ARRAYS;
00057 
00058 #define NBWORKARRAY(TYPE,NAME,SIZE) \
00059   computeNonbondedWorkArrays->NAME.resize(SIZE); \
00060   TYPE * NAME = computeNonbondedWorkArrays->NAME.begin();
00061 
00062 class ComputeNonbondedWorkArrays {
00063 public:
00064   ResizeArray<plint> pairlisti;
00065   ResizeArray<BigReal> r2list;
00066 
00067   // DMK - Atom Sort
00068   // NOTE : TODO : For pair nonbonded compute objects, these arrays are needed
00069   //   for the atom sorting code.  However, grouplist and fixglist will not be
00070   //   used if these arrays are so they could overlap in memory.  TODO: Find a
00071   //   way to allow them to use the same memory.  For now, it's not much memory
00072   //   so just keep them separate because of the type differences.  I haven't
00073   //   looked through all the details yet, but could probably just use the
00074   //   larger type and cast the pointer type as needed for the other one to
00075   //   ensure there is enough memory in both cases.
00076   #if NAMD_ComputeNonbonded_SortAtoms != 0
00077     ResizeArray<SortEntry> atomSort_0_sortValues__;
00078     ResizeArray<SortEntry> atomSort_1_sortValues__;
00079     ResizeArray<BigReal> p_0_sortValues;
00080   #endif
00081 
00082   ResizeArray<plint> grouplist;
00083   ResizeArray<plint> fixglist;
00084   ResizeArray<plint> goodglist;
00085   ResizeArray<plint> pairlistx;
00086   ResizeArray<plint> pairlistm;
00087 
00088   ResizeArray<plint> pairlistnAlch;
00089   ResizeArray<plint> pairlistnA0;
00090   ResizeArray<plint> pairlistnA1;
00091   ResizeArray<plint> pairlistxA1;
00092   ResizeArray<plint> pairlistmA1;
00093   ResizeArray<plint> pairlistnA2;
00094   ResizeArray<plint> pairlistxA2;
00095   ResizeArray<plint> pairlistmA2;
00096   
00097   ResizeArray<plint> pairlist;
00098   ResizeArray<plint> pairlist2;
00099   ResizeArray<short> vdwtype_array;
00100   ResizeArray<Force> f_0;
00101   ResizeArray<Force> fullf_0;
00102 };
00103 
00104 // function arguments
00105 struct nonbonded {
00106   CompAtom* p[2];
00107 #ifdef MEM_OPT_VERSION
00108   CompAtomExt *pExt[2];
00109 #endif
00110   Force* ff[2];
00111   // for full electrostatics
00112   Force* fullf [2];
00113 
00114   int numAtoms[2];
00115 
00116   Vector offset;
00117 
00118   // DMK - Atom Separation (water vs. non-water)
00119   #if NAMD_SeparateWaters != 0
00120     int numWaterAtoms[2];
00121   #endif
00122 
00123   BigReal *reduction;
00124   BigReal *pressureProfileReduction;
00125 
00126   ComputeNonbondedWorkArrays *workArrays;
00127 
00128   Pairlists *pairlists;
00129   int savePairlists;
00130   int usePairlists;
00131   BigReal plcutoff;
00132   BigReal groupplcutoff;
00133 
00134   int minPart;
00135   int maxPart;
00136   int numParts;
00137 };
00138 
00139 class ComputeNonbondedUtil {
00140 
00141 public:
00142 
00143   ComputeNonbondedUtil() {}
00144   virtual ~ComputeNonbondedUtil() {}
00145   static void select(void);
00146 
00147   static void (*calcPair)(nonbonded *);
00148   static void (*calcPairEnergy)(nonbonded *);
00149   static void (*calcSelf)(nonbonded *);
00150   static void (*calcSelfEnergy)(nonbonded *);
00151 
00152   static void (*calcFullPair)(nonbonded *);
00153   static void (*calcFullPairEnergy)(nonbonded *);
00154   static void (*calcFullSelf)(nonbonded *);
00155   static void (*calcFullSelfEnergy)(nonbonded *);
00156 
00157   static void (*calcMergePair)(nonbonded *);
00158   static void (*calcMergePairEnergy)(nonbonded *);
00159   static void (*calcMergeSelf)(nonbonded *);
00160   static void (*calcMergeSelfEnergy)(nonbonded *);
00161 
00162   static void (*calcSlowPair)(nonbonded *);
00163   static void (*calcSlowPairEnergy)(nonbonded *);
00164   static void (*calcSlowSelf)(nonbonded *);
00165   static void (*calcSlowSelfEnergy)(nonbonded *);
00166 
00167   enum { exclChecksumIndex, pairlistWarningIndex,
00168          electEnergyIndex, fullElectEnergyIndex, vdwEnergyIndex,
00169 //sd-db
00170          electEnergyIndex_s, fullElectEnergyIndex_s, vdwEnergyIndex_s,
00171          electEnergyIndex_ti_1, fullElectEnergyIndex_ti_1, vdwEnergyIndex_ti_1,
00172          electEnergyIndex_ti_2, fullElectEnergyIndex_ti_2, vdwEnergyIndex_ti_2,
00173 //sd-de
00174          TENSOR(virialIndex), TENSOR(fullElectVirialIndex),
00175          VECTOR(pairVDWForceIndex), VECTOR(pairElectForceIndex),
00176          reductionDataSize };
00177   static void submitReductionData(BigReal*,SubmitReduction*);
00178   static void submitPressureProfileData(BigReal*,SubmitReduction*);
00179 
00180   static Bool commOnly;
00181   static Bool fixedAtomsOn;
00182   static BigReal cutoff;
00183   static BigReal cutoff2;
00184   static BigReal dielectric_1;
00185   static const LJTable* ljTable;
00186   static const Molecule* mol;
00187   static BigReal r2_delta, r2_delta_1;
00188   static int r2_delta_exp;
00189   static BigReal *table_alloc;
00190   static BigReal *table_short;
00191   static BigReal *table_noshort;
00192   static BigReal *fast_table;
00193   static BigReal *scor_table;
00194   static BigReal *slow_table;
00195   static BigReal *corr_table;
00196   static BigReal *full_table;
00197   static BigReal *vdwa_table;
00198   static BigReal *vdwb_table;
00199   static BigReal *r2_table;
00200   static BigReal scaling;
00201   static BigReal scale14;
00202   static BigReal switchOn;
00203   static BigReal switchOn_1;
00204   static BigReal switchOn2;
00205   static BigReal c0;
00206   static BigReal c1;
00207   static BigReal c3;
00208   static BigReal c5;
00209   static BigReal c6;
00210   static BigReal c7;
00211   static BigReal c8;
00212   // static BigReal d0;
00213 //sd-db
00214   static Bool fepOn;
00215   static Bool thermInt;
00216   static BigReal lambda;
00217   static BigReal lambda2;
00218   static BigReal fepVdwShiftCoeff;
00219   static BigReal fepElecLambdaStart;
00220   static BigReal fepVdwLambdaEnd;
00221   static Bool decouple;
00222 //sd-de
00223   static Bool lesOn;
00224   static int lesFactor;
00225   static BigReal lesScaling;
00226 
00227   static BigReal *lambda_table;
00228 
00229   static Bool pairInteractionOn;
00230   static Bool pairInteractionSelf;
00231 
00232   static Bool pressureProfileOn;
00233   static int pressureProfileSlabs;
00234   static int pressureProfileAtomTypes;
00235   static BigReal pressureProfileThickness;
00236   static BigReal pressureProfileMin;
00237 
00238   // for particle mesh Ewald
00239   static BigReal ewaldcof;
00240   static BigReal pi_ewaldcof;
00241 
00242   // for simplifying some common functions
00243   inline static BigReal square( const BigReal &x,
00244                                 const BigReal &y,
00245                                 const BigReal &z)
00246         {
00247         return(x*x+y*y+z*z);
00248         }
00249 
00250   static void calc_error(nonbonded *);
00251 
00252   static void calc_pair(nonbonded *);
00253   static void calc_pair_energy(nonbonded *);
00254   static void calc_pair_fullelect(nonbonded *);
00255   static void calc_pair_energy_fullelect(nonbonded *);
00256   static void calc_pair_merge_fullelect(nonbonded *);
00257   static void calc_pair_energy_merge_fullelect(nonbonded *);
00258   static void calc_pair_slow_fullelect(nonbonded *);
00259   static void calc_pair_energy_slow_fullelect(nonbonded *);
00260 
00261   static void calc_self(nonbonded *);
00262   static void calc_self_energy(nonbonded *);
00263   static void calc_self_fullelect(nonbonded *);
00264   static void calc_self_energy_fullelect(nonbonded *);
00265   static void calc_self_merge_fullelect(nonbonded *);
00266   static void calc_self_energy_merge_fullelect(nonbonded *);
00267   static void calc_self_slow_fullelect(nonbonded *);
00268   static void calc_self_energy_slow_fullelect(nonbonded *);
00269 
00270 //alchemical fep calcualtion
00271   static void calc_pair_energy_fep(nonbonded *);
00272   static void calc_pair_energy_fullelect_fep (nonbonded *);
00273   static void calc_pair_energy_merge_fullelect_fep (nonbonded *);
00274   static void calc_pair_energy_slow_fullelect_fep (nonbonded *);
00275   static void calc_self_energy_fep (nonbonded *);
00276   static void calc_self_energy_fullelect_fep (nonbonded *);
00277   static void calc_self_energy_merge_fullelect_fep (nonbonded *);
00278   static void calc_self_energy_slow_fullelect_fep (nonbonded *);
00279 
00280   static void calc_pair_energy_ti(nonbonded *);
00281   static void calc_pair_ti(nonbonded *);
00282   static void calc_pair_energy_fullelect_ti (nonbonded *);
00283   static void calc_pair_fullelect_ti (nonbonded *);
00284   static void calc_pair_energy_merge_fullelect_ti (nonbonded *);
00285   static void calc_pair_merge_fullelect_ti (nonbonded *);
00286   static void calc_pair_energy_slow_fullelect_ti (nonbonded *);
00287   static void calc_pair_slow_fullelect_ti (nonbonded *);
00288   static void calc_self_energy_ti (nonbonded *);
00289   static void calc_self_ti (nonbonded *);
00290   static void calc_self_energy_fullelect_ti (nonbonded *);
00291   static void calc_self_fullelect_ti (nonbonded *);
00292   static void calc_self_energy_merge_fullelect_ti (nonbonded *);
00293   static void calc_self_merge_fullelect_ti (nonbonded *);
00294   static void calc_self_energy_slow_fullelect_ti (nonbonded *);
00295   static void calc_self_slow_fullelect_ti (nonbonded *);
00296   
00297 //locally enhanced sampling calcualtion
00298   static void calc_pair_les(nonbonded *);
00299   static void calc_pair_energy_les(nonbonded *);
00300   static void calc_pair_fullelect_les (nonbonded *);
00301   static void calc_pair_energy_fullelect_les (nonbonded *);
00302   static void calc_pair_merge_fullelect_les (nonbonded *);
00303   static void calc_pair_energy_merge_fullelect_les (nonbonded *);
00304   static void calc_pair_slow_fullelect_les (nonbonded *);
00305   static void calc_pair_energy_slow_fullelect_les (nonbonded *);
00306   static void calc_self_les (nonbonded *);
00307   static void calc_self_energy_les (nonbonded *);
00308   static void calc_self_fullelect_les (nonbonded *);
00309   static void calc_self_energy_fullelect_les (nonbonded *);
00310   static void calc_self_merge_fullelect_les (nonbonded *);
00311   static void calc_self_energy_merge_fullelect_les (nonbonded *);
00312   static void calc_self_slow_fullelect_les (nonbonded *);
00313   static void calc_self_energy_slow_fullelect_les (nonbonded *);
00314 
00315 //pair interaction calcualtion
00316   static void calc_pair_energy_int(nonbonded *);
00317   static void calc_pair_energy_fullelect_int(nonbonded *);
00318   static void calc_pair_energy_merge_fullelect_int(nonbonded *);
00319   static void calc_self_energy_int (nonbonded *);
00320   static void calc_self_energy_fullelect_int(nonbonded *);
00321   static void calc_self_energy_merge_fullelect_int(nonbonded *);
00322 
00323 //pressure profile calcualtion
00324   static void calc_pair_pprof(nonbonded *);
00325   static void calc_pair_energy_pprof(nonbonded *);
00326   static void calc_pair_fullelect_pprof(nonbonded *);
00327   static void calc_pair_energy_fullelect_pprof(nonbonded *);
00328   static void calc_pair_merge_fullelect_pprof(nonbonded *);
00329   static void calc_pair_energy_merge_fullelect_pprof(nonbonded *);
00330   static void calc_pair_slow_fullelect_pprof(nonbonded *);
00331   static void calc_pair_energy_slow_fullelect_pprof(nonbonded *);
00332   static void calc_self_pprof(nonbonded *);
00333   static void calc_self_energy_pprof(nonbonded *);
00334   static void calc_self_fullelect_pprof (nonbonded *);
00335   static void calc_self_energy_fullelect_pprof (nonbonded *);
00336   static void calc_self_merge_fullelect_pprof (nonbonded *);
00337   static void calc_self_energy_merge_fullelect_pprof (nonbonded *);
00338   static void calc_self_slow_fullelect_pprof (nonbonded *);
00339   static void calc_self_energy_slow_fullelect_pprof (nonbonded *);
00340 };
00341 
00342 #endif
00343 

Generated on Sun Sep 7 04:07:40 2008 for NAMD by  doxygen 1.3.9.1