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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include <ElasticSection2d.h>
00040 #include <Matrix.h>
00041 #include <Vector.h>
00042 #include <Channel.h>
00043 #include <FEM_ObjectBroker.h>
00044 #include <MatrixUtil.h>
00045 #include <stdlib.h>
00046
00047 #include <G3Globals.h>
00048 #include <classTags.h>
00049
00050 ID ElasticSection2d::code(2);
00051
00052 ElasticSection2d::ElasticSection2d(void)
00053 :SectionForceDeformation(0, SEC_TAG_Elastic2d),
00054 E(0), A(0), I(0),
00055 e(2), eCommit(2)
00056 {
00057 if (code(0) != SECTION_RESPONSE_P)
00058 {
00059 code(0) = SECTION_RESPONSE_P;
00060 code(1) = SECTION_RESPONSE_MZ;
00061 }
00062 }
00063
00064 ElasticSection2d::ElasticSection2d
00065 (int tag, double E_in, double A_in, double I_in)
00066 :SectionForceDeformation(tag, SEC_TAG_Elastic2d),
00067 E(E_in), A(A_in), I(I_in),
00068 e(2), eCommit(2)
00069 {
00070 if (E <= 0.0) {
00071 g3ErrorHandler->warning("%s -- Input E <= 0.0 ... setting E to 1.0",
00072 "ElasticSection2d::ElasticSection2d");
00073 E = 1.0;
00074 }
00075
00076 if (A <= 0.0) {
00077 g3ErrorHandler->warning("%s -- Input A <= 0.0 ... setting A to 1.0",
00078 "ElasticSection2d::ElasticSection2d");
00079 A = 1.0;
00080 }
00081
00082 if (I <= 0.0) {
00083 g3ErrorHandler->warning("%s -- Input I <= 0.0 ... setting I to 1.0",
00084 "ElasticSection2d::ElasticSection2d");
00085 I = 1.0;
00086 }
00087
00088 if (code(0) != SECTION_RESPONSE_P)
00089 {
00090 code(0) = SECTION_RESPONSE_P;
00091 code(1) = SECTION_RESPONSE_MZ;
00092 }
00093 }
00094
00095 ElasticSection2d::ElasticSection2d
00096 (int tag, double EA_in, double EI_in)
00097 :SectionForceDeformation(tag, SEC_TAG_Elastic2d),
00098 E(1), A(EA_in), I(EI_in),
00099 e(2), eCommit(2)
00100 {
00101 if (A <= 0.0) {
00102 g3ErrorHandler->warning("%s -- Input EA <= 0.0 ... setting EA to 1.0",
00103 "ElasticSection2d::ElasticSection2d");
00104 A = 1.0;
00105 }
00106
00107 if (I <= 0.0) {
00108 g3ErrorHandler->warning("%s -- Input EI <= 0.0 ... setting EI to 1.0",
00109 "ElasticSection2d::ElasticSection2d");
00110 I = 1.0;
00111 }
00112
00113 if (code(0) != SECTION_RESPONSE_P)
00114 {
00115 code(0) = SECTION_RESPONSE_P;
00116 code(1) = SECTION_RESPONSE_MZ;
00117 }
00118 }
00119
00120 ElasticSection2d::~ElasticSection2d(void)
00121 {
00122
00123 }
00124
00125 int
00126 ElasticSection2d::commitState(void)
00127 {
00128 eCommit = e;
00129
00130 return 0;
00131 }
00132
00133 int
00134 ElasticSection2d::revertToLastCommit(void)
00135 {
00136 e = eCommit;
00137
00138 return 0;
00139 }
00140
00141 int
00142 ElasticSection2d::revertToStart(void)
00143 {
00144 eCommit.Zero();
00145
00146 return 0;
00147 }
00148
00149 int
00150 ElasticSection2d::setTrialSectionDeformation (const Vector &def)
00151 {
00152 e = def;
00153
00154 return 0;
00155 }
00156
00157 const Vector &
00158 ElasticSection2d::getSectionDeformation (void)
00159 {
00160 return e;
00161 }
00162
00163 const Vector &
00164 ElasticSection2d::getStressResultant (void)
00165 {
00166 static Vector s(2);
00167
00168 s(0) = E*A*e(0);
00169 s(1) = E*I*e(1);
00170
00171 return s;
00172 }
00173
00174 const Matrix &
00175 ElasticSection2d::getSectionTangent(void)
00176 {
00177 static Matrix ks(2,2);
00178
00179 ks(0,0) = E*A;
00180 ks(1,1) = E*I;
00181
00182 return ks;
00183 }
00184
00185 const Matrix &
00186 ElasticSection2d::getSectionFlexibility (void)
00187 {
00188 static Matrix fs(2,2);
00189
00190 fs(0,0) = 1.0/(E*A);
00191 fs(1,1) = 1.0/(E*I);
00192
00193 return fs;
00194 }
00195
00196 SectionForceDeformation*
00197 ElasticSection2d::getCopy ()
00198 {
00199
00200 ElasticSection2d *theCopy =
00201 new ElasticSection2d (this->getTag(), E, A, I);
00202
00203 theCopy->eCommit = eCommit;
00204
00205 return theCopy;
00206 }
00207
00208 const ID&
00209 ElasticSection2d::getType () const
00210 {
00211 return code;
00212 }
00213
00214 int
00215 ElasticSection2d::getOrder () const
00216 {
00217 return 2;
00218 }
00219
00220 int
00221 ElasticSection2d::sendSelf(int commitTag, Channel &theChannel)
00222 {
00223 int res = 0;
00224
00225 static Vector data(6);
00226
00227 int dataTag = this->getDbTag();
00228
00229 data(0) = this->getTag();
00230 data(1) = E;
00231 data(2) = A;
00232 data(3) = I;
00233 data(4) = eCommit(0);
00234 data(5) = eCommit(1);
00235
00236 res += theChannel.sendVector(dataTag, commitTag, data);
00237 if (res<0) {
00238 g3ErrorHandler->warning("%s -- failed to send data",
00239 "ElasticSection2d::sendSelf");
00240 return res;
00241 }
00242
00243 return res;
00244 }
00245
00246 int
00247 ElasticSection2d::recvSelf(int commitTag, Channel &theChannel,
00248 FEM_ObjectBroker &theBroker)
00249 {
00250 int res = 0;
00251
00252 static Vector data(6);
00253
00254 int dataTag = this->getDbTag();
00255
00256 res += theChannel.recvVector(dataTag, commitTag, data);
00257 if(res < 0) {
00258 g3ErrorHandler->warning("%s -- failed to receive data",
00259 "ElasticSection2d::recvSelf");
00260 return res;
00261 }
00262
00263 this->setTag((int)data(0));
00264 E = data(1);
00265 A = data(2);
00266 I = data(3);
00267 eCommit(0) = data(4);
00268 eCommit(1) = data(5);
00269
00270 return res;
00271 }
00272
00273 void
00274 ElasticSection2d::Print(ostream &s, int flag)
00275 {
00276 s << "ElasticSection2d, tag: " << this->getTag() << endl;
00277 s << "\tE: " << E << endl;
00278 s << "\tA: " << A << endl;
00279 s << "\tI: " << I << endl;
00280 }
00281