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 #include <stdlib.h>
00030 #include <string.h>
00031 #include <Domain.h>
00032
00033 #include <ErrorHandler.h>
00034 #include <EightNodeBrick.h>
00035 #include <TclModelBuilder.h>
00036
00037 extern void printCommand(int argc, TCL_Char **argv);
00038
00039 int
00040 TclModelBuilder_addEightNodeBrick(ClientData clientData, Tcl_Interp *interp, int argc,
00041 TCL_Char **argv, Domain*theTclDomain,
00042 TclModelBuilder *theTclBuilder, int eleArgStart)
00043 {
00044
00045 if (theTclBuilder == 0) {
00046 opserr << "command: element Brick8N - no modelbuilder\n";
00047 return TCL_ERROR;
00048 }
00049
00050
00051 if ((argc-eleArgStart) < 15) {
00052 opserr << "command: element Brick8N - insufficient args - want: " <<
00053 "element Brick8N eleTag? node1? node2? .. node8? matTag? bforce1? bforce2? bforce3? massDensity?\n";
00054 return TCL_ERROR;
00055 }
00056
00057
00058 int eleID, matID;
00059 int nodes[8];
00060 double bodyforces[3], massDensity;
00061
00062
00063
00064 if (Tcl_GetInt(interp, argv[1+eleArgStart], &eleID) != TCL_OK) {
00065 opserr << "command: element Brick8N - invalid integer tag " << argv[1+eleArgStart] << endln;
00066 return TCL_ERROR;
00067 }
00068
00069
00070 int i;
00071 for (i=0; i<8; i++) {
00072 if (Tcl_GetInt(interp, argv[2+i+eleArgStart], &nodes[i]) != TCL_OK) {
00073 opserr << "command: element Brick8N " << eleID << " - invalid integer tag " << argv[2+i+eleArgStart] << endln;
00074 return TCL_ERROR;
00075 }
00076 }
00077
00078
00079 if (Tcl_GetInt(interp, argv[10+eleArgStart], &matID) != TCL_OK) {
00080 opserr << "command: element Brick8N " << eleID << " - invalid matID tag " << argv[10+eleArgStart] << endln;
00081 return TCL_ERROR;
00082 }
00083
00084 NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);
00085
00086 if (theMaterial == 0) {
00087 opserr << "command: element Brick8N " << eleID << " - no NDMaterial with tag " << argv[10+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[11+i+eleArgStart], &bodyforces[i]) != TCL_OK) {
00096 opserr << "command: element Brick8N " << eleID << " - invalid bodyforces tag " << argv[11+i+eleArgStart] << endln;
00097 return TCL_ERROR;
00098 }
00099 }
00100
00101
00102 if (Tcl_GetDouble(interp, argv[14+eleArgStart], &massDensity) != TCL_OK) {
00103 opserr << "command: element Brick8N " << eleID << " - invalid massDensity " << argv[14+eleArgStart] << endln;
00104 return TCL_ERROR;
00105 }
00106
00107
00108 EightNodeBrick *theEle = new EightNodeBrick(eleID,nodes[0], nodes[1], nodes[2], nodes[3], nodes[4],
00109 nodes[5],nodes[6], nodes[7], theMaterial,
00110 bodyforces[0], bodyforces[1], bodyforces[2], massDensity, 0.0);
00111
00112 if (theEle == 0) {
00113 opserr << "command: element Brick8N " << eleID << " - out of memory\n";
00114 return TCL_ERROR;
00115 }
00116
00117 if (theTclDomain->addElement(theEle) == false) {
00118 opserr << "command: element Brick8N " << eleID << "- could not add ele to domain\n";
00119 delete theEle;
00120 return TCL_ERROR;
00121 }
00122
00123
00124 return TCL_OK;
00125 }
00126
00127
00128