TclGFunEvaluator.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 2001, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** Reliability module developed by:                                   **
00020 **   Terje Haukaas (haukaas@ce.berkeley.edu)                          **
00021 **   Armen Der Kiureghian (adk@ce.berkeley.edu)                       **
00022 **                                                                    **
00023 ** ****************************************************************** */
00024                                                                         
00025 // $Revision: 1.3 $
00026 // $Date: 2003/10/27 23:45:43 $
00027 // $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/gFunction/TclGFunEvaluator.cpp,v $
00028 
00029 
00030 //
00031 // Written by Terje Haukaas (haukaas@ce.berkeley.edu)
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 //#include <fstream>
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         // Initial declarations
00066         char theCommand[100];
00067         int i;
00068 
00069 
00071 
00072         // Zero out the response in the structural domain to make ready for next analysis
00073         char theRevertToStartCommand[10] = "reset";
00074         Tcl_Eval( theTclInterp, theRevertToStartCommand );
00075 
00076 
00077         // Put random variables into the structural domain according to the RandomVariablePositioners
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         // Set values of random variables in the Tcl intepreter
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         // Source the code file that the user has provided
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 

Generated on Mon Oct 23 15:05:25 2006 for OpenSees by doxygen 1.5.0