ComputeImpropers.h

Go to the documentation of this file.
00001 
00007 #ifndef COMPUTEIMPROPERS_H
00008 #define COMPUTEIMPROPERS_H
00009 
00010 #include "ComputeHomeTuples.h"
00011 #include "ComputeSelfTuples.h"
00012 #include "ReductionMgr.h"
00013 
00014 class Molecule;
00015 class ImproperValue;
00016 
00017 class ImproperElem {
00018 public:
00019     // ComputeHomeTuples interface
00020     enum { size = 4 };
00021     AtomID atomID[size];
00022     int    localIndex[size];
00023     TuplePatchElem *p[size];
00024     Real scale;
00025     static void computeForce(ImproperElem*, int, BigReal*, BigReal *);
00026 
00027     static void getMoleculePointers(Molecule*, int*, int32***, Improper**);
00028     static void getParameterPointers(Parameters*, const ImproperValue**);
00029     static void getTupleInfo(AtomSignature* sig, int *count, TupleSignature** t) {
00030         *count = sig->improperCnt;
00031         *t = sig->improperSigs;
00032     }
00033 
00034     // pressure profile parameters
00035     static int pressureProfileSlabs;
00036     static int pressureProfileAtomTypes;
00037     static BigReal pressureProfileThickness;
00038     static BigReal pressureProfileMin;
00039 
00040     // Internal data
00041     const ImproperValue *value;
00042 
00043   int hash() const {
00044     return 0x7FFFFFFF &((atomID[0]<<24) + (atomID[1]<<16) + (atomID[2]<<8) + atomID[3]);
00045   }
00046   enum { improperEnergyIndex, improperEnergyIndex_f, improperEnergyIndex_ti_1, 
00047          improperEnergyIndex_ti_2, TENSOR(virialIndex), reductionDataSize };
00048   enum { reductionChecksumLabel = REDUCTION_IMPROPER_CHECKSUM };
00049   static void submitReductionData(BigReal*,SubmitReduction*);
00050 
00051   ImproperElem() { ; }
00052 
00053   ImproperElem(AtomID atom0, const TupleSignature *sig, const ImproperValue *v){
00054       atomID[0] = atom0;
00055       atomID[1] = atom0 + sig->offset[0];
00056       atomID[2] = atom0 + sig->offset[1];
00057       atomID[3] = atom0 + sig->offset[2];
00058       value = &v[sig->tupleParamType];
00059   }
00060 
00061   ImproperElem(const Improper *a, const ImproperValue *v) {
00062     atomID[0] = a->atom1;
00063     atomID[1] = a->atom2;
00064     atomID[2] = a->atom3;
00065     atomID[3] = a->atom4;
00066     value = &v[a->improper_type];
00067   }
00068 
00069   ImproperElem(AtomID atom0, AtomID atom1, AtomID atom2, AtomID atom3) {
00070     if (atom0 > atom3) {  // Swap end atoms so lowest is first!
00071       AtomID tmp = atom3; atom3 = atom0; atom0 = tmp; 
00072       tmp = atom1; atom1 = atom2; atom2 = tmp;
00073     }
00074     atomID[0] = atom0;
00075     atomID[1] = atom1;
00076     atomID[2] = atom2;
00077     atomID[3] = atom3;
00078   }
00079   ~ImproperElem() {};
00080 
00081   int operator==(const ImproperElem &a) const {
00082     return (a.atomID[0] == atomID[0] && a.atomID[1] == atomID[1] &&
00083         a.atomID[2] == atomID[2] && a.atomID[3] == atomID[3]);
00084   }
00085 
00086   int operator<(const ImproperElem &a) const {
00087     return  (atomID[0] < a.atomID[0] ||
00088             (atomID[0] == a.atomID[0] &&
00089             (atomID[1] < a.atomID[1] ||
00090             (atomID[1] == a.atomID[1] &&
00091             (atomID[2] < a.atomID[2] ||
00092             (atomID[2] == a.atomID[2] &&
00093              atomID[3] < a.atomID[3] 
00094              ))))));
00095   }
00096 };
00097 
00098 class ComputeImpropers : public ComputeHomeTuples<ImproperElem,Improper,ImproperValue>
00099 {
00100 public:
00101 
00102   ComputeImpropers(ComputeID c, PatchIDList &p) : ComputeHomeTuples<ImproperElem,Improper,ImproperValue>(c,p) { ; }
00103 
00104 };
00105 
00106 class ComputeSelfImpropers : public ComputeSelfTuples<ImproperElem,Improper,ImproperValue>
00107 {
00108 public:
00109 
00110   ComputeSelfImpropers(ComputeID c, PatchID p) : ComputeSelfTuples<ImproperElem,Improper,ImproperValue>(c,p) { ; }
00111 
00112 };
00113 
00114 #endif
00115 

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