NAMD
ComputeHomePatch.C
Go to the documentation of this file.
1 
7 /*
8  Compute object which deals with a single patch.
9 */
10 
11 #include "InfoStream.h"
12 #include "WorkDistrib.decl.h"
13 #include "Node.h"
14 #include "ComputeHomePatch.h"
15 #include "PatchMap.inl"
16 #include "HomePatch.h"
17 #include "Priorities.h"
18 
19 #define MIN_DEBUG_LEVEL 4
20 //#define DEBUGM
21 #include "Debug.h"
22 
24  setNumPatches(1);
25  patchID = p;
26  patch = NULL;
27  homePatch = NULL;
28  positionBox = NULL;
29  forceBox = NULL;
30 }
31 
33  DebugM(4, "~ComputeHomePatch("<<cid<<") numAtoms("<<patchID<<") = "
34  << numAtoms << "\n");
35  if (positionBox != NULL) {
37  &positionBox);
38  }
39  if (forceBox != NULL) {
41  &forceBox);
42  }
43 }
44 
46  // How can we tell if BoxOwner has packed up and left? Need a mechanism
47  // to handle this or do we assume the Boxes have been dumped?
48 
49  if (positionBox == NULL) { // We have yet to get boxes
50  if (!(patch = PatchMap::Object()->patch(patchID))) {
51  NAMD_bug("ComputeHomePatch used with unknown patch.");
52  }
53  if (!(homePatch = PatchMap::Object()->homePatch(patchID))) {
54  NAMD_bug("ComputeHomePatch used with proxy.");
55  }
56  DebugM(3, "initialize(" << cid <<") patchid = "<<patch->getPatchID()<<"\n");
57  positionBox = patch->registerPositionPickup(this);
58  forceBox = patch->registerForceDeposit(this);
59  }
61 
62  DebugM(3, "initialize("<<cid<<") numAtoms("<<patchID<<") = "
63  << numAtoms << " patchAddr=" << patch << "\n");
65 
66  int myNode = CkMyPe();
68 }
69 
71  // How can we tell if BoxOwner has packed up and left? Need a mechanism
72  // to handle this or do we assume the Boxes have been dumped?
74 }
75 
77  CompAtom* p;
78  Results* r;
80 
81  DebugM(3,patchID << ": doWork() called.\n");
82 
83  // Open up positionBox, forceBox, and atomBox
84  p = positionBox->open();
85  r = forceBox->open();
86 
87  // Pass pointers to doForce
88  doForce(a,r);
89 
90  // Close up boxes
91  positionBox->close(&p);
92  forceBox->close(&r);
93 
94  DebugM(2,patchID << ": doWork() completed.\n");
95 }
96 
void setNumPatches(int n)
Definition: Compute.h:52
virtual ~ComputeHomePatch()
int ComputeID
Definition: NamdTypes.h:183
static PatchMap * Object()
Definition: PatchMap.h:27
#define DebugM(x, y)
Definition: Debug.h:59
void unregisterForceDeposit(Compute *cid, Box< Patch, Results > **const box)
Definition: Patch.C:239
virtual void initialize()
virtual void initialize()
Definition: Compute.h:56
Patch * patch(PatchID pid)
Definition: PatchMap.h:235
virtual void doWork()
FullAtomList & getAtomList()
Definition: HomePatch.h:455
#define COMPUTE_HOME_PRIORITY
Definition: Priorities.h:76
void NAMD_bug(const char *err_msg)
Definition: common.C:129
int PatchID
Definition: NamdTypes.h:182
virtual void doForce(FullAtom *p, Results *r)=0
virtual void atomUpdate()
void unregisterPositionPickup(Compute *cid, Box< Patch, CompAtom > **const box)
Definition: Patch.C:122
PatchID getPatchID()
Definition: Patch.h:114
int getNumAtoms()
Definition: Patch.h:105
int basePriority
Definition: Compute.h:37
Data * open(void)
Definition: Box.h:39
const ComputeID cid
Definition: Compute.h:43
void close(Data **const t)
Definition: Box.h:49
Box< Patch, CompAtom > * registerPositionPickup(Compute *cid)
Definition: Patch.C:107
HomePatch * homePatch
ComputeHomePatch(ComputeID c, PatchID pid)
#define PATCH_PRIORITY(PID)
Definition: Priorities.h:25
iterator begin(void)
Definition: ResizeArray.h:36
Box< Patch, Results > * registerForceDeposit(Compute *cid)
Definition: Patch.C:228