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

NamdTypes.h

Go to the documentation of this file.
00001 
00007 #ifndef NAMDTYPES_H
00008 
00009 #define NAMDTYPES_H
00010 
00011 #include "common.h"
00012 #include "Vector.h"
00013 #include "ResizeArray.h"
00014 
00015 class Patch;
00016 class Compute;
00017 
00018 typedef Vector Position;
00019 typedef Vector Velocity;
00020 
00021 //#ifdef ARCH_POWERPC
00022 //typedef AlignVector Force;
00023 //#else
00024 typedef Vector Force;
00025 //#endif
00026 
00027 typedef int AtomID;
00028 typedef int AtomType;
00029 typedef float Mass;
00030 typedef float Charge;
00031 
00032 typedef double Coordinate;
00033 
00034 struct Transform
00035 {
00036   signed char i,j,k;
00037   Transform(void) { i=0; j=0; k=0; }
00038 };
00039 
00040 /*
00041  * 1. "position" field in this structure is very important since it
00042  * needs to be sent to every patch after every timestep.
00043  * 2. Anything that is static (value is decided before computation)
00044  * or only changes after atom migration should be put into the CompAtomExt structure
00045  * 3. This data structure is 32-byte long which is particularly optimized for some machines
00046  * (including BG/L) for better cache and message performance. Therefore, changes
00047  * to this structure should be cautioned for the sake of performance.
00048  */
00049 struct CompAtom {
00050   Position position;
00051   Charge charge;
00052   unsigned int id : 22;
00053   unsigned int hydrogenGroupSize : 3;
00054   unsigned int nonbondedGroupIsAtom : 1;
00055   unsigned int atomFixed : 1;
00056   unsigned int groupFixed : 1;
00057   unsigned int partition : 4;
00058 
00059   CompAtom() { ; }
00060 
00061   // Needed for IBM's xlC compiler
00062   inline CompAtom(const CompAtom &a) :
00063     position(a.position), charge(a.charge),
00064     id(a.id), hydrogenGroupSize(a.hydrogenGroupSize),
00065     nonbondedGroupIsAtom(a.nonbondedGroupIsAtom),
00066     atomFixed(a.atomFixed), groupFixed(a.groupFixed),
00067     partition(a.partition){
00068       ;
00069   }
00070 
00071   // Needed for IBM's xlC compiler
00072   inline CompAtom& operator=(const CompAtom &a) {
00073     position = a.position;
00074     charge = a.charge;
00075     id = a.id;
00076     hydrogenGroupSize = a.hydrogenGroupSize;
00077     nonbondedGroupIsAtom = a.nonbondedGroupIsAtom;
00078     atomFixed = a.atomFixed;
00079     groupFixed = a.groupFixed;
00080     partition = a.partition;
00081 
00082     return *this;
00083   }
00084 
00085 };
00086 
00087 //CompAtomExt is now needed even in normal case
00088 //for changing the packed msg type related to
00089 //ProxyPatch into varsize msg type where
00090 // two types of proxy msgs (originally, the msg 
00091 // for the step where atoms migrate (ProxyAllMsg), 
00092 // and  the msg for normal steps (ProxyDataMsg))
00093 // are declared as the same class (ProxyDataMsg).
00094 // Note that in normal case, the class is needed
00095 // just for passing the compilation, but not involved
00096 // in the actual force calculation.
00097 // --Chao Mei
00098 
00099 typedef unsigned short AtomSigID;
00100 typedef unsigned short ExclSigID;
00101 typedef unsigned short VDW_TYPE;
00102 
00103 struct CompAtomExt {
00104   AtomSigID sigId;
00105   ExclSigID exclId;
00106   VDW_TYPE vdwType;
00107 
00108   CompAtomExt(){;}
00109 
00110   // Needed for IBM's xlC compiler
00111   inline CompAtomExt(const CompAtomExt &a) :
00112     sigId(a.sigId), exclId(a.exclId), vdwType(a.vdwType){
00113   }
00114 
00115   // Needed for IBM's xlC compiler
00116   inline CompAtomExt& operator=(const CompAtomExt &a) {
00117     sigId = a.sigId;
00118     exclId = a.exclId;
00119     vdwType = a.vdwType;
00120 
00121     return *this;
00122   }
00123 
00124 };
00125 
00126 #ifdef MEM_OPT_VERSION
00127 struct FullAtom : CompAtom, CompAtomExt{
00128 #else
00129 struct FullAtom : CompAtom {
00130 #endif
00131   Velocity velocity;
00132   Position fixedPosition;
00133   Mass mass;
00134   Transform transform;
00135 };
00136 
00137 typedef ResizeArray<CompAtom> CompAtomList;
00138 
00139 #ifdef MEM_OPT_VERSION
00140 typedef ResizeArray<CompAtomExt> CompAtomExtList;
00141 #endif
00142 
00143 typedef ResizeArray<FullAtom> FullAtomList;
00144 typedef ResizeArray<Position> PositionList;
00145 typedef ResizeArray<Velocity> VelocityList;
00146 typedef ResizeArray<Force> ForceList;
00147 typedef ResizeArray<Transform> TransformList;
00148 
00149 typedef ResizeArray<AtomID> AtomIDList;
00150 
00151 typedef int PatchID;
00152 typedef int ComputeID;
00153 typedef int NodeID;
00154 
00155 typedef ResizeArray<PatchID> PatchIDList;
00156 typedef ResizeArray<Patch *> PatchList;
00157 
00158 typedef ResizeArray<Compute *> ComputeList;
00159 
00160 // See AtomMap
00161 struct LocalID
00162 {
00163   PatchID pid;
00164   int index;
00165 };
00166 
00167 typedef ResizeArray<NodeID> NodeIDList;
00168 
00169 struct ExtForce {
00170   int replace;
00171   Force force;
00172   ExtForce() : replace(0) {;}
00173 };
00174 
00175 
00176 // DMK - Atom Sort
00177 #if NAMD_ComputeNonbonded_SortAtoms != 0
00178 
00179   typedef struct __sort_entry {
00180     unsigned int index;  // Index of atom in CompAtom array
00181     BigReal sortValue;   // Distance of PAp from P0 (see calculation code)
00182   } SortEntry;
00183 
00184 #endif
00185 
00186 //This class represents a tree node of proxy spanning tree
00187 //All pes in this array have the same "nodeID". In other words,
00188 //all those pes are in the same physical node.
00189 //This is a structure for adapting NAMD to multicore processors
00190 struct proxyTreeNode{
00191     int nodeID;
00192     int *peIDs;
00193     int numPes;
00194 
00195     proxyTreeNode(){
00196         nodeID = -1;
00197         peIDs = NULL;
00198         numPes = 0;
00199     }
00200     proxyTreeNode(int nid, int numPes_, int *pes){
00201         nodeID = nid;
00202         numPes = numPes_;
00203         peIDs = new int[numPes];
00204         memcpy(peIDs, pes, sizeof(int)*numPes);
00205     }
00206 
00207     inline proxyTreeNode(const proxyTreeNode &n){
00208         nodeID = n.nodeID;
00209         numPes = n.numPes;
00210         if(numPes==0) {
00211             peIDs = NULL;
00212         }else{
00213             peIDs = new int[n.numPes];
00214             memcpy(peIDs, n.peIDs, sizeof(int)*numPes);
00215         }
00216     }
00217     inline proxyTreeNode &operator=(const proxyTreeNode &n){
00218         nodeID = n.nodeID;
00219         numPes = n.numPes;
00220         delete [] peIDs;
00221         if(numPes==0) {
00222             peIDs = NULL;
00223             return (*this);
00224         }
00225         peIDs = new int[n.numPes];
00226         memcpy(peIDs, n.peIDs, sizeof(int)*numPes);
00227         return (*this);
00228     }
00229     ~proxyTreeNode(){
00230         delete [] peIDs;
00231     }
00232 };
00233 
00234 typedef ResizeArray<proxyTreeNode> proxyTreeNodeList;
00235 
00236 #endif /* NAMDTYPES_H */
00237 

Generated on Sun Sep 7 04:07:41 2008 for NAMD by  doxygen 1.3.9.1