TclEightNodeBrickCommand.cpp

Go to the documentation of this file.
00001 
00002 //
00003 // COPYLEFT (C):     :-))
00004 //``This  source code is Copyrighted in U.S., by the The Regents of the University
00005 //of California, for an indefinite period, and anybody caught using it without our
00006 //permission,  will  be  mighty  good friends of ourn, cause we don't give a darn.
00007 //Hack  it.  Compile it. Debug it. Run it. Yodel it. Enjoy it. We wrote it, that's
00008 //all we wanted to do.'' bj
00009 // PROJECT:           Object Oriented Finite Element Program
00010 // FILE:              EightNodeBrick.h
00011 // CLASS:             EightNodeBrick
00012 // MEMBER FUNCTIONS:
00013 //
00014 // MEMBER VARIABLES
00015 //
00016 // PURPOSE:           Finite Element Class
00017 // RETURN:
00018 // VERSION:
00019 // LANGUAGE:          C++.ver >= 3.0
00020 // TARGET OS:         DOS || UNIX || . . .
00021 // DESIGNER:          Boris Jeremic, Zhaohui Yang and Xiaoyan Wu
00022 // PROGRAMMER:        Boris Jeremic, Zhaohui Yang  and Xiaoyan Wu
00023 // DATE:              Aug. 2000
00024 // Description: This file contains the implementation of the TclModelBuilder_addEightNodeBrick() 
00025 // command. 
00026 //
00027 // What: "@(#) TclModelBuilder.C, revA"
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   // ensure the destructor has not been called - 
00045   if (theTclBuilder == 0) {
00046       opserr << "command: element Brick8N - no modelbuilder\n";
00047       return TCL_ERROR;
00048   }
00049 
00050   // check the number of arguments is correct
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   // get the id and end nodes 
00058   int eleID, matID;
00059   int nodes[8];
00060   double bodyforces[3], massDensity;
00061   //char *type;
00062   
00063   // read the eleTag
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   // read the 8 node tags
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   // read in material tag & check the material exists in the model builder
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   //type = argv[11+eleArgStart];
00092 
00093   // read the 3 bodyforce accel's 
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   // now get the massDensity
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   // now create the EightNodeBrick and add it to the Domain
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   // if get here we have sucessfully created the node and added it to the domain
00124   return TCL_OK;
00125 }
00126 
00127 
00128 

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