TclElasticBeamCommand.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.4 $
00022 // $Date: 2003/02/25 23:32:50 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/elasticBeamColumn/TclElasticBeamCommand.cpp,v $
00024                                                                         
00025 // Written: fmk 
00026 // Created: 07/99
00027 // Revision: A
00028 //
00029 // Description: This file contains the function to parse the TCL input
00030 // for the elasticBeamColumn element.
00031 
00032 #include <stdlib.h>
00033 #include <string.h>
00034 #include <Domain.h>
00035 
00036 #include <ElasticBeam2d.h>
00037 #include <ElasticBeam3d.h>
00038 #include <SectionForceDeformation.h>
00039 
00040 #include <CrdTransf2d.h>
00041 #include <CrdTransf3d.h>
00042 
00043 #include <TclModelBuilder.h>
00044 
00045 extern void printCommand(int argc, TCL_Char **argv);
00046 
00047 int
00048 TclModelBuilder_addElasticBeam(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 - elasticBeamColumn \n";    
00055     return TCL_ERROR;
00056   }
00057 
00058   int ndm = theTclBuilder->getNDM();
00059   int ndf = theTclBuilder->getNDF();
00060 
00061   Element *theBeam = 0;
00062 
00063   if (ndm == 2) {
00064     // check plane frame problem has 3 dof per node
00065     if (ndf != 3) {
00066       opserr << "WARNING invalid ndf: " << ndf;
00067       opserr << ", for plane problem need 3 - elasticBeamColumn \n";    
00068       return TCL_ERROR;
00069     } 
00070 
00071     // check the number of arguments
00072     if ((argc-eleArgStart) < 8) {
00073       opserr << "WARNING bad command - want: elasticBeamColumn beamId iNode jNode A E I <alpha> <d> transTag\n";
00074       printCommand(argc, argv);
00075       return TCL_ERROR;
00076     }    
00077 
00078     // get the id, end nodes, and section properties
00079     int beamId, iNode, jNode, transTag;
00080     double A,E,I;
00081     if (Tcl_GetInt(interp, argv[1+eleArgStart], &beamId) != TCL_OK) {
00082       opserr << "WARNING invalid beamId: " << argv[1+eleArgStart];
00083       opserr << " - elasticBeamColumn beamId iNode jNode A E I\n";
00084       return TCL_ERROR;
00085     }
00086     if (Tcl_GetInt(interp, argv[2+eleArgStart], &iNode) != TCL_OK) {
00087       opserr << "WARNING invalid iNode - elasticBeamColumn " << beamId << " iNode jNode A E I\n";
00088       return TCL_ERROR;
00089     }
00090     if (Tcl_GetInt(interp, argv[3+eleArgStart], &jNode) != TCL_OK) {
00091       opserr << "WARNING invalid jNode - elasticBeamColumn " << beamId << " iNode jNode A E I\n";
00092       return TCL_ERROR;
00093     }
00094 
00095     if (Tcl_GetDouble(interp, argv[4+eleArgStart], &A) != TCL_OK) {
00096       opserr << "WARNING invalid A - elasticBeamColumn " << beamId << " iNode jNode A E I\n";
00097       return TCL_ERROR;
00098     }
00099     if (Tcl_GetDouble(interp, argv[5+eleArgStart], &E) != TCL_OK) {
00100       opserr << "WARNING invalid E - elasticBeam " << beamId << " iNode jNode A E I\n";
00101       return TCL_ERROR;
00102     }
00103     
00104     if (Tcl_GetDouble(interp, argv[6+eleArgStart], &I) != TCL_OK) {
00105       opserr << "WARNING invalid I - elasticBeamColumn " << beamId << " iNode jNode A E I\n";
00106       return TCL_ERROR;
00107     }  
00108 
00109     double alpha = 0.0;
00110     double d = 0.0;
00111 
00112     if ((argc-eleArgStart) == 10) {    
00113       if (Tcl_GetDouble(interp, argv[7+eleArgStart], &alpha) != TCL_OK) {
00114         opserr << "WARNING invalid alpha - elasticBeamColumn " << beamId << " iNode jNode A E I alpha d \n";
00115         return TCL_ERROR;
00116       }
00117       if (Tcl_GetDouble(interp, argv[8+eleArgStart], &d) != TCL_OK) {
00118         opserr << "WARNING invalid d - elasticBeamColumn " << beamId << " iNode jNode A E I alpha d \n";
00119         return TCL_ERROR;
00120       }
00121       if (Tcl_GetInt(interp, argv[9+eleArgStart], &transTag) != TCL_OK) {
00122         opserr << "WARNING invalid transTag - elasticBeamColumn " << beamId << " iNode jNode A E I alpha d transTag\n";
00123         return TCL_ERROR;
00124       }
00125     } 
00126 
00127     else {
00128       if (Tcl_GetInt(interp, argv[7+eleArgStart], &transTag) != TCL_OK) {
00129         opserr << "WARNING invalid transTag - elasticBeamColumn " << beamId << " iNode jNode A E I transTag\n";
00130         return TCL_ERROR;
00131       }
00132     }
00133 
00134     CrdTransf2d *theTrans = theTclBuilder->getCrdTransf2d(transTag);
00135     
00136     if (theTrans == 0) {
00137         opserr << "WARNING transformation object not found - elasticBeamColumn " << beamId;
00138         return TCL_ERROR;
00139     }
00140     
00141     // now create the beam and add it to the Domain
00142     theBeam = new ElasticBeam2d (beamId,A,E,I,iNode,jNode, *theTrans, alpha, d, 0.0);
00143     
00144     if (theBeam == 0) {
00145       opserr << "WARNING ran out of memory creating beam - elasticBeamColumn "; 
00146       opserr << beamId << " iNode jNode A E I\n";
00147       return TCL_ERROR;
00148     }
00149   }
00150 
00151   else if (ndm == 3) {
00152     // check space frame problem has 6 dof per node
00153     if (ndf != 6) {
00154       opserr << "WARNING invalid ndof: " << ndf;
00155       opserr << ", for 3d problem  need 6 - elasticBeamColumn \n";    
00156       return TCL_ERROR;
00157     } 
00158 
00159     // check the number of arguments
00160     if (((argc-eleArgStart) < 11) && ((argc-eleArgStart) != 6)) {
00161       opserr << "WARNING bad command - want: elasticBeamColumn beamId iNode jNode";
00162       opserr << " A E G Jx Iy Iz transTag" << endln;
00163       printCommand(argc, argv);
00164       return TCL_ERROR;
00165     }    
00166 
00167     // get the id, end nodes, and section properties
00168     int beamId, iNode, jNode, transTag;
00169     double A,E,G,Jx,Iy,Iz;
00170     if (Tcl_GetInt(interp, argv[1+eleArgStart], &beamId) != TCL_OK) {
00171       opserr << "WARNING invalid beamId: " << argv[1+eleArgStart];
00172       opserr << " - elasticBeamColumn beamId iNode jNode A E G Jx Iy Iz\n ";
00173       return TCL_ERROR;
00174     }
00175     if (Tcl_GetInt(interp, argv[2+eleArgStart], &iNode) != TCL_OK) {
00176       opserr << "WARNING invalid iNode - elasticBeamColumn " << beamId;
00177       opserr << " iNode jNode A E G Jx Iy Iz\n";
00178       return TCL_ERROR;
00179     }
00180     if (Tcl_GetInt(interp, argv[3+eleArgStart], &jNode) != TCL_OK) {
00181       opserr << "WARNING invalid jNode - elasticBeamColumn " << beamId;
00182       opserr << " iNode jNode A E G Jx Iy Iz\n";
00183       return TCL_ERROR;
00184     }
00185 
00186     if ((argc-eleArgStart) == 6) {
00187       int section;
00188       if (Tcl_GetInt(interp, argv[4+eleArgStart], &section) != TCL_OK) {
00189         opserr << "WARNING invalid secTag - elasticBeamColumn iNode jNode sectionTag? transfTag?\n";
00190         return TCL_ERROR;
00191       }
00192       
00193       SectionForceDeformation *theSection = theTclBuilder->getSection(section);
00194 
00195       if (Tcl_GetInt(interp, argv[5+eleArgStart], &transTag) != TCL_OK) {
00196         opserr << "WARNING invalid transTag - elasticBeamColumn " << beamId;
00197         opserr << " iNode jNode sectionTag? transfTag?\n";
00198         return TCL_ERROR;
00199       }      
00200       
00201       CrdTransf3d *theTrans = theTclBuilder->getCrdTransf3d(transTag);
00202     
00203       if (theTrans == 0) {
00204         opserr << "WARNING transformation object not found - elasticBeamColumn " << beamId;
00205         return TCL_ERROR;
00206       }
00207       
00208       // now create the beam and add it to the Domain
00209       theBeam = new ElasticBeam3d (beamId, iNode, jNode, theSection, *theTrans);      
00210 
00211     } else {
00212 
00213       if (Tcl_GetDouble(interp, argv[4+eleArgStart], &A) != TCL_OK) {
00214         opserr << "WARNING invalid A - elasticBeamColumn " << beamId;
00215         opserr << " iNode jNode A E G Jx Iy Iz\n";
00216         return TCL_ERROR;
00217       }
00218       if (Tcl_GetDouble(interp, argv[5+eleArgStart], &E) != TCL_OK) {
00219         opserr << "WARNING invalid E - elasticBeamColumn " << beamId;
00220         opserr << " iNode jNode A E G Jx Iy Iz\n";
00221         return TCL_ERROR;
00222       }
00223       if (Tcl_GetDouble(interp, argv[6+eleArgStart], &G) != TCL_OK) {
00224         opserr << "WARNING invalid G - elasticBeamColumn " << beamId;
00225         opserr << " iNode jNode A E G Jx Iy Iz\n";
00226         return TCL_ERROR;
00227       }  
00228       if (Tcl_GetDouble(interp, argv[7+eleArgStart], &Jx) != TCL_OK) {
00229         opserr << "WARNING invalid Jx - elasticBeamColumn " << beamId;
00230         opserr << " iNode jNode A E G Jx Iy Iz\n";
00231         return TCL_ERROR;
00232       }  
00233       if (Tcl_GetDouble(interp, argv[8+eleArgStart], &Iy) != TCL_OK) {
00234         opserr << "WARNING invalid Iy - elasticBeamColumn " << beamId;
00235         opserr << " iNode jNode A E G Jx Iy Iz\n";
00236         return TCL_ERROR;
00237       }  
00238       if (Tcl_GetDouble(interp, argv[9+eleArgStart], &Iz) != TCL_OK) {
00239         opserr << "WARNING invalid Iz - elasticBeamColumn " << beamId;
00240         opserr << " iNode jNode A E G Jx Iy Iz\n";
00241         return TCL_ERROR;
00242       }  
00243       if (Tcl_GetInt(interp, argv[10+eleArgStart], &transTag) != TCL_OK) {
00244         opserr << "WARNING invalid transTag - elasticBeamColumn " << beamId;
00245         opserr << " iNode jNode A E G Jx Iy Iz\n";
00246         return TCL_ERROR;
00247       }      
00248       
00249       CrdTransf3d *theTrans = theTclBuilder->getCrdTransf3d(transTag);
00250     
00251       if (theTrans == 0) {
00252         opserr << "WARNING transformation object not found - elasticBeamColumn " << beamId;
00253         return TCL_ERROR;
00254       }
00255       
00256       // now create the beam and add it to the Domain
00257       theBeam = new ElasticBeam3d (beamId,A,E,G,Jx,Iy,Iz,iNode,jNode, *theTrans);
00258     }
00259 
00260     if (theBeam == 0) {
00261       opserr << "WARNING ran out of memory creating beam - elasticBeamColumn "; 
00262       opserr << beamId << " iNode jNode A E G Jx Iy Iz\n";
00263       return TCL_ERROR;
00264     }
00265   }
00266 
00267   else {
00268     opserr << "WARNING elasticBeamColumn command only works when ndm is 2 or 3, ndm: ";
00269     opserr << ndm << endln;
00270     return TCL_ERROR;
00271   }
00272 
00273   // now add the beam to the domain
00274   if (theTclDomain->addElement(theBeam) == false) {
00275     opserr << "WARNING TclModelBuilder - addBeam - could not add beam to domain ";
00276     opserr << *theBeam;
00277     delete theBeam; // clean up the memory to avoid leaks
00278     return TCL_ERROR;
00279   }
00280 
00281   // if get here we have sucessfully created the node and added it to the domain
00282   return TCL_OK;
00283 }

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