Beam2dUniformLoad.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.6 $
00022 // $Date: 2006/09/05 23:08:00 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/load/Beam2dUniformLoad.cpp,v $
00024                                                                         
00025 
00026 // Written: fmk 
00027 //
00028 // Purpose: This file contains the class implementation of Beam2dUniformLoad.
00029 
00030 #include <Beam2dUniformLoad.h>
00031 #include <Vector.h>
00032 #include <Channel.h>
00033 #include <FEM_ObjectBroker.h>
00034 #include <Information.h>
00035 #include <Parameter.h>
00036 
00037 Vector Beam2dUniformLoad::data(2);
00038 
00039 Beam2dUniformLoad::Beam2dUniformLoad(int tag, double wt, double wa,
00040                                      const ID &theElementTags)
00041   :ElementalLoad(tag, LOAD_TAG_Beam2dUniformLoad, theElementTags),
00042    wTrans(wt), wAxial(wa), parameterID(0)
00043 {
00044 
00045 }
00046 
00047 Beam2dUniformLoad::Beam2dUniformLoad()
00048   :ElementalLoad(LOAD_TAG_Beam2dUniformLoad),
00049    wTrans(0.0), wAxial(0.0), parameterID(0)
00050 {
00051 
00052 }
00053 
00054 Beam2dUniformLoad::~Beam2dUniformLoad()
00055 {
00056 
00057 }
00058 
00059 const Vector &
00060 Beam2dUniformLoad::getData(int &type, double loadFactor)
00061 {
00062   type = LOAD_TAG_Beam2dUniformLoad;
00063   data(0) = wTrans;
00064   data(1) = wAxial;
00065   return data;
00066 }
00067 
00068 
00069 int 
00070 Beam2dUniformLoad::sendSelf(int commitTag, Channel &theChannel)
00071 {
00072   int dbTag = this->getDbTag();
00073   const ID &theElements = this->getElementTags();
00074 
00075   static Vector vectData(3);
00076   vectData(0) = wTrans;
00077   vectData(1) = wAxial;
00078   vectData(2) = theElements.Size();
00079 
00080   int result = theChannel.sendVector(dbTag, commitTag, vectData);
00081   if (result < 0) {
00082     opserr << "Beam2dUniformLoad::sendSelf - failed to send data\n";
00083     return result;
00084   }
00085 
00086   result = theChannel.sendID(dbTag, commitTag, theElements);
00087   if (result < 0) {
00088     opserr << "Beam2dUniformLoad::sendSelf - failed to send element tags\n";
00089     return result;
00090   }
00091   
00092   return 0;
00093 }
00094 
00095 int 
00096 Beam2dUniformLoad::recvSelf(int commitTag, Channel &theChannel,  FEM_ObjectBroker &theBroker)
00097 {
00098   int dbTag = this->getDbTag();
00099 
00100   static Vector vectData(3);
00101 
00102   int result = theChannel.recvVector(dbTag, commitTag, vectData);
00103   if (result < 0) {
00104     opserr << "Beam2dUniformLoad::sendSelf - failed to send data\n";
00105     return result;
00106   }
00107 
00108   wTrans = vectData(0);;
00109   wAxial = vectData(1);;
00110   int numEle = vectData(2);
00111 
00112   if (theElementTags == 0 || theElementTags->Size() != numEle) {
00113     if (theElementTags != 0)
00114       delete theElementTags;
00115     theElementTags = new ID(numEle);
00116     if (theElementTags == 0) {
00117       opserr << "Beam2dUniformLoad::sendSelf - failed to create an ID\n";
00118       return -3;
00119     }
00120   }
00121 
00122   result = theChannel.recvID(dbTag, commitTag, *theElementTags);
00123   if (result < 0) {
00124     opserr << "Beam2dUniformLoad::sendSelf - failed to send element tags\n";
00125     return result;
00126   }
00127   
00128   return 0;
00129 }
00130 
00131 void 
00132 Beam2dUniformLoad::Print(OPS_Stream &s, int flag)
00133 {
00134   s << "Beam2dUniformLoad - Reference load" << endln;
00135   s << "  Transverse: " << wTrans << endln;
00136   s << "  Axial:      " << wAxial << endln;
00137   s << "  Elements acted on: " << this->getElementTags();
00138 }
00139 
00140 int
00141 Beam2dUniformLoad::setParameter(const char **argv, int argc, Parameter &param)
00142 {
00143   if (argc < 1)
00144     return -1;
00145   
00146   if (strcmp(argv[0],"wTrans") == 0 || strcmp(argv[0],"wy") == 0)
00147     return param.addObject(1, this);
00148 
00149   if (strcmp(argv[0],"wAxial") == 0 || strcmp(argv[0],"wx") == 0)
00150     return param.addObject(2, this);
00151 
00152   return -1;
00153 }
00154 
00155 int
00156 Beam2dUniformLoad::updateParameter(int parameterID, Information &info)
00157 {
00158   switch (parameterID) {
00159   case 1:
00160     wTrans = info.theDouble;
00161     return 0;
00162   case 2:
00163     wAxial = info.theDouble;
00164     return 0;
00165   default:
00166     return -1;
00167   }
00168 }
00169 
00170 int
00171 Beam2dUniformLoad::activateParameter(int paramID)
00172 {
00173   parameterID = paramID;
00174 
00175   return 0;
00176 }
00177 
00178 const Vector&
00179 Beam2dUniformLoad::getSensitivityData(int gradNumber)
00180 {
00181   data.Zero();
00182 
00183   switch(parameterID) {
00184   case 1:
00185     data(0) = 1.0;
00186     break;
00187   case 2:
00188     data(1) = 1.0;
00189     break;
00190   default:
00191     break;
00192   }
00193 
00194   return data;
00195 }

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