00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <stdlib.h>
00025 #include <string.h>
00026 #include <OPS_Stream.h>
00027 #include <Domain.h>
00028
00029 #include <ErrorHandler.h>
00030 #include <TwentyNodeBrick.h>
00031 #include <TclModelBuilder.h>
00032
00033 extern void printCommand(int argc, TCL_Char **argv);
00034
00035 int
00036 TclModelBuilder_addTwentyNodeBrick(ClientData clientData, Tcl_Interp *interp, int argc,
00037 TCL_Char **argv, Domain*theTclDomain,
00038 TclModelBuilder *theTclBuilder, int eleArgStart)
00039 {
00040
00041 if (theTclBuilder == 0) {
00042 opserr << "command: element Brick20N - no modelbuilder\n";
00043 return TCL_ERROR;
00044 }
00045
00046
00047 if ((argc-eleArgStart) < 27) {
00048 opserr << "command: element Brick20N - insufficient args - want " <<
00049 "element Brick20N eleTag? node1? node2? .. node20? matTag? bforce1? bforce2? bforce3? massDensity?\n";
00050 return TCL_ERROR;
00051 }
00052
00053
00054 int eleID, matID;
00055 int nodes[20];
00056 double bodyforces[3], massDensity;
00057
00058
00059
00060 if (Tcl_GetInt(interp, argv[1+eleArgStart], &eleID) != TCL_OK) {
00061 opserr << "command: element Brick20N - invalid integer tag " << argv[1+eleArgStart] << endln;
00062 return TCL_ERROR;
00063 }
00064
00065
00066 int i;
00067 for (i=0; i<20; i++) {
00068 if (Tcl_GetInt(interp, argv[2+i+eleArgStart], &nodes[i]) != TCL_OK) {
00069 opserr << "command: element Brick20N " << eleID << " - invalid integer tag " <<
00070 argv[2+i+eleArgStart] << endln;
00071 return TCL_ERROR;
00072 }
00073 }
00074
00075
00076 if (Tcl_GetInt(interp, argv[22+eleArgStart], &matID) != TCL_OK) {
00077 opserr << "command: element Brick20N " << eleID << " - invalid matID tag " <<
00078 argv[22+eleArgStart] << endln;
00079
00080 return TCL_ERROR;
00081 }
00082
00083 NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);
00084
00085 if (theMaterial == 0) {
00086 opserr << "command: element Brick20N " << eleID <<
00087 " - no NDMaterial with tag " << argv[22+eleArgStart] << "exists\n";
00088 return TCL_ERROR;
00089 }
00090
00091
00092
00093
00094 for (i=0; i<3; i++) {
00095 if (Tcl_GetDouble(interp, argv[23+i+eleArgStart], &bodyforces[i]) != TCL_OK) {
00096 opserr << "command: element Brick20N " << eleID << " - invalid bodyforces tag " <<
00097 argv[23+i+eleArgStart] << endln;
00098 return TCL_ERROR;
00099 }
00100 }
00101
00102
00103 if (Tcl_GetDouble(interp, argv[26+eleArgStart], &massDensity) != TCL_OK) {
00104 opserr << "command: element Brick20N " << eleID << "- invalid massDensity " <<
00105 argv[26+eleArgStart] << endln;
00106 return TCL_ERROR;
00107 }
00108
00109
00110 TwentyNodeBrick *theEle = new TwentyNodeBrick(eleID, nodes[ 0], nodes [1], nodes[ 2], nodes[ 3], nodes[ 4],
00111 nodes[ 5], nodes [6], nodes[ 7], nodes[ 8], nodes[ 9],
00112 nodes[10], nodes[11], nodes[12], nodes[13], nodes[14],
00113 nodes[15], nodes[16], nodes[17], nodes[18], nodes[19],
00114 theMaterial, bodyforces[0], bodyforces[1], bodyforces[2], massDensity, 0.0);
00115
00116 if (theEle == 0) {
00117 opserr << "command: element Brick20N " << eleID << " - out of memory\n";
00118 return TCL_ERROR;
00119 }
00120
00121 if (theTclDomain->addElement(theEle) == false) {
00122 opserr << "command: element Brick20N - could not add ele: " << eleID << " to domain\n";
00123 delete theEle;
00124 return TCL_ERROR;
00125 }
00126
00127
00128 return TCL_OK;
00129 }
00130
00131
00132