TclModelBuilderSectionCommand.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.23 $
00022 // $Date: 2006/09/05 23:33:20 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/material/section/TclModelBuilderSectionCommand.cpp,v $
00024                                                                         
00025                                                                         
00026 // Written: rms, MHS 
00027 // Created: 07/99
00028 //
00029 // Description: This file contains the function invoked when the user invokes
00030 // the section command in the interpreter.
00031 //
00032 // What: "@(#) TclModelBuilderMaterialCommands.C, revA"
00033 
00034 #include <TclModelBuilder.h>
00035 
00036 #include <ElasticSection2d.h>
00037 #include <ElasticSection3d.h>
00038 #include <GenericSection1d.h>
00039 //#include <GenericSectionNd.h>
00040 #include <SectionAggregator.h>
00041 //#include <FiberSection.h>
00042 #include <FiberSection2d.h>
00043 #include <FiberSection3d.h>
00044 #include <FiberSectionGJ.h>
00045 #include <FiberSectionRepr.h>
00046 
00047 #include <ElasticPlateSection.h>
00048 #include <ElasticMembranePlateSection.h>
00049 #include <MembranePlateFiberSection.h>
00050 
00051 #include <QuadPatch.h>
00052 #include <CircPatch.h>
00053 #include <QuadCell.h>
00054 #include <StraightReinfLayer.h>
00055 #include <CircReinfLayer.h>
00056 #include <ReinfBar.h>
00057 
00058 #include <UniaxialFiber2d.h>
00059 #include <UniaxialFiber3d.h>
00060 
00061 #include <Bidirectional.h>
00062 #include <Isolator2spring.h>
00063 
00064 //#include <WSection2d.h>
00065 #include <WideFlangeSectionIntegration.h>
00066 #include <RCSectionIntegration.h>
00067 
00068 #include <string.h>
00069 #include <fstream>
00070 using std::ifstream;
00071 
00072 #include <iostream>
00073 using std::ios;
00074 
00075 static void printCommand(int argc, TCL_Char **argv)
00076 {
00077     opserr << "Input command: \n";
00078     for (int i=0; i<argc; i++)
00079         opserr << argv[i] << " \n";
00080     opserr << endln;
00081 } 
00082 
00083 int
00084 TclModelBuilder_addFiberSection (ClientData clientData, Tcl_Interp *interp, int argc,
00085                                  TCL_Char **argv, TclModelBuilder *theBuilder);
00086 
00087 int
00088 TclModelBuilder_addUCFiberSection (ClientData clientData, Tcl_Interp *interp, int argc,
00089                                    TCL_Char **argv, TclModelBuilder *theBuilder);
00090 
00091 
00092 SectionForceDeformation *
00093 TclModelBuilderYS_SectionCommand(ClientData clientData, Tcl_Interp *interp, int argc, 
00094                                  TCL_Char **argv, TclModelBuilder *theTclBuilder);
00095 
00096 int
00097 TclModelBuilderSectionCommand (ClientData clientData, Tcl_Interp *interp, int argc,
00098                                TCL_Char **argv, TclModelBuilder *theTclBuilder)
00099 {
00100     // Pointer to a section that will be added to the model builder
00101     SectionForceDeformation *theSection = 0;
00102 
00103     // Check argv[1] for section type
00104     if (strcmp(argv[1],"Elastic") == 0) {
00105         if (argc < 5) {
00106             opserr << "WARNING insufficient arguments\n";
00107             printCommand(argc,argv);
00108             //opserr << "Want: section Elastic tag? EA? EIz? <EIy? GJ?>" << endln;
00109                 opserr << "Want: section Elastic tag? E? A? Iz? <Iy? G? J?>" << endln;
00110             return TCL_ERROR;
00111         }
00112         
00113         int tag;
00114         double E, A, Iz, Iy, G, J;
00115         
00116         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00117             opserr << "WARNING invalid section Elastic tag" << endln;
00118             return TCL_ERROR;           
00119         }
00120 
00121         if (Tcl_GetDouble (interp, argv[3], &E) != TCL_OK) {
00122             opserr << "WARNING invalid E" << endln;
00123             opserr << "Elastic section: " << tag << endln;          
00124             return TCL_ERROR;
00125         }       
00126 
00127         if (Tcl_GetDouble (interp, argv[4], &A) != TCL_OK) {
00128             opserr << "WARNING invalid A" << endln;
00129             opserr << "Elastic section: " << tag << endln;          
00130             return TCL_ERROR;
00131         }       
00132         
00133         if (Tcl_GetDouble (interp, argv[5], &Iz) != TCL_OK) {
00134             opserr << "WARNING invalid Iz" << endln;
00135             opserr << "Elastic section: " << tag << endln;                  
00136             return TCL_ERROR;
00137         }       
00138         
00139         if (argc > 8) {
00140             if (Tcl_GetDouble (interp, argv[6], &Iy) != TCL_OK) {
00141                 opserr << "WARNING invalid EIy" << endln;
00142                 opserr << "Elastic section: " << tag << endln;                  
00143                 return TCL_ERROR;
00144             }
00145                 
00146             if (Tcl_GetDouble (interp, argv[7], &G) != TCL_OK) {
00147                 opserr << "WARNING invalid G" << endln;
00148                 opserr << "Elastic section: " << tag << endln;      
00149                 return TCL_ERROR;
00150             }
00151 
00152                 if (Tcl_GetDouble (interp, argv[8], &J) != TCL_OK) {
00153                 opserr << "WARNING invalid J" << endln;
00154                 opserr << "Elastic section: " << tag << endln;      
00155                 return TCL_ERROR;
00156             }
00157                 
00158             // Parsing was successful, allocate the section
00159             theSection = new ElasticSection3d (tag, E, A, Iz, Iy, G, J);
00160         }
00161         else
00162             // Parsing was successful, allocate the section
00163             theSection = new ElasticSection2d (tag, E, A, Iz);
00164     }   
00165         
00166     else if (strcmp(argv[1],"Generic1D") == 0 ||
00167              strcmp(argv[1],"Generic1d") == 0 ||
00168              strcmp(argv[1],"Uniaxial") == 0) {
00169         if (argc < 5) {
00170             opserr << "WARNING insufficient arguments\n";
00171             printCommand(argc,argv);
00172             opserr << "Want: section Uniaxial tag? 1DTag? code?" << endln;
00173             return TCL_ERROR;
00174         }
00175 
00176         int tag, uniTag, code;
00177 
00178         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00179             opserr << "WARNING invalid section Uniaxial tag" << endln;
00180             return TCL_ERROR;           
00181         }
00182 
00183         if (Tcl_GetInt(interp, argv[3], &uniTag) != TCL_OK) {
00184             opserr << "WARNING invalid 1DTag" << endln;
00185             opserr << "Uniaxial section: " << tag << endln;         
00186             return TCL_ERROR;           
00187         }
00188 
00189         if (strcmp(argv[4],"Mz") == 0)
00190             code = SECTION_RESPONSE_MZ;
00191         else if (strcmp(argv[4],"P") == 0)
00192             code = SECTION_RESPONSE_P;
00193         else if (strcmp(argv[4],"Vy") == 0)
00194             code = SECTION_RESPONSE_VY;
00195         else if (strcmp(argv[4],"My") == 0)
00196             code = SECTION_RESPONSE_MY;
00197         else if (strcmp(argv[4],"Vz") == 0)
00198             code = SECTION_RESPONSE_VZ;
00199         else if (strcmp(argv[4],"T") == 0)
00200             code = SECTION_RESPONSE_T;
00201         else {
00202             opserr << "WARNING invalid code" << endln;
00203             opserr << "Uniaxial section: " << tag << endln;
00204             return TCL_ERROR;           
00205         }
00206                 
00207         // Retrieve the uniaxial material from the model builder
00208         UniaxialMaterial *theMat = theTclBuilder->getUniaxialMaterial(uniTag);
00209         
00210         if (theMat == 0) {
00211             opserr << "WARNING uniaxial material does not exist\n";
00212             opserr << "uniaxial material: " << uniTag; 
00213             opserr << "\nUniaxial section: " << tag << endln;
00214             return TCL_ERROR;
00215         }
00216         
00217         // Parsing was successful, allocate the section
00218         theSection = new GenericSection1d (tag, *theMat, code);
00219     }
00220 
00221     else if (strcmp(argv[1],"GenericND") == 0 || strcmp(argv[1],"GenericNd") == 0) {
00222       opserr << "section GenericND is no longer available" << endln;
00223       return TCL_ERROR;
00224 
00225       /*
00226         if (argc < 5) {
00227             opserr << "WARNING insufficient arguments\n";
00228             printCommand(argc,argv);
00229             opserr << "Want: section GenericNd tag? NDTag? code?" << endln;
00230             return TCL_ERROR;
00231         }
00232         
00233         int tag, NDTag;
00234         
00235         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00236             opserr << "WARNING invalid section GenericNd tag" << endln;
00237             return TCL_ERROR;           
00238         }
00239         
00240         if (Tcl_GetInt(interp, argv[3], &NDTag) != TCL_OK) {
00241             opserr << "WARNING invalid NDTag" << endln;
00242             opserr << "GenericNd section: " << tag << endln;        
00243             return TCL_ERROR;           
00244         }
00245         
00246         ID code(argc-4);
00247         
00248         int i,j;
00249         
00250         // Read in the code
00251         for (i = 4, j = 0; i < argc; i++, j++) {
00252             if (strcmp(argv[i],"Mz") == 0)
00253                 code(j) = SECTION_RESPONSE_MZ;
00254             else if (strcmp(argv[i],"P") == 0)
00255                 code(j) = SECTION_RESPONSE_P;
00256             else if (strcmp(argv[i],"Vy") == 0)
00257                 code(j) = SECTION_RESPONSE_VY;
00258             else if (strcmp(argv[i],"My") == 0)
00259                 code(j) = SECTION_RESPONSE_MY;
00260             else if (strcmp(argv[i],"Vz") == 0)
00261                 code(j) = SECTION_RESPONSE_VZ;
00262             else if (strcmp(argv[i],"T") == 0)
00263                 code(j) = SECTION_RESPONSE_T;
00264             else {
00265                 opserr << "WARNING invalid GenericND code" << endln;
00266                 opserr << "\nGenericND section: " << tag << endln;
00267                 return TCL_ERROR;               
00268             }
00269         }
00270         
00271         // Retrieve the uniaxial material from the model builder
00272         NDMaterial *theMat = theTclBuilder->getNDMaterial(NDTag);
00273         
00274         if (theMat == 0) {
00275             opserr << "WARNING nD material does not exist\n";
00276             opserr << "nD material: " << NDTag; 
00277             opserr << "\nGenericNd section: " << tag << endln;
00278             return TCL_ERROR;
00279         }
00280         
00281         // Parsing was successful, allocate the section
00282         theSection = new GenericSectionNd (tag, *theMat, code);
00283         */
00284     }   
00285 
00286     else if (strcmp(argv[1],"WSection2d") == 0) {
00287         if (argc < 10) {
00288             opserr << "WARNING insufficient arguments\n";
00289             printCommand(argc,argv);
00290             opserr << "Want: section WSection2d tag? matTag? d? tw? bf? tf? nfdw? nftf? <shape?>" << endln;
00291             return TCL_ERROR;
00292         }
00293         
00294         int tag, matTag;
00295         double d, tw, bf, tf;
00296         int nfdw, nftf;
00297         double shape;
00298         bool isShape = false;
00299         bool flag = true;
00300 
00301         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00302             opserr << "WARNING invalid section WSection2d tag" << endln;
00303             return TCL_ERROR;           
00304         }
00305 
00306         if (Tcl_GetInt(interp, argv[3], &matTag) != TCL_OK) {
00307             opserr << "WARNING invalid section WSection2d matTag" << endln;
00308             return TCL_ERROR;           
00309         }
00310 
00311         if (Tcl_GetDouble (interp, argv[4], &d) != TCL_OK) {
00312             opserr << "WARNING invalid d" << endln;
00313             opserr << "WSection2d section: " << tag << endln;       
00314             return TCL_ERROR;
00315         }       
00316 
00317         if (Tcl_GetDouble (interp, argv[5], &tw) != TCL_OK) {
00318             opserr << "WARNING invalid tw" << endln;
00319             opserr << "WSection2d section: " << tag << endln;       
00320             return TCL_ERROR;
00321         }       
00322         
00323         if (Tcl_GetDouble (interp, argv[6], &bf) != TCL_OK) {
00324             opserr << "WARNING invalid bf" << endln;
00325             opserr << "WSection2d section: " << tag << endln;               
00326             return TCL_ERROR;
00327         }       
00328 
00329         if (Tcl_GetDouble (interp, argv[7], &tf) != TCL_OK) {
00330             opserr << "WARNING invalid tf" << endln;
00331             opserr << "WSection2d section: " << tag << endln;               
00332             return TCL_ERROR;
00333         }       
00334 
00335         if (Tcl_GetInt (interp, argv[8], &nfdw) != TCL_OK) {
00336             opserr << "WARNING invalid nfdw" << endln;
00337             opserr << "WSection2d section: " << tag << endln;               
00338             return TCL_ERROR;
00339         }       
00340 
00341         if (Tcl_GetInt (interp, argv[9], &nftf) != TCL_OK) {
00342             opserr << "WARNING invalid nftf" << endln;
00343             opserr << "WSection2d section: " << tag << endln;               
00344             return TCL_ERROR;
00345         }       
00346 
00347         if (argc > 10) {
00348           if (Tcl_GetDouble (interp, argv[10], &shape) != TCL_OK) {
00349             opserr << "WARNING invalid shapeFactor" << endln;
00350             opserr << "WSection2d section: " << tag << endln;               
00351             return TCL_ERROR;
00352           }
00353           else
00354             isShape = true;
00355         }
00356 
00357         if (argc > 11) {
00358           int shit;
00359           if (Tcl_GetInt(interp, argv[11], &shit) != TCL_OK) {
00360             opserr << "WARNING invalid shapeFactor" << endln;
00361             opserr << "WSection2d section: " << tag << endln;               
00362             return TCL_ERROR;
00363           }
00364           if (shit == 0)
00365             flag = false;
00366           else
00367             flag = true;
00368         }
00369 
00370         // Retrieve the NDMaterial from the model builder
00371         NDMaterial *theMat = theTclBuilder->getNDMaterial(matTag);
00372         
00373         if (theMat == 0) {
00374             opserr << "WARNING nD material does not exist\n";
00375             opserr << "nD material: " << matTag; 
00376             opserr << "\nWSection2d section: " << tag << endln;
00377             return TCL_ERROR;
00378         }
00379         
00380         // Parsing was successful, allocate the section
00381         //if (isShape)
00382         //  theSection = new WSection2d (tag, *theMat, d, tw, bf, tf,
00383         //                     nfdw, nftf, shape, flag);
00384         //else
00385         //theSection = new WSection2d (tag, *theMat, d, tw, bf, tf,
00386         //                     nfdw, nftf);
00387     }   
00388     
00389     else if (strcmp(argv[1],"WFSection2d") == 0) {
00390         if (argc < 10) {
00391             opserr << "WARNING insufficient arguments\n";
00392             printCommand(argc,argv);
00393             opserr << "Want: section WFSection2d tag? matTag? d? tw? bf? tf? nfdw? nftf?" << endln;
00394             return TCL_ERROR;
00395         }
00396         
00397         int tag, matTag;
00398         double d, tw, bf, tf;
00399         int nfdw, nftf;
00400 
00401         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00402             opserr << "WARNING invalid section WSection2d tag" << endln;
00403             return TCL_ERROR;           
00404         }
00405 
00406         if (Tcl_GetInt(interp, argv[3], &matTag) != TCL_OK) {
00407             opserr << "WARNING invalid section WSection2d matTag" << endln;
00408             return TCL_ERROR;           
00409         }
00410 
00411         if (Tcl_GetDouble (interp, argv[4], &d) != TCL_OK) {
00412             opserr << "WARNING invalid d" << endln;
00413             opserr << "WSection2d section: " << tag << endln;       
00414             return TCL_ERROR;
00415         }       
00416 
00417         if (Tcl_GetDouble (interp, argv[5], &tw) != TCL_OK) {
00418             opserr << "WARNING invalid tw" << endln;
00419             opserr << "WSection2d section: " << tag << endln;       
00420             return TCL_ERROR;
00421         }       
00422         
00423         if (Tcl_GetDouble (interp, argv[6], &bf) != TCL_OK) {
00424             opserr << "WARNING invalid bf" << endln;
00425             opserr << "WSection2d section: " << tag << endln;               
00426             return TCL_ERROR;
00427         }       
00428 
00429         if (Tcl_GetDouble (interp, argv[7], &tf) != TCL_OK) {
00430             opserr << "WARNING invalid tf" << endln;
00431             opserr << "WSection2d section: " << tag << endln;               
00432             return TCL_ERROR;
00433         }       
00434 
00435         if (Tcl_GetInt (interp, argv[8], &nfdw) != TCL_OK) {
00436             opserr << "WARNING invalid nfdw" << endln;
00437             opserr << "WSection2d section: " << tag << endln;               
00438             return TCL_ERROR;
00439         }       
00440 
00441         if (Tcl_GetInt (interp, argv[9], &nftf) != TCL_OK) {
00442             opserr << "WARNING invalid nftf" << endln;
00443             opserr << "WSection2d section: " << tag << endln;               
00444             return TCL_ERROR;
00445         }       
00446 
00447         UniaxialMaterial *theSteel = theTclBuilder->getUniaxialMaterial(matTag);
00448         
00449         if (theSteel == 0) {
00450             opserr << "WARNING uniaxial material does not exist\n";
00451             opserr << "material: " << matTag; 
00452             opserr << "\nWFSection2d section: " << tag << endln;
00453             return TCL_ERROR;
00454         }
00455         
00456         WideFlangeSectionIntegration wfsect(d, tw, bf, tf, nfdw, nftf);
00457 
00458         int numFibers = wfsect.getNumFibers();
00459 
00460         UniaxialMaterial **theMats = new UniaxialMaterial *[numFibers];
00461 
00462         wfsect.arrangeFibers(theMats, theSteel);
00463 
00464         // Parsing was successful, allocate the section
00465         theSection = new FiberSection2d(tag, numFibers, theMats, wfsect);
00466 
00467         delete [] theMats;
00468     }
00469 
00470     else if (strcmp(argv[1],"RCSection2d") == 0) {
00471         if (argc < 14) {
00472             opserr << "WARNING insufficient arguments\n";
00473             printCommand(argc,argv);
00474             opserr << "Want: section RCSection2d tag? coreTag? coverTag? steelTag? d? b? cover? Amain? Aside? nfcore? nfcover? nfs?" << endln;
00475             return TCL_ERROR;
00476         }
00477         
00478         int tag, coreTag, coverTag, steelTag;
00479         double d, b, cover, Amain, Aside;
00480         int nfcore, nfcover, nfs;
00481 
00482         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00483             opserr << "WARNING invalid section RCSection2d tag" << endln;
00484             return TCL_ERROR;           
00485         }
00486 
00487         if (Tcl_GetInt(interp, argv[3], &coreTag) != TCL_OK) {
00488             opserr << "WARNING invalid section RCSection2d coreTag" << endln;
00489             return TCL_ERROR;           
00490         }
00491 
00492         if (Tcl_GetInt(interp, argv[4], &coverTag) != TCL_OK) {
00493             opserr << "WARNING invalid section RCSection2d coverTag" << endln;
00494             return TCL_ERROR;           
00495         }
00496 
00497         if (Tcl_GetInt(interp, argv[5], &steelTag) != TCL_OK) {
00498             opserr << "WARNING invalid section RCSection2d steelTag" << endln;
00499             return TCL_ERROR;           
00500         }
00501 
00502         if (Tcl_GetDouble (interp, argv[6], &d) != TCL_OK) {
00503             opserr << "WARNING invalid d" << endln;
00504             opserr << "RCSection2d section: " << tag << endln;      
00505             return TCL_ERROR;
00506         }       
00507 
00508         if (Tcl_GetDouble (interp, argv[7], &b) != TCL_OK) {
00509             opserr << "WARNING invalid b" << endln;
00510             opserr << "RCSection2d section: " << tag << endln;      
00511             return TCL_ERROR;
00512         }       
00513         
00514         if (Tcl_GetDouble (interp, argv[8], &cover) != TCL_OK) {
00515             opserr << "WARNING invalid cover" << endln;
00516             opserr << "RCSection2d section: " << tag << endln;              
00517             return TCL_ERROR;
00518         }       
00519 
00520         if (Tcl_GetDouble (interp, argv[9], &Amain) != TCL_OK) {
00521             opserr << "WARNING invalid Amain" << endln;
00522             opserr << "RCSection2d section: " << tag << endln;              
00523             return TCL_ERROR;
00524         }       
00525 
00526         if (Tcl_GetDouble (interp, argv[10], &Aside) != TCL_OK) {
00527             opserr << "WARNING invalid Aside" << endln;
00528             opserr << "RCSection2d section: " << tag << endln;              
00529             return TCL_ERROR;
00530         }       
00531 
00532         if (Tcl_GetInt (interp, argv[11], &nfcore) != TCL_OK) {
00533             opserr << "WARNING invalid nfcore" << endln;
00534             opserr << "RCSection2d section: " << tag << endln;              
00535             return TCL_ERROR;
00536         }       
00537 
00538         if (Tcl_GetInt (interp, argv[12], &nfcover) != TCL_OK) {
00539             opserr << "WARNING invalid nfcover" << endln;
00540             opserr << "RCSection2d section: " << tag << endln;              
00541             return TCL_ERROR;
00542         }       
00543 
00544         if (Tcl_GetInt (interp, argv[13], &nfs) != TCL_OK) {
00545             opserr << "WARNING invalid nfs" << endln;
00546             opserr << "RCSection2d section: " << tag << endln;              
00547             return TCL_ERROR;
00548         }       
00549 
00550         UniaxialMaterial *theCore = theTclBuilder->getUniaxialMaterial(coreTag);
00551         
00552         if (theCore == 0) {
00553             opserr << "WARNING uniaxial material does not exist\n";
00554             opserr << "material: " << coreTag; 
00555             opserr << "\nRCSection2d section: " << tag << endln;
00556             return TCL_ERROR;
00557         }
00558         
00559         UniaxialMaterial *theCover = theTclBuilder->getUniaxialMaterial(coverTag);
00560         
00561         if (theCover == 0) {
00562             opserr << "WARNING uniaxial material does not exist\4n";
00563             opserr << "material: " << coverTag; 
00564             opserr << "\nRCSection2d section: " << tag << endln;
00565             return TCL_ERROR;
00566         }
00567         
00568         UniaxialMaterial *theSteel = theTclBuilder->getUniaxialMaterial(steelTag);
00569 
00570         if (theSteel == 0) {
00571             opserr << "WARNING uniaxial material does not exist\n";
00572             opserr << "material: " << steelTag; 
00573             opserr << "\nRCSection2d section: " << tag << endln;
00574             return TCL_ERROR;
00575         }
00576         
00577         RCSectionIntegration rcsect(d, b, Amain, Aside, cover, nfcore, nfcover, nfs);
00578 
00579         int numFibers = rcsect.getNumFibers();
00580 
00581         UniaxialMaterial **theMats = new UniaxialMaterial *[numFibers];
00582 
00583         rcsect.arrangeFibers(theMats, theCore, theCover, theSteel);
00584 
00585         // Parsing was successful, allocate the section
00586         theSection = new FiberSection2d(tag, numFibers, theMats, rcsect);
00587 
00588         delete [] theMats;
00589     }
00590 
00591     else if (strcmp(argv[1],"AddDeformation") == 0 || strcmp(argv[1],"Aggregator") == 0) {
00592         if (argc < 5) {
00593             opserr << "WARNING insufficient arguments\n";
00594             printCommand(argc,argv);
00595             opserr << "Want: section Aggregator tag? uniTag1? code1? ... <-section secTag?>" << endln;
00596             return TCL_ERROR;
00597         }
00598             
00599         int tag;
00600         int secTag;
00601         SectionForceDeformation *theSec = 0;
00602             
00603         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00604             opserr << "WARNING invalid Aggregator tag" << endln;
00605             return TCL_ERROR;           
00606         }
00607 
00608         int nArgs = argc-3;
00609         
00610         for (int ii = 5; ii < argc; ii++) {
00611             if (strcmp(argv[ii],"-section") == 0 && ++ii < argc) {
00612                 if (Tcl_GetInt(interp, argv[ii], &secTag) != TCL_OK) {
00613                     opserr << "WARNING invalid Aggregator tag" << endln;
00614                     return TCL_ERROR;           
00615                 }
00616                 
00617                 theSec = theTclBuilder->getSection(secTag);
00618                 
00619                 if (theSec == 0) {
00620                     opserr << "WARNING section does not exist\n";
00621                     opserr << "section: " << secTag; 
00622                     opserr << "\nsection Aggregator: " << tag << endln;
00623                     return TCL_ERROR;
00624                 }
00625                 
00626                 nArgs -= 2;
00627             }
00628         }
00629         
00630         int nMats = nArgs / 2;
00631         
00632         if (nArgs%2 != 0) {
00633             opserr << "WARNING improper number of arguments for Aggregator" << endln;
00634             return TCL_ERROR;
00635         }
00636         
00637         UniaxialMaterial **theMats = 0;
00638         ID codes(nMats);
00639         
00640         theMats = new UniaxialMaterial *[nMats];
00641         
00642         if (theMats == 0) {
00643             opserr << "TclModelBuilderSection (Aggregator) -- unable to create uniaxial array" << endln;
00644             return TCL_ERROR;
00645         }       
00646         
00647         int tagI;
00648         int i, j;
00649         
00650         for (i = 3, j = 0; j < nMats; i++, j++) {
00651             if (Tcl_GetInt(interp, argv[i], &tagI) != TCL_OK) {
00652                 opserr << "WARNING invalid Aggregator matTag" << endln;
00653                 return TCL_ERROR;               
00654             }
00655             
00656             theMats[j] = theTclBuilder->getUniaxialMaterial(tagI);
00657             
00658             if (theMats[j] == 0) {
00659                 opserr << "WARNING uniaxial material does not exist\n";
00660                 opserr << "uniaxial material: " << tagI; 
00661                 opserr << "\nsection Aggregator: " << tag << endln;
00662                 return TCL_ERROR;
00663             }
00664             
00665             i++;
00666             
00667             if (strcmp(argv[i],"Mz") == 0)
00668                 codes(j) = SECTION_RESPONSE_MZ;
00669             else if (strcmp(argv[i],"P") == 0)
00670                 codes(j) = SECTION_RESPONSE_P;
00671             else if (strcmp(argv[i],"Vy") == 0)
00672                 codes(j) = SECTION_RESPONSE_VY;
00673             else if (strcmp(argv[i],"My") == 0)
00674                 codes(j) = SECTION_RESPONSE_MY;
00675             else if (strcmp(argv[i],"Vz") == 0)
00676                 codes(j) = SECTION_RESPONSE_VZ;
00677             else if (strcmp(argv[i],"T") == 0)
00678                 codes(j) = SECTION_RESPONSE_T;
00679             else {
00680                 opserr << "WARNING invalid code" << endln;
00681                 opserr << "\nsection Aggregator: " << tag << endln;
00682                 return TCL_ERROR;               
00683             }
00684         }
00685         
00686         if (theSec)
00687             theSection = new SectionAggregator (tag, *theSec, nMats, theMats, codes);
00688         else
00689             theSection = new SectionAggregator (tag, nMats, theMats, codes);
00690         
00691         delete [] theMats;
00692     }           
00693     
00694     else if (strcmp(argv[1],"Fiber") == 0 || strcmp(argv[1],"fiberSec") == 0)
00695         return TclModelBuilder_addFiberSection (clientData, interp, argc, argv,
00696                                                 theTclBuilder);
00697 
00698     else if (strcmp(argv[1],"UCFiber") == 0)
00699         return TclModelBuilder_addUCFiberSection (clientData, interp, argc, argv,
00700                                                   theTclBuilder);
00701 
00702     else if (strcmp(argv[1],"ElasticPlateSection") == 0) {
00703         if (argc < 5) {
00704             opserr << "WARNING insufficient arguments\n";
00705             printCommand(argc,argv);
00706             opserr << "Want: section ElasticPlateSection tag? E? nu? h? " << endln;
00707             return TCL_ERROR;
00708         }
00709         
00710         int tag;
00711         double E, nu, h;
00712         
00713         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00714             opserr << "WARNING invalid section ElasticPlateSection tag" << endln;
00715             return TCL_ERROR;           
00716         }
00717 
00718         if (Tcl_GetDouble (interp, argv[3], &E) != TCL_OK) {
00719             opserr << "WARNING invalid E" << endln;
00720             opserr << "ElasticPlateSection section: " << tag << endln;      
00721             return TCL_ERROR;
00722         }       
00723 
00724         if (Tcl_GetDouble (interp, argv[4], &nu) != TCL_OK) {
00725             opserr << "WARNING invalid nu" << endln;
00726             opserr << "ElasticPlateSection section: " << tag << endln;      
00727             return TCL_ERROR;
00728         }       
00729         
00730         if (Tcl_GetDouble (interp, argv[5], &h) != TCL_OK) {
00731             opserr << "WARNING invalid h" << endln;
00732             opserr << "ElasticPlateSection section: " << tag << endln;              
00733             return TCL_ERROR;
00734         }       
00735 
00736         theSection = new ElasticPlateSection (tag, E, nu, h);
00737     }   
00738 
00739     else if (strcmp(argv[1],"ElasticMembranePlateSection") == 0) {
00740         if (argc < 5) {
00741             opserr << "WARNING insufficient arguments\n";
00742             printCommand(argc,argv);
00743             opserr << "Want: section ElasticMembranePlateSection tag? E? nu? h? <rho?>" << endln;
00744             return TCL_ERROR;
00745         }
00746         
00747         int tag;
00748         double E, nu, h;
00749         double rho = 0.0;
00750         
00751         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00752             opserr << "WARNING invalid section ElasticMembranePlateSection tag" << endln;
00753             return TCL_ERROR;           
00754         }
00755 
00756         if (Tcl_GetDouble (interp, argv[3], &E) != TCL_OK) {
00757             opserr << "WARNING invalid E" << endln;
00758             opserr << "ElasticMembranePlateSection section: " << tag << endln;      
00759             return TCL_ERROR;
00760         }       
00761 
00762         if (Tcl_GetDouble (interp, argv[4], &nu) != TCL_OK) {
00763             opserr << "WARNING invalid nu" << endln;
00764             opserr << "ElasticMembranePlateSection section: " << tag << endln;      
00765             return TCL_ERROR;
00766         }       
00767         
00768         if (Tcl_GetDouble (interp, argv[5], &h) != TCL_OK) {
00769             opserr << "WARNING invalid h" << endln;
00770             opserr << "ElasticMembranePlateSection section: " << tag << endln;              
00771             return TCL_ERROR;
00772         }       
00773 
00774         if (argc > 6 && Tcl_GetDouble (interp, argv[6], &rho) != TCL_OK) {
00775             opserr << "WARNING invalid rho" << endln;
00776             opserr << "ElasticMembranePlateSection section: " << tag << endln;              
00777             return TCL_ERROR;
00778         }
00779 
00780         theSection = new ElasticMembranePlateSection (tag, E, nu, h, rho);
00781     }   
00782 
00783     else if (strcmp(argv[1],"PlateFiber") == 0) {
00784         if (argc < 5) {
00785             opserr << "WARNING insufficient arguments\n";
00786             printCommand(argc,argv);
00787             opserr << "Want: section PlateFiber tag? matTag? h? " << endln;
00788             return TCL_ERROR;
00789         }
00790         
00791         int tag, matTag;
00792         double  h;
00793         
00794         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00795             opserr << "WARNING invalid section PlateFiber tag" << endln;
00796             return TCL_ERROR;           
00797         }
00798 
00799         if (Tcl_GetInt (interp, argv[3], &matTag) != TCL_OK) {
00800             opserr << "WARNING invalid matTag" << endln;
00801             opserr << "PlateFiber section: " << matTag << endln;                    
00802             return TCL_ERROR;
00803         }       
00804 
00805         if (Tcl_GetDouble (interp, argv[4], &h) != TCL_OK) {
00806             opserr << "WARNING invalid h" << endln;
00807             opserr << "PlateFiber section: " << tag << endln;               
00808             return TCL_ERROR;
00809         }       
00810 
00811         NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matTag);
00812         if (theMaterial == 0) {
00813             opserr << "WARNING nD material does not exist\n";
00814             opserr << "nD material: " << matTag; 
00815             opserr << "\nPlateFiber section: " << tag << endln;
00816             return TCL_ERROR;
00817         }
00818 
00819         theSection = new MembranePlateFiberSection( tag, h, *theMaterial );
00820     }   
00821     
00822         else if (strcmp(argv[1],"Bidirectional") == 0) {
00823         if (argc < 7) {
00824             opserr << "WARNING insufficient arguments\n";
00825             printCommand(argc,argv);
00826             opserr << "Want: section Bidirectional tag? E? sigY? Hiso? Hkin?" << endln;
00827             return TCL_ERROR;
00828         }    
00829 
00830         int tag;
00831         double E, sigY, Hi, Hk;
00832         
00833         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00834             opserr << "WARNING invalid Bidirectional tag" << endln;
00835             return TCL_ERROR;           
00836         }
00837 
00838         if (Tcl_GetDouble(interp, argv[3], &E) != TCL_OK) {
00839             opserr << "WARNING invalid E\n";
00840             opserr << "section Bidirectional: " << tag << endln;
00841             return TCL_ERROR;   
00842         }
00843 
00844         if (Tcl_GetDouble(interp, argv[4], &sigY) != TCL_OK) {
00845             opserr << "WARNING invalid sigY\n";
00846             opserr << "section Bidirectional: " << tag << endln;
00847             return TCL_ERROR;   
00848         }
00849 
00850         if (Tcl_GetDouble(interp, argv[5], &Hi) != TCL_OK) {
00851             opserr << "WARNING invalid Hiso\n";
00852             opserr << "section Bidirectional: " << tag << endln;
00853             return TCL_ERROR;   
00854         }
00855 
00856         if (Tcl_GetDouble(interp, argv[6], &Hk) != TCL_OK) {
00857             opserr << "WARNING invalid Hkin\n";
00858             opserr << "section Bidirectional: " << tag << endln;
00859             return TCL_ERROR;   
00860         }
00861 
00862         theSection = new Bidirectional(tag, E, sigY, Hi, Hk);
00863         }
00864 
00865         else if (strcmp(argv[1],"Iso2spring") == 0) {
00866           if (argc < 10) {
00867             opserr << "WARNING insufficient arguments\n";
00868             printCommand(argc,argv);
00869             opserr << "Want: section Iso2spring tag? tol? k1? Fy? k2? kv? hb? Pe? <Po?>" << endln;
00870             return TCL_ERROR;
00871           }    
00872           
00873           int tag;
00874           double tol, k1, Fy, kb, kvo, hb, Pe, Po;
00875 
00876           if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00877             opserr << "WARNING invalid Iso2spring tag" << endln;
00878             return TCL_ERROR;           
00879           }
00880 
00881           if (Tcl_GetDouble(interp, argv[3], &tol) != TCL_OK) {
00882             opserr << "WARNING invalid tol\n";
00883             opserr << "section Iso2spring: " << tag << endln;
00884             return TCL_ERROR;
00885           }
00886           
00887           if (Tcl_GetDouble(interp, argv[4], &k1) != TCL_OK) {
00888             opserr << "WARNING invalid k1\n";
00889             opserr << "section Iso2spring: " << tag << endln;
00890             return TCL_ERROR;   
00891           }
00892           
00893           if (Tcl_GetDouble(interp, argv[5], &Fy) != TCL_OK) {
00894             opserr << "WARNING invalid Fy\n";
00895             opserr << "section Iso2spring: " << tag << endln;
00896             return TCL_ERROR;   
00897           }
00898           
00899           if (Tcl_GetDouble(interp, argv[6], &kb) != TCL_OK) {
00900             opserr << "WARNING invalid k2\n";
00901             opserr << "section Iso2spring: " << tag << endln;
00902             return TCL_ERROR;   
00903           }
00904           
00905           if (Tcl_GetDouble(interp, argv[7], &kvo) != TCL_OK) {
00906             opserr << "WARNING invalid kv\n";
00907             opserr << "section Iso2spring: " << tag << endln;
00908             return TCL_ERROR;   
00909           }
00910           if (Tcl_GetDouble(interp, argv[8], &hb) != TCL_OK) {
00911             opserr << "WARNING invalid hb\n";
00912             opserr << "section Iso2spring: " << tag << endln;
00913             return TCL_ERROR;   
00914         }
00915           
00916           if (Tcl_GetDouble(interp, argv[9], &Pe) != TCL_OK) {
00917             opserr << "WARNING invalid Pe\n";
00918             opserr << "section Iso2spring: " << tag << endln;
00919             return TCL_ERROR;   
00920           }
00921           if (argc > 10) {
00922             if (Tcl_GetDouble(interp, argv[10], &Po) != TCL_OK) {
00923               opserr << "WARNING invalid Po\n";
00924               opserr << "section Iso2spring: " << tag << endln;
00925               return TCL_ERROR; 
00926             }
00927           }         
00928           
00929           theSection = new Isolator2spring(tag, tol, k1, Fy, kb, kvo, hb, Pe, Po);
00930         }
00931                 
00932     else {
00933       theSection = TclModelBuilderYS_SectionCommand(clientData, interp, argc, 
00934                                                     argv, theTclBuilder);
00935     }
00936     
00937     // Ensure we have created the Material, out of memory if got here and no section
00938     if (theSection == 0) {
00939       opserr << "WARNING could not create section " << argv[1] << endln;
00940       return TCL_ERROR;
00941     }
00942     
00943     // Now add the material to the modelBuilder
00944     if (theTclBuilder->addSection(*theSection) < 0) {
00945         opserr << "WARNING could not add section to the domain\n";
00946         opserr << *theSection << endln;
00947         delete theSection; // invoke the material objects destructor, otherwise mem leak
00948         return TCL_ERROR;
00949     }
00950     
00951     return TCL_OK;
00952 }
00953 
00954 static int currentSectionTag = 0;
00955     
00956 int
00957 buildSection(Tcl_Interp *interp, TclModelBuilder *theTclModelBuilder,
00958              int secTag, bool isTorsion, double GJ);
00959 
00960 int
00961 TclModelBuilder_addFiberSection (ClientData clientData, Tcl_Interp *interp, int argc,
00962                                  TCL_Char **argv, TclModelBuilder *theTclModelBuilder)
00963 {
00964     int secTag;
00965     int maxNumPatches = 30; 
00966     int maxNumReinfLayers = 30;
00967     
00968     if (argc < 4) 
00969         return TCL_ERROR;
00970     
00971     if (Tcl_GetInt(interp, argv[2], &secTag) != TCL_OK) {
00972       opserr <<  "WARNING bad command - want: \nsection fiberSec secTag { \n\tpatch <patch arguments> \n\tlayer <layer arguments> \n}\n";
00973         return TCL_ERROR;
00974     }
00975     
00976     currentSectionTag = secTag;
00977       
00978     // create the fiber section representation (with the geometric information) 
00979       
00980     SectionRepres *fiberSectionRepr =
00981         new FiberSectionRepr(secTag, maxNumPatches, maxNumReinfLayers);  
00982 
00983     if (fiberSectionRepr == 0) {
00984       opserr <<  "WARNING - ran out of memory to create section representation\n";
00985         return TCL_ERROR;
00986     }
00987 
00988     if (theTclModelBuilder->addSectionRepres(*fiberSectionRepr) < 0) {
00989         opserr <<  "WARNING - cannot add section representation\n";
00990         return TCL_ERROR;
00991     }   
00992 
00993     int brace = 3; // Start of recursive parse
00994     double GJ = 1.0;
00995     bool isTorsion = false;
00996     if (strcmp(argv[3],"-GJ") == 0) {
00997       if (Tcl_GetDouble(interp, argv[4], &GJ) != TCL_OK) {
00998         interp->result = "WARNING invalid GJ";
00999         return TCL_ERROR;
01000       }
01001       isTorsion = true;
01002       brace = 5;
01003     }
01004 
01005     // parse the information inside the braces (patches and reinforcing layers)
01006     if (Tcl_Eval(interp, argv[brace]) != TCL_OK) {
01007         opserr << "WARNING - error reading information in { } \n";
01008         return TCL_ERROR;
01009     }
01010 
01011     // build the fiber section (for analysis)
01012     if (buildSection(interp, theTclModelBuilder, secTag, isTorsion, GJ) != TCL_OK) {
01013         opserr << "WARNING - error constructing the section\n";
01014         return TCL_ERROR;
01015     }
01016     
01017 //    currentSectionTag = 0;
01018 
01019     return TCL_OK;
01020 }
01021 
01022 
01023 
01024 
01025 // add patch to fiber section
01026 int
01027 TclModelBuilder_addPatch(ClientData clientData, Tcl_Interp *interp, int argc, 
01028                              TCL_Char **argv, TclModelBuilder *theTclModelBuilder)
01029 {
01030     // check if a section is being processed
01031     if (currentSectionTag == 0) {
01032         opserr <<  "WARNING subcommand 'patch' is only valid inside a 'section' command\n";
01033         return TCL_ERROR;
01034     }      
01035     
01036     // make sure at least one other argument to contain patch type
01037     if (argc < 2) {
01038         opserr <<  "WARNING need to specify a patch type \n";
01039         return TCL_ERROR;
01040     }    
01041 
01042     // check argv[1] for type of patch  and create the object
01043     if (strcmp(argv[1], "quad") == 0 || strcmp(argv[1], "quadr") == 0) {
01044         int numSubdivIJ, numSubdivJK, matTag, secTag;
01045         double vertexCoordY, vertexCoordZ;
01046         static Matrix vertexCoords(4,2);
01047         int j, argi;
01048 
01049         if (argc < 13) {
01050             opserr <<  "WARNING invalid number of parameters: patch quad matTag numSubdivIJ numSubdivJK yVertI zVertI yVertJ zVertJ yVertK zVertK yVertL zVertL\n";
01051             return TCL_ERROR;
01052         }
01053   
01054         argi = 2;
01055       
01056       if (Tcl_GetInt(interp, argv[argi++], &matTag) != TCL_OK)
01057       {
01058          opserr <<  "WARNING invalid matTag: patch quad matTag numSubdivIJ numSubdivJK yVertI zVertI yVertJ zVertJ yVertK zVertK yVertL zVertL\n";
01059          return TCL_ERROR;
01060       }
01061       //opserr << "\n\tmatTag: " << matTag;
01062 
01063       if (Tcl_GetInt(interp, argv[argi++], &numSubdivIJ) != TCL_OK)
01064       {
01065          opserr <<  "WARNING invalid numSubdivIJ: patch quad matTag numSubdivIJ numSubdivJK yVertI zVertI yVertJ zVertJ yVertK zVertK yVertL zVertL\n";
01066          return TCL_ERROR;
01067       }
01068       //opserr << "\n\tnumSubdivIJ: " << numSubdivIJ;
01069  
01070       if (Tcl_GetInt(interp, argv[argi++], &numSubdivJK) != TCL_OK)
01071       {
01072          opserr <<  "WARNING invalid numSubdivJK: patch quad matTag numSubdivIJ numSubdivJK yVertI zVertI yVertJ zVertJ yVertK zVertK yVertL zVertL\n";
01073          return TCL_ERROR;
01074       }
01075       //opserr << "\n\tnumSubdivJK: " << numSubdivJK;
01076 
01077       for (j=0; j < 4; j++)
01078       {
01079          //opserr << "\n\tVertexCoord: " << j;
01080          if (Tcl_GetDouble(interp, argv[argi++], &vertexCoordY) != TCL_OK)
01081          {
01082             opserr <<  "WARNING invalid Coordinate y: ...yVertI zVertI yVertJ zVertJ yVertK zVertK yVertL zVertL\n";
01083             return TCL_ERROR;
01084          }
01085          //opserr << "\n\t\tvertexCoordY: " << vertexCoordY; 
01086 
01087          if (Tcl_GetDouble(interp, argv[argi++], &vertexCoordZ) != TCL_OK)
01088          {
01089             opserr <<  "WARNING invalid Coordinate z: ...yVertI zVertI yVertJ zVertJ yVertK zVertK yVertL zVertL\n";
01090             return TCL_ERROR;
01091          }
01092          //opserr << "\n\t\tvertexCoordZ: " << vertexCoordZ; 
01093 
01094          vertexCoords(j,0) = vertexCoordY;
01095          vertexCoords(j,1) = vertexCoordZ;
01096       }
01097        
01098       // get section representation
01099       secTag = currentSectionTag;
01100       
01101       SectionRepres *sectionRepres = theTclModelBuilder->getSectionRepres(secTag);
01102       if (sectionRepres == 0) 
01103       {
01104          opserr <<  "WARNING cannot retrieve section\n";
01105          return TCL_ERROR;
01106       }    
01107      
01108       if (sectionRepres->getType() != SEC_TAG_FiberSection)
01109       {
01110          opserr <<  "WARNING section invalid: patch can only be added to fiber sections\n";
01111          return TCL_ERROR;
01112       }
01113 
01114       FiberSectionRepr *fiberSectionRepr = (FiberSectionRepr *) sectionRepres;
01115 
01116       // create patch
01117 
01118       QuadPatch *patch = new QuadPatch(matTag, numSubdivIJ, numSubdivJK, vertexCoords);
01119       if (!patch)
01120       {
01121          opserr <<  "WARNING cannot alocate patch\n";
01122          return TCL_ERROR;
01123       }
01124 
01125       //opserr << "\n\tpatch: " << *patch;
01126       
01127       // add patch to section representation
01128 
01129       int error = fiberSectionRepr->addPatch(*patch);
01130       delete patch;
01131       
01132       if (error)
01133       {
01134          opserr <<  "WARNING cannot add patch to section\n";
01135          return TCL_ERROR;
01136       }  
01137   }
01138     
01139     
01140     // check argv[1] for type of patch  and create the object
01141     else if (strcmp(argv[1], "rect") == 0 || 
01142              strcmp(argv[1], "rectangular") == 0) {
01143         
01144         int numSubdivIJ, numSubdivJK, matTag, secTag;
01145         double vertexCoordY, vertexCoordZ;
01146         static Matrix vertexCoords(4,2);
01147         int j, argi;
01148 
01149         if (argc < 9) {
01150             opserr <<  "WARNING invalid number of parameters: patch quad matTag numSubdivIJ numSubdivJK yVertI zVertI yVertK zVertK\n";
01151             return TCL_ERROR;
01152         }
01153   
01154         argi = 2;
01155       
01156         if (Tcl_GetInt(interp, argv[argi++], &matTag) != TCL_OK) {
01157             opserr <<  "WARNING invalid matTag: patch quad matTag numSubdivIJ numSubdivJK yVertI zVertI yVertJ zVertJ yVertK zVertK yVertL zVertL\n";
01158             return TCL_ERROR;
01159         }
01160 
01161         if (Tcl_GetInt(interp, argv[argi++], &numSubdivIJ) != TCL_OK) {
01162             opserr <<  "WARNING invalid numSubdivIJ: patch quad matTag numSubdivIJ numSubdivJK yVertI zVertI yVertJ zVertJ yVertK zVertK yVertL zVertL\n";
01163             return TCL_ERROR;
01164         }
01165  
01166         if (Tcl_GetInt(interp, argv[argi++], &numSubdivJK) != TCL_OK) {
01167             opserr <<  "WARNING invalid numSubdivJK: patch quad matTag numSubdivIJ numSubdivJK yVertI zVertI yVertJ zVertJ yVertK zVertK yVertL zVertL\n";
01168             return TCL_ERROR;
01169         }
01170 
01171         for (j=0; j < 2; j++) {
01172             if (Tcl_GetDouble(interp, argv[argi++], &vertexCoordY) != TCL_OK) {
01173                 opserr <<  "WARNING invalid Coordinate y: ...yVertI zVertI yVertJ zVertJ yVertK zVertK yVertL zVertL\n";
01174                 return TCL_ERROR;
01175             }
01176 
01177             if (Tcl_GetDouble(interp, argv[argi++], &vertexCoordZ) != TCL_OK) {
01178                 opserr <<  "WARNING invalid Coordinate z: ...yVertI zVertI yVertJ zVertJ yVertK zVertK yVertL zVertL\n";
01179                 return TCL_ERROR;
01180             }
01181 
01182             vertexCoords(j*2,0) = vertexCoordY;
01183             vertexCoords(j*2,1) = vertexCoordZ;
01184         }
01185 
01186         vertexCoords(1,0) = vertexCoords(2,0);
01187         vertexCoords(1,1) = vertexCoords(0,1);  
01188         vertexCoords(3,0) = vertexCoords(0,0);
01189         vertexCoords(3,1) = vertexCoords(2,1);          
01190             
01191       // get section representation
01192       secTag = currentSectionTag;
01193       
01194       SectionRepres *sectionRepres = theTclModelBuilder->getSectionRepres(secTag);
01195       if (sectionRepres == 0) {
01196          opserr <<  "WARNING cannot retrieve section\n";
01197          return TCL_ERROR;
01198       }    
01199      
01200       if (sectionRepres->getType() != SEC_TAG_FiberSection) {
01201          opserr <<  "WARNING section invalid: patch can only be added to fiber sections\n";
01202          return TCL_ERROR;
01203       }
01204 
01205       FiberSectionRepr *fiberSectionRepr = (FiberSectionRepr *) sectionRepres;
01206 
01207       // create patch
01208 
01209       QuadPatch *patch = new QuadPatch(matTag, numSubdivIJ, numSubdivJK, vertexCoords);
01210       if (!patch)
01211       {
01212          opserr <<  "WARNING cannot alocate patch\n";
01213          return TCL_ERROR;
01214       }
01215 
01216       //opserr << "\n\tpatch: " << *patch;
01217       
01218       // add patch to section representation
01219 
01220       int error = fiberSectionRepr->addPatch(*patch);
01221       delete patch;
01222       
01223       if (error)
01224       {
01225          opserr <<  "WARNING cannot add patch to section\n";
01226          return TCL_ERROR;
01227       }  
01228   }    
01229     
01230     
01231     
01232          
01233     else if (strcmp(argv[1], "circ") == 0) {
01234         int numSubdivRad, numSubdivCirc, matTag, secTag;
01235         double yCenter, zCenter;
01236         static Vector centerPosition(2);
01237         double intRad, extRad;
01238         double startAng, endAng;
01239 
01240         int argi;
01241 
01242       argi = 2;
01243       if (argc < 11)
01244       {
01245          opserr <<  "WARNING invalid number of parameters: patch circ matTag numSubdivCirc numSubdivRad yCenter zCenter intRad extRad startAng endAng\n";
01246          return TCL_ERROR;
01247       }
01248   
01249       if (Tcl_GetInt(interp, argv[argi++], &matTag) != TCL_OK)
01250       {
01251          opserr <<  "WARNING invalid matTag: patch circ matTag numSubdivCirc numSubdivRad yCenter zCenter intRad extRad startAng endAng\n";
01252          return TCL_ERROR;
01253       }
01254       //opserr << "\n\tmatTag: " << matTag;
01255 
01256       if (Tcl_GetInt(interp, argv[argi++], &numSubdivCirc) != TCL_OK)
01257       {
01258          opserr <<  "WARNING invalid numSubdivCirc: patch circ matTag numSubdivCirc numSubdivRad yCenter zCenter intRad extRad startAng endAng\n";
01259          return TCL_ERROR;
01260       }
01261       //opserr << "\n\tnumSubdivCirc: " << numSubdivCirc;
01262 
01263       if (Tcl_GetInt(interp, argv[argi++], &numSubdivRad) != TCL_OK)
01264       {
01265          opserr <<  "WARNING invalid numSubdivRad: patch circ matTag numSubdivCirc numSubdivRad yCenter zCenter intRad extRad startAng endAng\n";
01266          return TCL_ERROR;
01267       }
01268       //opserr << "\n\tnumSubdivRad: " << numSubdivRad;
01269 
01270       if (Tcl_GetDouble(interp, argv[argi++], &yCenter) != TCL_OK)
01271       {
01272          opserr <<  "WARNING invalid yCenter: patch circ matTag numSubdivCirc numSubdivRad yCenter zCenter intRad extRad startAng endAng\n";
01273          return TCL_ERROR;
01274       }
01275       //opserr << "\n\tyCenter: " << yCenter;
01276 
01277       if (Tcl_GetDouble(interp, argv[argi++], &zCenter) != TCL_OK)
01278       {
01279          opserr <<  "WARNING invalid zCenter: patch circ matTag numSubdivCirc numSubdivRad yCenter zCenter intRad extRad startAng endAng\n";
01280          return TCL_ERROR;
01281       }
01282       //opserr << "\n\tzCenter: " << zCenter;
01283 
01284       if (Tcl_GetDouble(interp, argv[argi++], &intRad) != TCL_OK)
01285       {
01286          opserr <<  "WARNING invalid intRad: patch circ matTag numSubdivCirc numSubdivRad yCenter zCenter intRad extRad startAng endAng\n";
01287          return TCL_ERROR;
01288       }
01289       //opserr << "\n\tintRad: " << intRad;
01290 
01291       if (Tcl_GetDouble(interp, argv[argi++], &extRad) != TCL_OK)
01292       {
01293          opserr <<  "WARNING invalid extRad: patch circ matTag numSubdivCirc numSubdivRad yCenter zCenter intRad extRad startAng endAng\n";
01294          return TCL_ERROR;
01295       }
01296       //opserr << "\n\textRad: " << extRad;
01297 
01298       if (Tcl_GetDouble(interp, argv[argi++], &startAng) != TCL_OK)
01299       {
01300          opserr <<  "WARNING invalid startAng: patch circ matTag numSubdivCirc numSubdivRad yCenter zCenter intRad extRad startAng endAng\n";
01301          return TCL_ERROR;
01302       }
01303       //opserr << "\n\tstartAngle: " << startAng;
01304 
01305       if (Tcl_GetDouble(interp, argv[argi++], &endAng) != TCL_OK)
01306       {
01307          opserr <<  "WARNING invalid endAng: patch circ matTag numSubdivCirc numSubdivRad yCenter zCenter intRad extRad startAng endAng\n";
01308          return TCL_ERROR;
01309       }
01310       //opserr << "\n\tendAng: " << endAng;
01311 
01312 
01313       // get section 
01314       secTag = currentSectionTag;
01315       
01316       SectionRepres *sectionRepres = theTclModelBuilder->getSectionRepres(secTag);
01317       if (sectionRepres == 0) 
01318       {
01319          opserr <<  "WARNING cannot retrieve section\n";
01320          return TCL_ERROR;
01321       }    
01322      
01323       if (sectionRepres->getType() != SEC_TAG_FiberSection)
01324       {
01325          opserr <<  "WARNING section invalid: patch can only be added to fiber sections\n";
01326          return TCL_ERROR;
01327       }
01328 
01329       FiberSectionRepr *fiberSectionRepr = (FiberSectionRepr *) sectionRepres;
01330 
01331       centerPosition(0) = yCenter; 
01332       centerPosition(1) = zCenter; 
01333    
01334       // create patch
01335 
01336       CircPatch *patch = new CircPatch(matTag, numSubdivCirc, numSubdivRad,
01337                                        centerPosition, intRad, extRad, 
01338                                        startAng, endAng);
01339       if (!patch)
01340       {
01341          opserr <<  "WARNING cannot alocate patch\n";
01342          return TCL_ERROR;
01343       }
01344 
01345       //opserr << "\n\tpatch: " << *patch;
01346       
01347       // add patch to section
01348 
01349       int error = fiberSectionRepr->addPatch(*patch);
01350       delete patch;
01351       
01352       if (error)
01353       {
01354          opserr <<  "WARNING cannot add patch to section\n";
01355          return TCL_ERROR;
01356       }
01357    }
01358 
01359    else
01360    {
01361       opserr <<  "WARNING patch type is not available\n";
01362       return TCL_ERROR;
01363    }
01364   
01365    return TCL_OK;
01366 }
01367 
01368 
01369 
01370 // add patch to fiber section
01371 int
01372 TclModelBuilder_addFiber(ClientData clientData, Tcl_Interp *interp, int argc, 
01373                          TCL_Char **argv, TclModelBuilder *theTclModelBuilder)
01374 {
01375     // check if a section is being processed
01376     if (currentSectionTag == 0) {
01377         opserr <<  "WARNING subcommand 'fiber' is only valid inside a 'section' command\n";
01378         return TCL_ERROR;
01379     }      
01380     
01381     // make sure at least one other argument to contain patch type
01382     if (argc < 5) {
01383         opserr <<  "WARNING invalid num args: fiber yLoc zLoc area matTag\n";
01384         return TCL_ERROR;
01385     }    
01386 
01387     SectionRepres *sectionRepres = 
01388         theTclModelBuilder->getSectionRepres(currentSectionTag);
01389     
01390     if (sectionRepres == 0) {
01391         opserr <<  "WARNING cannot retrieve section\n";
01392         return TCL_ERROR;
01393     }    
01394         
01395     if (sectionRepres->getType() != SEC_TAG_FiberSection) {
01396         opserr <<  "WARNING section invalid: patch can only be added to fiber sections\n";
01397         return TCL_ERROR;
01398     }
01399 
01400     FiberSectionRepr *fiberSectionRepr = (FiberSectionRepr *) sectionRepres;
01401     int numFibers = fiberSectionRepr->getNumFibers();    
01402     
01403     int NDM = theTclModelBuilder->getNDM();  
01404     
01405     Fiber *theFiber =0;
01406       
01407     int matTag;
01408     double yLoc, zLoc, area;
01409 
01410     
01411     if (Tcl_GetDouble(interp, argv[1], &yLoc) != TCL_OK) {
01412          opserr <<  "WARNING invalid yLoc: fiber yLoc zLoc area matTag\n";
01413          return TCL_ERROR;
01414      }    
01415     if (Tcl_GetDouble(interp, argv[2], &zLoc) != TCL_OK) {
01416          opserr <<  "WARNING invalid zLoc: fiber yLoc zLoc area matTag\n";
01417          return TCL_ERROR;
01418      }        
01419     if (Tcl_GetDouble(interp, argv[3], &area) != TCL_OK) {
01420          opserr <<  "WARNING invalid area: fiber yLoc zLoc area matTag\n";
01421          return TCL_ERROR;
01422      }            
01423     
01424     if (Tcl_GetInt(interp, argv[4], &matTag) != TCL_OK) {
01425          opserr <<  "WARNING invalid matTag: fiber yLoc zLoc area matTag\n";
01426          return TCL_ERROR;
01427      }                
01428     
01429     UniaxialMaterial *material = theTclModelBuilder->getUniaxialMaterial(matTag);
01430     
01431     // creates 2d section      
01432     if (NDM == 2) {
01433 
01434         if (material == 0) {
01435             opserr <<  "WARNING invalid material ID for patch\n";
01436             return TCL_ERROR;
01437         }   
01438 
01439         theFiber = new UniaxialFiber2d(numFibers, *material, area, yLoc);
01440         if (theFiber == 0) {
01441             opserr <<  "WARNING unable to allocate fiber \n";
01442             return TCL_ERROR;
01443         }    
01444     }
01445 
01446     else if (NDM == 3) {
01447 
01448       static Vector fiberPosition(2);
01449         fiberPosition(0) = yLoc;
01450         fiberPosition(1) = zLoc;
01451             
01452         theFiber = new UniaxialFiber3d(numFibers, *material, area, fiberPosition);
01453         if (theFiber == 0) {
01454             opserr <<  "WARNING unable to allocate fiber \n";
01455             return TCL_ERROR;
01456         }    
01457     }
01458 
01459     else {
01460         opserr <<  "WARNING fiber command for FiberSection only fo 2 or 3d \n";
01461         return TCL_ERROR;
01462     }    
01463         
01464     // add patch to section representation
01465     int error = fiberSectionRepr->addFiber(*theFiber);
01466 
01467     if (error) {
01468         opserr <<  "WARNING cannot add patch to section\n";
01469         return TCL_ERROR;
01470     }  
01471 
01472     return TCL_OK;
01473 }
01474 
01475 
01476 
01477 
01478 // add layers of reinforcing bars to fiber section
01479           
01480 int
01481 TclModelBuilder_addReinfLayer(ClientData clientData, Tcl_Interp *interp, int argc, 
01482                                   TCL_Char **argv, TclModelBuilder *theTclModelBuilder)
01483 {
01484    //opserr << "\nreading layer:\n";
01485 
01486    // check if a section is being processed
01487    if (currentSectionTag == 0)
01488    {
01489       opserr <<  "WARNING subcommand 'patch' is only valid inside a 'section' command\n";
01490       return TCL_ERROR;
01491    }       
01492 
01493    // make sure at least one other argument to contain layer type
01494    if (argc < 2) 
01495    {
01496       opserr <<  "WARNING need to specify a layer type \n";
01497       return TCL_ERROR;
01498    }    
01499 
01500    // check argv[1] for type of layer and create the object
01501    if (strcmp(argv[1], "straight") == 0) 
01502    {
01503       if (argc < 9)
01504       {
01505          opserr <<  "WARNING invalid number of parameters: layer straight matTag numReinfBars reinfBarArea yStartPt zStartPt yEndPt zEndPt\n";
01506          return TCL_ERROR;
01507       }
01508 
01509       int secTag, matTag, numReinfBars;
01510       double reinfBarArea;
01511       double yStartPt, zStartPt, yEndPt, zEndPt;
01512      
01513       int argi;
01514 
01515       argi = 2;
01516       
01517       if (Tcl_GetInt(interp, argv[argi++], &matTag) != TCL_OK)
01518       {
01519          opserr <<  "WARNING invalid matTag: layer straight matTag numReinfBars reinfBarArea  yStartPt zStartPt yEndPt zEndPt\n";
01520          return TCL_ERROR;
01521       }
01522       //opserr << "\n\tmatTag: " << matTag;
01523 
01524       if (Tcl_GetInt(interp, argv[argi++], &numReinfBars) != TCL_OK)
01525       {
01526          opserr <<  "WARNING invalid numReinfBars: layer straight matTag numReinfBars reinfBarArea  yStartPt zStartPt yEndPt zEndPt\n";
01527          return TCL_ERROR;
01528       }
01529       //opserr << "\n\tnumReinfBars: " << numReinfBars;
01530 
01531       if (Tcl_GetDouble(interp, argv[argi++], &reinfBarArea) != TCL_OK)
01532       {
01533          opserr <<  "WARNING invalid reinfBarArea: layer straight matTag numReinfBars reinfBarArea  yStartPt zStartPt yEndPt zEndPt\n";
01534          return TCL_ERROR;
01535       }
01536       //opserr << "\n\treinfBarArea: " << reinfBarArea;
01537 
01538       if (Tcl_GetDouble(interp, argv[argi++], &yStartPt) != TCL_OK)
01539       {
01540          opserr <<  "WARNING invalid yStartPt: layer straight matTag numReinfBars reinfBarArea  yStartPt zStartPt yEndPt zEndPt\n";
01541          return TCL_ERROR;
01542       }
01543       //opserr << "\n\tyStartPt: " << yStartPt;
01544     
01545       if (Tcl_GetDouble(interp, argv[argi++], &zStartPt) != TCL_OK)
01546       {
01547          opserr <<  "WARNING invalid zStartPt: layer straight matTag numReinfBars reinfBarArea  yStartPt zStartPt yEndPt zEndPt\n";
01548          return TCL_ERROR;
01549       }
01550       //opserr << "\n\tzStartPt: " << zStartPt;
01551        
01552       if (Tcl_GetDouble(interp, argv[argi++], &yEndPt) != TCL_OK)
01553       {
01554          opserr <<  "WARNING invalid yEndPt: layer straight matTag numReinfBars reinfBarArea  yStartPt zStartPt yEndPt zEndPt\n";
01555          return TCL_ERROR;
01556       }
01557       //opserr << "\n\tyEndPt: " << yEndPt;
01558     
01559       if (Tcl_GetDouble(interp, argv[argi++], &zEndPt) != TCL_OK)
01560       {
01561          opserr <<  "WARNING invalid zEndPt: layer straight matTag numReinfBars reinfBarArea  yStartPt zStartPt yEndPt zEndPt\n";
01562          return TCL_ERROR;
01563       }
01564       
01565       //opserr << "\n\tzEndPt: " << zEndPt;
01566       
01567       // get section 
01568       secTag = currentSectionTag;
01569 
01570       SectionRepres *sectionRepres = theTclModelBuilder->getSectionRepres(secTag);
01571       if (sectionRepres == 0) 
01572       {
01573          opserr <<  "WARNING cannot retrieve section\n";
01574          return TCL_ERROR;
01575       }    
01576      
01577       if (sectionRepres->getType() != SEC_TAG_FiberSection)
01578       {
01579          opserr <<  "WARNING section invalid: patch can only be added to fiber sections\n";
01580          return TCL_ERROR;
01581       }
01582 
01583       FiberSectionRepr *fiberSectionRepr = (FiberSectionRepr *) sectionRepres;
01584  
01585       // create the reinforcing layer
01586 
01587       static Vector startPt(2);
01588       static Vector endPt(2);
01589 
01590       startPt(0)  = yStartPt;
01591       startPt(1)  = zStartPt;
01592       endPt(0) = yEndPt;
01593       endPt(1) = zEndPt;
01594 
01595       StraightReinfLayer *reinfLayer = new StraightReinfLayer (matTag,
01596                                                    numReinfBars, reinfBarArea,
01597                                                    startPt, endPt);
01598       if (!reinfLayer)
01599       {
01600          opserr <<  "WARNING cannot alocate reinfLayer\n";
01601          return TCL_ERROR;
01602       }
01603       //opserr << "\nStraigthReinfLayer: " << *reinfLayer;
01604 
01605       // add reinfLayer to section
01606       int error = fiberSectionRepr->addReinfLayer(*reinfLayer);
01607       delete reinfLayer;
01608       
01609       if (error)
01610       {
01611          opserr <<  "WARNING cannot add reinforcing layer to section\n";
01612          return TCL_ERROR;
01613       }
01614       
01615    }
01616    else if (strcmp(argv[1], "circ") == 0) 
01617    {
01618       if (argc < 8)
01619       {
01620          opserr <<  "WARNING invalid number of parameters: layer circ matTag numReinfBars reinfBarArea yCenter zCenter arcRadius <startAng endAng>\n";
01621          return TCL_ERROR;
01622       }
01623 
01624       int secTag, matTag, numReinfBars;
01625       double reinfBarArea;
01626       double yCenter, zCenter, radius, startAng, endAng;
01627      
01628       int argi;
01629 
01630       argi = 2;
01631       
01632       if (Tcl_GetInt(interp, argv[argi++], &matTag) != TCL_OK)
01633       {
01634          opserr <<  "WARNING invalid matTag: layer circ matTag numReinfBars reinfBarArea yCenter zCenter radius startAng endAng\n";
01635          return TCL_ERROR;
01636       }
01637       //opserr << "\n\tmatTag: " << matTag;
01638 
01639       if (Tcl_GetInt(interp, argv[argi++], &numReinfBars) != TCL_OK)
01640       {
01641          opserr <<  "WARNING invalid numReinfBars: layer circ matTag numReinfBars reinfBarArea yCenter zCenter radius startAng endAng\n";
01642          return TCL_ERROR;
01643       }
01644       //opserr << "\n\tnumReinfBars: " << numReinfBars;
01645 
01646       if (Tcl_GetDouble(interp, argv[argi++], &reinfBarArea) != TCL_OK)
01647       {
01648          opserr <<  "WARNING invalid reinfBarArea: layer circ matTag numReinfBars reinfBarArea yCenter zCenter radius startAng endAng\n";
01649          return TCL_ERROR;
01650       }
01651       //opserr << "\n\treinfBarArea: " << reinfBarArea;
01652 
01653       if (Tcl_GetDouble(interp, argv[argi++], &yCenter) != TCL_OK)
01654       {
01655          opserr <<  "WARNING invalid yCenter: layer circ matTag numReinfBars reinfBarArea yCenter zCenter radius startAng endAng\n";
01656          return TCL_ERROR;
01657       }
01658       //opserr << "\n\tyCenter: " << yCenter;
01659     
01660       if (Tcl_GetDouble(interp, argv[argi++], &zCenter) != TCL_OK)
01661       {
01662          opserr <<  "WARNING invalid zCenter: layer circ matTag numReinfBars reinfBarArea yCenter zCenter radius startAng endAng\n";
01663          return TCL_ERROR;
01664       }
01665       //opserr << "\n\tzCenter: " << zCenter;
01666        
01667       if (Tcl_GetDouble(interp, argv[argi++], &radius) != TCL_OK)
01668       {
01669          opserr <<  "WARNING invalid radius: layer circ matTag numReinfBars reinfBarArea yCenter zCenter radius startAng endAng\n";
01670          return TCL_ERROR;
01671       }
01672       //opserr << "\n\tradius: " << radius;
01673     
01674           bool anglesSpecified = false;
01675 
01676       if (argc > 9) {
01677                   if (Tcl_GetDouble(interp, argv[argi++], &startAng) != TCL_OK)
01678                   {
01679                          opserr <<  "WARNING invalid startAng: layer circ matTag numReinfBars reinfBarArea yCenter zCenter radius startAng endAng\n";
01680                          return TCL_ERROR;
01681                   }
01682                   //opserr << "\n\tstartAng: " << startAng;
01683 
01684                   if (Tcl_GetDouble(interp, argv[argi++], &endAng) != TCL_OK)
01685                   {
01686                          opserr <<  "WARNING invalid endAng: layer circ matTag numReinfBars reinfBarArea yCenter zCenter radius startAng endAng\n";
01687                          return TCL_ERROR;
01688                   }
01689                   //opserr << "\n\tendAng: " << endAng;
01690 
01691                   anglesSpecified = true;
01692           }
01693 
01694       // get section 
01695       secTag = currentSectionTag;
01696       
01697       SectionRepres *sectionRepres = theTclModelBuilder->getSectionRepres(secTag);
01698       if (sectionRepres == 0) 
01699       {
01700          opserr <<  "WARNING cannot retrieve section\n";
01701          return TCL_ERROR;
01702       }    
01703      
01704       if (sectionRepres->getType() != SEC_TAG_FiberSection)
01705       {
01706          opserr <<  "WARNING section invalid: patch can only be added to fiber sections\n";
01707          return TCL_ERROR;
01708       }
01709 
01710       FiberSectionRepr *fiberSectionRepr = (FiberSectionRepr *) sectionRepres;
01711  
01712       // create the reinforcing layer
01713 
01714       static Vector center(2);
01715 
01716       center(0) = yCenter; 
01717       center(1) = zCenter; 
01718 
01719       CircReinfLayer *reinfLayer = 0;
01720           if (anglesSpecified)
01721                   // Construct arc
01722                   reinfLayer = new CircReinfLayer (matTag, numReinfBars, reinfBarArea,
01723                         center, radius, startAng, endAng);
01724           else
01725                   // Construct circle
01726                   reinfLayer = new CircReinfLayer (matTag, numReinfBars, reinfBarArea,
01727                         center, radius);
01728 
01729       if (!reinfLayer)
01730       {
01731          opserr <<  "WARNING cannot alocate reinfLayer\n";
01732          return TCL_ERROR;
01733       }
01734       //opserr << "\nCircReinfLayer: " << *reinfLayer;
01735 
01736       // add reinfLayer to section
01737       int error = fiberSectionRepr->addReinfLayer(*reinfLayer);
01738       delete reinfLayer;
01739       
01740       if (error)
01741       {
01742          opserr <<  "WARNING cannot add reinforcing layer to section\n";
01743          return TCL_ERROR;
01744       }
01745       
01746    }
01747    else
01748    {
01749       opserr <<  "WARNING reinforcing layer type is not available\n";
01750       return TCL_ERROR;
01751    }
01752   
01753    return TCL_OK;
01754 }    
01755 
01756 
01757 
01758 // build the section
01759 int 
01760 buildSection(Tcl_Interp *interp, TclModelBuilder *theTclModelBuilder,
01761              int secTag, bool isTorsion, double GJ)
01762 {
01763    SectionRepres *sectionRepres = theTclModelBuilder->getSectionRepres(secTag);
01764    if (sectionRepres == 0) 
01765    {
01766       opserr <<  "WARNING cannot retrieve section\n";
01767       return TCL_ERROR;
01768    }    
01769      
01770    if (sectionRepres->getType() == SEC_TAG_FiberSection)
01771    {
01772       // build the section
01773   
01774       FiberSectionRepr *fiberSectionRepr = (FiberSectionRepr *) sectionRepres;
01775 
01776       int i, j, k;
01777       int numFibers;
01778       
01779       int numPatches;
01780       Patch **patch;
01781 
01782       int  numReinfLayers;
01783       ReinfLayer **reinfLayer;
01784 
01785       numPatches     = fiberSectionRepr->getNumPatches();
01786       patch          = fiberSectionRepr->getPatches();
01787       numReinfLayers = fiberSectionRepr->getNumReinfLayers();
01788       reinfLayer     = fiberSectionRepr->getReinfLayers(); 
01789 
01790       int numSectionRepresFibers = fiberSectionRepr->getNumFibers();
01791       Fiber **sectionRepresFibers = fiberSectionRepr->getFibers();
01792       
01793       numFibers = numSectionRepresFibers;
01794       for (i = 0; i < numPatches; i++)
01795          numFibers += patch[i]->getNumCells();
01796       
01797       for (i = 0; i < numReinfLayers; i++)
01798          numFibers += reinfLayer[i]->getNumReinfBars();
01799       
01800       //opserr << "\nnumFibers: " << numFibers;
01801       
01802       static Vector fiberPosition(2);
01803       int    matTag;
01804       
01805       ID     fibersMaterial(numFibers-numSectionRepresFibers);
01806       Matrix fibersPosition(2,numFibers-numSectionRepresFibers);
01807       Vector fibersArea(numFibers-numSectionRepresFibers);
01808 
01809       int  numCells;
01810       Cell **cell;
01811     
01812       k = 0;
01813       for (i = 0; i < numPatches; i++)
01814       {
01815          //opserr << "\nPatch :" << i;
01816       
01817          numCells   = patch[i]->getNumCells();
01818          matTag = patch[i]->getMaterialID();
01819 
01820          //opserr << "\nmatTag: " << matTag(k);
01821 
01822          cell = patch[i]->getCells();
01823 
01824          if (cell == 0)
01825          {
01826             opserr <<  "WARNING out of run to create fibers\n";
01827             return TCL_ERROR;
01828          }    
01829          
01830          //opserr << "\n\tnumCells :" << numCells;
01831       
01832          for (j = 0; j < numCells; j++)
01833          {
01834             fibersMaterial(k) = matTag;
01835             fibersArea(k)     = cell[j]->getArea();
01836             fiberPosition     = cell[j]->getCentroidPosition();
01837 
01838             fibersPosition(0,k) = fiberPosition(0);
01839             fibersPosition(1,k) = fiberPosition(1);
01840               
01841             k++;
01842          }
01843   
01844          for (j = 0; j < numCells; j++)
01845            delete cell[j];
01846   
01847          delete [] cell;
01848       }
01849          
01850       ReinfBar *reinfBar;
01851       int numReinfBars;
01852 
01853       for (i = 0; i < numReinfLayers; i++)
01854       {
01855          numReinfBars = reinfLayer[i]->getNumReinfBars();
01856          reinfBar     = reinfLayer[i]->getReinfBars();
01857          matTag  = reinfLayer[i]->getMaterialID();
01858    
01859          for (j = 0; j < numReinfBars; j++)
01860          {
01861             fibersMaterial(k) = matTag; 
01862             fibersArea(k)     = reinfBar[j].getArea();
01863             fiberPosition     = reinfBar[j].getPosition();
01864      
01865             fibersPosition(0,k) = fiberPosition(0);
01866             fibersPosition(1,k) = fiberPosition(1);
01867         
01868             k++;
01869          }
01870          delete [] reinfBar;
01871       }
01872 
01873       UniaxialMaterial *material;
01874       
01875       int NDM = theTclModelBuilder->getNDM();   // dimension of the structure (1d, 2d, or 3d)
01876 
01877 
01878       Fiber **fiber = new Fiber *[numFibers];
01879       if (fiber == 0) {
01880           opserr <<  "WARNING unable to allocate fibers \n";
01881           return TCL_ERROR;
01882       }          
01883       
01884       // copy the section repres fibers
01885       for (i=0; i<numSectionRepresFibers; i++)
01886           fiber[i] = sectionRepresFibers[i];
01887 
01888       // creates 2d section      
01889 
01890 
01891       if (NDM == 2)     
01892       {
01893          k = 0;
01894          for (i = numSectionRepresFibers; i < numFibers; i++)
01895          {    
01896             material = theTclModelBuilder->getUniaxialMaterial(fibersMaterial(k));
01897             if (material == 0)
01898             {
01899                opserr <<  "WARNING invalid material ID for patch\n";
01900                return TCL_ERROR;
01901             }   
01902             
01903             fiber[i] = new UniaxialFiber2d(k, *material, fibersArea(k), fibersPosition(0,k));
01904             if (!fiber[i]) 
01905             {
01906                opserr <<  "WARNING unable to allocate fiber \n";
01907                return TCL_ERROR;
01908             }    
01909    
01910             //opserr << *fiber[k];
01911             k++;
01912          }
01913         
01914          SectionForceDeformation *section = new FiberSection2d(secTag, numFibers, fiber);
01915          //SectionForceDeformation *section = new FiberSection(secTag, numFibers, fiber);
01916    
01917          // Delete fibers
01918          for (i = 0; i < numFibers; i++)
01919            delete fiber[i];
01920 
01921          if (section == 0)
01922          {
01923             opserr <<  "WARNING - cannot construct section\n";
01924             return TCL_ERROR;
01925          }
01926        
01927          if (theTclModelBuilder->addSection (*section) < 0)
01928          {
01929             opserr <<  "WARNING - cannot add section\n";
01930             return TCL_ERROR;
01931          }
01932 
01933         //opserr << "section: " << *section;
01934      
01935       }
01936       else if (NDM == 3)     
01937       {
01938 
01939          static Vector fiberPosition(2);
01940          k = 0;
01941          for (i = numSectionRepresFibers; i < numFibers; i++)
01942          {    
01943             material = theTclModelBuilder->getUniaxialMaterial(fibersMaterial(k));
01944             if (material == 0)
01945             {
01946                opserr <<  "WARNING invalid material ID for patch\n";
01947                return TCL_ERROR;
01948             }   
01949             
01950             fiberPosition(0) = fibersPosition(0,k);
01951             fiberPosition(1) = fibersPosition(1,k);
01952             
01953             fiber[i] = new UniaxialFiber3d(k, *material, fibersArea(k), fiberPosition);
01954             if (fibersArea(k) < 0) opserr << "ERROR: " << fiberPosition(0) << " " << fiberPosition(1) << endln;
01955             if (!fiber[k]) 
01956             {
01957                opserr <<  "WARNING unable to allocate fiber \n";
01958                return TCL_ERROR;
01959             }    
01960             k++;
01961             //opserr << *fiber[k];
01962          }
01963         
01964          //SectionForceDeformation *section = new FiberSection(secTag, numFibers, fiber);
01965          SectionForceDeformation *section = 0;
01966          if (isTorsion)
01967            section = new FiberSectionGJ(secTag, numFibers, fiber, GJ);
01968          else
01969            section = new FiberSection3d(secTag, numFibers, fiber);
01970    
01971          // Delete fibers
01972          for (i = 0; i < numFibers; i++)
01973            delete fiber[i];
01974 
01975          if (section == 0)
01976          {
01977             opserr <<  "WARNING - cannot construct section\n";
01978             return TCL_ERROR;
01979          }
01980        
01981          if (theTclModelBuilder->addSection (*section) < 0)
01982          {
01983             opserr <<  "WARNING - cannot add section\n";
01984             return TCL_ERROR;
01985          }
01986 
01987         //opserr << "section: " << *section;
01988        
01989       }
01990       else
01991       {
01992          opserr << "WARNING NDM = " << NDM << " is imcompatible with available frame elements\n";
01993          return TCL_ERROR;
01994       }
01995 
01996       // Delete fiber array
01997       delete [] fiber;
01998 
01999    }
02000    else 
02001    {
02002       opserr <<  "WARNING section invalid: can only build fiber sections\n";
02003       return TCL_ERROR;
02004    }    
02005 
02006    return TCL_OK;
02007 }
02008 
02009 
02010 
02011 
02012 int
02013 TclModelBuilder_addUCFiberSection (ClientData clientData, Tcl_Interp *interp, int argc,
02014                                    TCL_Char **argv, TclModelBuilder *theTclModelBuilder)
02015 {
02016     int secTag;
02017     
02018     if (argc < 4) 
02019         return TCL_ERROR;
02020     
02021     if (Tcl_GetInt(interp, argv[2], &secTag) != TCL_OK) {
02022       opserr <<  "could not read section tag\n";
02023       return TCL_ERROR;
02024     }
02025 
02026     currentSectionTag = secTag;
02027 
02028     // first create an empty FiberSection
02029     int NDM = theTclModelBuilder->getNDM();   // dimension of the structure (1d, 2d, or 3d)
02030 
02031     SectionForceDeformation *section = 0;
02032     FiberSection2d *section2d =0;
02033     FiberSection3d *section3d =0;
02034 
02035     if (NDM == 2) {
02036       section2d = new FiberSection2d(secTag, 0, 0);
02037       section = section2d;
02038       //SectionForceDeformation *section = new FiberSection(secTag, 0, 0);
02039     } else if (NDM == 3) {
02040       section3d = new FiberSection3d(secTag, 0, 0);
02041       section = section3d;
02042     } 
02043 
02044     if (section == 0) {
02045       return TCL_ERROR;
02046     }
02047 
02048     //
02049     // now parse the ouput file containing the fiber data, 
02050     // create fibers and add them to the section
02051     //
02052 
02053     // open the file
02054     TCL_Char *fileName = argv[3];
02055     ifstream theFile;
02056     theFile.open(fileName, ios::in);
02057     if (!theFile) {
02058       opserr << "section UCFiber - could not open file named " << fileName;
02059       return TCL_ERROR;
02060     } else {
02061       int foundStart = 0;
02062       static char garbage[100];
02063 
02064       // parse through until find start of fiber data
02065       while (foundStart == 0 && theFile >> garbage) 
02066         if (strcmp(garbage, "#FIBERS") == 0) 
02067           foundStart = 1;
02068 
02069       if (foundStart == 0) {
02070         theFile.close();
02071         return TCL_ERROR;
02072       }
02073 
02074       // parse the fiber data until eof, creating a fiber and adding to section as go
02075       double ycoord, zcoord, area, prestrain;
02076       int matTag;
02077       int fiberCount = 0;
02078       
02079       while (theFile >> ycoord >> zcoord >> area >> prestrain >> garbage >> matTag) {
02080 
02081         UniaxialMaterial *theMaterial = theTclModelBuilder->getUniaxialMaterial(matTag);
02082         if (theMaterial == 0) {
02083           opserr << "section UCFiber - no material exists with tag << " << matTag << endln;
02084           return TCL_ERROR;
02085         }
02086         
02087         Fiber *theFiber = 0;
02088         if (NDM == 2) {
02089           theFiber = new UniaxialFiber2d(fiberCount++, *theMaterial, area, zcoord);
02090           if (theFiber != 0) {
02091             section2d->addFiber(*theFiber);
02092             delete theFiber;
02093           }
02094         } else {
02095           static Vector pos(2);
02096           pos(0) = ycoord; pos(1) = zcoord;
02097           theFiber = new UniaxialFiber3d(fiberCount++, *theMaterial, area, pos);
02098           if (theFiber != 0) {
02099             section3d->addFiber(*theFiber);
02100             delete theFiber;
02101           }
02102         }   
02103       }
02104 
02105       // close the file
02106       theFile.close();
02107     }
02108 
02109     // finally add the section to our modelbuilder
02110     if (theTclModelBuilder->addSection (*section) < 0) {
02111       opserr <<  "WARNING - cannot add section\n";
02112       return TCL_ERROR;
02113     }
02114 
02115 
02116     return TCL_OK;
02117 }

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