00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <UniformExcitation.h>
00035 #include <GroundMotion.h>
00036 #include <Domain.h>
00037 #include <NodeIter.h>
00038 #include <Node.h>
00039 #include <ElementIter.h>
00040 #include <Element.h>
00041 #include <Channel.h>
00042 #include <FEM_ObjectBroker.h>
00043
00044 UniformExcitation::UniformExcitation()
00045 :EarthquakePattern(0, PATTERN_TAG_UniformExcitation),
00046 theMotion(0), theDof(0), vel0(0.0)
00047 {
00048
00049 }
00050
00051
00052 UniformExcitation::UniformExcitation(GroundMotion &_theMotion,
00053 int dof, int tag, double velZero)
00054 :EarthquakePattern(tag, PATTERN_TAG_UniformExcitation),
00055 theMotion(&_theMotion), theDof(dof), vel0(velZero)
00056 {
00057
00058 this->addMotion(*theMotion);
00059 }
00060
00061
00062 UniformExcitation::~UniformExcitation()
00063 {
00064
00065 }
00066
00067
00068 void
00069 UniformExcitation::setDomain(Domain *theDomain)
00070 {
00071 this->LoadPattern::setDomain(theDomain);
00072
00073
00074 if (vel0 != 0.0) {
00075 NodeIter &theNodes = theDomain->getNodes();
00076 Node *theNode;
00077 Vector newVel(1);
00078 int currentSize = 1;
00079 while ((theNode = theNodes()) != 0) {
00080 int numDOF = theNode->getNumberDOF();
00081 if (numDOF != currentSize)
00082 newVel.resize(numDOF);
00083
00084 newVel = theNode->getVel();
00085 newVel(theDof) = vel0;
00086 theNode->setTrialVel(newVel);
00087 theNode->commitState();
00088 }
00089 }
00090 }
00091
00092 void
00093 UniformExcitation::applyLoad(double time)
00094 {
00095 Domain *theDomain = this->getDomain();
00096 if (theDomain == 0)
00097 return;
00098
00099
00100 NodeIter &theNodes = theDomain->getNodes();
00101 Node *theNode;
00102 while ((theNode = theNodes()) != 0) {
00103 theNode->setNumColR(1);
00104 theNode->setR(theDof, 0, 1.0);
00105 }
00106
00107
00108 this->EarthquakePattern::applyLoad(time);
00109
00110 return;
00111 }
00112
00113
00114 void
00115 UniformExcitation::applyLoadSensitivity(double time)
00116 {
00117 Domain *theDomain = this->getDomain();
00118 if (theDomain == 0)
00119 return;
00120
00121
00122 NodeIter &theNodes = theDomain->getNodes();
00123 Node *theNode;
00124 while ((theNode = theNodes()) != 0) {
00125 theNode->setNumColR(1);
00126 theNode->setR(theDof, 0, 1.0);
00127 }
00128
00129
00130 this->EarthquakePattern::applyLoadSensitivity(time);
00131
00132 return;
00133 }
00134
00135
00136
00137 int
00138 UniformExcitation::sendSelf(int commitTag, Channel &theChannel)
00139 {
00140 int dbTag = this->getDbTag();
00141
00142 static Vector data(5);
00143 data(0) = this->getTag();
00144 data(1) = theDof;
00145 data(2) = vel0;
00146 data(3) = theMotion->getClassTag();
00147
00148 int motionDbTag = theMotion->getDbTag();
00149 if (motionDbTag == 0) {
00150 motionDbTag = theChannel.getDbTag();
00151 theMotion->setDbTag(motionDbTag);
00152 }
00153 data(4) = motionDbTag;
00154
00155 int res = theChannel.sendVector(dbTag, commitTag, data);
00156 if (res < 0) {
00157 opserr << "UniformExcitation::sendSelf() - channel failed to send data\n";
00158 return res;
00159 }
00160
00161 res = theMotion->sendSelf(commitTag, theChannel);
00162 if (res < 0) {
00163 opserr << "UniformExcitation::sendSelf() - ground motion to send self\n";
00164 return res;
00165 }
00166
00167 return 0;
00168 }
00169
00170
00171 int
00172 UniformExcitation::recvSelf(int commitTag, Channel &theChannel,
00173 FEM_ObjectBroker &theBroker)
00174 {
00175 int dbTag = this->getDbTag();
00176
00177 static Vector data(5);
00178 int res = theChannel.recvVector(dbTag, commitTag, data);
00179 if (res < 0) {
00180 opserr << "UniformExcitation::recvSelf() - channel failed to recv data\n";
00181 return res;
00182 }
00183
00184 this->setTag(data(0));
00185 theDof = data(1);
00186 vel0 = data(2);
00187 int motionClassTag = data(3);
00188 int motionDbTag = data(4);
00189
00190 if (theMotion == 0 || theMotion->getClassTag() != motionClassTag) {
00191 if (theMotion != 0)
00192 delete theMotion;
00193 theMotion = theBroker.getNewGroundMotion(motionClassTag);
00194 if (theMotion == 0) {
00195 opserr << "UniformExcitation::recvSelf() - could not create a grond motion\n";
00196 return -3;
00197 }
00198
00199
00200 if (numMotions == 0)
00201 this->addMotion(*theMotion);
00202 else
00203 theMotions[0] = theMotion;
00204 }
00205
00206 theMotion->setDbTag(motionDbTag);
00207 res = theMotion->recvSelf(commitTag, theChannel, theBroker);
00208 if (res < 0) {
00209 opserr << "UniformExcitation::recvSelf() - motion could not receive itself \n";
00210 return res;
00211 }
00212
00213 return 0;
00214 }
00215
00216
00217 void
00218 UniformExcitation::Print(OPS_Stream &s, int flag)
00219 {
00220 s << "UniformExcitation " << this->getTag() << " - Not Printing the GroundMotion\n";
00221 }
00222
00223 LoadPattern *
00224 UniformExcitation::getCopy(void)
00225 {
00226 LoadPattern *theCopy = new UniformExcitation(*theMotion, theDof, this->getTag());
00227 return theCopy;
00228 }
00229