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

ComputeHomePatch.C

Go to the documentation of this file.
00001 
00007 /*
00008    Compute object which deals with a single patch.
00009 */
00010 
00011 #include "InfoStream.h"
00012 #include "WorkDistrib.decl.h"
00013 #include "Node.h"
00014 #include "ComputeHomePatch.h"
00015 #include "PatchMap.inl"
00016 #include "HomePatch.h"
00017 #include "Priorities.h"
00018 
00019 #define MIN_DEBUG_LEVEL 4
00020 //#define DEBUGM
00021 #include "Debug.h"
00022 
00023 ComputeHomePatch::ComputeHomePatch(ComputeID c, PatchID p) : Compute(c) {
00024     setNumPatches(1);
00025     patchID = p;
00026     patch = NULL;
00027     homePatch = NULL;
00028     positionBox = NULL;
00029     forceBox = NULL;
00030 }
00031 
00032 ComputeHomePatch::~ComputeHomePatch() {
00033   DebugM(4, "~ComputeHomePatch("<<cid<<") numAtoms("<<patchID<<") = " 
00034     << numAtoms << "\n");
00035     if (positionBox != NULL) {
00036       PatchMap::Object()->patch(patchID)->unregisterPositionPickup(cid,
00037          &positionBox);
00038     }
00039     if (forceBox != NULL) {
00040       PatchMap::Object()->patch(patchID)->unregisterForceDeposit(cid,
00041                 &forceBox);
00042     }
00043 }
00044 
00045 void ComputeHomePatch::initialize() {
00046     // How can we tell if BoxOwner has packed up and left?  Need a mechanism
00047     // to handle this or do we assume the Boxes have been dumped?
00048 
00049         if (positionBox == NULL) { // We have yet to get boxes
00050             if (!(patch = PatchMap::Object()->patch(patchID))) {
00051               NAMD_bug("ComputeHomePatch used with unknown patch.");
00052             }
00053             if (!(homePatch = PatchMap::Object()->homePatch(patchID))) {
00054               NAMD_bug("ComputeHomePatch used with proxy.");
00055             }
00056             DebugM(3, "initialize(" << cid <<")  patchid = "<<patch->getPatchID()<<"\n");
00057             positionBox = patch->registerPositionPickup(cid);
00058             forceBox = patch->registerForceDeposit(cid);
00059         }
00060         numAtoms = patch->getNumAtoms();
00061 
00062   DebugM(3, "initialize("<<cid<<") numAtoms("<<patchID<<") = " 
00063     << numAtoms  << " patchAddr=" << patch << "\n");
00064     Compute::initialize();
00065 
00066     int myNode = CkMyPe();
00067     if ( PatchMap::Object()->node(patchID) != myNode )
00068     {
00069       basePriority = COMPUTE_PROXY_PRIORITY + PATCH_PRIORITY(patchID);
00070     }
00071     else
00072     {
00073       basePriority = COMPUTE_HOME_PRIORITY + PATCH_PRIORITY(patchID);
00074     }
00075 }
00076 
00077 void ComputeHomePatch::atomUpdate() {
00078     // How can we tell if BoxOwner has packed up and left?  Need a mechanism
00079     // to handle this or do we assume the Boxes have been dumped?
00080     numAtoms = patch->getNumAtoms();
00081 }
00082 
00083 void ComputeHomePatch::doWork() {
00084   CompAtom* p;
00085   Results* r;
00086   FullAtom* a = homePatch->getAtomList().begin();
00087 
00088   DebugM(3,patchID << ": doWork() called.\n");
00089 
00090   // Open up positionBox, forceBox, and atomBox
00091   p = positionBox->open();
00092   r = forceBox->open();
00093 
00094   // Pass pointers to doForce
00095   doForce(a,r);
00096 
00097   // Close up boxes
00098   positionBox->close(&p);
00099   forceBox->close(&r);
00100 
00101   DebugM(2,patchID << ": doWork() completed.\n");
00102 }
00103 

Generated on Tue Nov 24 04:07:42 2009 for NAMD by  doxygen 1.3.9.1