#include <ComputeTclBC.h>
Inheritance diagram for ComputeTclBC:

Public Member Functions | |
| ComputeTclBC (ComputeID c) | |
| virtual | ~ComputeTclBC () |
| void | doWork () |
|
|
Definition at line 25 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(), SimParameters::tclBCScript, SimParameters::tclIsThreaded, and ReductionMgr::willSubmit(). 00026 : ComputeHomePatches(c), ap(patchList) { 00027 00028 reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC); 00029 SimParameters *simParams = Node::Object()->simParameters; 00030 00031 wrapmode = WRAPMODE_PATCH; 00032 00033 drops.resize(Node::Object()->molecule->numAtoms); 00034 cleardrops(); 00035 00036 #ifdef NAMD_TCL 00037 if ( CkMyRank() && ! simParams->tclIsThreaded ) { 00038 NAMD_die("Sorry, tclBC requires TCL to be built with --enable-threads to use multiple threads per process."); 00039 } 00040 00041 interp = Tcl_CreateInterp(); 00042 tcl_vector_math_init(interp); 00043 00044 Tcl_CreateCommand(interp, "print", Tcl_print, 00045 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); 00046 Tcl_CreateCommand(interp, "wrapmode", Tcl_wrapmode, 00047 (ClientData) this, (Tcl_CmdDeleteProc *) NULL); 00048 Tcl_CreateObjCommand(interp, "cleardrops", Tcl_cleardrops, 00049 (ClientData) this, (Tcl_CmdDeleteProc *) NULL); 00050 00051 // run script to define calcforces, etc. 00052 if ( simParams->tclBCScript ) { 00053 int code = Tcl_Eval(interp,simParams->tclBCScript); 00054 const char *result = Tcl_GetStringResult(interp); 00055 if (result && *result != 0) CkPrintf("TCL: %s\n",result); 00056 if (code != TCL_OK) { 00057 const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0); 00058 NAMD_die(errorInfo); 00059 } 00060 } else NAMD_bug("tclBCScript pointer was NULL"); 00061 00062 // don't want these available until calcforces call 00063 Tcl_CreateObjCommand(interp, "dropatom", Tcl_dropatom, 00064 (ClientData) this, (Tcl_CmdDeleteProc *) NULL); 00065 Tcl_CreateObjCommand(interp, "nextatom", Tcl_nextatom, 00066 (ClientData) this, (Tcl_CmdDeleteProc *) NULL); 00067 Tcl_CreateObjCommand(interp, "getcoord", Tcl_getcoord, 00068 (ClientData) this, (Tcl_CmdDeleteProc *) NULL); 00069 Tcl_CreateObjCommand(interp, "getcell", Tcl_getcell, 00070 (ClientData) this, (Tcl_CmdDeleteProc *) NULL); 00071 Tcl_CreateObjCommand(interp, "getmass", Tcl_getmass, 00072 (ClientData) this, (Tcl_CmdDeleteProc *) NULL); 00073 Tcl_CreateObjCommand(interp, "getcharge", Tcl_getcharge, 00074 (ClientData) this, (Tcl_CmdDeleteProc *) NULL); 00075 Tcl_CreateObjCommand(interp, "getid", Tcl_getid, 00076 (ClientData) this, (Tcl_CmdDeleteProc *) NULL); 00077 Tcl_CreateObjCommand(interp, "addforce", Tcl_addforce, 00078 (ClientData) this, (Tcl_CmdDeleteProc *) NULL); 00079 Tcl_CreateObjCommand(interp, "addenergy", Tcl_addenergy, 00080 (ClientData) this, (Tcl_CmdDeleteProc *) NULL); 00081 00082 #else 00083 00084 NAMD_die("Sorry, tclBC is not available; built without TCL."); 00085 00086 #endif 00087 00088 }
|
|
|
Definition at line 91 of file ComputeTclBC.C. 00091 {
00092 #ifdef NAMD_TCL
00093 Tcl_DeleteInterp(interp);
00094 #endif
00095 delete reduction;
00096 }
|
|
|
Reimplemented from Compute. Definition at line 99 of file ComputeTclBC.C. References SubmitReduction::item(), NAMD_die(), Node::Object(), REDUCTION_BC_ENERGY, Node::simParameters, simParams, SubmitReduction::submit(), and SimParameters::tclBCArgs. 00099 {
00100
00101 SimParameters *simParams = Node::Object()->simParameters;
00102 lattice = &(patchList[0].p->lattice);
00103 const int step = patchList[0].p->flags.step;
00104 char cmd[128];
00105
00106 energy = 0;
00107 n_atom = -1; // set initial flags for iteration by nextatom
00108
00109 #ifdef NAMD_TCL
00110 sprintf(cmd,"calcforces %d %d %s",step,hasPatchZero,simParams->tclBCArgs);
00111 int code = Tcl_Eval(interp,cmd);
00112 if (code != TCL_OK) {
00113 const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
00114 NAMD_die(errorInfo);
00115 }
00116 if (n_atom != -2) {
00117 NAMD_die("tclBCScript failed to call nextatom until failure");
00118 }
00119 #endif
00120
00121 reduction->item(REDUCTION_BC_ENERGY) += energy;
00122 reduction->submit();
00123
00124 }
|
1.3.9.1