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

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