ComputeHomeTuples< T, S, P > Class Template Reference

#include <ComputeHomeTuples.h>

Inheritance diagram for ComputeHomeTuples< T, S, P >:

Compute ComputeAngles ComputeAniso ComputeBonds ComputeCrossterms ComputeDihedrals ComputeGromacsPair ComputeImpropers ComputeSelfTuples< T, S, P > ComputeSelfTuples< AngleElem, angle, AngleValue > ComputeSelfTuples< AnisoElem, aniso, aniso > ComputeSelfTuples< BondElem, bond, BondValue > ComputeSelfTuples< CrosstermElem, crossterm, CrosstermValue > ComputeSelfTuples< DihedralElem, dihedral, DihedralValue > ComputeSelfTuples< ExclElem, Exclusion, int > ComputeSelfTuples< GromacsPairElem, gromacsPair, GromacsPairValue > ComputeSelfTuples< ImproperElem, improper, ImproperValue > ComputeSelfTuples< TholeElem, thole, thole > ComputeThole List of all members.

Public Member Functions

virtual ~ComputeHomeTuples ()
virtual void initialize (void)
void atomUpdate (void)
virtual void doWork (void)

Protected Member Functions

virtual void loadTuples (void)
 ComputeHomeTuples (ComputeID c)
 ComputeHomeTuples (ComputeID c, PatchIDList &pids)

Protected Attributes

int doLoadTuples
ResizeArray< T > tupleList
TuplePatchList tuplePatchList
PatchMappatchMap
AtomMapatomMap
SubmitReductionreduction
int accelMDdoDihe
SubmitReductionpressureProfileReduction
BigRealpressureProfileData
int pressureProfileSlabs
char * isBasePatch

Detailed Description

template<class T, class S, class P>
class ComputeHomeTuples< T, S, P >

Definition at line 315 of file ComputeHomeTuples.h.


Constructor & Destructor Documentation

template<class T, class S, class P>
ComputeHomeTuples< T, S, P >::ComputeHomeTuples ( ComputeID  c  )  [inline, protected]

Definition at line 463 of file ComputeHomeTuples.h.

00463                                    : Compute(c) {
00464       patchMap = PatchMap::Object();
00465       atomMap = AtomMap::Object();
00466       reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00467       
00468       SimParameters *params = Node::Object()->simParameters;
00469       accelMDdoDihe=false;
00470       if (params->accelMDOn) {
00471          if (params->accelMDdihe || params->accelMDdual) accelMDdoDihe=true;
00472       }
00473       if (params->pressureProfileOn) {
00474         pressureProfileSlabs = T::pressureProfileSlabs = 
00475           params->pressureProfileSlabs;
00476         int n = T::pressureProfileAtomTypes = params->pressureProfileAtomTypes;
00477         pressureProfileReduction = ReductionMgr::Object()->willSubmit(
00478           REDUCTIONS_PPROF_BONDED, 3*pressureProfileSlabs*((n*(n+1))/2));
00479         int numAtomTypePairs = n*n;
00480         pressureProfileData = new BigReal[3*pressureProfileSlabs*numAtomTypePairs];
00481       } else {
00482         pressureProfileReduction = NULL;
00483         pressureProfileData = NULL;
00484       }
00485       doLoadTuples = false;
00486       isBasePatch = 0;
00487 #ifdef USE_HOMETUPLES
00488       tuples = NULL;
00489 #endif
00490     }

template<class T, class S, class P>
ComputeHomeTuples< T, S, P >::ComputeHomeTuples ( ComputeID  c,
PatchIDList pids 
) [inline, protected]

Definition at line 492 of file ComputeHomeTuples.h.

00492                                                       : Compute(c) {
00493       patchMap = PatchMap::Object();
00494       atomMap = AtomMap::Object();
00495       reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00496       SimParameters *params = Node::Object()->simParameters;
00497       accelMDdoDihe=false;
00498       if (params->accelMDOn) {
00499          if (params->accelMDdihe || params->accelMDdual) accelMDdoDihe=true;
00500       }
00501       if (params->pressureProfileOn) {
00502         pressureProfileSlabs = T::pressureProfileSlabs = 
00503           params->pressureProfileSlabs;
00504         int n = T::pressureProfileAtomTypes = params->pressureProfileAtomTypes;
00505         pressureProfileReduction = ReductionMgr::Object()->willSubmit(
00506           REDUCTIONS_PPROF_BONDED, 3*pressureProfileSlabs*((n*(n+1))/2));
00507         int numAtomTypePairs = n*n;
00508         pressureProfileData = new BigReal[3*pressureProfileSlabs*numAtomTypePairs];
00509       } else {
00510         pressureProfileReduction = NULL;
00511         pressureProfileData = NULL;
00512       }
00513       doLoadTuples = false;
00514       int nPatches = patchMap->numPatches();
00515       isBasePatch = new char[nPatches];
00516       int i;
00517       for (i=0; i<nPatches; ++i) { isBasePatch[i] = 0; }
00518       for (i=0; i<pids.size(); ++i) { isBasePatch[pids[i]] = 1; }
00519 #ifdef USE_HOMETUPLES
00520       tuples = NULL;
00521 #endif
00522     }

