NAMD
Public Member Functions | List of all members
ComputeTclBC Class Reference

#include <ComputeTclBC.h>

Inheritance diagram for ComputeTclBC:
ComputeHomePatches Compute

Public Member Functions

 ComputeTclBC (ComputeID c)
 
virtual ~ComputeTclBC ()
 
void doWork ()
 
- Public Member Functions inherited from ComputeHomePatches
 ComputeHomePatches (ComputeID c)
 
virtual ~ComputeHomePatches ()
 
virtual void initialize ()
 
virtual void atomUpdate ()
 
FlagsgetFlags (void)
 
- Public Member Functions inherited from Compute
 Compute (ComputeID)
 
int type ()
 
virtual ~Compute ()
 
void setNumPatches (int n)
 
int getNumPatches ()
 
virtual void patchReady (PatchID, int doneMigration, int seq)
 
virtual int noWork ()
 
virtual void finishPatch (int)
 
int sequence (void)
 
int priority (void)
 
int getGBISPhase (void)
 
virtual void gbisP2PatchReady (PatchID, int seq)
 
virtual void gbisP3PatchReady (PatchID, int seq)
 

Additional Inherited Members

- Public Attributes inherited from Compute
const ComputeID cid
 
LDObjHandle ldObjHandle
 
LocalWorkMsg *const localWorkMsg
 
- Protected Member Functions inherited from Compute
void enqueueWork ()
 
- Protected Attributes inherited from ComputeHomePatches
int useAvgPositions
 
int hasPatchZero
 
ComputeHomePatchList patchList
 
PatchMappatchMap
 
- Protected Attributes inherited from Compute
int computeType
 
int basePriority
 
int gbisPhase
 
int gbisPhasePriority [3]
 

Detailed Description

Definition at line 23 of file ComputeTclBC.h.

Constructor & Destructor Documentation

ComputeTclBC::ComputeTclBC ( ComputeID  c)

Definition at line 24 of file ComputeTclBC.C.

References NAMD_bug(), NAMD_die(), Node::Object(), ReductionMgr::Object(), REDUCTIONS_BASIC, ResizeArray< T >::resize(), Node::simParameters, simParams, tcl_vector_math_init(), SimParameters::tclBCScript, SimParameters::tclIsThreaded, ReductionMgr::willSubmit(), and WRAPMODE_PATCH.

25  : ComputeHomePatches(c), ap(patchList) {
26 
29 
30  wrapmode = WRAPMODE_PATCH;
31 
32  drops.resize(Node::Object()->molecule->numAtoms);
33  cleardrops();
34 
35 #ifdef NAMD_TCL
36  if ( CkMyRank() && ! simParams->tclIsThreaded ) {
37  NAMD_die("Sorry, tclBC requires TCL to be built with --enable-threads to use multiple threads per process.");
38  }
39 
40  interp = Tcl_CreateInterp();
41  tcl_vector_math_init(interp);
42 
43  Tcl_CreateCommand(interp, "print", Tcl_print,
44  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
45  Tcl_CreateCommand(interp, "wrapmode", Tcl_wrapmode,
46  (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
47  Tcl_CreateObjCommand(interp, "cleardrops", Tcl_cleardrops,
48  (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
49 
50  // run script to define calcforces, etc.
51  if ( simParams->tclBCScript ) {
52  int code = Tcl_Eval(interp,simParams->tclBCScript);
53  const char *result = Tcl_GetStringResult(interp);
54  if (result && *result != 0) CkPrintf("TCL: %s\n",result);
55  if (code != TCL_OK) {
56  const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
57  NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
58  }
59  } else NAMD_bug("tclBCScript pointer was NULL");
60 
61  // don't want these available until calcforces call
62  Tcl_CreateObjCommand(interp, "dropatom", Tcl_dropatom,
63  (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
64  Tcl_CreateObjCommand(interp, "nextatom", Tcl_nextatom,
65  (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
66  Tcl_CreateObjCommand(interp, "getcoord", Tcl_getcoord,
67  (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
68  Tcl_CreateObjCommand(interp, "getcell", Tcl_getcell,
69  (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
70  Tcl_CreateObjCommand(interp, "getmass", Tcl_getmass,
71  (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
72  Tcl_CreateObjCommand(interp, "getcharge", Tcl_getcharge,
73  (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
74  Tcl_CreateObjCommand(interp, "getid", Tcl_getid,
75  (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
76  Tcl_CreateObjCommand(interp, "addforce", Tcl_addforce,
77  (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
78  Tcl_CreateObjCommand(interp, "addenergy", Tcl_addenergy,
79  (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
80 
81 #else
82 
83  NAMD_die("Sorry, tclBC is not available; built without TCL.");
84 
85 #endif
86 
87 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
ComputeHomePatchList patchList
char * tclBCScript
#define WRAPMODE_PATCH
Definition: ComputeTclBC.C:19
SubmitReduction * willSubmit(int setID, int size=-1)
Definition: ReductionMgr.C:365
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:278
ComputeHomePatches(ComputeID c)
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void NAMD_die(const char *err_msg)
Definition: common.C:85
#define simParams
Definition: Output.C:127
int tcl_vector_math_init(Tcl_Interp *interp)
Definition: TclCommands.C:299
void resize(int i)
Definition: ResizeArray.h:84
ComputeTclBC::~ComputeTclBC ( )
virtual

Definition at line 90 of file ComputeTclBC.C.

90  {
91 #ifdef NAMD_TCL
92  Tcl_DeleteInterp(interp);
93 #endif
94  delete reduction;
95 }

Member Function Documentation

void ComputeTclBC::doWork ( void  )
virtual

Reimplemented from Compute.

Definition at line 98 of file ComputeTclBC.C.

References ComputeHomePatches::hasPatchZero, SubmitReduction::item(), NAMD_die(), Node::Object(), ComputeHomePatches::patchList, REDUCTION_BC_ENERGY, Node::simParameters, simParams, SubmitReduction::submit(), and SimParameters::tclBCArgs.

98  {
99 
101  lattice = &(patchList[0].p->lattice);
102  const int step = patchList[0].p->flags.step;
103  char cmd[128];
104 
105  energy = 0;
106  n_atom = -1; // set initial flags for iteration by nextatom
107 
108 #ifdef NAMD_TCL
109  sprintf(cmd,"calcforces %d %d %s",step,hasPatchZero,simParams->tclBCArgs);
110  int code = Tcl_Eval(interp,cmd);
111  if (code != TCL_OK) {
112  const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
113  NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
114  }
115  if (n_atom != -2) {
116  NAMD_die("tclBCScript failed to call nextatom until failure");
117  }
118 #endif
119 
120  reduction->item(REDUCTION_BC_ENERGY) += energy;
121  reduction->submit();
122 
123 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
ComputeHomePatchList patchList
BigReal & item(int i)
Definition: ReductionMgr.h:312
char tclBCArgs[NAMD_FILENAME_BUFFER_SIZE]
void NAMD_die(const char *err_msg)
Definition: common.C:85
#define simParams
Definition: Output.C:127
void submit(void)
Definition: ReductionMgr.h:323

The documentation for this class was generated from the following files: