00001
00007
00008
00009
00010
00011
00012 #ifndef COMPUTEEWALD_H
00013 #define COMPUTEEWALD_H
00014
00015 #include "ComputeHomePatches.h"
00016 #include "NamdTypes.h"
00017 #include "ComputeMgr.decl.h"
00018
00019 class floatcomplex {
00020 public:
00021 float r, i;
00022 floatcomplex() {}
00023 floatcomplex(float c) : r(c), i(0) {}
00024 floatcomplex(float a, float b) : r(a), i(b) {}
00025 ~floatcomplex() {}
00026
00027
00028 floatcomplex star() const
00029 {
00030 return floatcomplex(r, -i);
00031 }
00032
00033 float mod2() const
00034 {
00035 return r*r + i*i;
00036 }
00037
00038 floatcomplex &operator=(const float &c)
00039 {
00040 r = c;
00041 i = 0;
00042 return *this;
00043 }
00044
00045 floatcomplex &operator+=(const floatcomplex &d)
00046 {
00047 r += d.r;
00048 i += d.i;
00049 return *this;
00050 }
00051
00052 floatcomplex &operator*=(const float &c)
00053 {
00054 r *= c;
00055 i *= c;
00056 return *this;
00057 }
00058
00059 floatcomplex &operator*=(const floatcomplex &d)
00060 {
00061 float re = r*d.r - i*d.i;
00062 float im = r*d.i + i*d.r;
00063 r = re;
00064 i = im;
00065 return *this;
00066 }
00067 };
00068
00069 class ComputeEwaldMsg : public CMessage_ComputeEwaldMsg {
00070 public:
00071 float *eik;
00072 };
00073
00074 class EwaldParticle;
00075 class ComputeMgr;
00076 class SubmitReduction;
00077
00078 class ComputeEwald : public ComputeHomePatches {
00079 public:
00080 ComputeEwald(ComputeID, ComputeMgr*);
00081 virtual ~ComputeEwald();
00082 void doWork();
00083 void recvData(ComputeEwaldMsg *);
00084 void recvResults(ComputeEwaldMsg *);
00085
00086 int getMasterNode() const { return masterNode; }
00087
00088 private:
00089 ComputeMgr *comm;
00090 SubmitReduction *reduction;
00091 int masterNode;
00092 int numWorkingPes;
00093 int recvCount;
00094
00095
00096 EwaldParticle *localAtoms;
00097 int *localPartitions;
00098 int numLocalAtoms;
00099
00100
00101 int pressureProfileSlabs;
00102 int pressureProfileAtomTypes;
00103 float pressureProfileMin, pressureProfileThickness;
00104 float *pressureProfileData;
00105
00106
00107 int kxmax, kymax, kzmax;
00108
00109
00110 int ktot;
00111
00112
00113 float kappa;
00114
00115
00116 float *eiktotal;
00117
00118
00119 floatcomplex *eiky, *eikz;
00120 float *expx, *expy, *expz;
00121 float *Qk;
00122
00123
00124
00125
00126 int *gridsForAtomType;
00127 int numAtomTypes;
00128
00129
00130
00131 Lattice lattice;
00132
00133
00134 void compute_structurefactor(float *);
00135
00136
00137
00138 void computePprofile(const float *eik) const;
00139 };
00140
00141 #endif
00142