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 #include <ImposedMotionSP.h>
00032 #include <classTags.h>
00033 #include <Vector.h>
00034 #include <Channel.h>
00035 #include <FEM_ObjectBroker.h>
00036 #include <GroundMotion.h>
00037 #include <Node.h>
00038 #include <Domain.h>
00039 #include <LoadPattern.h>
00040 #include <ID.h>
00041
00042
00043 ImposedMotionSP::ImposedMotionSP()
00044 :SP_Constraint(CNSTRNT_TAG_ImposedMotionSP),
00045 groundMotionTag(0), patternTag(0),
00046 theGroundMotion(0), theNode(0), theNodeResponse(0), theGroundMotionResponse(3)
00047
00048 {
00049
00050 }
00051
00052
00053 ImposedMotionSP::ImposedMotionSP(int tag, int node, int ndof, int pattern, int motion)
00054 :SP_Constraint(tag, node, ndof, CNSTRNT_TAG_ImposedMotionSP),
00055 groundMotionTag(motion), patternTag(pattern),
00056 theGroundMotion(0), theNode(0), theNodeResponse(0), theGroundMotionResponse(3)
00057 {
00058
00059 }
00060
00061
00062 ImposedMotionSP::~ImposedMotionSP()
00063 {
00064 if (theNodeResponse != 0)
00065 delete theNodeResponse;
00066 }
00067
00068
00069
00070 double
00071 ImposedMotionSP::getValue(void)
00072 {
00073
00074 return theGroundMotionResponse(0);
00075 }
00076
00077
00078 int
00079 ImposedMotionSP::applyConstraint(double time)
00080 {
00081
00082 if (theGroundMotion == 0 || theNode == 0 || theNodeResponse) {
00083 Domain *theDomain = this->getDomain();
00084
00085 theNode = theDomain->getNode(nodeTag);
00086 if (theNode == 0) {
00087 return -1;
00088 }
00089 theNodeResponse = new Vector(theNode->getNumberDOF());
00090 if (theNodeResponse == 0) {
00091 return -2;
00092 }
00093
00094 LoadPattern *theLoadPattern = theDomain->getLoadPattern(patternTag);
00095 if (theLoadPattern == 0)
00096 return -3;
00097
00098 theGroundMotion = theLoadPattern->getMotion(groundMotionTag);
00099 if (theGroundMotion == 0)
00100 return -4;
00101 }
00102
00103
00104 theGroundMotionResponse = theGroundMotion->getDispVelAccel(time);
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 *theNodeResponse = theNode->getTrialVel();
00120 (*theNodeResponse)(dofNumber) = theGroundMotionResponse(1);
00121 theNode->setTrialVel(*theNodeResponse);
00122
00123 *theNodeResponse = theNode->getTrialAccel();
00124 (*theNodeResponse)(dofNumber) = theGroundMotionResponse(2);
00125 theNode->setTrialAccel(*theNodeResponse);
00126
00127 return 0;
00128 }
00129
00130
00131 bool
00132 ImposedMotionSP::isHomogeneous(void) const
00133 {
00134 return true;
00135 }
00136
00137
00138 int
00139 ImposedMotionSP::sendSelf(int cTag, Channel &theChannel)
00140 {
00141 int dbTag = this->getDbTag();
00142 int result = 0;
00143 result = this->SP_Constraint::sendSelf(cTag, theChannel);
00144 if (result < 0) {
00145 opserr << "ImposedMotionSP::sendSelf() - base SP_Constraint class failed\n";
00146 return -1;
00147 }
00148
00149 static ID myExtraData(2);
00150 myExtraData(0) = groundMotionTag;
00151 myExtraData(1) = patternTag;
00152 if (theChannel.sendID(dbTag, cTag, myExtraData) < 0) {
00153 opserr << "ImposedMotionSP::sendSelf() - failed to send extra data\n";
00154 return -1;
00155 }
00156
00157 return 0;
00158 }
00159
00160 int
00161 ImposedMotionSP::recvSelf(int cTag, Channel &theChannel,
00162 FEM_ObjectBroker &theBroker)
00163 {
00164 int dbTag = this->getDbTag();
00165 int result = 0;
00166 result = this->SP_Constraint::recvSelf(cTag, theChannel, theBroker);
00167 if (result < 0) {
00168 opserr << "ImposedMotionSP::recvSelf() - base SP_Constraint class failed\n";
00169 return -1;
00170 }
00171
00172 static ID myExtraData(2);
00173 if (theChannel.recvID(dbTag, cTag, myExtraData) < 0) {
00174 opserr << "ImposedMotionSP::sendSelf() - failed to send extra data\n";
00175 return -1;
00176 }
00177 groundMotionTag = myExtraData(0);
00178 patternTag = myExtraData(1);
00179
00180 return 0;
00181 }
00182
00183 void
00184 ImposedMotionSP::Print(OPS_Stream &s, int flag)
00185 {
00186 s << "ImposedMotionSP: " << this->getTag();
00187 s << "\t Node: " << this->getNodeTag();
00188 s << " DOF: " << this->getDOF_Number() << endln;
00189 }
00190
00191
00192
00193
00194
00195
00196
00197