UniaxialFiber3d.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.8 $
00022 // $Date: 2006/08/04 18:32:01 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/material/section/fiber/UniaxialFiber3d.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/section/UniaxialFiber3d.C
00027 //
00028 // Written: Remo Magalhaes de Souza
00029 // Created: 10/98
00030 // Revision: 
00031 //
00032 // Description: This file contains the implementation for the
00033 // UniaxialFiber3d class. UniaxialFiber3d provides the abstraction of a
00034 // uniaxial fiber that forms a fiber section for 3d frame elements.
00035 // The UniaxialFiber3d is subjected to a stress state with
00036 // only one nonzero axial stress and corresponding axial strain.
00037 //
00038 // What: "@(#) UniaxialFiber3d.C, revA"
00039 
00040 #include <stdlib.h>
00041 #include <stdio.h>
00042 
00043 #include <UniaxialMaterial.h>
00044 #include <UniaxialFiber3d.h>
00045 #include <Vector.h>
00046 #include <Channel.h>
00047 #include <FEM_ObjectBroker.h>
00048 #include <ID.h>
00049 #include <SectionForceDeformation.h>
00050 #include <Information.h>
00051 #include <FiberResponse.h>
00052 
00053 Matrix UniaxialFiber3d::ks(3,3); 
00054 Vector UniaxialFiber3d::fs(3); 
00055 ID UniaxialFiber3d::code(3); 
00056 
00057 // constructor:
00058 UniaxialFiber3d::UniaxialFiber3d()
00059 :Fiber(0, FIBER_TAG_Uniaxial3d),
00060  theMaterial(0), area(0.0)
00061 {
00062         if (code(0) != SECTION_RESPONSE_P) {
00063                 code(0) = SECTION_RESPONSE_P;
00064                 code(1) = SECTION_RESPONSE_MZ;
00065                 code(2) = SECTION_RESPONSE_MY;
00066         }
00067 
00068    as[0] = 0.0;
00069    as[1] = 0.0;
00070 }
00071 
00072 UniaxialFiber3d::UniaxialFiber3d(int tag, 
00073                                  UniaxialMaterial &theMat,
00074                                  double Area, const Vector &position)
00075 :Fiber(tag, FIBER_TAG_Uniaxial3d),
00076  theMaterial(0), area(Area)
00077 {
00078         theMaterial = theMat.getCopy();  // get a copy of the MaterialModel
00079 
00080         if (theMaterial == 0) {
00081           opserr << "UniaxialFiber3d::UniaxialFiber2d -- failed to get copy of UniaxialMaterial\n";
00082           exit(-1);
00083         }
00084         
00085         if (code(0) != SECTION_RESPONSE_P) {
00086                 code(0) = SECTION_RESPONSE_P;
00087                 code(1) = SECTION_RESPONSE_MZ;
00088                 code(2) = SECTION_RESPONSE_MY;
00089         }
00090 
00091         as[0] = -position(0);
00092         as[1] =  position(1);
00093 }
00094 
00095 // destructor:
00096 UniaxialFiber3d::~UniaxialFiber3d ()
00097 {
00098    if (theMaterial != 0)
00099       delete theMaterial;
00100 }
00101 
00102 
00103 int   
00104 UniaxialFiber3d::setTrialFiberStrain(const Vector &vs)
00105 {
00106   double strain = vs(0) + as[0]*vs(1) + as[1]*vs(2);
00107 
00108   if (theMaterial != 0)
00109       return theMaterial->setTrialStrain(strain);
00110   else {
00111     opserr << "UniaxialFiber3d::setTrialFiberStrain() - no material!\n";
00112     return -1; // in case fatal does not exit
00113   }
00114 }
00115 
00116 
00117 
00118 // get fiber stress resultants 
00119 Vector &
00120 UniaxialFiber3d::getFiberStressResultants (void)
00121 {
00122     double df = theMaterial->getStress() * area;
00123 
00124     // fs = as^ df;
00125     fs(0) = df;
00126     fs(1) = as[0]*df;
00127     fs(2) = as[1]*df;
00128 
00129     return fs;
00130 }
00131 
00132 
00133 
00134 // get contribution of fiber to section tangent stiffness
00135 Matrix &
00136 UniaxialFiber3d::getFiberTangentStiffContr(void) 
00137 {
00138     // ks = (as^as) * area * Et;
00139     double value = theMaterial->getTangent() * area;
00140 
00141     double as1 = as[0];
00142     double as2 = as[1];
00143     double vas1 = as1*value;
00144     double vas2 = as2*value;
00145     double vas1as2 = vas1*as2;
00146 
00147     ks(0,0) = value;
00148     ks(0,1) = vas1;
00149     ks(0,2) = vas2;
00150     
00151     ks(1,0) = vas1;
00152     ks(1,1) = vas1*as1;
00153     ks(1,2) = vas1as2;
00154     
00155     ks(2,0) = vas2;
00156     ks(2,1) = vas1as2;
00157     ks(2,2) = vas2*as2;
00158 
00159     return ks;
00160 }
00161 
00162 Fiber*
00163 UniaxialFiber3d::getCopy (void)
00164 {
00165    // make a copy of the fiber 
00166    static Vector position(2);
00167 
00168    position(0) = -as[0];
00169    position(1) =  as[1];
00170 
00171    UniaxialFiber3d *theCopy = new UniaxialFiber3d (this->getTag(), 
00172                                                    *theMaterial, area, 
00173                                                    position);
00174    return theCopy;
00175 }  
00176 
00177 int
00178 UniaxialFiber3d::getOrder(void)
00179 {
00180         return 3;
00181 }
00182 
00183 const ID&
00184 UniaxialFiber3d::getType(void)
00185 {
00186         return code;
00187 }
00188 
00189 int   
00190 UniaxialFiber3d::commitState(void)
00191 {
00192    return theMaterial->commitState();
00193 }
00194 
00195 
00196 int   
00197 UniaxialFiber3d::revertToLastCommit(void)
00198 {
00199    return theMaterial->revertToLastCommit();
00200 }
00201 
00202 int   
00203 UniaxialFiber3d::revertToStart(void)
00204 {
00205    return theMaterial->revertToStart();
00206 }
00207 
00208 
00209 int   
00210 UniaxialFiber3d::sendSelf(int commitTag, Channel &theChannel)
00211 {
00212     // 
00213     // store tag and material info in an ID and send it
00214     //
00215 
00216     static ID idData(3);
00217     int dbTag = this->getDbTag();
00218     idData(0) = this->getTag();
00219     idData(1) = theMaterial->getClassTag();
00220     int matDbTag = theMaterial->getDbTag();
00221     if (matDbTag == 0) {
00222         matDbTag = theChannel.getDbTag();
00223         if (matDbTag != 0)
00224             theMaterial->setDbTag(matDbTag);
00225     }
00226     idData(2) = matDbTag;
00227     
00228     if (theChannel.sendID(dbTag, commitTag, idData) < 0)  {
00229         opserr << "UniaxialFiber3d::sendSelf() -  failed to send ID data\n";
00230         return -1;
00231     }    
00232     
00233     // 
00234     // store area and position data in a vector and send it
00235     //
00236     
00237     static Vector dData(3);
00238     dData(0) = area;
00239     dData(1) = as[0];
00240     dData(2) = as[1];
00241     if (theChannel.sendVector(dbTag, commitTag, dData) < 0)  {
00242       opserr << "UniaxialFiber3d::sendSelf() -  failed to send Vector data\n";
00243       return -2;
00244     }    
00245 
00246     // now invoke sendSelf on the material
00247     if (theMaterial->sendSelf(commitTag, theChannel) < 0) {
00248       opserr << "UniaxialFiber3d::sendSelf() -  the material failed in sendSelf()\n";
00249       return -3;
00250     }           
00251     
00252     return 0;
00253 }
00254 
00255 
00256 int   
00257 UniaxialFiber3d::recvSelf(int commitTag, Channel &theChannel, 
00258                           FEM_ObjectBroker &theBroker)
00259 {
00260     // 
00261     // get tag and material info from an ID
00262     //
00263 
00264     static ID idData(3);
00265     int dbTag = this->getDbTag();
00266     
00267     if (theChannel.recvID(dbTag, commitTag, idData) < 0)  {
00268         opserr << "UniaxialFiber3d::recvSelf() -  failed to recv ID data\n";
00269         return -1;
00270     }    
00271 
00272     this->setTag(idData(0));
00273 
00274     // 
00275     // get area and position datafrom a vector
00276     //
00277     
00278     static Vector dData(3);
00279     if (theChannel.recvVector(dbTag, commitTag, dData) < 0)  {
00280       opserr << "UniaxialFiber3d::recvSelf() -  failed to recv Vector data\n";
00281         return -2;
00282     }        
00283     area = dData(0);
00284     as[0] = dData(1);
00285     as[1] = dData(2);
00286 
00287     //
00288     // now we do the material stuff
00289     //
00290     
00291     int matClassTag = idData(1);    
00292     
00293     // if we have a material, check it is of correct type
00294     if (theMaterial != 0) {
00295         if (matClassTag != theMaterial->getClassTag()) {
00296             delete theMaterial;
00297             theMaterial = 0;
00298         } 
00299     }
00300 
00301     // if no material we need to get one,
00302     // NOTE: not an else if in case deleted in if above
00303     if (theMaterial == 0) {
00304         theMaterial = theBroker.getNewUniaxialMaterial(matClassTag);
00305         if (theMaterial == 0) {
00306           opserr << "UniaxialFiber3d::recvSelf() - " << 
00307             "failed to get a UniaxialMaterial of type "<< matClassTag << endln;
00308             return -3;
00309         }
00310     }
00311 
00312     // set the materials dbTag and invoke recvSelf on the material
00313     theMaterial->setDbTag(idData(2));
00314 
00315     // now invoke recvSelf on the material
00316     if (theMaterial->recvSelf(commitTag, theChannel, theBroker) < 0) {
00317       opserr << "UniaxialFiber3d::recvSelf() -  the material failed in recvSelf()\n";
00318         return -4;
00319     }           
00320 
00321     return 0;
00322 }
00323 
00324 
00325 void UniaxialFiber3d::Print(OPS_Stream &s, int flag)
00326 {
00327     s << "\nUniaxialFiber3d, tag: " << this->getTag() << endln;
00328     s << "\tArea: " << area << endln; 
00329     s << "\tMatrix as: " << 1.0 << " " << as[0] << " " << as[1] << endln; 
00330     s << "\tMaterial, tag: " << theMaterial->getTag() << endln;
00331 }
00332 
00333 Response*
00334 UniaxialFiber3d::setResponse(const char **argv, int argc, Information &info, OPS_Stream &s)
00335 {
00336         if (argc == 0)
00337                 return 0;
00338 
00339         if (strcmp(argv[0],"force") == 0 || strcmp(argv[0],"forces") == 0)              
00340                 return new FiberResponse(this, 1, Vector(3));
00341 
00342         else
00343           return theMaterial->setResponse(argv, argc, info, s);
00344 }
00345 
00346 int
00347 UniaxialFiber3d::getResponse(int responseID, Information &fibInfo)
00348 {
00349         switch(responseID) {
00350                 case 1:
00351                         return fibInfo.setVector(this->getFiberStressResultants());
00352 
00353                 default:
00354                         return -1;
00355         }
00356 }
00357 
00358 void 
00359 UniaxialFiber3d::getFiberLocation(double &yLoc, double &zLoc)
00360 {
00361         yLoc = -as[0];
00362         zLoc = as[1];
00363 }

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