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
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 loadTuplesForAtom(void*, AtomID, Molecule*);
00028 static void getMoleculePointers(Molecule*, int*, int32***, Improper**);
00029 static void getParameterPointers(Parameters*, const ImproperValue**);
00030 static void getTupleInfo(AtomSignature* sig, int *count, TupleSignature** t) {
00031 *count = sig->improperCnt;
00032 *t = sig->improperSigs;
00033 }
00034
00035
00036 static int pressureProfileSlabs;
00037 static int pressureProfileAtomTypes;
00038 static BigReal pressureProfileThickness;
00039 static BigReal pressureProfileMin;
00040
00041
00042 const ImproperValue *value;
00043
00044 int hash() const {
00045 return 0x7FFFFFFF &((atomID[0]<<24) + (atomID[1]<<16) + (atomID[2]<<8) + atomID[3]);
00046 }
00047 enum { improperEnergyIndex, 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) {
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