NAMD
Macros | Functions
ComputeGBIS.C File Reference
#include "ComputeNonbondedUtil.h"
#include "ComputeGBIS.inl"
#include "time.h"

Go to the source code of this file.

Macros

#define CHECK_PRIORITIES   0
 

Functions

void pairlistFromAll (nonbonded *params, GBISParamStruct *gbisParams, int minIg, int strideIg, int maxI)
 

Macro Definition Documentation

#define CHECK_PRIORITIES   0

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 9 of file ComputeGBIS.C.

Function Documentation

void pairlistFromAll ( nonbonded params,
GBISParamStruct gbisParams,
int  minIg,
int  strideIg,
int  maxI 
)
inline

Definition at line 44 of file ComputeGBIS.C.

References GBISParamStruct::a_cut, GBISParamStruct::cid, GBISParamStruct::cutoff, FS_MAX, GBISParamStruct::gbisPhase, GBISParamStruct::gbisStepPairlists, GBISParamStruct::intRad, GBISParamStruct::maxGroupRadius, Pairlists::newsize(), CompAtom::nonbondedGroupSize, nonbonded::numAtoms, GBISParamStruct::numPatches, nonbonded::offset, nonbonded::p, CompAtom::position, Pairlists::reset(), GBISParamStruct::sequence, Vector::x, Vector::y, and Vector::z.

Referenced by ComputeNonbondedUtil::calcGBIS().

