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