ComputeMsm Class Reference

#include <ComputeMsm.h>

Inheritance diagram for ComputeMsm:

ComputeHomePatches Compute List of all members.

Public Member Functions

 ComputeMsm (ComputeID c)
virtual ~ComputeMsm ()
void doWork ()
void saveResults ()
void setMgr (ComputeMsmMgr *mgr)

Detailed Description

Definition at line 25 of file ComputeMsm.h.


Constructor & Destructor Documentation

ComputeMsm::ComputeMsm ( ComputeID  c  ) 

Definition at line 6053 of file ComputeMsm.C.

References COULOMB, ReductionMgr::Object(), Node::Object(), REDUCTIONS_BASIC, Node::simParameters, simParams, and ReductionMgr::willSubmit().

06053                                   : ComputeHomePatches(c)
06054 {
06055   CProxy_ComputeMsmMgr::ckLocalBranch(
06056       CkpvAccess(BOCclass_group).computeMsmMgr)->setCompute(this);
06057   SimParameters *simParams = Node::Object()->simParameters;
06058   qscaling = sqrtf(COULOMB / simParams->dielectric);
06059   reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
06060 #ifdef DEBUG_MSM_VERBOSE
06061   printf("ComputeMsm:  (constructor) PE=%d\n", CkMyPe());
06062 #endif
06063 }

ComputeMsm::~ComputeMsm (  )  [virtual]

Definition at line 6065 of file ComputeMsm.C.

06066 {
06067   // free memory
06068 #ifdef DEBUG_MSM_VERBOSE
06069   printf("ComputeMsm:  (destructor) PE=%d\n", CkMyPe());
06070 #endif
06071 }


Member Function Documentation

void ComputeMsm::doWork (  )  [virtual]

Reimplemented from Compute.

Definition at line 6073 of file ComputeMsm.C.

References msm::Array< T >::append(), ASSERT, ResizeArrayIter< T >::begin(), msm::PatchData::coordArray(), ResizeArrayIter< T >::end(), CompAtomExt::id, msm::PatchData::init(), msm::Array< T >::len(), ComputeMsmMgr::mapData(), ComputeHomePatches::patchList, ComputeMsmMgr::patchPtrArray(), msm::Array< T >::resize(), Compute::sequence(), ResizeArray< Elem >::size(), SubmitReduction::submit(), and x.

06074 {
06075   // for each patch do stuff
06076 #ifdef DEBUG_MSM_VERBOSE
06077   printf("ComputeMsm:  doWork() PE=%d\n", CkMyPe());
06078 #endif
06079 
06080 #if 0
06081 #ifdef MSM_TIMING
06082   myMgr->initTiming();
06083 #endif
06084 #ifdef MSM_PROFILING
06085   myMgr->initProfiling();
06086 #endif
06087 #endif
06088 
06089   // patchList is inherited from ComputeHomePatches
06090   ResizeArrayIter<PatchElem> ap(patchList);
06091   numLocalPatches = patchList.size();
06092   cntLocalPatches = 0;
06093   ASSERT(cntLocalPatches < numLocalPatches);
06094 
06095 #ifdef DEBUG_MSM_VERBOSE
06096   printf("patchList size = %d\n", patchList.size() );
06097 #endif
06098 
06099   // Skip computations if nothing to do.
06100   if ( ! patchList[0].p->flags.doFullElectrostatics ) {
06101     for (ap = ap.begin();  ap != ap.end();  ap++) {
06102       CompAtom *x = (*ap).positionBox->open();
06103       Results *r = (*ap).forceBox->open();
06104       (*ap).positionBox->close(&x);
06105       (*ap).forceBox->close(&r);
06106     }
06107     reduction->submit();
06108     return;
06109   }
06110   msm::Map& map = myMgr->mapData();
06111   // This is the patchPtr array for MSM; any local patch will be set up
06112   // with a non-NULL pointer to its supporting data structure.
06113   msm::PatchPtrArray& patchPtr = myMgr->patchPtrArray();
06114   // also store just a list of IDs for the local patches
06115   msm::Array<int> patchIDList(numLocalPatches);
06116   patchIDList.resize(0);  // to use append on pre-allocated array buffer
06117   int cnt=0, n;
06118   for (ap = ap.begin();  ap != ap.end();  ap++) {
06119     CompAtom *x = (*ap).positionBox->open();
06120     CompAtomExt *xExt = (*ap).p->getCompAtomExtInfo();
06121     if ( patchList[0].p->flags.doMolly ) {
06122       (*ap).positionBox->close(&x);
06123       x = (*ap).avgPositionBox->open();
06124     }
06125     int numAtoms = (*ap).p->getNumAtoms();
06126     int patchID = (*ap).patchID;
06127     patchIDList.append(patchID);
06128     if (patchPtr[patchID] == NULL) {
06129       // create PatchData if it doesn't exist for this patchID
06130       patchPtr[patchID] = new msm::PatchData(myMgr, patchID);
06131 #ifdef DEBUG_MSM_VERBOSE
06132       printf("Creating new PatchData:  patchID=%d  PE=%d\n",
06133           patchID, CkMyPe());
06134 #endif
06135     }
06136     msm::PatchData& patch = *(patchPtr[patchID]);
06137     patch.init(numAtoms);
06138     msm::AtomCoordArray& coord = patch.coordArray();
06139     ASSERT(coord.len() == numAtoms);
06140     for (n = 0;  n < numAtoms;  n++) {
06141       coord[n].position = x[n].position;
06142       coord[n].charge = qscaling * x[n].charge;
06143       coord[n].id = xExt[n].id;
06144     }
06145     if ( patchList[0].p->flags.doMolly ) {
06146       (*ap).avgPositionBox->close(&x);
06147     }
06148     else {
06149       (*ap).positionBox->close(&x);
06150     }
06151     patch.sequence = sequence();
06152   }
06153 
06154   myMgr->compute(patchIDList);
06155 }

