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

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     void computeForce(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, TENSOR(virialIndex), reductionDataSize };
00047   enum { reductionChecksumLabel = REDUCTION_IMPROPER_CHECKSUM };
00048   static void submitReductionData(BigReal*,SubmitReduction*);
00049 
00050   ImproperElem() { ; }
00051 
00052   ImproperElem(AtomID atom0, const TupleSignature *sig, const ImproperValue *v){
00053       atomID[0] = atom0;
00054       atomID[1] = atom0 + sig->offset[0];
00055       atomID[2] = atom0 + sig->offset[1];
00056       atomID[3] = atom0 + sig->offset[2];
00057       value = &v[sig->tupleParamType];
00058   }
00059 
00060   ImproperElem(const Improper *a, const ImproperValue *v) {
00061     atomID[0] = a->atom1;
00062     atomID[1] = a->atom2;
00063     atomID[2] = a->atom3;
00064     atomID[3] = a->atom4;
00065     value = &v[a->improper_type];
00066   }
00067 
00068   ImproperElem(AtomID atom0, AtomID atom1, AtomID atom2, AtomID atom3) {
00069     if (atom0 > atom3) {  // Swap end atoms so lowest is first!
00070       AtomID tmp = atom3; atom3 = atom0; atom0 = tmp; 
00071       tmp = atom1; atom1 = atom2; atom2 = tmp;
00072     }
00073     atomID[0] = atom0;
00074     atomID[1] = atom1;
00075     atomID[2] = atom2;
00076     atomID[3] = atom3;
00077   }
00078   ~ImproperElem() {};
00079 
00080   int operator==(const ImproperElem &a) const {
00081     return (a.atomID[0] == atomID[0] && a.atomID[1] == atomID[1] &&
00082         a.atomID[2] == atomID[2] && a.atomID[3] == atomID[3]);
00083   }
00084 
00085   int operator<(const ImproperElem &a) const {
00086     return  (atomID[0] < a.atomID[0] ||
00087             (atomID[0] == a.atomID[0] &&
00088             (atomID[1] < a.atomID[1] ||
00089             (atomID[1] == a.atomID[1] &&
00090             (atomID[2] < a.atomID[2] ||
00091             (atomID[2] == a.atomID[2] &&
00092              atomID[3] < a.atomID[3] 
00093              ))))));
00094   }
00095 };
00096 
00097 class ComputeImpropers : public ComputeHomeTuples<ImproperElem,Improper,ImproperValue>
00098 {
00099 public:
00100 
00101   ComputeImpropers(ComputeID c, PatchIDList p) : ComputeHomeTuples<ImproperElem,Improper,ImproperValue>(c,p) { ; }
00102 
00103 };
00104 
00105 class ComputeSelfImpropers : public ComputeSelfTuples<ImproperElem,Improper,ImproperValue>
00106 {
00107 public:
00108 
00109   ComputeSelfImpropers(ComputeID c, PatchID p) : ComputeSelfTuples<ImproperElem,Improper,ImproperValue>(c,p) { ; }
00110 
00111 };
00112 
00113 #endif
00114 

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