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 #include <NodalLoad.h>
00033 #include <stdlib.h>
00034 #include <Domain.h>
00035 #include <Channel.h>
00036 #include <Information.h>
00037 #include <Parameter.h>
00038
00039
00040 Vector NodalLoad::gradientVector(1);
00041
00042
00043 NodalLoad::NodalLoad(int theClasTag)
00044 :Load(0,theClasTag),
00045 myNode(0), myNodePtr(0), load(0), konstant(false)
00046 {
00047
00048
00049 parameterID = 0;
00050
00051 }
00052
00053 NodalLoad::NodalLoad(int tag, int node, int theClassTag)
00054 :Load(tag,theClassTag),
00055 myNode(node), myNodePtr(0), load(0), konstant(false)
00056 {
00057
00058 parameterID = 0;
00059
00060 }
00061
00062 NodalLoad::NodalLoad(int tag, int node, const Vector &theLoad, bool isLoadConstant)
00063 :Load(tag, LOAD_TAG_NodalLoad),
00064 myNode(node), myNodePtr(0), load(0), konstant(isLoadConstant)
00065 {
00066 load = new Vector(theLoad);
00067
00068 if (load == 0) {
00069 opserr << "FATAL NodalLoad::NodalLoad(int node, const Vector &theLoad) -";
00070 opserr << " ran out of memory for load on Node " << node << endln;
00071 exit(-1);
00072 }
00073
00074 parameterID = 0;
00075
00076 }
00077
00078
00079
00080
00081
00082 NodalLoad::~NodalLoad()
00083 {
00084 if (load != 0)
00085 delete load;
00086 }
00087
00088 void
00089 NodalLoad::setDomain(Domain *newDomain)
00090 {
00091
00092 if (newDomain == 0)
00093 return;
00094
00095
00096 this->DomainComponent::setDomain(newDomain);
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 }
00112
00113 int
00114 NodalLoad::getNodeTag(void) const
00115 {
00116 return myNode;
00117 }
00118
00119
00120 void
00121 NodalLoad::applyLoad(double loadFactor)
00122 {
00123 if (myNodePtr == 0) {
00124 Domain *theDomain=this->getDomain();
00125 if ((theDomain == 0) ||
00126 (myNodePtr = theDomain->getNode(myNode)) == 0) {
00127 opserr << "WARNING NodalLoad::applyLoad() - No associated Node node " ;
00128 opserr << " for NodalLoad " << *this;
00129 return;
00130 }
00131 }
00132
00133
00134 if (konstant == false)
00135 myNodePtr->addUnbalancedLoad(*load,loadFactor);
00136 else
00137 myNodePtr->addUnbalancedLoad(*load,1.0);
00138
00139
00140 }
00141
00142
00143
00144 int
00145 NodalLoad::sendSelf(int cTag, Channel &theChannel)
00146 {
00147 int dataTag = this->getDbTag();
00148 ID data(5);
00149 data(0) = this->getTag();
00150 data(1) = myNode;
00151 if (load != 0)
00152 data(2) = load->Size();
00153 else
00154 data(2) = 0;
00155 data(3) = konstant;
00156 data(4) = this->getLoadPatternTag();
00157
00158 int result = theChannel.sendID(dataTag, cTag, data);
00159 if (result < 0) {
00160 opserr << "NodalLoad::sendSelf - failed to send data\n";
00161 return result;
00162 }
00163
00164 if (load != 0){
00165 int result = theChannel.sendVector(dataTag, cTag, *load);
00166 if (result < 0) {
00167 opserr << "NodalLoad::sendSelf - failed to Load data\n";
00168 return result;
00169 }
00170 }
00171
00172 return 0;
00173 }
00174
00175 int
00176 NodalLoad::recvSelf(int cTag, Channel &theChannel,
00177 FEM_ObjectBroker &theBroker)
00178 {
00179 int result;
00180 int dataTag = this->getDbTag();
00181 ID data(5);
00182 result = theChannel.recvID(dataTag, cTag, data);
00183 if (result < 0) {
00184 opserr << "NodalLoad::recvSelf() - failed to recv data\n";
00185 return result;
00186 }
00187 this->setTag(data(0));
00188 myNode = data(1);
00189 int loadSize = data(2);
00190 konstant = data(3);
00191 this->setLoadPatternTag(data(4));
00192 if (loadSize != 0) {
00193 load = new Vector(data(2));
00194 result = theChannel.recvVector(dataTag, cTag, *load);
00195 if (result < 0) {
00196 opserr << "NodalLoad::recvSelf() - failed to recv load\n";
00197 return result;
00198 }
00199 }
00200
00201 return 0;
00202 }
00203
00204
00205 void
00206 NodalLoad::Print(OPS_Stream &s, int flag)
00207 {
00208 s << "Nodal Load: " << myNode;
00209 if (load != 0)
00210 s << " load : " << *load;
00211 }
00212
00213
00214
00215 int
00216 NodalLoad::setParameter(const char **argv, int argc, Parameter ¶m)
00217 {
00218 if (argc < 1)
00219 return -1;
00220
00221 if (strcmp(argv[0],"1") == 0)
00222 return param.addObject(1, this);
00223
00224 if (strcmp(argv[0],"2") == 0)
00225 return param.addObject(2, this);
00226
00227 if (strcmp(argv[0],"3") == 0)
00228 return param.addObject(3, this);
00229
00230 return -1;
00231 }
00232
00233 int
00234 NodalLoad::updateParameter(int parameterID, Information &info)
00235 {
00236 switch (parameterID) {
00237 case -1:
00238 return -1;
00239 case 1:
00240 (*load)(0) = info.theDouble;
00241 return 0;
00242 case 2:
00243 (*load)(1) = info.theDouble;
00244 return 0;
00245 case 3:
00246 (*load)(2) = info.theDouble;
00247 return 0;
00248 default:
00249 return -1;
00250 }
00251 }
00252
00253
00254 int
00255 NodalLoad::activateParameter(int passedParameterID)
00256 {
00257 parameterID = passedParameterID;
00258
00259 return 0;
00260 }
00261
00262
00263 const Vector &
00264 NodalLoad::getExternalForceSensitivity(int gradNumber)
00265 {
00266 gradientVector(0) = (double)parameterID;
00267
00268 return gradientVector;
00269 }
00270
00271
00272
00273