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(this,
00037          &positionBox);
00038     }
00039     if (forceBox != NULL) {
00040       PatchMap::Object()->patch(patchID)->unregisterForceDeposit(this,
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(this);
00058             forceBox = patch->registerForceDeposit(this);
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     basePriority = COMPUTE_HOME_PRIORITY + PATCH_PRIORITY(patchID);
00068 }
00069 
00070 void ComputeHomePatch::atomUpdate() {
00071     // How can we tell if BoxOwner has packed up and left?  Need a mechanism
00072     // to handle this or do we assume the Boxes have been dumped?
00073     numAtoms = patch->getNumAtoms();
00074 }
00075 
00076 void ComputeHomePatch::doWork() {
00077   CompAtom* p;
00078   Results* r;
00079   FullAtom* a = homePatch->getAtomList().begin();
00080 
00081   DebugM(3,patchID << ": doWork() called.\n");
00082 
00083   // Open up positionBox, forceBox, and atomBox
00084   p = positionBox->open();
00085   r = forceBox->open();
00086 
00087   // Pass pointers to doForce
00088   doForce(a,r);
00089 
00090   // Close up boxes
00091   positionBox->close(&p);
00092   forceBox->close(&r);
00093 
00094   DebugM(2,patchID << ": doWork() completed.\n");
00095 }
00096 

Generated on Tue Nov 21 01:17:11 2017 for NAMD by  doxygen 1.4.7