TclTwentySevenNodeBrickCommand.cpp

Go to the documentation of this file.
00001 
00002 //
00003 // COPYRIGHT (C):     :-))
00004 // PROJECT:           Object Oriented Finite Element Program
00005 // FILE:              TwentySevenNodeBrick.cpp
00006 // CLASS:             TwentySevenNodeBrick
00007 // MEMBER FUNCTIONS:
00008 //
00009 // MEMBER VARIABLES
00010 //
00011 // PURPOSE:           Finite Element Class
00012 // RETURN:
00013 // VERSION:
00014 // LANGUAGE:          C++
00015 // TARGET OS:         all
00016 // DESIGNER:          Boris Jeremic,  Guanzhou Jie
00017 // PROGRAMMER:        Guanzhou Jie and Boris Jeremic
00018 // DATE:              Oct. 2003
00019 // UPDATE HISTORY:
00020 // Description: This file contains the implementation of the
00021 // TclModelBuilder_addTwentySevenNodeBrick()
00022 // command.
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   // ensure the destructor has not been called -
00042   if (theTclBuilder == 0) {
00043       opserr << "command: element Brick27N - no modelbuilder\n";
00044       return TCL_ERROR;
00045   }
00046 
00047   // check the number of arguments is correct
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   // get the id and end nodes
00055   int eleID, matID;
00056   int nodes[27];
00057   double bodyforces[3], massDensity;
00058   //char *type;
00059 
00060   // read the eleTag
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   // read the 27 node tags
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   // read in material tag & check the material exists in the model builder
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   //type = argv[11+eleArgStart];
00093 
00094   // read the 3 bodyforce accel's
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   // now get the massDensity
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   // now create the EightNodeBrick and add it to the Domain
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   // if get here we have sucessfully created the node and added it to the domain
00131   return TCL_OK;
00132 }
00133 
00134 
00135 

Generated on Mon Oct 23 15:05:03 2006 for OpenSees by doxygen 1.5.0