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

ComputePatch.C

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

Generated on Mon Oct 13 04:07:41 2008 for NAMD by  doxygen 1.3.9.1