Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Patch.h

Go to the documentation of this file.
00001 
00007 #ifndef PATCH_H
00008 #define PATCH_H
00009 
00010 #include "NamdTypes.h"
00011 #include "OwnerBox.h"
00012 #include "Box.h"
00013 #include "UniqueSortedArray.h"
00014 #include "Lattice.h"
00015 #include "PatchTypes.h"
00016 
00017 typedef SortedArray<ComputeID> ComputeIDList;
00018 
00019 class Compute;
00020 class Sequencer;
00021 class PatchMap;
00022 
00023 
00024 // This the base class of homepatches and proxy patches. It maintains
00025 // common functions of these patches. These include managing dependences
00026 // between compute (force) objects and the patch and updating atom map.
00027 
00028 class Patch
00029 {
00030   public:
00031 
00032      Patch(PatchID pd);
00033      int hasNewAtoms() { return _hasNewAtoms; }
00034      virtual ~Patch(void) { };
00035 
00036      // methods for use by Compute objects
00037      Box<Patch,CompAtom>* registerPositionPickup(ComputeID cid, int trans = 13);
00038      void unregisterPositionPickup(ComputeID cid,
00039                                    Box<Patch,CompAtom>**const box);
00040      Box<Patch,CompAtom>* registerAvgPositionPickup(ComputeID cid, int trans = 13);
00041      void unregisterAvgPositionPickup(ComputeID cid,
00042                                    Box<Patch,CompAtom>**const box);
00043      Box<Patch,Results>* registerForceDeposit(ComputeID cid);
00044      void unregisterForceDeposit(ComputeID cid, Box<Patch,Results> **const box);
00045 
00046      // methods for use by Sequencer or ProxyManager
00047      // void positionsReady(void) { positionsReady(0); }
00048      void positionsReady(int n=0);
00049 
00050      // methods for Box callbacks
00051      void positionBoxClosed(void);
00052      void forceBoxClosed(void);
00053      void avgPositionBoxClosed(void);
00054 
00055      int getNumAtoms() { return numAtoms; }
00056 
00057      // DMK - Atom Separation (water vs. non-water)
00058      #if NAMD_SeparateWaters != 0
00059        int getNumWaterAtoms() { return numWaterAtoms; }
00060      #endif
00061 
00062      int getNumFixedAtoms() { return numFixedAtoms; }  // not updated
00063      void setNumFixedAtoms(int numFixed) { numFixedAtoms=numFixed; }  // not updated
00064      PatchID getPatchID() { return patchID; }
00065      int getNumComputes() { return positionComputeList.size(); }
00066 
00067      CompAtomExt* getCompAtomExtInfo() { return pExt.begin(); }
00068 
00069      Lattice &lattice;
00070      Flags flags;
00071 
00072   protected:
00073 
00074      const PatchID patchID;
00075      int           numAtoms;
00076      int           numFixedAtoms;
00077      CompAtomList  p;
00078      CompAtomList  p_avg;
00079 
00080      // DMK - Atom Separation (water vs. non-water)
00081      #if NAMD_SeparateWaters != 0
00082        int numWaterAtoms;  // Set numWaters to the number of water atoms at
00083                            //   the lead of the atoms list.  If numWaters is
00084                            //   set to -1, this should indicate that
00085                            //   atoms has not been separated yet.
00086      #endif
00087 
00088      CompAtomExtList pExt;
00089 
00090 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
00091      //1. Those fields are declared for reusing position info
00092      //inside the ProxyDataMsg msg at every step so that the
00093      //extra copy is avoided.
00094      //Regarding the CompAtomExt list inside the msg of ProxyAllMsg type
00095      //we cannot avoid the copy in the current scheme because this information
00096      //will be lost as the msg will be deleted at the next timestep. But the
00097      //overhead is amortized among the steps that atoms don't migrate
00098      //2. positionPtrBegin is better to be made 32-byte aligned so we could
00099      // have better cache performance in the force calculation part. This
00100      // is especially needed for BG/L machine.
00101      // --Chao Mei
00102      CompAtom      *positionPtrBegin;
00103      CompAtom      *positionPtrEnd;     
00104 #endif
00105      CompAtom      *avgPositionPtrBegin;
00106      CompAtom      *avgPositionPtrEnd;
00107 
00108      ForceList     f[Results::maxNumForces];
00109      Results       results;
00110 
00111      OwnerBox<Patch,CompAtom> positionBox;
00112      ComputeIDList              positionComputeList;
00113      OwnerBox<Patch,CompAtom> avgPositionBox;
00114      ComputeIDList              avgPositionComputeList;
00115      OwnerBox<Patch,Results>    forceBox;
00116      ComputeIDList              forceComputeList;
00117 
00118      virtual void boxClosed(int /* box */) = 0;
00119      int boxesOpen;
00120 
00121      int _hasNewAtoms;
00122 
00123 #ifdef NODEAWARE_PROXY_SPANNINGTREE    
00124     //its own children in proxy tree
00125     int *children;
00126     int numChild;
00127     #ifdef USE_NODEPATCHMGR
00128     //the immediate children (in terms of node id) also cotains two parts
00129     //as the above variable shows
00130     //If this patch has proxies residing on the same node, then the last entry
00131     //of "nodeChildren" stores this node id. It is same with that variable
00132     //in ProxyPatch      
00133     //If this proxy resides on node A, then the last entry
00134     //of "nodeChildren" has to be A
00135     //It is same with that variable in HomePatch
00136     int *nodeChildren;
00137     int numNodeChild;
00138     #endif
00139 #endif
00140 
00141 
00142   private:
00143   
00144 
00145 };
00146 
00147 
00148 #endif
00149 

Generated on Mon Nov 23 04:59:23 2009 for NAMD by  doxygen 1.3.9.1