50  {
51  const BigReal offset_x = params->offset.x;
52  const BigReal offset_y = params->offset.y;
53  const BigReal offset_z = params->offset.z;
54 
55  int unique = (gbisParams->numPatches == 1) ? 1 : 0;
56 
57  int maxPairs = params->numAtoms[1];
58  int seq = gbisParams->sequence;
59  int cid = gbisParams->cid;
60  int pe = CkMyPe();
61  int gbisPhase = gbisParams->gbisPhase;
62 
63  //determine long and short cutoff
64  float fsMax = FS_MAX; // gbisParams->fsMax;
65  float a_cut = gbisParams->a_cut - fsMax;
66  float a_cut_ps2 = (a_cut+fsMax)*(a_cut+fsMax);
67  float r_cut = gbisParams->cutoff;
68  float a_cut2 = a_cut*a_cut;
69  float r_cut2 = r_cut*r_cut;
70  int s = 0;// 0 is short cutoff list
71  int l = 1;// 1 is long-short cutoff list
72 #ifdef BENCHMARK
73  double t1 = 1.0*clock()/CLOCKS_PER_SEC;
74  int nops = 0;
75 #endif
76  Position ri, rj;
77  Position ngri, ngrj;
78  float r, dr, r2;
79  float rhoi0, rhois, rhoj0, rhojs, rhois2, rhojs2, rhois2_16;
80  float ami2, amj2, api2, apj2;
81  int numGBISPairlists = 4;
82 
83  float max_gcut2 = r_cut;
84  if (a_cut+fsMax > r_cut)
85  max_gcut2 = a_cut+fsMax;
86  max_gcut2 += 2.0*gbisParams->maxGroupRadius;
87  //CkPrintf("max_cut = %f, %f\n",max_gcut2,gbisParams->maxGroupRadius);
88  max_gcut2 *= max_gcut2;
89 
90  int maxGroupPairs = params->numAtoms[1];
91  short *groupPairs = new short[maxGroupPairs];/*delete*/
92 
93  //foreach nonbonded group i
94  for (int ngi = minIg; ngi < maxI; /*ngi updated at loop bottom*/ ) {
95  int numGroupPairs = 0;
96  ngri = params->p[0][ngi].position;
97  ngri.x += offset_x;
98  ngri.y += offset_y;
99  ngri.z += offset_z;
100 
101  //find close j-groups; include i-group
102  for (int ngj = unique*(ngi+params->p[0][ngi].nonbondedGroupSize); ngj < params->numAtoms[1]; ngj+=params->p[1][ngj].nonbondedGroupSize) {
103 
104  ngrj = params->p[1][ngj].position;
105  dr = ngri.x - ngrj.x;
106  r2 = dr*dr;
107  dr = ngri.y - ngrj.y;
108  r2 += dr*dr;
109  dr = ngri.z - ngrj.z;
110  r2 += dr*dr;
111  if (r2 < max_gcut2) {
112  groupPairs[numGroupPairs++] = ngj;
113  }
114  }
115 
116  //for all i in i-group
117  int iGroupSize = params->p[0][ngi].nonbondedGroupSize;
118  for (int i=ngi; i<ngi+iGroupSize; i++) {
119  //CkPrintf("\tFORALL i=%05i\n",params->pExt[0][i].id);
120  //extend pairlists
121  int *size = new int[numGBISPairlists];
122  plint **pairs = new plint*[numGBISPairlists];
123  for (int k = 0; k < numGBISPairlists; k++) {
124  size[k] = 0;
125  pairs[k] = gbisParams->gbisStepPairlists[k]->
126  newlist(maxPairs);
127  }
128 
129  //load i values
130  ri = params->p[0][i].position;
131  ri.x += offset_x;
132  ri.y += offset_y;
133  ri.z += offset_z;
134  rhois = gbisParams->intRad[0][2*i+1];
135  api2 = a_cut + rhois;
136  api2 *= api2;
137  ami2 = a_cut - rhois;
138  ami2 *= ami2;
139  rhois2 = rhois*rhois;
140  rhois2_16 = 16.0*rhois2;
141 
142  //for all other i's in i-group
143  if (unique)
144  for (int j = i+1; j < ngi+iGroupSize; j++) {
145 
146 #ifdef BENCHMARK
147  nops ++;
148 #endif
149  rj = params->p[1][j].position;
150  dr = ri.x - rj.x;
151  r2 = dr*dr;
152  dr = ri.y - rj.y;
153  r2 += dr*dr;
154  dr = ri.z - rj.z;
155  r2 += dr*dr;
156 
157  rhojs = gbisParams->intRad[1][2*j+1];
158  rhojs2 = rhojs*rhojs;
159  //r = sqrt(r2);
160  amj2 = a_cut - rhojs;
161  amj2 *= amj2;
162 
163  apj2 = a_cut + rhojs;
164  apj2 *= apj2;
165  //CkPrintf("IPAIR %5i %5i %5i\n",0*gbisParams->cid,params->pExt[0][i].id,params->pExt[1][j].id);
166 
167  if ( r2 < ami2 && r2 < amj2 &&
168  r2 > rhois2_16 && r2 > 16.0*rhojs2 ) {
169  //belongs to 22
170  pairs[0][size[0]++] = j;
171  } else if ( r2 < api2 && r2 < apj2 &&
172  r2 > ami2 && r2 > amj2 ) {
173  //belongs to 11
174  pairs[1][size[1]++] = j;
175  } else if ( r2 < a_cut_ps2 ) {
176  //belongs to other a_cut
177  pairs[2][size[2]++] = j;
178  } else if ( r2 < r_cut2 ) {
179  //belongs to r_cut and (r_cut > a_cut)
180  pairs[3][size[3]++] = j;
181  }
182  }
183 
184  //foreach j-group
185  for (int g = 0; g < numGroupPairs; g++) {
186  int ngj = groupPairs[g];
187  int jGroupSize = params->p[1][ngj].nonbondedGroupSize;
188  //for each j in j-group
189  int maxJ = ngj+jGroupSize;
190  for (int j = ngj; j < maxJ; j++) {
191 
192  //CkPrintf("for j-atom%i\n",j);
193 #ifdef BENCHMARK
194  nops ++;
195 #endif
196  rj = params->p[1][j].position;
197  dr = ri.x - rj.x;
198  r2 = dr*dr;
199  dr = ri.y - rj.y;
200  r2 += dr*dr;
201  dr = ri.z - rj.z;
202  r2 += dr*dr;
203  //CkPrintf("PAIR %5i %5i %5i\n",0*gbisParams->cid,params->pExt[0][i].id,params->pExt[1][j].id);
204 
205  rhojs = gbisParams->intRad[1][2*j+1];
206  rhojs2 = rhojs*rhojs;
207  //r = sqrt(r2);
208  amj2 = a_cut - rhojs;
209  amj2 *= amj2;
210 
211  apj2 = a_cut + rhojs;
212  apj2 *= apj2;
213 
214  if ( r2 < ami2 && r2 < amj2 &&
215  r2 > rhois2_16 && r2 > 16.0*rhojs2 ) {
216  //belongs to 22
217  //CkPrintf("Pair22 %06i %06i\n",params->pExt[0][i].id,params->pExt[1][j].id);
218  pairs[0][size[0]++] = j;
219  } else if ( r2 < api2 && r2 < apj2 &&
220  r2 > ami2 && r2 > amj2 ) {
221  //CkPrintf("Pair11 %06i %06i\n",params->pExt[0][i].id,params->pExt[1][j].id);
222  //belongs to 11
223  pairs[1][size[1]++] = j;
224  } else if ( r2 < a_cut_ps2 ) {
225  //CkPrintf("PairAA %06i %06i\n",params->pExt[0][i].id,params->pExt[1][j].id);
226  //belongs to other a_cut
227  pairs[2][size[2]++] = j;
228  } else if ( r2 < r_cut2 ) {
229  //CkPrintf("PairRR %06i %06i\n",params->pExt[0][i].id,params->pExt[1][j].id);
230  //belongs to r_cut and (r_cut > a_cut)
231  pairs[3][size[3]++] = j;
232  }
233  }//end j inner loop
234  }//end j-group loop
235  for (int k = 0; k < numGBISPairlists; k++) {
236  gbisParams->gbisStepPairlists[k]->newsize(size[k]);
237  }
238  delete[] size;
239  delete[] pairs;
240  }//end i all atom loop
241 
242  //jump to next nbg for round-robin
243  //same iteration patter followed in all three gbisPhases below
244  for (int s = 0; s < strideIg; s++) {
245  ngi+=params->p[0][ngi].nonbondedGroupSize;
246  }
247  }//end i-group loop
248  delete[] groupPairs;
249  for (int k = 0; k < numGBISPairlists; k++)
250  gbisParams->gbisStepPairlists[k]->reset();
251 
252 #ifdef BENCHMARK
253  double t2 = 1.0*clock()/CLOCKS_PER_SEC;
254  CkPrintf("PHASELST: %8.3f ms @ %8.3f ns/iter for %i iter\n",1000.0*(t2-t1), 1000000000.0*(t2-t1)/nops, nops);
255 #endif
256 }//end pairlist method
CompAtom * p[2]
Definition: Vector.h:64
BigReal z
Definition: Vector.h:66
Position position
Definition: NamdTypes.h:53
unsigned short plint
Pairlists * gbisStepPairlists[4]
BigReal x
Definition: Vector.h:66
#define FS_MAX
Definition: ComputeGBIS.inl:24
BigReal y
Definition: Vector.h:66
void newsize(int list_size)
unsigned int nonbondedGroupSize
Definition: NamdTypes.h:57
double BigReal
Definition: common.h:114