template<class T, class S, class P>
virtual ComputeHomeTuples< T, S, P >::~ComputeHomeTuples (  )  [inline, virtual]

Definition at line 526 of file ComputeHomeTuples.h.

00526                                  {
00527       delete reduction;
00528       delete [] isBasePatch;
00529       delete pressureProfileReduction;
00530       delete pressureProfileData;
00531 #ifdef USE_HOMETUPLES
00532       if (tuples != NULL) delete tuples;
00533 #endif
00534     }


Member Function Documentation

template<class T, class S, class P>
void ComputeHomeTuples< T, S, P >::atomUpdate ( void   )  [inline, virtual]

Reimplemented from Compute.

Definition at line 590 of file ComputeHomeTuples.h.

00590                           {
00591       doLoadTuples = true;
00592     }

template<class T, class S, class P>
virtual void ComputeHomeTuples< T, S, P >::doWork ( void   )  [inline, virtual]

Reimplemented from Compute.

Reimplemented in ComputeSelfTuples< T, S, P >, ComputeSelfTuples< GromacsPairElem, gromacsPair, GromacsPairValue >, ComputeSelfTuples< AngleElem, angle, AngleValue >, ComputeSelfTuples< ExclElem, Exclusion, int >, ComputeSelfTuples< ImproperElem, improper, ImproperValue >, ComputeSelfTuples< BondElem, bond, BondValue >, ComputeSelfTuples< TholeElem, thole, thole >, ComputeSelfTuples< DihedralElem, dihedral, DihedralValue >, ComputeSelfTuples< CrosstermElem, crossterm, CrosstermValue >, and ComputeSelfTuples< AnisoElem, aniso, aniso >.

Definition at line 599 of file ComputeHomeTuples.h.

Referenced by ComputeSelfTuples< AnisoElem, aniso, aniso >::doWork().

