TclTwentyNodeBrickCommand.cpp

Go to the documentation of this file.
00001 
00002 //
00003 // COPYRIGHT (C):     :-))
00004 // PROJECT:           Object Oriented Finite Element Program
00005 // FILE:              TwentyNodeBrick.cpp
00006 // CLASS:             TwentyNodeBrick
00007 // MEMBER FUNCTIONS:
00008 //
00009 // MEMBER VARIABLES
00010 //
00011 // PURPOSE:           Finite Element Class
00012 // RETURN:
00013 // VERSION:
00014 // LANGUAGE:          C++
00015 // TARGET OS:         DOS || UNIX || . . .
00016 // DESIGNER:          Boris Jeremic, Zhaohui Yang and Xiaoyan Wu
00017 // PROGRAMMER:        Boris Jeremic, Zhaohui Yang  and Xiaoyan Wu
00018 // DATE:              Aug. 2001
00019 // UPDATE HISTORY:
00020 // Description: This file contains the implementation of the TclModelBuilder_addEightNodeBrick() 
00021 // command. 
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   // ensure the destructor has not been called - 
00041   if (theTclBuilder == 0) {
00042       opserr << "command: element Brick20N - no modelbuilder\n";
00043       return TCL_ERROR;
00044   }
00045 
00046   // check the number of arguments is correct
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   // get the id and end nodes 
00054   int eleID, matID;
00055   int nodes[20];
00056   double bodyforces[3], massDensity;
00057   //char *type;
00058   
00059   // read the eleTag
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   // read the 20 node tags
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   // read in material tag & check the material exists in the model builder
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   //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[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   // now get the massDensity
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   // now create the EightNodeBrick and add it to the Domain
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   // if get here we have sucessfully created the node and added it to the domain
00128   return TCL_OK;
00129 }
00130 
00131 
00132 

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