Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

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 *)

Constructor & Destructor Documentation

ComputeExt::ComputeExt ComputeID  c  ) 
 

Definition at line 85 of file ComputeExt.C.

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

00085                                   :
00086   ComputeHomePatches(c)
00087 {
00088   CProxy_ComputeExtMgr::ckLocalBranch(
00089         CkpvAccess(BOCclass_group).computeExtMgr)->setCompute(this);
00090 
00091   reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00092 
00093 }

ComputeExt::~ComputeExt  )  [virtual]
 

Definition at line 95 of file ComputeExt.C.

00096 {
00097 }


Member Function Documentation

void ComputeExt::doWork  )  [virtual]
 

Reimplemented from Compute.

Definition at line 99 of file ComputeExt.C.

References ResizeArrayIter< T >::begin(), ExtCoordMsg::coord, ResizeArrayIter< T >::end(), ExtCoordMsg::lattice, ExtCoordMsg::numAtoms, ExtCoordMsg::sourceNode, and SubmitReduction::submit().

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

void ComputeExt::saveResults ExtForceMsg  ) 
 

Definition at line 297 of file ComputeExt.C.

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

Referenced by ComputeExtMgr::recvForce().

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


The documentation for this class was generated from the following files:
Generated on Tue Oct 7 04:08:16 2008 for NAMD by  doxygen 1.3.9.1