ComputeMsmSerial Class Reference

#include <ComputeMsmSerial.h>

Inheritance diagram for ComputeMsmSerial:

ComputeHomePatches Compute List of all members.

Public Member Functions

 ComputeMsmSerial (ComputeID c)
virtual ~ComputeMsmSerial ()
void doWork ()
void saveResults (MsmSerialForceMsg *)

Detailed Description

Definition at line 17 of file ComputeMsmSerial.h.


Constructor & Destructor Documentation

ComputeMsmSerial::ComputeMsmSerial ( ComputeID  c  ) 

Definition at line 101 of file ComputeMsmSerial.C.

References ReductionMgr::Object(), REDUCTIONS_BASIC, and ReductionMgr::willSubmit().

00101                                               :
00102   ComputeHomePatches(c)
00103 {
00104   CProxy_ComputeMsmSerialMgr::ckLocalBranch(
00105         CkpvAccess(BOCclass_group).computeMsmSerialMgr)->setCompute(this);
00106   reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00107 }

ComputeMsmSerial::~ComputeMsmSerial (  )  [virtual]

Definition at line 109 of file ComputeMsmSerial.C.

00110 {
00111 }


Member Function Documentation

void ComputeMsmSerial::doWork (  )  [virtual]

Reimplemented from Compute.

Definition at line 113 of file ComputeMsmSerial.C.

References ResizeArrayIter< T >::begin(), ComputeMsmSerialAtom::charge, MsmSerialCoordMsg::coord, ResizeArrayIter< T >::end(), CompAtomExt::id, ComputeMsmSerialAtom::id, MsmSerialCoordMsg::lattice, MsmSerialCoordMsg::numAtoms, ComputeHomePatches::patchList, ComputeMsmSerialAtom::position, MsmSerialCoordMsg::sourceNode, SubmitReduction::submit(), and x.

00114 {
00115   ResizeArrayIter<PatchElem> ap(patchList);
00116 
00117   // Skip computations if nothing to do.
00118   if ( ! patchList[0].p->flags.doFullElectrostatics )
00119   {
00120     for (ap = ap.begin(); ap != ap.end(); ap++) {
00121       CompAtom *x = (*ap).positionBox->open();
00122       Results *r = (*ap).forceBox->open();
00123       (*ap).positionBox->close(&x);
00124       (*ap).forceBox->close(&r);
00125     }
00126     reduction->submit();
00127     return;
00128   }
00129 
00130   // allocate message
00131   int numLocalAtoms = 0;
00132   for (ap = ap.begin(); ap != ap.end(); ap++) {
00133     numLocalAtoms += (*ap).p->getNumAtoms();
00134   }
00135 
00136   MsmSerialCoordMsg *msg = new (numLocalAtoms, 0) MsmSerialCoordMsg;
00137   msg->sourceNode = CkMyPe();
00138   msg->numAtoms = numLocalAtoms;
00139   msg->lattice = patchList[0].p->flags.lattice;
00140   ComputeMsmSerialAtom *data_ptr = msg->coord;
00141 
00142   // get positions
00143   for (ap = ap.begin();  ap != ap.end();  ap++) {
00144     CompAtom *x = (*ap).positionBox->open();
00145     CompAtomExt *xExt = (*ap).p->getCompAtomExtInfo();
00146     if ( patchList[0].p->flags.doMolly ) {
00147       (*ap).positionBox->close(&x);
00148       x = (*ap).avgPositionBox->open();
00149     }
00150     int numAtoms = (*ap).p->getNumAtoms();
00151 
00152     for(int i=0;  i < numAtoms;  i++)
00153     {
00154       data_ptr->position = x[i].position;
00155       data_ptr->charge = x[i].charge;
00156       data_ptr->id = xExt[i].id;
00157       ++data_ptr;
00158     }
00159 
00160     if ( patchList[0].p->flags.doMolly ) { (*ap).avgPositionBox->close(&x); }
00161     else { (*ap).positionBox->close(&x); }
00162   }
00163 
00164   CProxy_ComputeMsmSerialMgr msmProxy(
00165       CkpvAccess(BOCclass_group).computeMsmSerialMgr);
00166   msmProxy[0].recvCoord(msg);
00167 }

void ComputeMsmSerial::saveResults ( MsmSerialForceMsg  ) 

Definition at line 467 of file ComputeMsmSerial.C.

References ResizeArrayIter< T >::begin(), ResizeArrayIter< T >::end(), MsmSerialForceMsg::energy, f, MsmSerialForceMsg::force, SubmitReduction::item(), ComputeHomePatches::patchList, REDUCTION_ELECT_ENERGY_SLOW, Results::slow, SubmitReduction::submit(), MsmSerialForceMsg::virial, Vector::x, x, Vector::y, and Vector::z.

Referenced by ComputeMsmSerialMgr::recvForce().

00468 {
00469   ResizeArrayIter<PatchElem> ap(patchList);
00470 
00471   MsmSerialForce *results_ptr = msg->force;
00472 
00473   // add in forces
00474   for (ap = ap.begin(); ap != ap.end(); ap++) {
00475     Results *r = (*ap).forceBox->open();
00476     Force *f = r->f[Results::slow];
00477     int numAtoms = (*ap).p->getNumAtoms();
00478 
00479     for(int i=0; i<numAtoms; ++i) {
00480       f[i].x += results_ptr->x;
00481       f[i].y += results_ptr->y;
00482       f[i].z += results_ptr->z;
00483       ++results_ptr;
00484     }
00485   
00486     (*ap).forceBox->close(&r);
00487   }
00488 
00489   reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += msg->energy;
00490   reduction->item(REDUCTION_VIRIAL_SLOW_XX) += msg->virial[0][0];
00491   reduction->item(REDUCTION_VIRIAL_SLOW_XY) += msg->virial[0][1];
00492   reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += msg->virial[0][2];
00493   reduction->item(REDUCTION_VIRIAL_SLOW_YX) += msg->virial[1][0];
00494   reduction->item(REDUCTION_VIRIAL_SLOW_YY) += msg->virial[1][1];
00495   reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += msg->virial[1][2];
00496   reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += msg->virial[2][0];
00497   reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += msg->virial[2][1];
00498   reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += msg->virial[2][2];
00499   reduction->submit();
00500 }


The documentation for this class was generated from the following files:
Generated on Sun Sep 24 01:17:17 2017 for NAMD by  doxygen 1.4.7