ComputeLCPO.h

Go to the documentation of this file.
00001 
00007 /*
00008    Solvent Accessible Surface Area calculation by LCPO
00009    Linear Combination of Pairwise Overlaps
00010 */
00011 
00012 #ifndef COMPUTELCPO_H
00013 #define COMPUTELCPO_H
00014 
00015 #include "Compute.h"
00016 #include "PatchTypes.h"
00017 #include "Box.h"
00018 #include "OwnerBox.h"
00019 #include "ComputeNonbondedUtil.h"
00020 #include "NamdTypes.h"
00021 
00022 struct LCPOAtom {
00023   float x, y, z, r;
00024   Vector *f; // where to write force 
00025 };
00026 
00027 class LCPONeighborList {
00028   enum {initsize = 10};
00029   int *nnfa; // number of neighbors for atom
00030   int curAtom;
00031   int maxAtoms;
00032   LCPOAtom *neighbors;
00033   int curNeighbor;
00034   int maxNeighbors;
00035   LCPONeighborList(const LCPONeighborList&) { ; }
00036   LCPONeighborList& operator=(const LCPONeighborList&) { return *this; }
00037 public:
00038   LCPONeighborList() :
00039       maxNeighbors(initsize), maxAtoms(initsize),
00040       curNeighbor(0), curAtom(0) {
00041     neighbors = new LCPOAtom[initsize];
00042     nnfa = new int[initsize];
00043   }
00044   ~LCPONeighborList() {
00045     delete [] neighbors;
00046     delete [] nnfa;
00047   }
00048   LCPOAtom *newlist(int max_size) {  // get a new list w/ room for max_size
00049     //do we need to make room for more neighbors
00050     int reqNewSize = curNeighbor + max_size;
00051     int newSize = maxNeighbors;
00052     while ( newSize < reqNewSize ) { newSize += newSize >> 1; }
00053     if ( newSize > maxNeighbors ) {
00054       LCPOAtom *newNeighbors = new LCPOAtom[newSize];
00055       CmiMemcpy(newNeighbors,neighbors,curNeighbor*sizeof(LCPOAtom));
00056       delete [] neighbors;
00057       neighbors = newNeighbors;
00058       maxNeighbors = newSize;
00059     }
00060     //do we need to make room for more atoms
00061     if (curAtom == maxAtoms) {
00062       newSize = maxAtoms + (maxAtoms >> 1);
00063       int *newNnfa = new int[newSize];
00064       CmiMemcpy(newNnfa,nnfa,curAtom*sizeof(int));
00065       delete [] nnfa;
00066       nnfa = newNnfa;
00067       maxAtoms = newSize;
00068     }
00069     return &neighbors[curNeighbor];
00070   }
00071   // don't specify size if previous allocation should have extra space
00072   LCPOAtom *newlist() {  // get a new list assuming already allocated
00073     return &neighbors[curNeighbor];
00074   }
00075   void newsize(int list_size) {  // set the size of the last list gotten
00076     nnfa[curAtom] = list_size;
00077     curAtom++;
00078     curNeighbor += list_size;
00079   }
00080   void reset() {  // go back to the beginning
00081     curNeighbor = 0;
00082     curAtom = 0;
00083   }
00084   void nextlist(LCPOAtom **list, int *list_size) {  // get next list and size
00085     *list = &neighbors[curNeighbor];
00086     *list_size = nnfa[curAtom];
00087     curNeighbor += nnfa[curAtom];
00088     curAtom ++;
00089   }
00090   int getSize() { return maxNeighbors; }
00091 };
00092 
00093 
00094 
00095 
00096 class Patch;
00097 class Node;
00098 class PatchMap;
00099 
00100 class ComputeLCPO: public Compute, private ComputeNonbondedUtil {
00101 
00102 public:
00103   ComputeLCPO(ComputeID c, PatchID pid[], int t[],
00104                 ComputeNonbondedWorkArrays* _workArrays,
00105                 int minPartition, int maxPartition, int numPartitions, int numPatches);
00106 
00107   virtual ~ComputeLCPO();
00108 
00109   virtual void initialize();
00110   virtual void atomUpdate();
00111   virtual void doWork();
00112   virtual int noWork();
00113 
00114 protected :
00115   int numAtoms[8];
00116   int valid[8][8];
00117   //0 if patch is invalid due to only 1 patch in that dimension
00118   int invalidPatch[8];
00119   CompAtomExt *posExt[8];
00120   CompAtom *pos[8];
00121   Results *force[8];
00122   int *lcpoType[8];
00123   int step;
00124 
00125   virtual void doForce();
00126   Patch *patch[8];
00127 
00128   PatchID patchID[8];
00129   int trans[8];
00130   Box<Patch,CompAtom> *positionBox[8];
00131   Box<Patch,Results> *forceBox[8];
00132   Box<Patch,int> *lcpoTypeBox[8];
00133 
00134   ComputeNonbondedWorkArrays* const workArrays;
00135   int minPart, maxPart, numParts;
00136 
00137   SubmitReduction *reduction;
00138 
00139   private:
00140     BigReal bounds[3][2];
00141     int periodic[3];
00142     int oob[3];
00143     Vector offset[8];
00144     int minIg[8];
00145     int strideIg;//stride through partitions
00146 
00147     //index "i" is patch; index "j" is valid atoms in patch
00148     Pairlists inAtomsPl;
00149     Real surfTen;
00150     Real maxAtomRadius;
00151     Real cut2;
00152     LCPONeighborList lcpoNeighborList;
00153 
00154     static const Real lcpoParams[23][5];
00155 
00156     int isInBounds( Real x, Real y, Real z );
00157 };
00158 
00159 #endif

Generated on Mon Nov 20 01:17:11 2017 for NAMD by  doxygen 1.4.7