GenericSection1d.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.7 $
00022 // $Date: 2006/09/05 21:31:56 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/material/section/GenericSection1d.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/material/GenericSection1d.C
00027 //
00028 // Written: MHS 
00029 // Created: Apr 2000
00030 // Revision: A
00031 //
00032 // Description: This file contains the class implementation for GenericSection1d.
00033 //
00034 // What: "@(#) GenericSection1d.C, revA"
00035 
00036 #include <GenericSection1d.h>
00037 #include <UniaxialMaterial.h>
00038 #include <Channel.h>
00039 #include <FEM_ObjectBroker.h>
00040 #include <Information.h>
00041 
00042 #include <Matrix.h>
00043 #include <Vector.h>
00044 #include <ID.h>
00045 
00046 #include <classTags.h>
00047 
00048 #include <string.h>
00049 
00050 Vector GenericSection1d::s(1);
00051 Matrix GenericSection1d::ks(1,1);
00052 ID GenericSection1d::c(1);
00053 
00054 GenericSection1d::GenericSection1d(int tag, UniaxialMaterial &m, int type)
00055 :SectionForceDeformation(tag,SEC_TAG_Generic1d), code(type)
00056 {
00057     theModel = m.getCopy();
00058 
00059     if (!theModel) {
00060       opserr << "GenericSection1d::GenericSection1d  -- failed to get copy of material model\n";
00061       exit(-1);
00062     }
00063 }
00064 
00065 GenericSection1d::GenericSection1d()
00066 :SectionForceDeformation(0,SEC_TAG_Generic1d), theModel(0), code(0)
00067 {
00068     
00069 }
00070 
00071 GenericSection1d::~GenericSection1d()
00072 {
00073     if (theModel)
00074                 delete theModel;
00075 }
00076 
00077 int
00078 GenericSection1d::setTrialSectionDeformation (const Vector& def)
00079 {
00080         return theModel->setTrialStrain(def(0));
00081 }
00082 
00083 const Vector&
00084 GenericSection1d::getSectionDeformation ()
00085 {
00086         static Vector e(1);     // static for class-wide returns
00087 
00088         e(0) = theModel->getStrain();
00089 
00090     return e;
00091 }
00092 
00093 const Vector&
00094 GenericSection1d::getStressResultant ()
00095 {
00096   s(0) = theModel->getStress();
00097 
00098   return s;
00099 }
00100 
00101 const Matrix&
00102 GenericSection1d::getSectionTangent ()
00103 {
00104   ks(0,0) = theModel->getTangent();
00105   
00106   return ks;
00107 }
00108 
00109 const Matrix&
00110 GenericSection1d::getInitialTangent ()
00111 {
00112   ks(0,0) = theModel->getInitialTangent();
00113   
00114   return ks;
00115 }
00116 
00117 const Matrix&
00118 GenericSection1d::getSectionFlexibility ()
00119 {
00120   double tangent = theModel->getTangent();
00121 
00122   if (tangent != 0.0)
00123     ks(0,0) = 1.0/tangent;
00124   else
00125     ks(0,0) = 1.0e12;
00126 
00127   return ks;
00128 }
00129 
00130 const Matrix&
00131 GenericSection1d::getInitialFlexibility ()
00132 {
00133   double tangent = theModel->getInitialTangent();
00134 
00135   ks(0,0) = 1.0/tangent;
00136 
00137   return ks;
00138 }
00139 
00140 int
00141 GenericSection1d::commitState ()
00142 {
00143     return theModel->commitState();
00144 }
00145 
00146 int
00147 GenericSection1d::revertToLastCommit ()
00148 {
00149     return theModel->revertToLastCommit();
00150 }
00151 
00152 int
00153 GenericSection1d::revertToStart ()
00154 {
00155     return theModel->revertToStart();
00156 }
00157 
00158 const ID&
00159 GenericSection1d::getType ()
00160 {
00161   c(0) = code;
00162 
00163   return c;
00164 }
00165 
00166 int
00167 GenericSection1d::getOrder () const
00168 {
00169     return 1;
00170 }
00171 
00172 SectionForceDeformation*
00173 GenericSection1d::getCopy ()
00174 {
00175     GenericSection1d *theCopy = new GenericSection1d (this->getTag(),
00176                                                       *theModel, code);
00177 
00178     return theCopy;
00179 }
00180 
00181 int
00182 GenericSection1d::sendSelf(int cTag, Channel &theChannel)
00183 {
00184     int res = 0;
00185 
00186         static ID data(4);
00187 
00188         data(0) = this->getTag();
00189         data(1) = code;
00190         data(2) = theModel->getClassTag();
00191 
00192         int dbTag = theModel->getDbTag();
00193 
00194         if (dbTag == 0) {
00195                 dbTag = theChannel.getDbTag();
00196                 if (dbTag != 0)
00197                         theModel->setDbTag(dbTag);
00198         }
00199 
00200         data(3) = dbTag;
00201 
00202         // Send the ID vector
00203         res += theChannel.sendID(this->getDbTag(), cTag, data);
00204         if (res < 0) {
00205           opserr << "GenericSection1d::sendSelf -- could not send ID\n";
00206           return res;
00207         }
00208     
00209         // Ask the UniaxialMaterial to send itself
00210         res += theModel->sendSelf(cTag, theChannel);
00211         if (res < 0) {
00212           opserr << "GenericSection1d::sendSelf -- could not send UniaxialMaterial\n";
00213           return res;
00214         }
00215 
00216     return res;
00217 }
00218 
00219 int
00220 GenericSection1d::recvSelf(int cTag, Channel &theChannel,
00221                                          FEM_ObjectBroker &theBroker)
00222 {
00223         int res = 0;
00224 
00225     static ID data(4);
00226 
00227     res += theChannel.recvID(this->getDbTag(), cTag, data);
00228         if (res < 0) {
00229           opserr << "GenericSection1d::recvSelf -- could not receive ID\n";
00230           return res;
00231         }
00232 
00233         this->setTag(data(0));
00234         code = data(1);
00235         int classTag = data(2);
00236 
00237         // Check if the material is null; if so, get a new one
00238         if (theModel == 0)
00239                 theModel = theBroker.getNewUniaxialMaterial(classTag);
00240 
00241         // Check that the material is of the right type; if not, delete
00242         // the current one and get a new one of the right type
00243         else if (theModel->getClassTag() != classTag) {
00244                 delete theModel;
00245                 theModel = theBroker.getNewUniaxialMaterial(classTag);
00246         }
00247 
00248         // Check if either allocation failed
00249         if (theModel == 0) {
00250           opserr << "GenericSection1d::recvSelf -- could not get a UniaxialMaterial\n";
00251           return -1;
00252         }
00253 
00254         // Now, receive the material
00255         theModel->setDbTag(data(3));
00256         res += theModel->recvSelf(cTag, theChannel, theBroker);
00257         if (res < 0) {
00258           opserr << "GenericSection1d::recvSelf -- could not receive UniaxialMaterial\n";
00259           return res;
00260         }
00261 
00262     return res;
00263 }
00264 
00265 void
00266 GenericSection1d::Print (OPS_Stream &s, int flag)
00267 {
00268     s << "GenericSection1d (Uniaxial), tag: " << this->getTag() << endln;
00269     s << "\tResponse code: " << code << endln;
00270     s << "\tUniaxialMaterial: " << theModel->getTag() << endln;
00271 }
00272 
00273 int
00274 GenericSection1d::setParameter(const char **argv, int argc, Parameter &param)
00275 {
00276   return theModel->setParameter(argv, argc, param);
00277 }
00278 
00279 const Vector&
00280 GenericSection1d::getStressResultantSensitivity(int gradNumber,
00281                                                 bool conditional)
00282 {
00283   static Vector dsdh(1);
00284 
00285   dsdh(0) = theModel->getStressSensitivity(gradNumber, conditional);
00286 
00287   return dsdh;
00288 }
00289 
00290 int
00291 GenericSection1d::commitSensitivity(const Vector &dedh, int gradNumber,
00292                                     int numGrads)
00293 {
00294   return theModel->commitSensitivity(dedh(0), gradNumber, numGrads);
00295 }

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