OpenAtom  Version1.5a
StructureFactor.h
1 #include "debug_flags.h"
2 #include "structureFactor.decl.h"
3 #include "StructureFactorMessages.h"
4 
5 #ifndef _StructureFactor_h_
6 #define _StructureFactor_h_
7 void *fftw_malloc(size_t );
8 void fftw_free(void *);
9 
10 /******************************************************************************
11  * Three dimensions: atm_grp, plane, dup
12  * Calculates structure factor, sends to sfcache group.
13  *
14  *
15  *****************************************************************************/
16 
17 
18 extern Config config;
19 
21 {
22  public:
23  StructureFactor(CkMigrateMessage *m);
24  StructureFactor(int _numSfGrps, int _numSfDups, int _natm_nl_grp_max, int _numdest, int *_destinations, UberCollection _thisInstance) : numSfGrps(_numSfGrps), numSfDups(_numSfDups), natm_nl_grp_max(_natm_nl_grp_max), numdest(_numdest), thisInstance(_thisInstance)
25  {
26  k_x=NULL;
27  k_y=NULL;
28  k_z=NULL;
29  structFactor=NULL;
30  structFactor_fx=NULL;
31  structFactor_fy=NULL;
32  structFactor_fz=NULL;
33  destinations =new int[numdest];
34  CmiMemcpy(destinations,_destinations, numdest *sizeof(int));
35 
36  gsSize=0;
37 /// usesAtSync=true; not until we come up with a migration scheme
38  setMigratable(false);
39 #ifdef _CP_DEBUG_SF_CALC_
40  CkPrintf("[%d %d %d] created SF\n",thisIndex.x, thisIndex.y, thisIndex.z);
41 #endif
42  }
43 
44  ~StructureFactor(){
45  if(k_x!=NULL)
46  {
47  fftw_free(k_x);
48  fftw_free(k_y);
49  fftw_free(k_z);
50  }
51  if(structFactor!=NULL)
52  {
53  fftw_free(structFactor);
54  fftw_free(structFactor_fx);
55  fftw_free(structFactor_fy);
56  fftw_free(structFactor_fz);
57  }
58  if(destinations!=NULL)
59  delete [] destinations;
60  }
61 
62  void acceptDestination(int _numdest, int *_destinations)
63  {
64 #ifdef _CP_DEBUG_SF_CALC_
65  CkPrintf("[%d %d %d] SF has %d destinations\n",thisIndex.x, thisIndex.y, thisIndex.z, _numdest);
66 #endif
67  numdest=_numdest;
68  destinations =new int[numdest];
69  CmiMemcpy(destinations,_destinations, numdest *sizeof(int));
70  }
71  // compute and send
72  void computeSF(SFDummyMsg *msg);
73 
74  // accept initializing kvector from gspace
75  void acceptKVectors(int n, int *_k_x, int *_k_y, int *_k_z)
76  {
77  gsSize=n;
78  k_x= (int *)fftw_malloc(gsSize*sizeof(int));
79  k_y= (int *)fftw_malloc(gsSize*sizeof(int));
80  k_z= (int *)fftw_malloc(gsSize*sizeof(int));
81  CmiMemcpy(k_x,_k_x,gsSize*sizeof(int));
82  CmiMemcpy(k_y,_k_y,gsSize*sizeof(int));
83  CmiMemcpy(k_z,_k_z,gsSize*sizeof(int));
84  }
85  void pup(PUP::er &p)
86  {
87  p|gsSize;
88  p|numSfGrps;
89  p|numSfDups;
90  p|natm_nl_grp_max;
91  p|numdest;
92  p((char*)structFactor,gsSize*natm_nl_grp_max*sizeof(complex));
93  p((char*)structFactor_fx,gsSize*natm_nl_grp_max*sizeof(complex));
94  p((char*)structFactor_fy,gsSize*natm_nl_grp_max*sizeof(complex));
95  p((char*)structFactor_fz,gsSize*natm_nl_grp_max*sizeof(complex));
96  p(k_x,gsSize);
97  p(k_y,gsSize);
98  p(k_z,gsSize);
99  p(destinations, numdest);
100  }
101 
102  private:
103  int numSfGrps;
104  int numSfDups;
105  int natm_nl_grp_max;
106  int gsSize;
107  int *k_x;
108  int *k_y;
109  int *k_z;
110  complex *structFactor;
111  complex *structFactor_fx;
112  complex *structFactor_fy;
113  complex *structFactor_fz;
114  int numdest;
115  int *destinations;
116  const UberCollection thisInstance;
117 };
118 
119 #endif //_StructureFactor_h_
holds the UberIndex and the offset for proxies
Definition: Uber.h:68
void computeSF(SFDummyMsg *msg)
StructureFactor(int _numSfGrps, int _numSfDups, int _natm_nl_grp_max, int _numdest, int *_destinations, UberCollection _thisInstance)
Useful debugging flags.