21 extern CkVec <CProxy_FFTcache> UfftCacheProxy;
23 extern CkVec <CProxy_eesCache> UeesCacheProxy;
36 int realSpaceUnits,
int s_grain,
int iplane_ind,
int istate_ind,
37 int len_nhc_cp,
int num_nhc_cp,
int nck_nhc_cp)
56 if(gSpaceUnits!=1 || realSpaceUnits!=1){
57 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
58 CkPrintf(
"gspacePPC==1 obsolete. We no longer parallelize g-space by plane\n");
59 CkPrintf(
"realSpacePPC==1 although real space is parallelized by plane\n");
60 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
63 gs->numNonZeroPlanes=1;
65 gs->planeSize =
size2d(sizeY,sizeZ);
72 gs->S_grainSize = s_grain;
74 gs->ydim = gs->planeSize[0];
75 gs->zdim = gs->planeSize[1];
76 gs->iplane_ind = iplane_ind;
77 gs->istate_ind = istate_ind;
78 gs->initNHC(len_nhc_cp,num_nhc_cp,nck_nhc_cp);
88 GStateSlab::~GStateSlab() {
90 if(packedPlaneData !=NULL) fftw_free( packedPlaneData);
91 if(packedForceData !=NULL) fftw_free( packedForceData);
92 if(packedVelData !=NULL) fftw_free( packedVelData);
94 if(packedPlaneDataScr !=NULL) fftw_free( packedPlaneDataScr);
96 #ifdef _CP_DEBUG_UPDATE_OFF_
98 if(packedPlaneDataTemp!=NULL) fftw_free( packedPlaneDataTemp);
103 packedPlaneData = NULL;
104 packedForceData = NULL;
105 packedVelData = NULL;
106 packedPlaneDataScr = NULL;
107 packedPlaneDataTemp = NULL;
144 p|nkx0; p|nkx0_uni; p|nkx0_red; p|nkx0_zero;
152 if (p.isUnpacking()) {
153 packedPlaneData = (
complex *)fftw_malloc(numPoints*
sizeof(
complex));
154 packedForceData = (
complex *)fftw_malloc(numFull*
sizeof(
complex));
155 packedVelData = (
complex *)fftw_malloc(numPoints*
sizeof(
complex));
158 packedPlaneDataScr = (
complex *)fftw_malloc(numPoints*
sizeof(
complex));
160 #ifdef _CP_DEBUG_UPDATE_OFF_
162 packedPlaneDataTemp = (
complex *)fftw_malloc(numPoints*
sizeof(
complex));
166 p((
char *) packedPlaneData, numPoints*
sizeof(
complex));
167 p((
char *) packedForceData, numFull*
sizeof(
complex));
168 p((
char *) packedVelData, numPoints*
sizeof(
complex));
169 p((
char *) packedRedPsi, nkx0*
sizeof(
complex));
171 p((
char *) packedPlaneDataScr, numPoints*
sizeof(
complex));
173 #ifdef _CP_DEBUG_UPDATE_OFF_
175 p((
char *) packedPlaneDataTemp, numPoints*
sizeof(
complex));
184 if (p.isUnpacking()) {
185 initNHC(len_nhc_cp,num_nhc_cp,nck_nhc_cp);
187 int nsize = num_nhc_cp*len_nhc_cp*nck_nhc_cp;
188 double *xt =
new double[nsize];
189 double *xtp =
new double[nsize];
190 double *vt =
new double[nsize];
191 double *ft =
new double[nsize];
194 for(
int k =0;k<num_nhc_cp;k++){
195 for(
int i =0;i<num_nhc_cp;i++){
196 for(
int j =0;j<len_nhc_cp;j++){
197 xt[iii] = xNHC[k][i][j];
198 xtp[iii] = xNHCP[k][i][j];
199 vt[iii] = vNHC[k][i][j];
200 ft[iii] = fNHC[k][i][j];
208 p(degFreeSplt,nck_nhc_cp);
209 p(istrNHC,nck_nhc_cp);
210 p(iendNHC,nck_nhc_cp);
215 if (p.isUnpacking()) {
217 for(
int k =0;k<nck_nhc_cp;k++){
218 for(
int i =0;i<num_nhc_cp;i++){
219 for(
int j =0;j<len_nhc_cp;j++){
220 xNHC[k][i][j] = xt[iii];
221 xNHCP[k][i][j] = xtp[iii];
222 vNHC[k][i][j] = vt[iii];
223 fNHC[k][i][j] = ft[iii];
242 void GStateSlab::addForces(
complex *points,
const int *k_x){
247 if(!config.doublePack){
249 for(i = 0; i < numPoints; i++){
250 packedForceData[i] += points[i];
256 for(i = 0; i < nkx0; i++){
257 #ifdef _CP_DEBUG_VKS_OFF_ // only non-local, no vks forces
258 packedForceData[i].re = 0.0; packedForceData[i].im = 0.0;
260 packedForceData[i] += points[i];
263 for(i = nkx0; i < numPoints; i++){
264 #ifdef _CP_DEBUG_VKS_OFF_ // only non-local, no vks forces
265 packedForceData[i].re = 0.0; packedForceData[i].im = 0.0;
267 packedForceData[i] *= 2.0;
268 packedForceData[i] += points[i];
292 CkAssert(n == numPoints);
308 if(config.doublePack){
309 for(i=0;i<numPoints;i++){
310 if(k_x[i]==0 && k_y[i]>0){nkx0_uni++;}
311 if(k_x[i]==0 && k_y[i]<0){nkx0_red++;}
312 if(k_x[i]==0 && k_y[i]==0 && k_z[i]>=0){nkx0_uni++;}
313 if(k_x[i]==0 && k_y[i]==0 && k_z[i]<0){nkx0_red++;}
314 if(k_x[i]==0 && k_y[i]==0 && k_z[i]==0){nkx0_zero++;ihave_g000=1;ind_g000=i;}
316 if(ihave_kx0==0){kx0_strt=i;}
321 kx0_end = kx0_strt + nkx0;
323 for(
int i=0;i<numPoints;i++){
324 if(k_x[i]==0 && k_y[i]==0 && k_z[i]==0){ihave_g000=1;ind_g000=i;}
331 if(config.doublePack){
334 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
335 CkPrintf(
"kx=0 should be stored first | kx_srt !=0\n");
336 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
337 CkAbort(
"kx=0 should be stored first | kx_srt !=0\n");
340 if(nkx0!=nkx0_uni+nkx0_red){
341 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
342 CkPrintf(
"Incorrect count of redundant guys\n");
343 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
344 CkAbort(
"Incorrect count of redundant guys\n");
349 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
350 CkPrintf(
"kx should be stored consecutively and first\n");
351 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
352 CkAbort(
"kx should be stored consecutively and first\n");
356 for(i=0;i<nkx0_red;i++){
357 if(k_y[i]>0 || (k_y[i]==0 && k_z[i]>=0)){
358 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
359 CkPrintf(
"ky <0 should be stored first\n");
360 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
361 CkAbort(
"ky <0 should be stored first\n");
365 for(i=nkx0_red;i<nkx0_uni;i++){
366 if(k_y[i]<0 || (k_y[i]==0 && k_z[i]<0)){
367 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
368 CkPrintf(
"ky <0 should be stored first\n");
369 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
370 CkAbort(
"ky <0 should be stored first\n");
378 memset(packedRedPsi, 0,
sizeof(
complex)*nkx0);
379 memset(packedRedPsiV, 0,
sizeof(
complex)*nkx0);
393 int gSpaceUnits,
int realSpaceUnits,
int stateIndex,
int planeIndex)
403 if(gSpaceUnits!=1 || realSpaceUnits!=1){
404 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
405 CkPrintf(
"gspacePPC==1 obsolete. We no longer parallelize g-space by plane\n");
406 CkPrintf(
"realSpacePPC==1 although real space is parallelized by plane\n");
407 CkPrintf(
"@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n");
411 rs->thisState = stateIndex;
412 rs->thisPlane = planeIndex;
414 rs->numPlanesToExpect = sim->nchareG;
415 if(config.doublePack){
416 int rsize_a = ngrid_a*(ngrid_b/2+1);
417 int rsize_b = ngrid_b*(ngrid_a/2+1);
418 rs->rsize = (rsize_a > rsize_b ? rsize_a : rsize_b);
419 rs->nsize = ngrid_a*ngrid_b;
420 rs->size = rs->rsize;
422 rs->rsize = 2*ngrid_a*ngrid_b;
423 rs->nsize = ngrid_a*ngrid_b;
424 rs->size = rs->nsize;
427 rs->planeArr = (
complex *) fftw_malloc(rs->size *
sizeof(
complex));
428 rs->planeArrR =
reinterpret_cast<double*
> (rs->planeArr);
430 rs->ngrid_a = ngrid_a;
431 rs->ngrid_b = ngrid_b;
441 RealStateSlab::~RealStateSlab() {
444 if(planeArr != NULL) {fftw_free(planeArr);planeArr = NULL; planeArrR=NULL;}
453 void RealStateSlab::pup(PUP::er &p) {
458 if (p.isUnpacking()) {
460 planeArrR =
reinterpret_cast<double*
> (planeArr);
462 PUParray(p, planeArr, size);
477 void RealStateSlab::allocate() {
478 if(planeArr == NULL) {
480 planeArrR =
reinterpret_cast<double*
> (planeArr);
489 void RealStateSlab::destroy() {
490 if(planeArr != NULL) {fftw_free(planeArr); planeArr=NULL; planeArrR = NULL;}
void pup(PUP::er &)
= data
== Size or location in a regular 2D array
void setKRange(int, int *, int *, int *)
void initGStateSlab(GStateSlab *gs, int sizeX, int sizeY, int sizeZ, int gSpaceUnits, int realSpaceUnits, int s_grain, int iplane_ind, int istate_ind, int len_nhc_cp, int num_nhc_cp, int nck_nhc_cp)
= slab initialization helpers
Add type declarations for simulationConstants class (readonly vars) and once class for each type of o...
Some basic data structures and the array map classes are defined here.
void initRealStateSlab(RealStateSlab *rs, int ngrid_a, int ngrid_b, int ngrid_c, int gSpaceUnits, int realSpaceUnits, int stateIndex, int planeIndex)