void ComputeMsm::saveResults (  ) 

Definition at line 6157 of file ComputeMsm.C.

References ASSERT, ResizeArrayIter< T >::begin(), ResizeArrayIter< T >::end(), msm::PatchData::energy, f, msm::PatchData::force, SubmitReduction::item(), ComputeMsmMgr::mapData(), NAMD_die(), msm::Map::patchList, ComputeHomePatches::patchList, ComputeMsmMgr::patchPtrArray(), REDUCTION_ELECT_ENERGY_SLOW, Results::slow, SubmitReduction::submit(), ComputeMsmMgr::virial, ComputeMsmMgr::VXX, ComputeMsmMgr::VXY, ComputeMsmMgr::VXZ, ComputeMsmMgr::VYY, ComputeMsmMgr::VYZ, and ComputeMsmMgr::VZZ.

Referenced by ComputeMsmMgr::doneCompute().

06158 {
06159   if (++cntLocalPatches != numLocalPatches) return;
06160 
06161   // NAMD patches
06162   ResizeArrayIter<PatchElem> ap(patchList);
06163 #ifdef DEBUG_MSM
06164   for (ap = ap.begin();  ap != ap.end();  ap++) {
06165     int patchID = (*ap).patchID;
06166     ASSERT(myMgr->patchPtrArray()[patchID]->cntRecvs ==
06167         myMgr->mapData().patchList[patchID].numRecvs);
06168   }
06169 #endif
06170 
06171   // get results from ComputeMsmMgr
06172   msm::PatchPtrArray& patchPtr = myMgr->patchPtrArray();
06173 
06174 #ifdef DEBUG_MSM_VERBOSE
06175   printf("ComputeMsm:  saveResults() PE=%d\n", CkMyPe());
06176 #endif
06177   // store force updates
06178   // submit reductions
06179 
06180   // add in forces
06181   int cnt=0, n;
06182   for (ap = ap.begin(); ap != ap.end(); ap++) {
06183     Results *r = (*ap).forceBox->open();
06184     Force *f = r->f[Results::slow];
06185     int numAtoms = (*ap).p->getNumAtoms();
06186     int patchID = (*ap).patchID;
06187     if (patchPtr[patchID] == NULL) {
06188       char msg[100];
06189       snprintf(msg, sizeof(msg), "Expecting patch %d to exist on PE %d",
06190           patchID, CkMyPe());
06191       NAMD_die(msg);
06192     }
06193     msm::PatchData& patch = *(patchPtr[patchID]);
06194     ASSERT(numAtoms == patch.force.len() );
06195     for (n = 0;  n < numAtoms;  n++) {
06196       f[n] += patch.force[n];
06197     }
06198     (*ap).forceBox->close(&r);
06199 
06200     reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += patch.energy;
06201 //    reduction->item(REDUCTION_VIRIAL_SLOW_XX) += patch.virial[0][0];
06202 //    reduction->item(REDUCTION_VIRIAL_SLOW_XY) += patch.virial[0][1];
06203 //    reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += patch.virial[0][2];
06204 //    reduction->item(REDUCTION_VIRIAL_SLOW_YX) += patch.virial[1][0];
06205 //    reduction->item(REDUCTION_VIRIAL_SLOW_YY) += patch.virial[1][1];
06206 //    reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += patch.virial[1][2];
06207 //    reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += patch.virial[2][0];
06208 //    reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += patch.virial[2][1];
06209 //    reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += patch.virial[2][2];
06210     Float *virial = myMgr->virial;
06211     reduction->item(REDUCTION_VIRIAL_SLOW_XX) += virial[ComputeMsmMgr::VXX];
06212     reduction->item(REDUCTION_VIRIAL_SLOW_XY) += virial[ComputeMsmMgr::VXY];
06213     reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += virial[ComputeMsmMgr::VXZ];
06214     reduction->item(REDUCTION_VIRIAL_SLOW_YX) += virial[ComputeMsmMgr::VXY];
06215     reduction->item(REDUCTION_VIRIAL_SLOW_YY) += virial[ComputeMsmMgr::VYY];
06216     reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += virial[ComputeMsmMgr::VYZ];
06217     reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += virial[ComputeMsmMgr::VXZ];
06218     reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += virial[ComputeMsmMgr::VYZ];
06219     reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += virial[ComputeMsmMgr::VZZ];
06220   }
06221   reduction->submit();
06222 }

void ComputeMsm::setMgr ( ComputeMsmMgr mgr  )  [inline]

Definition at line 32 of file ComputeMsm.h.

00032 { myMgr = mgr; }


The documentation for this class was generated from the following files:
Generated on Thu Nov 23 01:17:17 2017 for NAMD by  doxygen 1.4.7