TclFeapElementCommand.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.3 $
00022 // $Date: 2003/02/25 23:32:51 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/feap/TclFeapElementCommand.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/element/TclElementCommands.C
00027 // 
00028 // Written: fmk 
00029 // Created: 07/99
00030 // Revision: A
00031 //
00032 // Description: This file contains the implementation of the TclElementCommands.
00033 // The file contains the routine TclElementCommands which is invoked by the
00034 // TclModelBuilder.
00035 //
00036 // What: "@(#) TclModelBuilder.C, revA"
00037 
00038 #include <stdlib.h>
00039 #include <string.h>
00040 #include <Domain.h>
00041 
00042 #include <fElmt02.h>
00043 #include <TclModelBuilder.h>
00044 
00045 extern void printCommand(int argc, TCL_Char **argv);
00046 
00047 int
00048 TclModelBuilder_addFeapTruss(ClientData clientData, Tcl_Interp *interp, int argc, 
00049                              TCL_Char **argv, Domain *theTclDomain, TclModelBuilder *theTclBuilder,
00050                              int eleArgStart)
00051 {
00052   // ensure the destructor has not been called - 
00053   if (theTclBuilder == 0) {
00054     opserr << "WARNING builder has been destroyed\n";    
00055     return TCL_ERROR;
00056   }
00057 
00058   int ndm = theTclBuilder->getNDM();
00059   int ndf = theTclBuilder->getNDF();
00060 
00061   if (ndm != 2 && ndf != 2) {
00062           opserr << "WARNING - fTruss eleTag? iNode? jNode? A? E? needs ndm=2, ndf=2\n";
00063           return TCL_ERROR;
00064   }
00065 
00066   // check the number of arguments is correct
00067   if ((argc-eleArgStart) < 5) {
00068     opserr << "WARNING insufficient arguments\n";
00069     printCommand(argc, argv);
00070     opserr << "Want: element fTruss eleTag? iNode? jNode? A? E?\n";
00071 
00072     return TCL_ERROR;
00073   }    
00074 
00075 
00076   // get the id and end nodes 
00077   int trussId, iNode, jNode;
00078   double A,E;
00079   if (Tcl_GetInt(interp, argv[1+eleArgStart], &trussId) != TCL_OK) {
00080     opserr << "WARNING invalid truss eleTag" << endln;
00081     return TCL_ERROR;
00082   }
00083   if (Tcl_GetInt(interp, argv[2+eleArgStart], &iNode) != TCL_OK) {
00084     opserr << "WARNING invalid iNode\n";
00085     opserr << "truss element: " << trussId << endln;
00086     return TCL_ERROR;
00087   }
00088   if (Tcl_GetInt(interp, argv[3+eleArgStart], &jNode) != TCL_OK) {
00089      opserr << "WARNING invalid jNode\n";
00090      opserr << "truss element: " << trussId << endln;
00091      return TCL_ERROR;
00092   }
00093   if (Tcl_GetDouble(interp, argv[4+eleArgStart], &A) != TCL_OK) {
00094           opserr << "WARNING invalid A\n";
00095           opserr << "truss element: " << trussId << endln;
00096           return TCL_ERROR;
00097   }
00098   if (Tcl_GetDouble(interp, argv[5+eleArgStart], &E) != TCL_OK) {
00099           opserr << "WARNING invalid E\n";
00100           opserr << "truss element: " << trussId << endln;
00101           return TCL_ERROR;
00102   }
00103 
00104  
00105    // now create the truss and add it to the Domain
00106    fElmt02 *theTruss = new fElmt02(trussId,iNode,jNode,A,E);
00107    if (theTruss == 0) {
00108           opserr << "WARNING ran out of memory creating element\n";
00109           opserr << "truss element: " << trussId << endln;
00110           return TCL_ERROR;
00111    }
00112 
00113    if (theTclDomain->addElement(theTruss) == false) {
00114           opserr << "WARNING could not add element to the domain\n";
00115           opserr << "truss element: " << trussId << endln;
00116           delete theTruss;
00117           return TCL_ERROR;
00118    }
00119    return TCL_OK;
00120 }
00121   
00122  
00123 

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