ComputeExt Class Reference

#include <ComputeExt.h>

Inheritance diagram for ComputeExt:

ComputeHomePatches Compute List of all members.

Public Member Functions

 ComputeExt (ComputeID c)
virtual ~ComputeExt ()
void doWork ()
void saveResults (ExtForceMsg *)

Detailed Description

Definition at line 17 of file ComputeExt.h.


Constructor & Destructor Documentation

ComputeExt::ComputeExt ( ComputeID  c  ) 

Definition at line 91 of file ComputeExt.C.

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

00091                                   :
00092   ComputeHomePatches(c)
00093 {
00094   CProxy_ComputeExtMgr::ckLocalBranch(
00095         CkpvAccess(BOCclass_group).computeExtMgr)->setCompute(this);
00096 
00097   reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00098 
00099 }

ComputeExt::~ComputeExt (  )  [virtual]

Definition at line 101 of file ComputeExt.C.

00102 {
00103 }


Member Function Documentation

void ComputeExt::doWork (  )  [virtual]

Reimplemented from Compute.

Definition at line 105 of file ComputeExt.C.

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

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

void ComputeExt::saveResults ( ExtForceMsg  ) 

Definition at line 298 of file ComputeExt.C.

References ResizeArrayIter< T >::begin(), ResizeArrayIter< T >::end(), ExtForceMsg::energy, f, ExtForce::force, ExtForceMsg::force, SubmitReduction::item(), Results::normal, ComputeHomePatches::patchList, REDUCTION_MISC_ENERGY, ExtForce::replace, SubmitReduction::submit(), and ExtForceMsg::virial.

Referenced by ComputeExtMgr::recvForce().

00299 {
00300   ResizeArrayIter<PatchElem> ap(patchList);
00301 
00302   ExtForce *results_ptr = msg->force;
00303 
00304   // add in forces
00305   for (ap = ap.begin(); ap != ap.end(); ap++) {
00306     Results *r = (*ap).forceBox->open();
00307     Force *f = r->f[Results::normal];
00308     int numAtoms = (*ap).p->getNumAtoms();
00309 
00310     int replace = 0;
00311     ExtForce *replacementForces = results_ptr;
00312     for(int i=0; i<numAtoms; ++i) {
00313       if ( results_ptr->replace ) replace = 1;
00314       else f[i] += results_ptr->force;
00315       ++results_ptr;
00316     }
00317     if ( replace ) (*ap).p->replaceForces(replacementForces);
00318   
00319       (*ap).forceBox->close(&r);
00320     }
00321 
00322     reduction->item(REDUCTION_MISC_ENERGY) += msg->energy;
00323     reduction->item(REDUCTION_VIRIAL_NORMAL_XX) += msg->virial[0][0];
00324     reduction->item(REDUCTION_VIRIAL_NORMAL_XY) += msg->virial[0][1];
00325     reduction->item(REDUCTION_VIRIAL_NORMAL_XZ) += msg->virial[0][2];
00326     reduction->item(REDUCTION_VIRIAL_NORMAL_YX) += msg->virial[1][0];
00327     reduction->item(REDUCTION_VIRIAL_NORMAL_YY) += msg->virial[1][1];
00328     reduction->item(REDUCTION_VIRIAL_NORMAL_YZ) += msg->virial[1][2];
00329     reduction->item(REDUCTION_VIRIAL_NORMAL_ZX) += msg->virial[2][0];
00330     reduction->item(REDUCTION_VIRIAL_NORMAL_ZY) += msg->virial[2][1];
00331     reduction->item(REDUCTION_VIRIAL_NORMAL_ZZ) += msg->virial[2][2];
00332     reduction->submit();
00333 }


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