TclFourNodeQuadCommand.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.5 $
00022 // $Date: 2003/02/25 23:32:54 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/fourNodeQuad/TclFourNodeQuadCommand.cpp,v $
00024                                                                         
00025 // File: ~/element/TclFourNodeQuadCommand.C
00026 // 
00027 // Written: fmk 
00028 // Created: 07/99
00029 // Revision: A
00030 //
00031 // Description: This file contains the implementation of the TclModelBuilder_addFourNodeQuad()
00032 // command. 
00033 //
00034 // What: "@(#) TclModelBuilder.C, revA"
00035 
00036 #include <stdlib.h>
00037 #include <string.h>
00038 #include <Domain.h>
00039 
00040 #include <FourNodeQuad.h>
00041 #include <ConstantPressureVolumeQuad.h>
00042 #include <EnhancedQuad.h>
00043 #include <NineNodeMixedQuad.h>
00044 
00045 #include <TclModelBuilder.h>
00046 
00047 extern void printCommand(int argc, TCL_Char **argv);
00048 
00049 /*  *****************************************************************************
00050     
00051     R E G U L A R    Q U A D
00052 
00053     ***************************************************************************** */
00054 
00055 int
00056 TclModelBuilder_addFourNodeQuad(ClientData clientData, Tcl_Interp *interp,  
00057                                 int argc, 
00058                                 TCL_Char **argv, 
00059                                 Domain*theTclDomain,
00060                                 TclModelBuilder *theTclBuilder)
00061 {
00062   // ensure the destructor has not been called - 
00063   if (theTclBuilder == 0) {
00064     opserr << "WARNING builder has been destroyed\n";    
00065     return TCL_ERROR;
00066   }
00067 
00068         if (theTclBuilder->getNDM() != 2 || theTclBuilder->getNDF() != 2) {
00069                 opserr << "WARNING -- model dimensions and/or nodal DOF not compatible with quad element\n";
00070                 return TCL_ERROR;
00071         }
00072 
00073   // check the number of arguments is correct
00074   int argStart = 2;
00075 
00076   if ((argc-argStart) < 8) {
00077     opserr << "WARNING insufficient arguments\n";
00078     printCommand(argc, argv);
00079     opserr << "Want: element FourNodeQuad eleTag? iNode? jNode? kNode? lNode? thk? type? matTag? <pressure? rho? b1? b2?>\n";
00080     return TCL_ERROR;
00081   }    
00082 
00083   // get the id and end nodes 
00084   int FourNodeQuadId, iNode, jNode, kNode, lNode, matID;
00085   double thickness;
00086         double p = 0.0;         // uniform normal traction (pressure)
00087         double r = 0.0;         // mass density
00088         double b1 = 0.0;
00089         double b2 = 0.0;
00090 
00091   if (Tcl_GetInt(interp, argv[argStart], &FourNodeQuadId) != TCL_OK) {
00092     opserr << "WARNING invalid FourNodeQuad eleTag" << endln;
00093     return TCL_ERROR;
00094   }
00095   if (Tcl_GetInt(interp, argv[1+argStart], &iNode) != TCL_OK) {
00096     opserr << "WARNING invalid iNode\n";
00097     opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00098     return TCL_ERROR;
00099   }
00100 
00101   if (Tcl_GetInt(interp, argv[2+argStart], &jNode) != TCL_OK) {
00102      opserr << "WARNING invalid jNode\n";
00103      opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00104      return TCL_ERROR;
00105   }
00106   
00107   if (Tcl_GetInt(interp, argv[3+argStart], &kNode) != TCL_OK) {
00108      opserr << "WARNING invalid kNode\n";
00109      opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00110      return TCL_ERROR;
00111   }  
00112   
00113   if (Tcl_GetInt(interp, argv[4+argStart], &lNode) != TCL_OK) {
00114      opserr << "WARNING invalid lNode\n";
00115      opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00116      return TCL_ERROR;
00117   }  
00118 
00119   if (Tcl_GetDouble(interp, argv[5+argStart], &thickness) != TCL_OK) {
00120      opserr << "WARNING invalid thickness\n";
00121      opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00122      return TCL_ERROR;
00123   }  
00124   
00125   TCL_Char *type = argv[6+argStart];
00126   
00127   if (Tcl_GetInt(interp, argv[7+argStart], &matID) != TCL_OK) {
00128      opserr << "WARNING invalid matID\n";
00129      opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00130      return TCL_ERROR;
00131   }
00132 
00133         if ((argc-argStart) > 11) {
00134                 if (Tcl_GetDouble(interp, argv[8+argStart], &p) != TCL_OK) {
00135                         opserr << "WARNING invalid pressure\n";
00136                         opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00137                         return TCL_ERROR;
00138                 }
00139                 if (Tcl_GetDouble(interp, argv[9+argStart], &r) != TCL_OK) {
00140                         opserr << "WARNING invalid rho\n";
00141                         opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00142                         return TCL_ERROR;
00143                 }
00144                 if (Tcl_GetDouble(interp, argv[10+argStart], &b1) != TCL_OK) {
00145                         opserr << "WARNING invalid b1\n";
00146                         opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00147                         return TCL_ERROR;
00148                 }
00149                 if (Tcl_GetDouble(interp, argv[11+argStart], &b2) != TCL_OK) {
00150                         opserr << "WARNING invalid b2\n";
00151                         opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00152                         return TCL_ERROR;
00153                 }
00154 
00155         }
00156 
00157   NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);
00158       
00159   if (theMaterial == 0) {
00160       opserr << "WARNING material not found\n";
00161       opserr << "Material: " << matID;
00162       opserr << "\nFourNodeQuad element: " << FourNodeQuadId << endln;
00163       return TCL_ERROR;
00164   }
00165   
00166   // now create the FourNodeQuad and add it to the Domain
00167   FourNodeQuad *theFourNodeQuad = 
00168       new FourNodeQuad(FourNodeQuadId,iNode,jNode,kNode,lNode,
00169                        *theMaterial, type, thickness, p, r, b1, b2);
00170   if (theFourNodeQuad == 0) {
00171       opserr << "WARNING ran out of memory creating element\n";
00172       opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00173       return TCL_ERROR;
00174   }
00175 
00176   if (theTclDomain->addElement(theFourNodeQuad) == false) {
00177       opserr << "WARNING could not add element to the domain\n";
00178       opserr << "FourNodeQuad element: " << FourNodeQuadId << endln;
00179       delete theFourNodeQuad;
00180       return TCL_ERROR;
00181   }
00182 
00183   // if get here we have sucessfully created the element and added it to the domain
00184   return TCL_OK;
00185 }
00186 
00187 
00188 /*  *****************************************************************************
00189     
00190     C O N S T A N T    P R E S S U R E    V O L U M E    Q U A D
00191 
00192     ***************************************************************************** */
00193 
00194 
00195 int
00196 TclModelBuilder_addConstantPressureVolumeQuad(ClientData clientData, Tcl_Interp *interp,  
00197                                 int argc, 
00198                                 TCL_Char **argv, 
00199                                 Domain*theTclDomain,
00200                                 TclModelBuilder *theTclBuilder)
00201 {
00202   // ensure the destructor has not been called - 
00203   if (theTclBuilder == 0) {
00204     opserr << "WARNING builder has been destroyed\n";    
00205     return TCL_ERROR;
00206   }
00207 
00208   if (theTclBuilder->getNDM() != 2 || theTclBuilder->getNDF() != 2) {
00209       opserr << "WARNING -- model dimensions and/or nodal DOF not compatible with quad element\n";
00210       return TCL_ERROR;
00211   }
00212 
00213   // check the number of arguments is correct
00214   int argStart = 2;
00215 
00216   if ((argc-argStart) < 6) {
00217     opserr << "WARNING insufficient arguments\n";
00218     printCommand(argc, argv);
00219     opserr << "Want: element ConstantPressureVolumeQuad eleTag? iNode? jNode? kNode? lNode? matTag?\n"; 
00220     return TCL_ERROR;
00221   }    
00222 
00223   // get the id and end nodes 
00224   int ConstantPressureVolumeQuadId, iNode, jNode, kNode, lNode, matID;
00225 
00226   if (Tcl_GetInt(interp, argv[argStart], &ConstantPressureVolumeQuadId) != TCL_OK) {
00227     opserr << "WARNING invalid ConstantPressureVolumeQuad eleTag" << endln;
00228     return TCL_ERROR;
00229   }
00230   if (Tcl_GetInt(interp, argv[1+argStart], &iNode) != TCL_OK) {
00231     opserr << "WARNING invalid iNode\n";
00232     opserr << "ConstantPressureVolumeQuad element: " << ConstantPressureVolumeQuadId << endln;
00233     return TCL_ERROR;
00234   }
00235 
00236   if (Tcl_GetInt(interp, argv[2+argStart], &jNode) != TCL_OK) {
00237      opserr << "WARNING invalid jNode\n";
00238      opserr << "ConstantPressureVolumeQuad element: " << ConstantPressureVolumeQuadId << endln;
00239      return TCL_ERROR;
00240   }
00241   
00242   if (Tcl_GetInt(interp, argv[3+argStart], &kNode) != TCL_OK) {
00243      opserr << "WARNING invalid kNode\n";
00244      opserr << "ConstantPressureVolumeQuad element: " << ConstantPressureVolumeQuadId << endln;
00245      return TCL_ERROR;
00246   }  
00247   
00248   if (Tcl_GetInt(interp, argv[4+argStart], &lNode) != TCL_OK) {
00249      opserr << "WARNING invalid lNode\n";
00250      opserr << "ConstantPressureVolumeQuad element: " << ConstantPressureVolumeQuadId << endln;
00251      return TCL_ERROR;
00252   }  
00253 
00254   if (Tcl_GetInt(interp, argv[5+argStart], &matID) != TCL_OK) {
00255      opserr << "WARNING invalid matID\n";
00256      opserr << "ConstantPressureVolumeQuad element: " << ConstantPressureVolumeQuadId << endln;
00257      return TCL_ERROR;
00258   }
00259 
00260   NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);
00261       
00262   if (theMaterial == 0) {
00263       opserr << "WARNING material not found\n";
00264       opserr << "Material: " << matID;
00265       opserr << "\nConstantPressureVolumeQuad element: " << ConstantPressureVolumeQuadId << endln;
00266       return TCL_ERROR;
00267   }
00268   
00269   // now create the ConstantPressureVolumeQuad and add it to the Domain
00270   ConstantPressureVolumeQuad *theConstantPressureVolumeQuad = 
00271       new ConstantPressureVolumeQuad(ConstantPressureVolumeQuadId,iNode,jNode,kNode,lNode,
00272                        *theMaterial);
00273   if (theConstantPressureVolumeQuad == 0) {
00274       opserr << "WARNING ran out of memory creating element\n";
00275       opserr << "ConstantPressureVolumeQuad element: " << ConstantPressureVolumeQuadId << endln;
00276       return TCL_ERROR;
00277   }
00278 
00279 
00280   if (theTclDomain->addElement(theConstantPressureVolumeQuad) == false) {
00281       opserr << "WARNING could not add element to the domain\n";
00282       opserr << "ConstantPressureVolumeQuad element: " << ConstantPressureVolumeQuadId << endln;
00283       delete theConstantPressureVolumeQuad;
00284       return TCL_ERROR;
00285   }
00286 
00287   // if get here we have sucessfully created the element and added it to the domain
00288   return TCL_OK;
00289 }
00290 
00291 
00292 /*  *****************************************************************************
00293     
00294     E N H A N C E D    Q U A D
00295 
00296     ***************************************************************************** */
00297 int
00298 TclModelBuilder_addEnhancedQuad(ClientData clientData, Tcl_Interp *interp,  
00299                                 int argc, 
00300                                 TCL_Char **argv, 
00301                                 Domain*theTclDomain,
00302                                 TclModelBuilder *theTclBuilder)
00303 {
00304   // ensure the destructor has not been called - 
00305   if (theTclBuilder == 0) {
00306     opserr << "WARNING builder has been destroyed\n";    
00307     return TCL_ERROR;
00308   }
00309 
00310         if (theTclBuilder->getNDM() != 2 || theTclBuilder->getNDF() != 2) {
00311                 opserr << "WARNING -- model dimensions and/or nodal DOF not compatible with quad element\n";
00312                 return TCL_ERROR;
00313         }
00314 
00315   // check the number of arguments is correct
00316   int argStart = 2;
00317 
00318   if ((argc-argStart) < 7) {
00319     opserr << "WARNING insufficient arguments\n";
00320     printCommand(argc, argv);
00321     opserr << "Want: element EnhancedQuad eleTag? iNode? jNode? kNode? lNode? type? matTag? \n";
00322     return TCL_ERROR;
00323   }    
00324 
00325   // get the id and end nodes 
00326   int EnhancedQuadId, iNode, jNode, kNode, lNode, matID;
00327   if (Tcl_GetInt(interp, argv[argStart], &EnhancedQuadId) != TCL_OK) {
00328     opserr << "WARNING invalid EnhancedQuad eleTag" << endln;
00329     return TCL_ERROR;
00330   }
00331   if (Tcl_GetInt(interp, argv[1+argStart], &iNode) != TCL_OK) {
00332     opserr << "WARNING invalid iNode\n";
00333     opserr << "EnhancedQuad element: " << EnhancedQuadId << endln;
00334     return TCL_ERROR;
00335   }
00336 
00337   if (Tcl_GetInt(interp, argv[2+argStart], &jNode) != TCL_OK) {
00338      opserr << "WARNING invalid jNode\n";
00339      opserr << "EnhancedQuad element: " << EnhancedQuadId << endln;
00340      return TCL_ERROR;
00341   }
00342   
00343   if (Tcl_GetInt(interp, argv[3+argStart], &kNode) != TCL_OK) {
00344      opserr << "WARNING invalid kNode\n";
00345      opserr << "EnhancedQuad element: " << EnhancedQuadId << endln;
00346      return TCL_ERROR;
00347   }  
00348   
00349   if (Tcl_GetInt(interp, argv[4+argStart], &lNode) != TCL_OK) {
00350      opserr << "WARNING invalid lNode\n";
00351      opserr << "EnhancedQuad element: " << EnhancedQuadId << endln;
00352      return TCL_ERROR;
00353   }  
00354 
00355   
00356   TCL_Char *type = argv[5+argStart];
00357 
00358   
00359   if (Tcl_GetInt(interp, argv[6+argStart], &matID) != TCL_OK) {
00360      opserr << "WARNING invalid matID\n";
00361      opserr << "EnhancedQuad element: " << EnhancedQuadId << endln;
00362      return TCL_ERROR;
00363   }
00364 
00365   NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);
00366       
00367   if (theMaterial == 0) {
00368       opserr << "WARNING material not found\n";
00369       opserr << "Material: " << matID;
00370       opserr << "\nEnhancedQuad element: " << EnhancedQuadId << endln;
00371       return TCL_ERROR;
00372   }
00373   
00374   // now create the EnhancedQuad and add it to the Domain
00375   EnhancedQuad *theEnhancedQuad = 
00376       new EnhancedQuad(EnhancedQuadId,iNode,jNode,kNode,lNode,
00377                        *theMaterial, type );
00378   if (theEnhancedQuad == 0) {
00379       opserr << "WARNING ran out of memory creating element\n";
00380       opserr << "EnhancedQuad element: " << EnhancedQuadId << endln;
00381       return TCL_ERROR;
00382   }
00383 
00384   if (theTclDomain->addElement(theEnhancedQuad) == false) {
00385       opserr << "WARNING could not add element to the domain\n";
00386       opserr << "EnhancedQuad element: " << EnhancedQuadId << endln;
00387       delete theEnhancedQuad;
00388       return TCL_ERROR;
00389   }
00390 
00391   // if get here we have sucessfully created the element and added it to the domain
00392   return TCL_OK;
00393 }
00394 
00395 
00396 
00397 /*  *****************************************************************************
00398     
00399     N I N E   N O D E   M I X E D  Q U A D 
00400 
00401     ***************************************************************************** */
00402 
00403 
00404 int
00405 TclModelBuilder_addNineNodeMixedQuad(ClientData clientData, Tcl_Interp *interp,  
00406                                      int argc, 
00407                                      TCL_Char **argv, 
00408                                      Domain*theTclDomain,
00409                                      TclModelBuilder *theTclBuilder)
00410 {
00411   // ensure the destructor has not been called - 
00412   if (theTclBuilder == 0) {
00413     opserr << "WARNING builder has been destroyed\n";    
00414     return TCL_ERROR;
00415   }
00416 
00417   if (theTclBuilder->getNDM() != 2 || theTclBuilder->getNDF() != 2) {
00418       opserr << "WARNING -- model dimensions and/or nodal DOF not compatible with quad element\n";
00419       return TCL_ERROR;
00420   }
00421 
00422   // check the number of arguments is correct
00423   int argStart = 2;
00424 
00425   if ((argc-argStart) < 11) {
00426     opserr << "WARNING insufficient arguments\n";
00427     printCommand(argc, argv);
00428     opserr << "Want: element NineNodeMixedQuad  eleTag?"  
00429          << " iNode? jNode? kNode? lNode? mNode, nNode, pNode, qNode, centerNode " 
00430          << " matTag?\n"; 
00431     return TCL_ERROR;
00432   }    
00433 
00434   // get the id and end nodes 
00435   int NineNodeMixedQuadId, iNode, jNode, kNode, lNode ;
00436   int                  mNode, nNode, pNode, qNode ;
00437   int centerNode ;
00438   int matID;
00439 
00440   if (Tcl_GetInt(interp, argv[argStart], &NineNodeMixedQuadId) != TCL_OK) {
00441     opserr << "WARNING invalid NineNodeMixedQuad eleTag" << endln;
00442     return TCL_ERROR;
00443   }
00444 
00445   if (Tcl_GetInt(interp, argv[1+argStart], &iNode) != TCL_OK) {
00446     opserr << "WARNING invalid iNode\n";
00447     opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00448     return TCL_ERROR;
00449   }
00450 
00451   if (Tcl_GetInt(interp, argv[2+argStart], &jNode) != TCL_OK) {
00452      opserr << "WARNING invalid jNode\n";
00453      opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00454      return TCL_ERROR;
00455   }
00456   
00457   if (Tcl_GetInt(interp, argv[3+argStart], &kNode) != TCL_OK) {
00458      opserr << "WARNING invalid kNode\n";
00459      opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00460      return TCL_ERROR;
00461   }  
00462   
00463   if (Tcl_GetInt(interp, argv[4+argStart], &lNode) != TCL_OK) {
00464      opserr << "WARNING invalid lNode\n";
00465      opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00466      return TCL_ERROR;
00467   }  
00468 
00469   if (Tcl_GetInt(interp, argv[5+argStart], &mNode) != TCL_OK) {
00470      opserr << "WARNING invalid mNode\n";
00471      opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00472      return TCL_ERROR;
00473   }  
00474 
00475   if (Tcl_GetInt(interp, argv[6+argStart], &nNode) != TCL_OK) {
00476      opserr << "WARNING invalid nNode\n";
00477      opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00478      return TCL_ERROR;
00479   }  
00480 
00481   if (Tcl_GetInt(interp, argv[7+argStart], &pNode) != TCL_OK) {
00482      opserr << "WARNING invalid pNode\n";
00483      opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00484      return TCL_ERROR;
00485   }  
00486 
00487   if (Tcl_GetInt(interp, argv[8+argStart], &qNode) != TCL_OK) {
00488      opserr << "WARNING invalid qNode\n";
00489      opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00490      return TCL_ERROR;
00491   }  
00492 
00493   if (Tcl_GetInt(interp, argv[9+argStart], &centerNode) != TCL_OK) {
00494      opserr << "WARNING invalid centerNode\n";
00495      opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00496      return TCL_ERROR;
00497   }  
00498 
00499 
00500   if (Tcl_GetInt(interp, argv[10+argStart], &matID) != TCL_OK) {
00501      opserr << "WARNING invalid matID\n";
00502      opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00503      return TCL_ERROR;
00504   }
00505 
00506   NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);
00507       
00508   if (theMaterial == 0) {
00509       opserr << "WARNING material not found\n";
00510       opserr << "Material: " << matID;
00511       opserr << "\nNineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00512       return TCL_ERROR;
00513   }
00514   
00515   // now create the NineNodeMixedQuad and add it to the Domain
00516   NineNodeMixedQuad *theNineNodeMixed = 
00517       new NineNodeMixedQuad(NineNodeMixedQuadId,iNode,jNode,kNode,lNode,
00518                             mNode, nNode, pNode, qNode, centerNode, *theMaterial);
00519 
00520   if (theNineNodeMixed == 0) {
00521       opserr << "WARNING ran out of memory creating element\n";
00522       opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00523       return TCL_ERROR;
00524   }
00525 
00526   if (theTclDomain->addElement(theNineNodeMixed) == false) {
00527       opserr << "WARNING could not add element to the domain\n";
00528       opserr << "NineNodeMixedQuad element: " << NineNodeMixedQuadId << endln;
00529       delete theNineNodeMixed;
00530       return TCL_ERROR;
00531   }
00532 
00533   // if get here we have sucessfully created the element and added it to the domain
00534   return TCL_OK;
00535 }

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