ComputeFmmSerial Class Reference

#include <ComputeFmmSerial.h>

Inheritance diagram for ComputeFmmSerial:

ComputeHomePatches Compute List of all members.

Public Member Functions

 ComputeFmmSerial (ComputeID c)
virtual ~ComputeFmmSerial ()
void doWork ()
void saveResults (FmmSerialForceMsg *)

Detailed Description

Definition at line 17 of file ComputeFmmSerial.h.


Constructor & Destructor Documentation

ComputeFmmSerial::ComputeFmmSerial ( ComputeID  c  ) 

Definition at line 131 of file ComputeFmmSerial.C.

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

00131                                               :
00132   ComputeHomePatches(c)
00133 {
00134   CProxy_ComputeFmmSerialMgr::ckLocalBranch(
00135         CkpvAccess(BOCclass_group).computeFmmSerialMgr)->setCompute(this);
00136   reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00137 }

ComputeFmmSerial::~ComputeFmmSerial (  )  [virtual]

Definition at line 139 of file ComputeFmmSerial.C.

00140 {
00141 }


Member Function Documentation

void ComputeFmmSerial::doWork (  )  [virtual]

Reimplemented from Compute.

Definition at line 143 of file ComputeFmmSerial.C.

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

00144 {
00145   ResizeArrayIter<PatchElem> ap(patchList);
00146 
00147   // Skip computations if nothing to do.
00148   if ( ! patchList[0].p->flags.doFullElectrostatics )
00149   {
00150     for (ap = ap.begin(); ap != ap.end(); ap++) {
00151       CompAtom *x = (*ap).positionBox->open();
00152       Results *r = (*ap).forceBox->open();
00153       (*ap).positionBox->close(&x);
00154       (*ap).forceBox->close(&r);
00155     }
00156     reduction->submit();
00157     return;
00158   }
00159 
00160   // allocate message
00161   int numLocalAtoms = 0;
00162   for (ap = ap.begin(); ap != ap.end(); ap++) {
00163     numLocalAtoms += (*ap).p->getNumAtoms();
00164   }
00165 
00166   FmmSerialCoordMsg *msg = new (numLocalAtoms, 0) FmmSerialCoordMsg;
00167   msg->sourceNode = CkMyPe();
00168   msg->numAtoms = numLocalAtoms;
00169   msg->lattice = patchList[0].p->flags.lattice;
00170   ComputeFmmSerialAtom *data_ptr = msg->coord;
00171 
00172   // get positions
00173   for (ap = ap.begin();  ap != ap.end();  ap++) {
00174     CompAtom *x = (*ap).positionBox->open();
00175     CompAtomExt *xExt = (*ap).p->getCompAtomExtInfo();
00176     if ( patchList[0].p->flags.doMolly ) {
00177       (*ap).positionBox->close(&x);
00178       x = (*ap).avgPositionBox->open();
00179     }
00180     int numAtoms = (*ap).p->getNumAtoms();
00181 
00182     for(int i=0;  i < numAtoms;  i++)
00183     {
00184       data_ptr->position = x[i].position;
00185       data_ptr->charge = x[i].charge;
00186       data_ptr->id = xExt[i].id;
00187       ++data_ptr;
00188     }
00189 
00190     if ( patchList[0].p->flags.doMolly ) { (*ap).avgPositionBox->close(&x); }
00191     else { (*ap).positionBox->close(&x); }
00192   }
00193 
00194   CProxy_ComputeFmmSerialMgr fmmProxy(
00195       CkpvAccess(BOCclass_group).computeFmmSerialMgr);
00196   fmmProxy[0].recvCoord(msg);
00197 }

void ComputeFmmSerial::saveResults ( FmmSerialForceMsg  ) 

Definition at line 360 of file ComputeFmmSerial.C.

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

Referenced by ComputeFmmSerialMgr::recvForce().

00361 {
00362   ResizeArrayIter<PatchElem> ap(patchList);
00363 
00364   FmmSerialForce *results_ptr = msg->force;
00365 
00366   // add in forces
00367   for (ap = ap.begin(); ap != ap.end(); ap++) {
00368     Results *r = (*ap).forceBox->open();
00369     Force *f = r->f[Results::slow];
00370     int numAtoms = (*ap).p->getNumAtoms();
00371 
00372     for(int i=0; i<numAtoms; ++i) {
00373       f[i].x += results_ptr->x;
00374       f[i].y += results_ptr->y;
00375       f[i].z += results_ptr->z;
00376       ++results_ptr;
00377     }
00378   
00379     (*ap).forceBox->close(&r);
00380   }
00381 
00382   reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += msg->energy;
00383   reduction->item(REDUCTION_VIRIAL_SLOW_XX) += msg->virial[0][0];
00384   reduction->item(REDUCTION_VIRIAL_SLOW_XY) += msg->virial[0][1];
00385   reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += msg->virial[0][2];
00386   reduction->item(REDUCTION_VIRIAL_SLOW_YX) += msg->virial[1][0];
00387   reduction->item(REDUCTION_VIRIAL_SLOW_YY) += msg->virial[1][1];
00388   reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += msg->virial[1][2];
00389   reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += msg->virial[2][0];
00390   reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += msg->virial[2][1];
00391   reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += msg->virial[2][2];
00392   reduction->submit();
00393 }


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