ComputeTclBC Class Reference

#include <ComputeTclBC.h>

Inheritance diagram for ComputeTclBC:

ComputeHomePatches Compute List of all members.

Public Member Functions

 ComputeTclBC (ComputeID c)
virtual ~ComputeTclBC ()
void doWork ()

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< Elem >::resize(), Node::simParameters, simParams, tcl_vector_math_init(), ReductionMgr::willSubmit(), and WRAPMODE_PATCH.

00025   : ComputeHomePatches(c), ap(patchList) {
00026 
00027   reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00028   SimParameters *simParams = Node::Object()->simParameters;
00029 
00030   wrapmode = WRAPMODE_PATCH;
00031 
00032   drops.resize(Node::Object()->molecule->numAtoms);
00033   cleardrops();
00034 
00035 #ifdef NAMD_TCL
00036   if ( CkMyRank() && ! simParams->tclIsThreaded ) {
00037     NAMD_die("Sorry, tclBC requires TCL to be built with --enable-threads to use multiple threads per process.");
00038   }
00039 
00040   interp = Tcl_CreateInterp();
00041   tcl_vector_math_init(interp);
00042 
00043   Tcl_CreateCommand(interp, "print", Tcl_print,
00044     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
00045   Tcl_CreateCommand(interp, "wrapmode", Tcl_wrapmode,
00046     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
00047   Tcl_CreateObjCommand(interp, "cleardrops", Tcl_cleardrops,
00048     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
00049 
00050   // run script to define calcforces, etc.
00051   if ( simParams->tclBCScript ) {
00052     int code = Tcl_Eval(interp,simParams->tclBCScript);
00053     const char *result = Tcl_GetStringResult(interp);
00054     if (result && *result != 0) CkPrintf("TCL: %s\n",result);
00055     if (code != TCL_OK) {
00056       const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
00057       NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
00058     }
00059   } else NAMD_bug("tclBCScript pointer was NULL");
00060 
00061   // don't want these available until calcforces call
00062   Tcl_CreateObjCommand(interp, "dropatom", Tcl_dropatom,
00063     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
00064   Tcl_CreateObjCommand(interp, "nextatom", Tcl_nextatom,
00065     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
00066   Tcl_CreateObjCommand(interp, "getcoord", Tcl_getcoord,
00067     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
00068   Tcl_CreateObjCommand(interp, "getcell", Tcl_getcell,
00069     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
00070   Tcl_CreateObjCommand(interp, "getmass", Tcl_getmass,
00071     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
00072   Tcl_CreateObjCommand(interp, "getcharge", Tcl_getcharge,
00073     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
00074   Tcl_CreateObjCommand(interp, "getid", Tcl_getid,
00075     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
00076   Tcl_CreateObjCommand(interp, "addforce", Tcl_addforce,
00077     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
00078   Tcl_CreateObjCommand(interp, "addenergy", Tcl_addenergy,
00079     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
00080 
00081 #else
00082 
00083   NAMD_die("Sorry, tclBC is not available; built without TCL.");
00084 
00085 #endif
00086 
00087 }

ComputeTclBC::~ComputeTclBC (  )  [virtual]

Definition at line 90 of file ComputeTclBC.C.

00090                             {
00091 #ifdef NAMD_TCL
00092   Tcl_DeleteInterp(interp);
00093 #endif
00094   delete reduction;
00095 }


Member Function Documentation

void ComputeTclBC::doWork (  )  [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, and SubmitReduction::submit().

00098                           {
00099 
00100   SimParameters *simParams = Node::Object()->simParameters;
00101   lattice = &(patchList[0].p->lattice);
00102   const int step = patchList[0].p->flags.step;
00103   char cmd[128];
00104 
00105   energy = 0;
00106   n_atom = -1;  // set initial flags for iteration by nextatom
00107 
00108 #ifdef NAMD_TCL
00109   sprintf(cmd,"calcforces %d %d %s",step,hasPatchZero,simParams->tclBCArgs);
00110   int code = Tcl_Eval(interp,cmd);
00111   if (code != TCL_OK) {
00112     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
00113     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
00114   }
00115   if (n_atom != -2) {
00116     NAMD_die("tclBCScript failed to call nextatom until failure");
00117   }
00118 #endif
00119 
00120   reduction->item(REDUCTION_BC_ENERGY) += energy;
00121   reduction->submit();
00122 
00123 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 18 01:17:18 2018 for NAMD by  doxygen 1.4.7