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 6057 of file ComputeMsm.C.

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

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

ComputeMsm::~ComputeMsm (  )  [virtual]

Definition at line 6069 of file ComputeMsm.C.

06070 {
06071   // free memory
06072 #ifdef DEBUG_MSM_VERBOSE
06073   printf("ComputeMsm:  (destructor) PE=%d\n", CkMyPe());
06074 #endif
06075 }


Member Function Documentation

void ComputeMsm::doWork ( void   )  [virtual]

Reimplemented from Compute.

Definition at line 6077 of file ComputeMsm.C.

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

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

void ComputeMsm::saveResults (  ) 

Definition at line 6161 of file ComputeMsm.C.

References ASSERT, ResizeArrayIter< T >::begin(), ResizeArrayIter< T >::end(), msm::PatchData::energy, Results::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().

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

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

Definition at line 32 of file ComputeMsm.h.

Referenced by ComputeMsmMgr::setCompute().

00032 { myMgr = mgr; }


The documentation for this class was generated from the following files:

Generated on 16 Jun 2022 for NAMD by  doxygen 1.6.1