00599                               {
00600 
00601       LdbCoordinator::Object()->startWork(ldObjHandle);
00602 
00603       // Open Boxes - register that we are using Positions
00604       // and will be depositing Forces.
00605       UniqueSetIter<TuplePatchElem> ap(tuplePatchList);
00606       for (ap = ap.begin(); ap != ap.end(); ap++) {
00607         ap->x = ap->positionBox->open();
00608         ap->xExt = ap->p->getCompAtomExtInfo();
00609         if ( ap->p->flags.doMolly ) ap->x_avg = ap->avgPositionBox->open();
00610         ap->r = ap->forceBox->open();
00611         ap->f = ap->r->f[Results::normal];
00612         if (accelMDdoDihe) ap->af = ap->r->f[Results::amdf]; // for dihedral-only or dual-boost accelMD
00613       } 
00614     
00615       BigReal reductionData[T::reductionDataSize];
00616       int tupleCount = 0;
00617       int numAtomTypes = T::pressureProfileAtomTypes;
00618       int numAtomTypePairs = numAtomTypes*numAtomTypes;
00619     
00620       for ( int i = 0; i < T::reductionDataSize; ++i ) reductionData[i] = 0;
00621       if (pressureProfileData) {
00622         memset(pressureProfileData, 0, 3*pressureProfileSlabs*numAtomTypePairs*sizeof(BigReal));
00623         // Silly variable hiding of the previous iterator
00624         UniqueSetIter<TuplePatchElem> newap(tuplePatchList);
00625         newap = newap.begin();
00626         const Lattice &lattice = newap->p->lattice;
00627         T::pressureProfileThickness = lattice.c().z / pressureProfileSlabs;
00628         T::pressureProfileMin = lattice.origin().z - 0.5*lattice.c().z;
00629       }
00630 
00631       if ( ! Node::Object()->simParameters->commOnly ) {
00632       if ( doLoadTuples ) {
00633 #ifdef USE_HOMETUPLES
00634         tuples->loadTuples(tuplePatchList, isBasePatch, AtomMap::Object());
00635 #else
00636         loadTuples();
00637 #endif
00638         doLoadTuples = false;
00639       }
00640       // take triplet and pass with tuple info to force eval
00641 #ifdef USE_HOMETUPLES
00642       T *al = (T *)tuples->getTupleList();
00643       const int ntuple = tuples->getNumTuples();
00644 #else
00645       T *al = tupleList.begin();
00646       const int ntuple = tupleList.size();
00647 #endif
00648       if ( ntuple ) T::computeForce(al, ntuple, reductionData, pressureProfileData);
00649       tupleCount += ntuple;
00650       }
00651  
00652     LdbCoordinator::Object()->endWork(ldObjHandle);
00653 
00654       T::submitReductionData(reductionData,reduction);
00655       reduction->item(T::reductionChecksumLabel) += (BigReal)tupleCount;
00656       reduction->submit();
00657 
00658       if (pressureProfileReduction) {
00659         // For ease of calculation we stored interactions between types
00660         // i and j in (ni+j).  For efficiency now we coalesce the
00661         // cross interactions so that just i<=j are stored.
00662         const int arraysize = 3*pressureProfileSlabs;
00663         const BigReal *data = pressureProfileData;
00664         for (int i=0; i<numAtomTypes; i++) {
00665           for (int j=0; j<numAtomTypes; j++) {
00666             int ii=i;
00667             int jj=j;
00668             if (ii > jj) { int tmp=ii; ii=jj; jj=tmp; }
00669             const int reductionOffset = 
00670               (ii*numAtomTypes - (ii*(ii+1))/2 + jj)*arraysize;
00671             for (int k=0; k<arraysize; k++) {
00672               pressureProfileReduction->item(reductionOffset+k) += data[k];
00673             }
00674             data += arraysize;
00675           }
00676         }
00677         pressureProfileReduction->submit();
00678       }
00679     
00680       // Close boxes - i.e. signal we are done with Positions and
00681       // AtomProperties and that we are depositing Forces
00682       for (ap = ap.begin(); ap != ap.end(); ap++) {
00683         ap->positionBox->close(&(ap->x));
00684         if ( ap->p->flags.doMolly ) ap->avgPositionBox->close(&(ap->x_avg));
00685         ap->forceBox->close(&(ap->r));
00686       }
00687     }

template<class T, class S, class P>
virtual void ComputeHomeTuples< T, S, P >::initialize ( void   )  [inline, virtual]

Reimplemented from Compute.

Reimplemented in ComputeSelfTuples< T, S, P >, ComputeSelfTuples< GromacsPairElem, gromacsPair, GromacsPairValue >, ComputeSelfTuples< AngleElem, angle, AngleValue >, ComputeSelfTuples< ExclElem, Exclusion, int >, ComputeSelfTuples< ImproperElem, improper, ImproperValue >, ComputeSelfTuples< BondElem, bond, BondValue >, ComputeSelfTuples< TholeElem, thole, thole >, ComputeSelfTuples< DihedralElem, dihedral, DihedralValue >, ComputeSelfTuples< CrosstermElem, crossterm, CrosstermValue >, and ComputeSelfTuples< AnisoElem, aniso, aniso >.

Definition at line 540 of file ComputeHomeTuples.h.

00540                                   {
00541 
00542 #ifdef NAMD_CUDA
00543       ProxyMgr *proxyMgr = ProxyMgr::Object();
00544 #endif
00545 
00546 #ifdef USE_HOMETUPLES
00547       tuples = new HomeTuples<T, S, P>();
00548 #endif
00549 
00550       // Start with empty list
00551       tuplePatchList.clear();
00552     
00553       int nPatches = patchMap->numPatches();
00554       int pid;
00555       for (pid=0; pid<nPatches; ++pid) {
00556         if ( isBasePatch[pid] ) {
00557 #ifdef NAMD_CUDA
00558           proxyMgr->createProxy(pid);
00559 #endif
00560           Patch *patch = patchMap->patch(pid);
00561           tuplePatchList.add(TuplePatchElem(patch, this));
00562         }
00563       }
00564     
00565       // Gather all proxy patches (neighbors, that is)
00566       PatchID neighbors[PatchMap::MaxOneOrTwoAway];
00567     
00568       for (pid=0; pid<nPatches; ++pid) if ( isBasePatch[pid] ) {
00569         int numNeighbors = patchMap->upstreamNeighbors(pid,neighbors);
00570         for ( int i = 0; i < numNeighbors; ++i ) {
00571           if ( ! tuplePatchList.find(TuplePatchElem(neighbors[i])) ) {
00572 #ifdef NAMD_CUDA
00573             proxyMgr->createProxy(neighbors[i]);
00574 #endif
00575             Patch *patch = patchMap->patch(neighbors[i]);
00576             tuplePatchList.add(TuplePatchElem(patch, this));
00577           }
00578         }
00579       }
00580       setNumPatches(tuplePatchList.size());
00581       doLoadTuples = true;
00582 
00583       basePriority = COMPUTE_PROXY_PRIORITY;  // no patch dependence
00584     }

