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 #include <ElasticSection2d.h>
00026 #include <Matrix.h>
00027 #include <Vector.h>
00028 #include <Channel.h>
00029 #include <FEM_ObjectBroker.h>
00030 #include <MatrixUtil.h>
00031 #include <stdlib.h>
00032 #include <Information.h>
00033 #include <Parameter.h>
00034
00035 #include <classTags.h>
00036
00037 Vector ElasticSection2d::s(2);
00038 Matrix ElasticSection2d::ks(2,2);
00039 ID ElasticSection2d::code(2);
00040
00041 ElasticSection2d::ElasticSection2d(void)
00042 :SectionForceDeformation(0, SEC_TAG_Elastic2d),
00043 E(0.0), A(0.0), I(0.0),
00044 e(2), eCommit(2)
00045 {
00046 if (code(0) != SECTION_RESPONSE_P)
00047 {
00048 code(0) = SECTION_RESPONSE_P;
00049 code(1) = SECTION_RESPONSE_MZ;
00050 }
00051 }
00052
00053 ElasticSection2d::ElasticSection2d
00054 (int tag, double E_in, double A_in, double I_in)
00055 :SectionForceDeformation(tag, SEC_TAG_Elastic2d),
00056 E(E_in), A(A_in), I(I_in),
00057 e(2), eCommit(2)
00058 {
00059 if (E <= 0.0) {
00060 opserr << "ElasticSection2d::ElasticSection2d -- Input E <= 0.0 ... setting E to 1.0\n";
00061 E = 1.0;
00062 }
00063
00064 if (A <= 0.0) {
00065 opserr << "ElasticSection2d::ElasticSection2d -- Input A <= 0.0 ... setting A to 1.0\n";
00066 A = 1.0;
00067 }
00068
00069 if (I <= 0.0) {
00070 opserr << "ElasticSection2d::ElasticSection2d -- Input I <= 0.0 ... setting I to 1.0\n";
00071 I = 1.0;
00072 }
00073
00074 if (code(0) != SECTION_RESPONSE_P)
00075 {
00076 code(0) = SECTION_RESPONSE_P;
00077 code(1) = SECTION_RESPONSE_MZ;
00078 }
00079 }
00080
00081 ElasticSection2d::~ElasticSection2d(void)
00082 {
00083
00084 }
00085
00086 int
00087 ElasticSection2d::commitState(void)
00088 {
00089 eCommit = e;
00090
00091 return 0;
00092 }
00093
00094 int
00095 ElasticSection2d::revertToLastCommit(void)
00096 {
00097 e = eCommit;
00098
00099 return 0;
00100 }
00101
00102 int
00103 ElasticSection2d::revertToStart(void)
00104 {
00105 eCommit.Zero();
00106
00107 return 0;
00108 }
00109
00110 int
00111 ElasticSection2d::setTrialSectionDeformation(const Vector &def)
00112 {
00113 e = def;
00114
00115 return 0;
00116 }
00117
00118 const Vector &
00119 ElasticSection2d::getSectionDeformation(void)
00120 {
00121 return e;
00122 }
00123
00124 const Vector &
00125 ElasticSection2d::getStressResultant(void)
00126 {
00127 s(0) = E*A*e(0);
00128 s(1) = E*I*e(1);
00129
00130 return s;
00131 }
00132
00133 const Matrix &
00134 ElasticSection2d::getSectionTangent(void)
00135 {
00136 ks(0,0) = E*A;
00137 ks(1,1) = E*I;
00138
00139 return ks;
00140 }
00141
00142 const Matrix &
00143 ElasticSection2d::getInitialTangent(void)
00144 {
00145 ks(0,0) = E*A;
00146 ks(1,1) = E*I;
00147
00148 return ks;
00149 }
00150
00151 const Matrix &
00152 ElasticSection2d::getSectionFlexibility(void)
00153 {
00154 ks(0,0) = 1.0/(E*A);
00155 ks(1,1) = 1.0/(E*I);
00156
00157 return ks;
00158 }
00159
00160 const Matrix &
00161 ElasticSection2d::getInitialFlexibility(void)
00162 {
00163 ks(0,0) = 1.0/(E*A);
00164 ks(1,1) = 1.0/(E*I);
00165
00166 return ks;
00167 }
00168
00169 SectionForceDeformation*
00170 ElasticSection2d::getCopy(void)
00171 {
00172
00173 ElasticSection2d *theCopy =
00174 new ElasticSection2d (this->getTag(), E, A, I);
00175
00176 theCopy->eCommit = eCommit;
00177
00178 return theCopy;
00179 }
00180
00181 const ID&
00182 ElasticSection2d::getType(void)
00183 {
00184 return code;
00185 }
00186
00187 int
00188 ElasticSection2d::getOrder(void) const
00189 {
00190 return 2;
00191 }
00192
00193 int
00194 ElasticSection2d::sendSelf(int commitTag, Channel &theChannel)
00195 {
00196 int res = 0;
00197
00198 static Vector data(6);
00199
00200 int dataTag = this->getDbTag();
00201
00202 data(0) = this->getTag();
00203 data(1) = E;
00204 data(2) = A;
00205 data(3) = I;
00206 data(4) = eCommit(0);
00207 data(5) = eCommit(1);
00208
00209 res += theChannel.sendVector(dataTag, commitTag, data);
00210 if (res<0) {
00211 opserr << "ElasticSection2d::sendSelf -- failed to send data\n";
00212 return res;
00213 }
00214
00215 return res;
00216 }
00217
00218 int
00219 ElasticSection2d::recvSelf(int commitTag, Channel &theChannel,
00220 FEM_ObjectBroker &theBroker)
00221 {
00222 int res = 0;
00223
00224 static Vector data(6);
00225
00226 int dataTag = this->getDbTag();
00227
00228 res += theChannel.recvVector(dataTag, commitTag, data);
00229 if(res < 0) {
00230 opserr << "ElasticSection2d::recvSelf -- failed to receive data\n";
00231 return res;
00232 }
00233
00234 this->setTag((int)data(0));
00235 E = data(1);
00236 A = data(2);
00237 I = data(3);
00238 eCommit(0) = data(4);
00239 eCommit(1) = data(5);
00240
00241 return res;
00242 }
00243
00244 void
00245 ElasticSection2d::Print(OPS_Stream &s, int flag)
00246 {
00247 s << "ElasticSection2d, tag: " << this->getTag() << endln;
00248 s << "\tE: " << E << endln;
00249 s << "\tA: " << A << endln;
00250 s << "\tI: " << I << endln;
00251 }
00252
00253 int
00254 ElasticSection2d::setParameter(const char **argv, int argc, Parameter ¶m)
00255 {
00256 if (argc < 1)
00257 return -1;
00258
00259 if (strcmp(argv[0],"E") == 0)
00260 return param.addObject(1, this);
00261
00262 if (strcmp(argv[0],"A") == 0)
00263 return param.addObject(2, this);
00264
00265 if (strcmp(argv[0],"I") == 0)
00266 return param.addObject(3, this);
00267
00268 return -1;
00269 }
00270
00271 int
00272 ElasticSection2d::updateParameter(int paramID, Information &info)
00273 {
00274 if (paramID == 1)
00275 E = info.theDouble;
00276 if (paramID == 2)
00277 A = info.theDouble;
00278 if (paramID == 3)
00279 I = info.theDouble;
00280
00281 return 0;
00282 }
00283
00284 int
00285 ElasticSection2d::activateParameter(int paramID)
00286 {
00287 parameterID = paramID;
00288
00289 return 0;
00290 }
00291
00292 const Vector&
00293 ElasticSection2d::getStressResultantSensitivity(int gradNumber,
00294 bool conditional)
00295 {
00296 s.Zero();
00297
00298 if (parameterID == 1) {
00299 s(0) = A*e(0);
00300 s(1) = I*e(1);
00301 }
00302 if (parameterID == 2)
00303 s(0) = E*e(0);
00304 if (parameterID == 3)
00305 s(1) = E*e(1);
00306
00307 return s;
00308 }
00309
00310 const Vector&
00311 ElasticSection2d::getSectionDeformationSensitivity(int gradNumber)
00312 {
00313 s.Zero();
00314
00315 return s;
00316 }
00317
00318 const Matrix&
00319 ElasticSection2d::getInitialTangentSensitivity(int gradNumber)
00320 {
00321 ks.Zero();
00322
00323 return ks;
00324 }
00325
00326 int
00327 ElasticSection2d::commitSensitivity(const Vector& sectionDeformationGradient,
00328 int gradNumber, int numGrads)
00329 {
00330
00331 return 0;
00332 }