LimitStateFunction.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.7 $
00026 // $Date: 2003/10/27 23:04:38 $
00027 // $Source: /usr/local/cvs/OpenSees/SRC/reliability/domain/components/LimitStateFunction.cpp,v $
00028 
00029 
00030 //
00031 // Written by Terje Haukaas (haukaas@ce.berkeley.edu)
00032 //
00033 
00034 #include <LimitStateFunction.h>
00035 #include <Vector.h>
00036 #include <string.h>
00037 #include <classTags.h>
00038 
00039 LimitStateFunction::LimitStateFunction( int passedTag, 
00040                                                                             TCL_Char *passedExpression)
00041 :ReliabilityDomainComponent(passedTag, LIMIT_STATE_FUNCTION)
00042 {
00043         originalExpression = new char[500];
00044         strcpy(originalExpression,passedExpression);
00045 
00046         expressionWithAddition = new char[500];
00047         strcpy(expressionWithAddition,passedExpression);
00048 
00049         tokenizedExpression = new char[500];
00050         tokenizeIt(passedExpression);
00051 }
00052 
00053 
00054 LimitStateFunction::~LimitStateFunction()
00055 {
00056         if (originalExpression != 0) {
00057                 delete [] originalExpression;
00058         }
00059         if (expressionWithAddition != 0) {
00060                 delete [] expressionWithAddition;
00061         }
00062         if (tokenizedExpression != 0) {
00063                 delete [] tokenizedExpression;
00064         }
00065 }
00066 
00067 
00068 void
00069 LimitStateFunction::Print(OPS_Stream &s, int flag)  
00070 {
00071 }
00072 
00073 
00074 
00075 char *
00076 LimitStateFunction::getExpression()
00077 {
00078         return expressionWithAddition;
00079 }
00080 
00081 
00082 char *
00083 LimitStateFunction::getTokenizedExpression()
00084 {
00085         return tokenizedExpression;
00086 }
00087 
00088 int
00089 LimitStateFunction::addExpression(char *addition)
00090 {
00091         strcat(expressionWithAddition,addition);
00092 
00093         tokenizeIt(expressionWithAddition);
00094 
00095         return 0;
00096 }
00097 
00098 int
00099 LimitStateFunction::removeAddedExpression()
00100 {
00101         strcpy(expressionWithAddition,originalExpression);
00102 
00103         tokenizeIt(expressionWithAddition);
00104 
00105         return 0;
00106 }
00107 
00108 
00109 int
00110 LimitStateFunction::tokenizeIt(TCL_Char *originalExpression)
00111 {
00112         // Also store the tokenized expression (with dollar signs in front of variable names)
00113         char *lsf_forTokenizing = new char[500];
00114         char separators[5] = "}{";
00115         char *dollarSign = "$";
00116         strcpy(lsf_forTokenizing,originalExpression);
00117         char lsf_expression[500] = "";
00118         char *tokenPtr2 = strtok( lsf_forTokenizing, separators);
00119         while ( tokenPtr2 != NULL ) {
00120                 if (   strncmp(tokenPtr2, "a",1) == 0
00121                         || strncmp(tokenPtr2, "b",1) == 0
00122                         || strncmp(tokenPtr2, "c",1) == 0
00123                         || strncmp(tokenPtr2, "d",1) == 0
00124                         || strncmp(tokenPtr2, "e",1) == 0
00125                         || strncmp(tokenPtr2, "f",1) == 0
00126                         || strncmp(tokenPtr2, "g",1) == 0
00127                         || strncmp(tokenPtr2, "h",1) == 0
00128                         || strncmp(tokenPtr2, "i",1) == 0
00129                         || strncmp(tokenPtr2, "j",1) == 0
00130                         || strncmp(tokenPtr2, "k",1) == 0
00131                         || strncmp(tokenPtr2, "l",1) == 0
00132                         || strncmp(tokenPtr2, "m",1) == 0
00133                         || strncmp(tokenPtr2, "n",1) == 0
00134                         || strncmp(tokenPtr2, "o",1) == 0
00135                         || strncmp(tokenPtr2, "p",1) == 0
00136                         || strncmp(tokenPtr2, "q",1) == 0
00137                         || strncmp(tokenPtr2, "r",1) == 0
00138                         || strncmp(tokenPtr2, "s",1) == 0
00139                         || strncmp(tokenPtr2, "t",1) == 0
00140                         || strncmp(tokenPtr2, "u",1) == 0
00141                         || strncmp(tokenPtr2, "v",1) == 0
00142                         || strncmp(tokenPtr2, "w",1) == 0
00143                         || strncmp(tokenPtr2, "x",1) == 0
00144                         || strncmp(tokenPtr2, "y",1) == 0
00145                         || strncmp(tokenPtr2, "z",1) == 0) {
00146                         strcat(lsf_expression, dollarSign);
00147                         strcat(lsf_expression, tokenPtr2);
00148                 }
00149                 else {
00150                         strcat(lsf_expression, tokenPtr2);
00151                 }
00152                 tokenPtr2 = strtok( NULL, separators);
00153         }
00154         delete [] lsf_forTokenizing;
00155 
00156         strcpy(tokenizedExpression,lsf_expression);
00157 
00158         return 0;
00159 }

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