TclJoint3dCommand.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 
00022 // $Revision: 1.3 $
00023 // $Date: 2004/09/01 04:01:27 $
00024 // $Source: /usr/local/cvs/OpenSees/SRC/element/joint/TclJoint3dCommand.cpp,v $
00025 
00026 // Written: Arash Altoontash, Gregory Deierlein,        Created: 04/01
00027 // Revision: 
00028 //                              AAA             02/03
00029 //
00030 // Description: This file contains the implementation of the TclModelBuilder_addJoint3D()
00031 // command. 
00032 //
00033 // What: "@(#) TclModelBuilder.C, revA"
00034 
00035 #include <stdlib.h>
00036 #include <string.h>
00037 #include <Domain.h>
00038 
00039 #include <Joint3D.h>
00040 #include <TclModelBuilder.h>
00041 
00042 //extern void printCommand(int argc, TCL_Char **argv);
00043 
00044 int
00045 TclModelBuilder_addJoint3D(ClientData clientData, Tcl_Interp *interp,  
00046                            int argc, 
00047                            TCL_Char **argv, 
00048                            Domain *theTclDomain,
00049                            TclModelBuilder *theTclBuilder)
00050 {
00051   // ensure the destructor has not been called
00052   if (theTclBuilder == 0) {
00053     opserr << "WARNING builder has been destroyed\n";
00054     return TCL_ERROR;
00055   }
00056   
00057   if (theTclBuilder->getNDM() != 3 || theTclBuilder->getNDF() != 6) {
00058     opserr << "WARNING -- model dimensions and/or nodal DOF not compatible with Joint3D element\n";
00059     return TCL_ERROR;
00060   }
00061   
00062   // check the number of arguments is correct
00063   int argStart = 2;
00064   
00065   if ( (argc-argStart) != 12 && (argc-argStart) != 16 ) {
00066     opserr << "WARNING incorrect number of arguments\n";
00067     //printCommand(argc, argv);
00068     opserr << "Want:\n";
00069     opserr << "element Joint3D Tag? NodI? NodJ? NodK? NodL? NodM? NodN? NodC? MatX? MatY? MatZ? LrgDsp?\n";
00070     opserr << "or:\n";
00071     opserr << "element Joint3D Tag? NodI? NodJ? NodK? NodL? NodM? NodN? NodC? MatX? MatY? MatZ? LrgDsp? -damage DmgX DmgY DmgZ\n";
00072     return TCL_ERROR;
00073   }
00074   
00075   // get the id and end nodes
00076   int Joint3DId, iNode, jNode, kNode, lNode, mNode, nNode;
00077   if (Tcl_GetInt(interp, argv[argStart], &Joint3DId) != TCL_OK) {
00078     opserr << "WARNING invalid Joint3D eleTag" << endln;
00079     return TCL_ERROR;
00080   }
00081   
00082   if (Tcl_GetInt(interp, argv[1+argStart], &iNode) != TCL_OK) {
00083     opserr << "WARNING invalid iNode\n";
00084     opserr << "Joint3D element: " << Joint3DId << endln;
00085     return TCL_ERROR;
00086   }
00087   
00088   if (Tcl_GetInt(interp, argv[2+argStart], &jNode) != TCL_OK) {
00089     opserr << "WARNING invalid jNode\n";
00090     opserr << "Joint3D element: " << Joint3DId << endln;
00091     return TCL_ERROR;
00092   }
00093   
00094   if (Tcl_GetInt(interp, argv[3+argStart], &kNode) != TCL_OK) {
00095     opserr << "WARNING invalid kNode\n";
00096     opserr << "Joint3D element: " << Joint3DId << endln;
00097     return TCL_ERROR;
00098   }
00099   
00100   if (Tcl_GetInt(interp, argv[4+argStart], &lNode) != TCL_OK) {
00101     opserr << "WARNING invalid lNode\n";
00102     opserr << "Joint3D element: " << Joint3DId << endln;
00103     return TCL_ERROR;
00104   }
00105   
00106   if (Tcl_GetInt(interp, argv[5+argStart], &mNode) != TCL_OK) {
00107     opserr << "WARNING invalid mNode\n";
00108     opserr << "Joint3D element: " << Joint3DId << endln;
00109     return TCL_ERROR;
00110   }
00111   
00112   if (Tcl_GetInt(interp, argv[6+argStart], &nNode) != TCL_OK) {
00113     opserr << "WARNING invalid nNode\n";
00114     opserr << "Joint3D element: " << Joint3DId << endln;
00115     return TCL_ERROR;
00116   }
00117   // Get the center node
00118   int CenterNodeTag;
00119   if (Tcl_GetInt(interp, argv[7+argStart], &CenterNodeTag) != TCL_OK) {
00120     opserr << "WARNING invalid tag for center node\n";
00121     opserr << "Joint3D element: " << Joint3DId << endln;
00122     return TCL_ERROR;
00123   }
00124   
00125   // check domain for existence of internal node tag
00126   Node *CenterNode = theTclDomain->getNode(CenterNodeTag);
00127   if (CenterNode != 0) {
00128     opserr << "WARNING node tag specified for the center node already exists.\n";
00129     opserr << "Use a new node tag.\n";
00130     opserr << "Joint3D element: " << Joint3DId << endln;
00131     return TCL_ERROR;
00132   }
00133   
00134   UniaxialMaterial *MatX = NULL;
00135   int MatXid;
00136   if (Tcl_GetInt(interp, argv[8+argStart], &MatXid) != TCL_OK) {
00137     opserr << "WARNING invalid material ID for spring X\n";
00138     opserr << "Joint3D element: " << Joint3DId << endln;
00139     return TCL_ERROR;
00140   }
00141   
00142   MatX = theTclBuilder->getUniaxialMaterial(MatXid);
00143   if ( MatX == NULL )
00144     {
00145       opserr << "WARNING material not found\n";
00146       opserr << "Material: " << MatXid;
00147       opserr << "\nJoint3D element: " << Joint3DId << endln;
00148       return TCL_ERROR;
00149     }
00150   
00151   UniaxialMaterial *MatY = NULL;
00152   int MatYid;
00153   if (Tcl_GetInt(interp, argv[9+argStart], &MatYid) != TCL_OK) {
00154     opserr << "WARNING invalid material ID for spring Y\n";
00155     opserr << "Joint3D element: " << Joint3DId << endln;
00156     return TCL_ERROR;
00157   }
00158   
00159   MatY = theTclBuilder->getUniaxialMaterial(MatYid);
00160   if ( MatY == NULL )
00161     {
00162       opserr << "WARNING material not found\n";
00163       opserr << "Material: " << MatYid;
00164       opserr << "\nJoint3D element: " << Joint3DId << endln;
00165       return TCL_ERROR;
00166     }           
00167   
00168   UniaxialMaterial *MatZ = NULL;
00169   int MatZid;
00170   if (Tcl_GetInt(interp, argv[10+argStart], &MatZid) != TCL_OK) {
00171     opserr << "WARNING invalid material ID for spring Z\n";
00172     opserr << "Joint3D element: " << Joint3DId << endln;
00173     return TCL_ERROR;
00174   }
00175   
00176   MatZ = theTclBuilder->getUniaxialMaterial(MatZid);
00177   if ( MatZ == NULL )
00178     {
00179       opserr << "WARNING material not found\n";
00180       opserr << "Material: " << MatZid;
00181       opserr << "\nJoint3D element: " << Joint3DId << endln;
00182       return TCL_ERROR;
00183     }           
00184   
00185   int LargeDisp;
00186   if (Tcl_GetInt(interp, argv[11+argStart], &LargeDisp) != TCL_OK) {
00187     // use 0 as default
00188     LargeDisp = 0;
00189   }
00190   
00191   
00192   Joint3D *theJoint3D;
00193   // Decide to use which constructor, based on the number of arguments
00194   if ( (argc-argStart) == 12 ) {
00195     
00196     // Using Joint3D constructor without damage 
00197     theJoint3D = new Joint3D( Joint3DId,
00198                               iNode,jNode,kNode,lNode,mNode,nNode,CenterNodeTag,
00199                               *MatX,*MatY,*MatZ, theTclDomain, LargeDisp);
00200     
00201     if (theJoint3D == 0) {
00202       opserr << "WARNING ran out of memory creating element\n";
00203       opserr << "Joint3D element: " << Joint3DId << endln;
00204       return TCL_ERROR;
00205     }
00206     
00207     if (theTclDomain->addElement(theJoint3D) == false) {
00208       opserr << "WARNING could not add element to the domain\n";
00209       opserr << "Joint3D element: " << Joint3DId << endln;
00210       delete theJoint3D;
00211       return TCL_ERROR;
00212     }
00213     
00214     // if get here we have sucessfully created the element and added it to the domain
00215     return TCL_OK;
00216   }
00217   
00218   else                  // if ( (argc-argStart) == 16  )
00219     { 
00220       // Using Joint3D constructor with damage 
00221       // not implemented in this version
00222       return TCL_ERROR;
00223     }
00224   return TCL_ERROR;
00225 }
00226 

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