TclBrickCommand.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.7 $
00022 // $Date: 2006/01/10 18:41:34 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/brick/TclBrickCommand.cpp,v $
00024                                                                         
00025 // Written: fmk 
00026 // Created: 03/01
00027 //
00028 // What: "@(#) TclBrickCommand.cpp, revA"
00029 
00030 #include <stdlib.h>
00031 #include <string.h>
00032 #include <Domain.h>
00033 
00034 #include <Brick.h>
00035 #include <BbarBrick.h>
00036 
00037 #ifdef _FLBrick
00038 #include <FLBrick.h>
00039 #endif
00040 
00041 #include <TclModelBuilder.h>
00042 
00043 extern void printCommand(int argc, TCL_Char **argv);
00044 
00045 int
00046 TclModelBuilder_addBrick(ClientData clientData, Tcl_Interp *interp,  int argc, 
00047                          TCL_Char **argv, Domain*theTclDomain,
00048                          TclModelBuilder *theTclBuilder, int eleArgStart)
00049 {
00050   // ensure the destructor has not been called - 
00051   if (theTclBuilder == 0) {
00052     opserr << "WARNING builder has been destroyed\n";    
00053     return TCL_ERROR;
00054   }
00055 
00056   // check the number of arguments is correct
00057   if ((argc-eleArgStart) < 11) {
00058     opserr << "WARNING insufficient arguments\n";
00059     printCommand(argc, argv);
00060     opserr << "Want: element Brick eleTag? Node1? Node2? Node3? Node4? Node5? Node6? Node7? Node 8? matTag?\n";
00061     return TCL_ERROR;
00062   }    
00063 
00064   // get the id and end nodes 
00065   int BrickId, Node1, Node2, Node3, Node4, matID;
00066   int          Node5, Node6, Node7, Node8 ;
00067 
00068   if (Tcl_GetInt(interp, argv[1+eleArgStart], &BrickId) != TCL_OK) {
00069     opserr << "WARNING invalid Brick eleTag" << endln;
00070     return TCL_ERROR;
00071   }
00072 
00073   if (Tcl_GetInt(interp, argv[2+eleArgStart], &Node1) != TCL_OK) {
00074     opserr << "WARNING invalid Node1\n";
00075     opserr << "Brick element: " << BrickId << endln;
00076     return TCL_ERROR;
00077   }
00078   if (Tcl_GetInt(interp, argv[3+eleArgStart], &Node2) != TCL_OK) {
00079      opserr << "WARNING invalid Node2\n";
00080      opserr << "Brick element: " << BrickId << endln;
00081      return TCL_ERROR;
00082   }
00083   if (Tcl_GetInt(interp, argv[4+eleArgStart], &Node3) != TCL_OK) {
00084      opserr << "WARNING invalid Node3\n";
00085      opserr << "Brick element: " << BrickId << endln;
00086      return TCL_ERROR;
00087   }
00088   if (Tcl_GetInt(interp, argv[5+eleArgStart], &Node4) != TCL_OK) {
00089      opserr << "WARNING invalid Node4\n";
00090      opserr << "Brick element: " << BrickId << endln;
00091      return TCL_ERROR;
00092   }
00093 
00094   if (Tcl_GetInt(interp, argv[6+eleArgStart], &Node5) != TCL_OK) {
00095     opserr << "WARNING invalid Node5\n";
00096     opserr << "Brick element: " << BrickId << endln;
00097     return TCL_ERROR;
00098   }
00099   if (Tcl_GetInt(interp, argv[7+eleArgStart], &Node6) != TCL_OK) {
00100      opserr << "WARNING invalid Node6\n";
00101      opserr << "Brick element: " << BrickId << endln;
00102      return TCL_ERROR;
00103   }
00104   if (Tcl_GetInt(interp, argv[8+eleArgStart], &Node7) != TCL_OK) {
00105      opserr << "WARNING invalid Node7\n";
00106      opserr << "Brick element: " << BrickId << endln;
00107      return TCL_ERROR;
00108   }
00109   if (Tcl_GetInt(interp, argv[9+eleArgStart], &Node8) != TCL_OK) {
00110      opserr << "WARNING invalid Node8\n";
00111      opserr << "Brick element: " << BrickId << endln;
00112      return TCL_ERROR;
00113   }
00114 
00115 
00116   if (Tcl_GetInt(interp, argv[10+eleArgStart], &matID) != TCL_OK) {
00117     opserr << "WARNING invalid matTag\n";
00118     opserr << "Brick element: " << BrickId << endln;
00119     return TCL_ERROR;
00120   }
00121 
00122    NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);      
00123       
00124   if (theMaterial== 0) {
00125     opserr << "WARNING material not found\n";
00126     opserr << "material tag: " << matID;
00127     opserr << "\nBrick element: " << BrickId << endln;
00128     return TCL_ERROR;
00129   }
00130   
00131   double b1=0.0;
00132   double b2=0.0; 
00133   double b3=0.0;
00134   if ((argc-eleArgStart) > 11) {
00135     if (Tcl_GetDouble(interp, argv[11+eleArgStart], &b1) != TCL_OK) {
00136        opserr << "WARNING invalid b1\n";
00137        opserr << "Brick element: " << BrickId << endln;
00138        return TCL_ERROR;
00139         }
00140   }
00141 
00142   if ((argc-eleArgStart) > 12) {
00143     if (Tcl_GetDouble(interp, argv[12+eleArgStart], &b2) != TCL_OK) {
00144        opserr << "WARNING invalid b2\n";
00145        opserr << "Brick element: " << BrickId << endln;
00146        return TCL_ERROR;
00147         }
00148   }
00149 
00150   if ((argc-eleArgStart) > 13) {
00151     if (Tcl_GetDouble(interp, argv[13+eleArgStart], &b3) != TCL_OK) {
00152        opserr << "WARNING invalid b3\n";
00153        opserr << "Brick element: " << BrickId << endln;
00154        return TCL_ERROR;
00155         }
00156   }
00157 
00158   // now create the Brick and add it to the Domain
00159   Element *theBrick = 0;
00160   if (strcmp(argv[1],"stdBrick") == 0) {
00161     theBrick = new Brick(BrickId,Node1,Node2,Node3,Node4,
00162                          Node5, Node6, Node7, Node8, *theMaterial,
00163                          b1, b2, b3);
00164   } else if (strcmp(argv[1],"bbarBrick") == 0) {
00165     theBrick = new BbarBrick(BrickId,Node1,Node2,Node3,Node4,
00166                              Node5, Node6, Node7, Node8, *theMaterial, b1, b2, b3);
00167 #ifdef _FLBrick
00168   } else if (strcmp(argv[1],"flBrick") == 0) {
00169     theBrick = new FLBrick(BrickId,Node1,Node2,Node3,Node4,
00170                            Node5, Node6, Node7, Node8, *theMaterial, b1, b2, b3);
00171   }
00172 #endif
00173 
00174   } else {
00175     opserr << "WARNING element " << argv[1] << " type not recognized\n";
00176     return TCL_ERROR;
00177   }
00178 
00179   
00180 
00181   if (theBrick == 0) {
00182     opserr << "WARNING ran out of memory creating element\n";
00183     opserr << "Brick element: " << BrickId << endln;
00184     return TCL_ERROR;
00185   }
00186 
00187   if (theTclDomain->addElement(theBrick) == false) {
00188     opserr << "WARNING could not add element to the domain\n";
00189     opserr << "Brick element: " << BrickId << endln;
00190     delete theBrick;
00191     return TCL_ERROR;
00192   }
00193 
00194   // if get here we have sucessfully created the node and added it to the domain
00195   return TCL_OK;
00196 }
00197 
00198 

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