template<class T, class S, class P>
virtual void ComputeHomeTuples< T, S, P >::loadTuples ( void   )  [inline, protected, virtual]

Definition at line 320 of file ComputeHomeTuples.h.

00320                                   {
00321       int numTuples;
00322 
00323       #ifdef MEM_OPT_VERSION
00324       typename ElemTraits<T>::signature *allSigs;      
00325       #else
00326       int32 **tuplesByAtom;
00327       /* const (need to propagate const) */ S *tupleStructs;
00328       #endif
00329       
00330       const P *tupleValues;
00331       Node *node = Node::Object();
00332 
00333       #ifdef MEM_OPT_VERSION
00334       allSigs = ElemTraits<T>::get_sig_pointer(node->molecule);
00335       #else      
00336       T::getMoleculePointers(node->molecule,
00337                     &numTuples, &tuplesByAtom, &tupleStructs);      
00338       #endif
00339       
00340       T::getParameterPointers(node->parameters, &tupleValues);
00341 
00342       tupleList.resize(0);
00343 
00344       LocalID aid[T::size];
00345 
00346       const int lesOn = node->simParameters->lesOn;
00347       const int soluteScalingOn = node->simParameters->soluteScalingOn;
00348       Real invLesFactor = lesOn ? 
00349                           1.0/node->simParameters->lesFactor :
00350                           1.0;
00351       const Real soluteScalingFactor = node->simParameters->soluteScalingFactor;
00352       const Bool soluteScalingAll = node->simParameters->soluteScalingAll;
00353 
00354       // cycle through each patch and gather all tuples
00355       TuplePatchListIter ai(tuplePatchList);
00356     
00357       for ( ai = ai.begin(); ai != ai.end(); ai++ )
00358       {
00359         // CompAtom *atom = (*ai).x;
00360         Patch *patch = (*ai).p;
00361         int numAtoms = patch->getNumAtoms();
00362         CompAtomExt *atomExt = (*ai).xExt; //patch->getCompAtomExtInfo();
00363     
00364         // cycle through each atom in the patch and load up tuples
00365         for (int j=0; j < numAtoms; j++)
00366         {              
00367            /* cycle through each tuple */
00368            #ifdef MEM_OPT_VERSION
00369            typename ElemTraits<T>::signature *thisAtomSig =
00370                    &allSigs[ElemTraits<T>::get_sig_id(atomExt[j])];
00371            TupleSignature *allTuples;
00372            T::getTupleInfo(thisAtomSig, &numTuples, &allTuples);
00373            for(int k=0; k<numTuples; k++) {
00374                T t(atomExt[j].id, &allTuples[k], tupleValues);
00375            #else
00376            /* get list of all tuples for the atom */
00377            int32 *curTuple = tuplesByAtom[atomExt[j].id];
00378            for( ; *curTuple != -1; ++curTuple) {             
00379              T t(&tupleStructs[*curTuple],tupleValues);
00380            #endif            
00381              register int i;
00382              aid[0] = atomMap->localID(t.atomID[0]);
00383              int homepatch = aid[0].pid;
00384              int samepatch = 1;
00385              int has_les = lesOn && node->molecule->get_fep_type(t.atomID[0]);
00386              int has_ss = soluteScalingOn && node->molecule->get_ss_type(t.atomID[0]);
00387              for (i=1; i < T::size; i++) {
00388                  aid[i] = atomMap->localID(t.atomID[i]);
00389                  samepatch = samepatch && ( homepatch == aid[i].pid );
00390                  has_les |= lesOn && node->molecule->get_fep_type(t.atomID[i]);
00391                  has_ss |= soluteScalingOn && node->molecule->get_ss_type(t.atomID[i]);
00392              }
00393              if (T::size < 4 && !soluteScalingAll) has_ss = false;
00394              if ( samepatch ) continue;
00395              t.scale = (!has_les && !has_ss) ? 1.0 : ( has_les ? invLesFactor : soluteScalingFactor );
00396              for (i=1; i < T::size; i++) {
00397                  homepatch = patchMap->downstream(homepatch,aid[i].pid);
00398              }
00399              if ( homepatch != notUsed && isBasePatch[homepatch] ) {
00400                TuplePatchElem *p;
00401                for (i=0; i < T::size; i++) {
00402                  t.p[i] = p = tuplePatchList.find(TuplePatchElem(aid[i].pid));
00403                  if ( ! p ) {
00404                      #ifdef MEM_OPT_VERSION
00405                      iout << iWARN << "Tuple with atoms ";
00406                      #else
00407                    iout << iWARN << "Tuple " << *curTuple << " with atoms ";
00408                      #endif
00409                    int erri;
00410                    for( erri = 0; erri < T::size; erri++ ) {
00411                      iout << t.atomID[erri] << "(" <<  aid[erri].pid << ") ";
00412                    }
00413                    iout << "missing patch " << aid[i].pid << "\n" << endi;
00414                    break;
00415                  }
00416                  t.localIndex[i] = aid[i].index;
00417                }
00418                if ( ! p ) continue;
00419              #ifdef MEM_OPT_VERSION
00420                //avoid adding Tuples whose atoms are all fixed
00421                if(node->simParameters->fixedAtomsOn &&
00422                   !node->simParameters->fixedAtomsForces) {
00423                  int allfixed = 1;
00424                  for(i=0; i<T::size; i++){
00425                    CompAtomExt *one = &(t.p[i]->xExt[aid[i].index]);
00426                    allfixed = allfixed & one->atomFixed;
00427                  }
00428                  if(!allfixed) tupleList.add(t);
00429                }else{
00430                  tupleList.add(t);
00431                }
00432              #else
00433                tupleList.add(t);
00434              #endif               
00435              }
00436            }
00437         }
00438       }
00439     }


Member Data Documentation

template<class T, class S, class P>
int ComputeHomeTuples< T, S, P >::accelMDdoDihe [protected]

Definition at line 457 of file ComputeHomeTuples.h.

template<class T, class S, class P>
AtomMap* ComputeHomeTuples< T, S, P >::atomMap [protected]

Definition at line 455 of file ComputeHomeTuples.h.

Referenced by ComputeHomeTuples< AnisoElem, aniso, aniso >::loadTuples().

template<class T, class S, class P>
int ComputeHomeTuples< T, S, P >::doLoadTuples [protected]

Definition at line 442 of file ComputeHomeTuples.h.

template<class T, class S, class P>
char* ComputeHomeTuples< T, S, P >::isBasePatch [protected]

Definition at line 461 of file ComputeHomeTuples.h.

template<class T, class S, class P>
PatchMap* ComputeHomeTuples< T, S, P >::patchMap [protected]

Definition at line 454 of file ComputeHomeTuples.h.

Referenced by ComputeHomeTuples< AnisoElem, aniso, aniso >::loadTuples().

template<class T, class S, class P>
BigReal* ComputeHomeTuples< T, S, P >::pressureProfileData [protected]

Definition at line 459 of file ComputeHomeTuples.h.

template<class T, class S, class P>
SubmitReduction* ComputeHomeTuples< T, S, P >::pressureProfileReduction [protected]

Definition at line 458 of file ComputeHomeTuples.h.

template<class T, class S, class P>
int ComputeHomeTuples< T, S, P >::pressureProfileSlabs [protected]

Definition at line 460 of file ComputeHomeTuples.h.

template<class T, class S, class P>
SubmitReduction* ComputeHomeTuples< T, S, P >::reduction [protected]

Definition at line 456 of file ComputeHomeTuples.h.

template<class T, class S, class P>
ResizeArray<T> ComputeHomeTuples< T, S, P >::tupleList [protected]

Definition at line 450 of file ComputeHomeTuples.h.

Referenced by ComputeHomeTuples< AnisoElem, aniso, aniso >::loadTuples().

template<class T, class S, class P>
TuplePatchList ComputeHomeTuples< T, S, P >::tuplePatchList [protected]

Definition at line 451 of file ComputeHomeTuples.h.

Referenced by ComputeHomeTuples< AnisoElem, aniso, aniso >::loadTuples().


The documentation for this class was generated from the following file:
Generated on Sat Jun 23 01:17:19 2018 for NAMD by  doxygen 1.4.7