TclCyclicModelCommands.cpp

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <string.h>
00003 #include <OPS_Stream.h>
00004 
00005 #include <Domain.h>
00006 #include <Node.h>
00007 #include <Matrix.h>
00008 
00009 #include <CyclicModel.h>
00010 #include <LinearCyclic.h>
00011 #include <BilinearCyclic.h>
00012 #include <QuadraticCyclic.h>
00013 #include <TclModelBuilder.h>
00014 
00015 
00016 int TclModelBuilder_addLinearCylic(ClientData clientData, Tcl_Interp *interp,
00017                                  int argc, TCL_Char **argv,
00018                                  TclModelBuilder *theBuilder)
00019 {
00020 int tag;
00021         
00022         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK)
00023         {
00024                 opserr << "WARNING invalid CyclicModel tag" << endln;
00025                 return TCL_ERROR;
00026         }
00027 
00028         CyclicModel *cModel = new LinearCyclic(tag);
00029         if(!cModel)
00030         {
00031                 opserr << "TclModelBuilder_addLinearCycylic - could not allocate memory\n";
00032                 return TCL_ERROR;
00033         }
00034         if (theBuilder->addCyclicModel(*cModel) < 0)
00035         {
00036                 opserr << "WARNING TclElmtBuilder - could not add cycModel to domain ";
00037                 opserr << tag << endln;
00038                 opserr << "\a";
00039                 return TCL_ERROR;
00040         }       
00041         
00042         return TCL_OK;
00043 }
00044 
00045 int TclModelBuilder_addBilinearCyclic(ClientData clientData, Tcl_Interp *interp,
00046                                  int argc, TCL_Char **argv,
00047                                  TclModelBuilder *theBuilder)
00048 {
00049 int tag;
00050 double wt;
00051         
00052         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK)
00053         {
00054                 opserr << "WARNING invalid CyclicModel tag" << endln;
00055                 return TCL_ERROR;
00056         }
00057         if (Tcl_GetDouble(interp, argv[3], &wt) != TCL_OK)
00058         {
00059                 opserr << "WARNING invalid arg[3]" << endln;
00060                 return TCL_ERROR;
00061         }
00062         
00063         CyclicModel *cModel = new BilinearCyclic(tag, wt);
00064         if (theBuilder->addCyclicModel(*cModel) <0)
00065         {
00066                 opserr << "WARNING TclElmtBuilder - could not add cycModel to domain ";
00067                 opserr << tag << endln;
00068                 opserr << "\a";
00069                 return TCL_ERROR;
00070         }       
00071         
00072         return TCL_OK;
00073 }
00074 
00075 
00076 int TclModelBuilder_addQuadraticCyclic(ClientData clientData, Tcl_Interp *interp,
00077                                  int argc, TCL_Char **argv,
00078                                  TclModelBuilder *theBuilder)
00079 {
00080 int tag;
00081 double wt, qy;
00082         
00083         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK)
00084         {
00085                 opserr << "WARNING invalid CyclicModel tag" << endln;
00086                 return TCL_ERROR;
00087         }
00088         if (Tcl_GetDouble(interp, argv[3], &wt) != TCL_OK)
00089         {
00090                 opserr << "WARNING invalid arg[3]" << endln;
00091                 return TCL_ERROR;
00092         }
00093         if (Tcl_GetDouble(interp, argv[4], &qy) != TCL_OK)
00094         {
00095                 opserr << "WARNING invalid arg[4]" << endln;
00096                 return TCL_ERROR;
00097         }
00098 
00099         
00100         CyclicModel *cModel = new QuadraticCyclic(tag, wt, qy);
00101         if (theBuilder->addCyclicModel(*cModel) < 0)
00102         {
00103                 opserr << "WARNING TclElmtBuilder - could not add cycModel to domain ";
00104                 opserr << tag << endln;
00105                 opserr << "\a";
00106                 return TCL_ERROR;
00107         }       
00108         return TCL_OK;
00109 }
00110 
00111 
00112 /*******************************************************************************************/
00113 int
00114 TclModelBuilderCyclicModelCommand (ClientData clientData, Tcl_Interp *interp, int argc,
00115                                                        TCL_Char **argv, TclModelBuilder *theTclBuilder)
00116 {
00117 
00118   if (strcmp(argv[1],"linear") == 0) {
00119           int result = TclModelBuilder_addLinearCylic(clientData, interp, argc, argv,
00120                                                  theTclBuilder);
00121     return result;
00122   }
00123   else if (strcmp(argv[1],"bilinear") == 0) {
00124           int result = TclModelBuilder_addBilinearCyclic(clientData, interp, argc, argv,
00125                                                  theTclBuilder);
00126     return result;
00127   }
00128   
00129    else if (strcmp(argv[1],"quadratic") == 0) {
00130           int result = TclModelBuilder_addQuadraticCyclic(clientData, interp, argc, argv,
00131                                                   theTclBuilder);
00132     return result;
00133   }
00134 
00135   else
00136 
00137         return TCL_ERROR;
00138 
00139 }

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