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