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
00035
00036
00037
00038 #include <Domain.h>
00039 #include "TclModelBuilder.h"
00040 #include "TclUniaxialMaterialTester.h"
00041
00042 #include <tcl.h>
00043 #include <tk.h>
00044
00045 #include <stdio.h>
00046 #include <stdlib.h>
00047 #include <string.h>
00048
00049 extern ModelBuilder *theBuilder;
00050 extern Domain theDomain;
00051
00052 int
00053 specifyModelBuilder(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv);
00054
00055 int myCommands(Tcl_Interp *interp) {
00056 Tcl_CreateCommand(interp, "model", specifyModelBuilder,
00057 (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
00058 return 0;
00059 }
00060
00061 int
00062 specifyModelBuilder(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv)
00063 {
00064
00065 if (argc < 2) {
00066 opserr << "WARNING need to specify a model type, valid types:\n";
00067 opserr << "\tBasicBuilder\n";
00068 return TCL_ERROR;
00069 }
00070
00071
00072 if (theBuilder != 0) {
00073 delete theBuilder;
00074 theBuilder = 0;
00075 }
00076
00077
00078 if (strcmp(argv[1],"basic") == 0 || strcmp(argv[1],"BasicBuilder") == 0) {
00079 int ndm =0;
00080 int ndf = 0;
00081
00082 if (argc < 4) {
00083 opserr << "WARNING incorrect number of command arguments\n";
00084 opserr << "model modelBuilderType -ndm ndm? <-ndf ndf?> \n";
00085 return TCL_ERROR;
00086 }
00087
00088 int argPos = 2;
00089 while (argPos < argc) {
00090 if (strcmp(argv[argPos],"-ndm") == 0 ||
00091 strcmp(argv[argPos],"-NDM") == 0) {
00092 argPos++;
00093 if (argPos < argc)
00094 if (Tcl_GetInt(interp, argv[argPos], &ndm) != TCL_OK) {
00095 opserr << "WARNING error reading ndm: " << argv[argPos];
00096 opserr << "\nmodel modelBuilderType -ndm ndm? <-ndf ndf?>\n";
00097 return TCL_ERROR;
00098 }
00099 argPos++;
00100 }
00101
00102 else if (strcmp(argv[argPos],"-ndf") == 0 ||
00103 strcmp(argv[argPos],"-NDF") == 0) {
00104 argPos++;
00105 if (argPos < argc)
00106 if (Tcl_GetInt(interp, argv[argPos], &ndf) != TCL_OK) {
00107 opserr << "WARNING error reading ndf: " << argv[argPos];
00108 opserr << "\nmodel modelBuilderType -ndm ndm? <-ndf ndf?>\n";
00109 return TCL_ERROR;
00110 }
00111 argPos++;
00112 }
00113
00114 else
00115 argPos++;
00116 }
00117
00118
00119 if (ndm == 0) {
00120 opserr << "WARNING need to specify ndm\n";
00121 opserr << "model modelBuilderType -ndm ndm? <-ndf ndf?>\n";
00122 return TCL_ERROR;
00123 }
00124
00125
00126 if (ndf == 0) {
00127 if (ndm == 1)
00128 ndf = 1;
00129 else if (ndm == 2)
00130 ndf = 3;
00131 else if (ndm == 3)
00132 ndf = 6;
00133 else {
00134 opserr << "WARNING specified ndm, " << ndm << ", will not work\n";
00135 opserr << "with any elements in BasicBuilder\n";
00136 return TCL_ERROR;
00137 }
00138 }
00139
00140
00141 theBuilder = new TclModelBuilder(theDomain, interp, ndm, ndf);
00142 if (theBuilder == 0) {
00143 opserr << "WARNING ran out of memory in creating BasicBuilder model\n";
00144 return TCL_ERROR;
00145 }
00146 }
00147
00148 else if (strcmp(argv[1],"test") == 0 || strcmp(argv[1],"TestUniaxial") == 0) {
00149 int count = 1;
00150 if (argc == 3) {
00151 if (Tcl_GetInt(interp, argv[2], &count) != TCL_OK) {
00152 return TCL_ERROR;
00153 }
00154 }
00155 theBuilder = new TclUniaxialMaterialTester(theDomain, interp, count);
00156 if (theBuilder == 0) {
00157 opserr << "WARNING ran out of memory in creating TclUniaxialMAterialTester model\n";
00158 return TCL_ERROR;
00159 }
00160 }
00161
00162 else
00163 {
00164 Tcl_SetResult(interp, "WARNING unknown model builder type", TCL_STATIC);
00165
00166 opserr << "WARNING model builder type " << argv[1]
00167 << " not supported\n";
00168 return TCL_ERROR;
00169 }
00170
00171 return TCL_OK;
00172 }
00173
00174
00175
00176
00177