Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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.1.1.1 $
00022 // $Date: 2000/09/15 08:23:22 $
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 <G3Globals.h>
00047 #include <classTags.h>
00048 
00049 #include <string.h>
00050 
00051 GenericSection1d::GenericSection1d(int tag, UniaxialMaterial &m, int c)
00052 :SectionForceDeformation(tag,SEC_TAG_Generic1d), code(c)
00053 {
00054     theModel = m.getCopy();
00055 
00056     if (!theModel) {
00057   g3ErrorHandler->fatal("%s -- failed to get copy of material model",
00058    "GenericSection1d::GenericSection1d");
00059     }
00060 }
00061 
00062 GenericSection1d::GenericSection1d()
00063 :SectionForceDeformation(0,SEC_TAG_Generic1d), theModel(0), code(0)
00064 {
00065     
00066 }
00067 
00068 GenericSection1d::~GenericSection1d()
00069 {
00070     if (theModel)
00071   delete theModel;
00072 }
00073 
00074 int
00075 GenericSection1d::setTrialSectionDeformation (const Vector& def)
00076 {
00077  return theModel->setTrialStrain(def(0));
00078 }
00079 
00080 const Vector&
00081 GenericSection1d::getSectionDeformation ()
00082 {
00083  static Vector e(1); // static for class-wide returns
00084 
00085  e(0) = theModel->getStrain();
00086 
00087     return e;
00088 }
00089 
00090 const Vector&
00091 GenericSection1d::getStressResultant ()
00092 {
00093  static Vector s(1); // static for class-wide returns
00094 
00095     s(0) = theModel->getStress();
00096 
00097     return s;
00098 }
00099 
00100 const Matrix&
00101 GenericSection1d::getSectionTangent ()
00102 {
00103  static Matrix k(1,1); // static for class-wide returns
00104 
00105     k(0,0) = theModel->getTangent();
00106 
00107     return k;
00108 }
00109 
00110 const Matrix&
00111 GenericSection1d::getSectionFlexibility ()
00112 {
00113  static Matrix f(1,1); // static for class-wide returns
00114 
00115     double tangent = theModel->getTangent();
00116 
00117     if (tangent != 0.0)
00118   f(0,0) = 1.0/tangent;
00119  else
00120   f(0,0) = 1.0e12;
00121 
00122     return f;
00123 }
00124 
00125 int
00126 GenericSection1d::commitState ()
00127 {
00128     return theModel->commitState();
00129 }
00130 
00131 int
00132 GenericSection1d::revertToLastCommit ()
00133 {
00134     return theModel->revertToLastCommit();
00135 }
00136 
00137 int
00138 GenericSection1d::revertToStart ()
00139 {
00140     return theModel->revertToStart();
00141 }
00142 
00143 const ID&
00144 GenericSection1d::getType () const
00145 {
00146  static ID c(1); // static for class-wide returns
00147 
00148  c(0) = code;
00149 
00150     return c;
00151 }
00152 
00153 int
00154 GenericSection1d::getOrder () const
00155 {
00156     return 1;
00157 }
00158 
00159 SectionForceDeformation*
00160 GenericSection1d::getCopy ()
00161 {
00162     GenericSection1d *theCopy = new GenericSection1d (this->getTag(),
00163             *theModel, code);
00164 
00165     return theCopy;
00166 }
00167 
00168 int
00169 GenericSection1d::sendSelf(int cTag, Channel &theChannel)
00170 {
00171     int res = 0;
00172 
00173  static ID data(4);
00174 
00175  data(0) = this->getTag();
00176  data(1) = code;
00177  data(2) = theModel->getClassTag();
00178 
00179  int dbTag = theModel->getDbTag();
00180 
00181  if (dbTag == 0) {
00182   dbTag = theChannel.getDbTag();
00183   if (dbTag != 0)
00184    theModel->setDbTag(dbTag);
00185  }
00186 
00187  data(3) = dbTag;
00188 
00189  // Send the ID vector
00190  res += theChannel.sendID(this->getDbTag(), cTag, data);
00191  if (res < 0) {
00192   g3ErrorHandler->warning("%s -- could not send ID",
00193    "GenericSection1d::sendSelf");
00194   return res;
00195  }
00196     
00197  // Ask the UniaxialMaterial to send itself
00198  res += theModel->sendSelf(cTag, theChannel);
00199  if (res < 0) {
00200   g3ErrorHandler->warning("%s -- could not send UniaxialMaterial",
00201    "GenericSection1d::sendSelf");
00202   return res;
00203  }
00204 
00205     return res;
00206 }
00207 
00208 int
00209 GenericSection1d::recvSelf(int cTag, Channel &theChannel,
00210       FEM_ObjectBroker &theBroker)
00211 {
00212  int res = 0;
00213 
00214     static ID data(4);
00215 
00216     res += theChannel.recvID(this->getDbTag(), cTag, data);
00217  if (res < 0) {
00218   g3ErrorHandler->warning("%s -- could not receive ID",
00219    "GenericSection1d::recvSelf");
00220   return res;
00221  }
00222 
00223  this->setTag(data(0));
00224  code = data(1);
00225  int classTag = data(2);
00226 
00227  // Check if the material is null; if so, get a new one
00228  if (theModel == 0)
00229   theModel = theBroker.getNewUniaxialMaterial(classTag);
00230 
00231  // Check that the material is of the right type; if not, delete
00232  // the current one and get a new one of the right type
00233  else if (theModel->getClassTag() != classTag) {
00234   delete theModel;
00235   theModel = theBroker.getNewUniaxialMaterial(classTag);
00236  }
00237 
00238  // Check if either allocation failed
00239  if (theModel == 0) {
00240   g3ErrorHandler->warning("%s -- could not get a UniaxialMaterial",
00241    "GenericSection1d::recvSelf");
00242   return -1;
00243  }
00244 
00245  // Now, receive the material
00246  theModel->setDbTag(data(3));
00247  res += theModel->recvSelf(cTag, theChannel, theBroker);
00248  if (res < 0) {
00249   g3ErrorHandler->warning("%s -- could not receive UniaxialMaterial",
00250    "GenericSection1d::recvSelf");
00251   return res;
00252  }
00253 
00254     return res;
00255 }
00256 
00257 void
00258 GenericSection1d::Print (ostream &s, int flag)
00259 {
00260     s << "GenericSection1d, tag: " << this->getTag() << endl;
00261     s << "\tResponse code: " << code << endl;
00262 }
Copyright Contact Us