NAMD
ComputeLCPO.h
Go to the documentation of this file.
1 
7 /*
8  Solvent Accessible Surface Area calculation by LCPO
9  Linear Combination of Pairwise Overlaps
10 */
11 
12 #ifndef COMPUTELCPO_H
13 #define COMPUTELCPO_H
14 
15 #include "Compute.h"
16 #include "PatchTypes.h"
17 #include "Box.h"
18 #include "OwnerBox.h"
19 #include "ComputeNonbondedUtil.h"
20 #include "NamdTypes.h"
21 
22 struct LCPOAtom {
23  float x, y, z, r;
24  Vector *f; // where to write force
25 };
26 
28  enum {initsize = 10};
29  int *nnfa; // number of neighbors for atom
30  int curAtom;
31  int maxAtoms;
32  LCPOAtom *neighbors;
33  int curNeighbor;
34  int maxNeighbors;
36  LCPONeighborList& operator=(const LCPONeighborList&) { return *this; }
37 public:
39  maxNeighbors(initsize), maxAtoms(initsize),
40  curNeighbor(0), curAtom(0) {
41  neighbors = new LCPOAtom[initsize];
42  nnfa = new int[initsize];
43  }
45  delete [] neighbors;
46  delete [] nnfa;
47  }
48  LCPOAtom *newlist(int max_size) { // get a new list w/ room for max_size
49  //do we need to make room for more neighbors
50  int reqNewSize = curNeighbor + max_size;
51  int newSize = maxNeighbors;
52  while ( newSize < reqNewSize ) { newSize += newSize >> 1; }
53  if ( newSize > maxNeighbors ) {
54  LCPOAtom *newNeighbors = new LCPOAtom[newSize];
55  CmiMemcpy(newNeighbors,neighbors,curNeighbor*sizeof(LCPOAtom));
56  delete [] neighbors;
57  neighbors = newNeighbors;
58  maxNeighbors = newSize;
59  }
60  //do we need to make room for more atoms
61  if (curAtom == maxAtoms) {
62  newSize = maxAtoms + (maxAtoms >> 1);
63  int *newNnfa = new int[newSize];
64  CmiMemcpy(newNnfa,nnfa,curAtom*sizeof(int));
65  delete [] nnfa;
66  nnfa = newNnfa;
67  maxAtoms = newSize;
68  }
69  return &neighbors[curNeighbor];
70  }
71  // don't specify size if previous allocation should have extra space
72  LCPOAtom *newlist() { // get a new list assuming already allocated
73  return &neighbors[curNeighbor];
74  }
75  void newsize(int list_size) { // set the size of the last list gotten
76  nnfa[curAtom] = list_size;
77  curAtom++;
78  curNeighbor += list_size;
79  }
80  void reset() { // go back to the beginning
81  curNeighbor = 0;
82  curAtom = 0;
83  }
84  void nextlist(LCPOAtom **list, int *list_size) { // get next list and size
85  *list = &neighbors[curNeighbor];
86  *list_size = nnfa[curAtom];
87  curNeighbor += nnfa[curAtom];
88  curAtom ++;
89  }
90  int getSize() { return maxNeighbors; }
91 };
92 
93 
94 
95 
96 class Patch;
97 class Node;
98 class PatchMap;
99 
100 class ComputeLCPO: public Compute, private ComputeNonbondedUtil {
101 
102 public:
103  ComputeLCPO(ComputeID c, PatchID pid[], int t[],
104  ComputeNonbondedWorkArrays* _workArrays,
105  int minPartition, int maxPartition, int numPartitions, int numPatches);
106 
107  virtual ~ComputeLCPO();
108 
109  virtual void initialize();
110  virtual void atomUpdate();
111  virtual void doWork();
112  virtual int noWork();
113 
114 protected :
115  int numAtoms[8];
116  int valid[8][8];
117  //0 if patch is invalid due to only 1 patch in that dimension
118  int invalidPatch[8];
122  int *lcpoType[8];
123  int step;
124 
125  virtual void doForce();
127 
129  int trans[8];
133 
136 
138 
139  private:
140  BigReal bounds[3][2];
141  int periodic[3];
142  int oob[3];
143  Vector offset[8];
144  int minIg[8];
145  int strideIg;//stride through partitions
146 
147  //index "i" is patch; index "j" is valid atoms in patch
148  Pairlists inAtomsPl;
149  Real surfTen;
150  Real maxAtomRadius;
151  Real cut2;
152  LCPONeighborList lcpoNeighborList;
153 
154  static const Real lcpoParams[23][5];
155 
156  int isInBounds( Real x, Real y, Real z );
157 };
158 
159 #endif
float r
Definition: ComputeLCPO.h:23
virtual int noWork()
Definition: ComputeLCPO.C:225
Definition: Node.h:78
int ComputeID
Definition: NamdTypes.h:183
Box< Patch, int > * lcpoTypeBox[8]
Definition: ComputeLCPO.h:132
Definition: Vector.h:64
Vector * f
Definition: ComputeLCPO.h:24
float Real
Definition: common.h:109
Results * force[8]
Definition: ComputeLCPO.h:121
LCPOAtom * newlist()
Definition: ComputeLCPO.h:72
CompAtomExt * posExt[8]
Definition: ComputeLCPO.h:119
int * lcpoType[8]
Definition: ComputeLCPO.h:122
ComputeNonbondedWorkArrays *const workArrays
Definition: ComputeLCPO.h:134
Box< Patch, Results > * forceBox[8]
Definition: ComputeLCPO.h:131
Definition: Patch.h:35
float x
Definition: ComputeLCPO.h:23
virtual void atomUpdate()
Definition: ComputeLCPO.C:193
virtual ~ComputeLCPO()
Definition: ComputeLCPO.C:61
float z
Definition: ComputeLCPO.h:23
int valid[8][8]
Definition: ComputeLCPO.h:116
virtual void initialize()
Definition: ComputeLCPO.C:86
float y
Definition: ComputeLCPO.h:23
virtual void doWork()
Definition: ComputeLCPO.C:202
gridSize z
int numAtoms[8]
Definition: ComputeLCPO.h:115
PatchID patchID[8]
Definition: ComputeLCPO.h:128
void newsize(int list_size)
Definition: ComputeLCPO.h:75
Box< Patch, CompAtom > * positionBox[8]
Definition: ComputeLCPO.h:130
int PatchID
Definition: NamdTypes.h:182
__global__ void const int const TileList *__restrict__ TileExcl *__restrict__ const int *__restrict__ const int const float2 *__restrict__ cudaTextureObject_t const int *__restrict__ const float3 const float3 const float3 const float4 *__restrict__ const float cudaTextureObject_t cudaTextureObject_t float const PatchPairRecord *__restrict__ const int *__restrict__ const int2 *__restrict__ const unsigned int *__restrict__ unsigned int *__restrict__ int *__restrict__ int *__restrict__ TileListStat *__restrict__ const BoundingBox *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ const int numPatches
LCPOAtom * newlist(int max_size)
Definition: ComputeLCPO.h:48
ComputeLCPO(ComputeID c, PatchID pid[], int t[], ComputeNonbondedWorkArrays *_workArrays, int minPartition, int maxPartition, int numPartitions, int numPatches)
Definition: ComputeLCPO.C:36
Patch * patch[8]
Definition: ComputeLCPO.h:126
CompAtom * pos[8]
Definition: ComputeLCPO.h:120
virtual void doForce()
Definition: ComputeLCPO.C:290
int trans[8]
Definition: ComputeLCPO.h:129
gridSize y
void nextlist(LCPOAtom **list, int *list_size)
Definition: ComputeLCPO.h:84
int invalidPatch[8]
Definition: ComputeLCPO.h:118
gridSize x
SubmitReduction * reduction
Definition: ComputeLCPO.h:137
double BigReal
Definition: common.h:114