PatchMap.inl

Go to the documentation of this file.
00001 
00007 #ifndef PATCHMAP_INL
00008 #define PATCHMAP_INL
00009 
00010 #include "PatchMap.h"
00011 #include "AtomMap.h"
00012 
00013 //----------------------------------------------------------------------
00014 inline PatchID PatchMap::assignToPatch(Position p, const Lattice &l)
00015 {
00016   int ai, bi, ci;
00017   ScaledPosition s = l.scale(p);
00018   ai = (int)floor(((BigReal)aDim)*((s.x-aOrigin)/aLength));
00019   bi = (int)floor(((BigReal)bDim)*((s.y-bOrigin)/bLength));
00020   ci = (int)floor(((BigReal)cDim)*((s.z-cOrigin)/cLength));
00021   return pid(ai,bi,ci);
00022 }
00023 
00024 //----------------------------------------------------------------------
00025 #define MODULO(I,J) ( (I)<0 ? ((J)-(-1*(I))%(J))%(J) : (I)%(J) )
00026 
00027 inline int PatchMap::pid(int aIndex, int bIndex, int cIndex)
00028 {
00029   if ( aPeriodic ) aIndex = MODULO(aIndex,aDim);
00030   else
00031   {
00032     if ( aIndex < 0 ) aIndex = 0;
00033     if ( aIndex >= aDim ) aIndex = aDim - 1;
00034   }
00035   if ( bPeriodic ) bIndex = MODULO(bIndex,bDim);
00036   else
00037   {
00038     if ( bIndex < 0 ) bIndex = 0;
00039     if ( bIndex >= bDim ) bIndex = bDim - 1;
00040   }
00041   if ( cPeriodic ) cIndex = MODULO(cIndex,cDim);
00042   else
00043   {
00044     if ( cIndex < 0 ) cIndex = 0;
00045     if ( cIndex >= cDim ) cIndex = cDim - 1;
00046   }
00047   return ((cIndex*bDim)+bIndex)*aDim + aIndex;
00048 }
00049 
00050 //----------------------------------------------------------------------
00051 inline int PatchMap::downstream(int pid1, int pid2)
00052 {
00053   register int ds;
00054 
00055   if ( pid1 == pid2 ) { ds = pid1; }
00056 
00057   else if ( pid1 == notUsed || pid2 == notUsed ) { ds =  notUsed; }
00058 
00059   else {
00060     register PatchData *pdat1 = &(patchData[pid1]);
00061     register PatchData *pdat2 = &(patchData[pid2]);
00062 
00063     // c
00064     register int k = pdat1->cIndex;
00065     register int k2 = pdat2->cIndex;
00066     if ( ( k ? k : cMaxIndex ) == k2 + 1 ) k = k2;
00067 
00068     // b
00069     register int j = pdat1->bIndex;
00070     register int j2 = pdat2->bIndex;
00071     if ( ( j ? j : bMaxIndex ) == j2 + 1 ) j = j2;
00072 
00073     // a
00074     register int i = pdat1->aIndex;
00075     register int i2 = pdat2->aIndex;
00076     if ( ( i ? i : aMaxIndex ) == i2 + 1 ) i = i2;
00077 
00078     ds = ((k*bDim)+j)*aDim + i;
00079   }
00080 
00081   return ds;
00082 }
00083 
00084 #endif
00085 

Generated on Tue Nov 21 01:17:14 2017 for NAMD by  doxygen 1.4.7