00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <TclGFunEvaluator.h>
00035 #include <Vector.h>
00036 #include <GFunEvaluator.h>
00037 #include <ReliabilityDomain.h>
00038 #include <LimitStateFunction.h>
00039 #include <RandomVariablePositioner.h>
00040
00041 #include <tcl.h>
00042 #include <string.h>
00043
00044
00045 TclGFunEvaluator::TclGFunEvaluator(Tcl_Interp *passedTclInterp,
00046 ReliabilityDomain *passedReliabilityDomain,
00047 TCL_Char *passed_fileName)
00048 :GFunEvaluator(passedTclInterp, passedReliabilityDomain)
00049 {
00050 fileName = new char[256];
00051 strcpy(fileName,passed_fileName);
00052 }
00053
00054
00055 TclGFunEvaluator::~TclGFunEvaluator()
00056 {
00057 if (fileName != 0)
00058 delete [] fileName;
00059 }
00060
00061
00062 int
00063 TclGFunEvaluator::runGFunAnalysis(Vector x)
00064 {
00065
00066 char theCommand[100];
00067 int i;
00068
00069
00071
00072
00073 char theRevertToStartCommand[10] = "reset";
00074 Tcl_Eval( theTclInterp, theRevertToStartCommand );
00075
00076
00077
00078 int numberOfRandomVariablePositioners = theReliabilityDomain->getNumberOfRandomVariablePositioners();
00079 RandomVariablePositioner *theRandomVariablePositioner;
00080 int rvNumber;
00081 for ( i=1 ; i<=numberOfRandomVariablePositioners ; i++ ) {
00082 theRandomVariablePositioner = theReliabilityDomain->getRandomVariablePositionerPtr(i);
00083 rvNumber = theRandomVariablePositioner->getRvNumber();
00084 theRandomVariablePositioner->update(x(rvNumber-1));
00085 }
00086
00088
00089
00090
00091 for (i=0; i<x.Size(); i++) {
00092 sprintf(theCommand,"set x_%d %20.12e",(i+1),x(i));
00093 Tcl_Eval( theTclInterp, theCommand );
00094 }
00095
00096
00097
00098 sprintf(theCommand,"source %s",fileName);
00099 Tcl_Eval( theTclInterp, theCommand );
00100
00101
00102 return 0;
00103 }
00104
00105
00106
00107
00108 int
00109 TclGFunEvaluator::tokenizeSpecials(TCL_Char *theExpression)
00110 {
00111
00112 return 0;
00113 }
00114