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 <Elastic2DGNL.h>
00010
00011 #include <TclModelBuilder.h>
00012
00013 #define tcl_debug 1
00014
00015
00016
00017
00018 int
00019 TclModelBuilder_addElastic2dGNL (ClientData clientData, Tcl_Interp *interp,
00020 int argc, TCL_Char **argv,
00021 Domain *theDomain, TclModelBuilder *theBuilder)
00022 {
00023
00024
00025
00026 if(tcl_debug)
00027 opserr << " TclModelBuilder_addElastic2dGNL \n";
00028
00029 if (argc < 8)
00030 {
00031 opserr << "WARNING insufficient arguments\n";
00032 opserr << "element element2dGNL int tag, int Nd1, int Nd2, double A, double E, double Iz, <int linear>\n";
00033
00034 return TCL_ERROR;
00035 }
00036
00037 int tag, ndI, ndJ;
00038 double E, A, I;
00039 double massDens = 0.0;
00040 bool linear = false;
00041
00042 if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK)
00043 {
00044 opserr << "WARNING invalid Elastic2dGNL tag" << endln;
00045 return TCL_ERROR;
00046 }
00047 if(tcl_debug) opserr << "\tElement tag = " << tag << "\n";
00048
00049 if (Tcl_GetInt (interp, argv[3], &ndI) != TCL_OK)
00050 {
00051 opserr << "WARNING invalid node I\n";
00052 opserr << "Elastic2dGNL: " << tag << endln;
00053 return TCL_ERROR;
00054 }
00055
00056 if (Tcl_GetInt (interp, argv[4], &ndJ) != TCL_OK)
00057 {
00058 opserr << "WARNING invalid node J\n";
00059 opserr << "Elastic2dGNL: " << tag << endln;
00060 return TCL_ERROR;
00061 }
00062
00063
00064 if (Tcl_GetDouble(interp, argv[5], &A) != TCL_OK)
00065 {
00066 opserr << "WARNING invalid A\n";
00067 opserr << "Elastic2dGNL: " << tag << endln;
00068 return TCL_ERROR;
00069 }
00070
00071 if (Tcl_GetDouble(interp, argv[6], &E) != TCL_OK)
00072 {
00073 opserr << "WARNING invalid E\n";
00074 opserr << "Elastic2dGNL: " << tag << endln;
00075 return TCL_ERROR;
00076 }
00077
00078 if (Tcl_GetDouble(interp, argv[7], &I) != TCL_OK)
00079 {
00080 opserr << "WARNING invalid I\n";
00081 opserr << "Elastic2dGNL: " << tag << endln;
00082 return TCL_ERROR;
00083 }
00084
00085 if(argc == 9)
00086 {
00087 int lin = 0;
00088 if(Tcl_GetInt(interp, argv[8], &lin) != TCL_OK)
00089 {
00090 opserr << "WARNING invalid Linear Flag\n";
00091 opserr << "Elastic2dGNL: " << tag << endln;
00092 return TCL_ERROR;
00093 }
00094
00095 if(lin == 1)
00096 linear = true;
00097
00098 if(tcl_debug)
00099 opserr << " 9 arguments - " << lin << endln;
00100 }
00101
00102
00103
00104
00105 Element *theElement = new Elastic2dGNL(tag, A, E, I, ndI, ndJ, linear);
00106
00107 if(tcl_debug) opserr << "\tElement created\n";
00108
00109
00110 if (theElement == 0)
00111 {
00112 opserr << "WARNING ran out of memory creating element\n";
00113 opserr << "Elastic2dGNL: " << tag << endln;
00114 opserr << "\a";
00115 return TCL_ERROR;
00116 }
00117
00118 if (theDomain->addElement(theElement) == false)
00119 {
00120 opserr << "WARNING TclElmtBuilder - addElastic2dGNL - could not add element to domain ";
00121 opserr << tag << endln;
00122 opserr << "\a";
00123 return TCL_ERROR;
00124 }
00125
00126 if(tcl_debug) opserr << "\tElement number " << tag << " added to domain - returning\n";
00127
00128 return TCL_OK;
00129 }