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
00035
00036
00037
00038 #include <stdlib.h>
00039
00040 #include <UniaxialMaterial.h>
00041 #include <UniaxialFiber2d.h>
00042 #include <Channel.h>
00043 #include <FEM_ObjectBroker.h>
00044 #include <ID.h>
00045 #include <SectionForceDeformation.h>
00046 #include <Information.h>
00047 #include <Parameter.h>
00048 #include <FiberResponse.h>
00049
00050 Matrix UniaxialFiber2d::ks(2,2);
00051 Vector UniaxialFiber2d::fs(2);
00052 ID UniaxialFiber2d::code(2);
00053
00054
00055 UniaxialFiber2d::UniaxialFiber2d(int tag,
00056 UniaxialMaterial &theMat,
00057 double Area, double position):
00058 Fiber(tag, FIBER_TAG_Uniaxial2d),
00059 theMaterial(0), area(Area), y(-position)
00060 {
00061 theMaterial = theMat.getCopy();
00062
00063 if (theMaterial == 0) {
00064 opserr <<"UniaxialFiber2d::UniaxialFiber2d -- failed to get copy of UniaxialMaterial\n";
00065 exit(-1);
00066 }
00067
00068 if (code(0) != SECTION_RESPONSE_P) {
00069 code(0) = SECTION_RESPONSE_P;
00070 code(1) = SECTION_RESPONSE_MZ;
00071 }
00072 }
00073
00074
00075 UniaxialFiber2d::UniaxialFiber2d(): Fiber(0, FIBER_TAG_Uniaxial2d),
00076 theMaterial(0), area(0), y(0.0)
00077 {
00078 if (code(0) != SECTION_RESPONSE_P) {
00079 code(0) = SECTION_RESPONSE_P;
00080 code(1) = SECTION_RESPONSE_MZ;
00081 }
00082 }
00083
00084
00085
00086 UniaxialFiber2d::~UniaxialFiber2d ()
00087 {
00088 if (theMaterial != 0)
00089 delete theMaterial;
00090 }
00091
00092
00093 int
00094 UniaxialFiber2d::setTrialFiberStrain(const Vector &vs)
00095 {
00096
00097
00098 double strain = vs(0) + y*vs(1);
00099
00100 return theMaterial->setTrialStrain(strain);
00101 }
00102
00103
00104
00105
00106 Vector &
00107 UniaxialFiber2d::getFiberStressResultants (void)
00108 {
00109
00110
00111
00112 double df = theMaterial->getStress() * area;
00113
00114 fs(0) = df;
00115 fs(1) = y * df;
00116
00117 return fs;
00118 }
00119
00120
00121
00122
00123 Matrix &
00124 UniaxialFiber2d::getFiberTangentStiffContr(void)
00125 {
00126
00127
00128
00129 double value = theMaterial->getTangent() * area;
00130 double value_as1 = value*y;
00131
00132 ks(0,0) = value;
00133 ks(0,1) = value_as1;
00134 ks(1,0) = value_as1;
00135 ks(1,1) = value_as1 * y;
00136
00137 return ks;
00138 }
00139
00140 Fiber*
00141 UniaxialFiber2d::getCopy (void)
00142 {
00143
00144 UniaxialFiber2d *theCopy = new UniaxialFiber2d (this->getTag(),
00145 *theMaterial, area, -y);
00146 return theCopy;
00147 }
00148
00149 int
00150 UniaxialFiber2d::getOrder(void)
00151 {
00152 return 2;
00153 }
00154
00155 const ID&
00156 UniaxialFiber2d::getType(void)
00157 {
00158 return code;
00159 }
00160
00161 int
00162 UniaxialFiber2d::commitState(void)
00163 {
00164 return theMaterial->commitState();
00165 }
00166
00167
00168 int
00169 UniaxialFiber2d::revertToLastCommit(void)
00170 {
00171 return theMaterial->revertToLastCommit();
00172 }
00173
00174
00175 int
00176 UniaxialFiber2d::revertToStart(void)
00177 {
00178 return theMaterial->revertToStart();
00179 }
00180
00181
00182 int
00183 UniaxialFiber2d::sendSelf(int commitTag, Channel &theChannel)
00184 {
00185
00186
00187
00188 int res = 0;
00189
00190 int dbTag = this->getDbTag();
00191
00192 static ID idData(3);
00193
00194 idData(0) = this->getTag();
00195 idData(1) = theMaterial->getClassTag();
00196
00197 int matDbTag = theMaterial->getDbTag();
00198 if (matDbTag == 0) {
00199 matDbTag = theChannel.getDbTag();
00200 if (matDbTag != 0)
00201 theMaterial->setDbTag(matDbTag);
00202 }
00203
00204 idData(2) = matDbTag;
00205
00206 res += theChannel.sendID(dbTag, commitTag, idData);
00207 if (res < 0) {
00208 opserr << "UniaxialFiber2d::sendSelf - failed to send ID data\n";
00209 return res;
00210 }
00211
00212
00213
00214
00215 static Vector dData(2);
00216
00217 dData(0) = area;
00218 dData(1) = y;
00219
00220 res += theChannel.sendVector(dbTag, commitTag, dData);
00221 if (res < 0) {
00222 opserr << "UniaxialFiber2d::sendSelf - failed to send Vector data\n";
00223 return res;
00224 }
00225
00226
00227 res += theMaterial->sendSelf(commitTag, theChannel);
00228 if (res < 0) {
00229 opserr << "UniaxialFiber2d::sendSelf - failed to send UniaxialMaterial\n";
00230 return res;
00231 }
00232
00233 return res;
00234 }
00235
00236
00237 int
00238 UniaxialFiber2d::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00239 {
00240
00241
00242
00243
00244 int res = 0;
00245
00246 int dbTag = this->getDbTag();
00247
00248 static ID idData(3);
00249
00250 res += theChannel.recvID(dbTag, commitTag, idData);
00251 if (res < 0) {
00252 opserr << "UniaxialFiber2d::rcvSelf - failed to receive ID data\n";
00253 return res;
00254 }
00255
00256 this->setTag(idData(0));
00257
00258
00259
00260
00261
00262 static Vector dData(2);
00263
00264 res += theChannel.recvVector(dbTag, commitTag, dData);
00265 if (res < 0) {
00266 opserr << "UniaxialFiber2d::recvSelf - failed to receive Vector data\n";
00267 return res;
00268 }
00269
00270 area = dData(0);
00271 y = dData(1);
00272
00273
00274
00275
00276
00277 int matClassTag = idData(1);
00278
00279
00280 if (theMaterial != 0) {
00281 if (matClassTag != theMaterial->getClassTag()) {
00282 delete theMaterial;
00283 theMaterial = 0;
00284 }
00285 }
00286
00287
00288
00289 if (theMaterial == 0) {
00290 theMaterial = theBroker.getNewUniaxialMaterial(matClassTag);
00291 if (theMaterial == 0) {
00292 opserr << "UniaxialFiber2d::recvSelf() - " <<
00293 "failed to get a UniaxialMaterial of type " << matClassTag << endln;
00294 return -1;
00295 }
00296 }
00297
00298
00299 theMaterial->setDbTag(idData(2));
00300
00301
00302 res += theMaterial->recvSelf(commitTag, theChannel, theBroker);
00303 if (res < 0) {
00304 opserr << "UniaxialFiber2d::recvSelf() - the material failed in recvSelf()\n";
00305 return res;
00306 }
00307
00308 return res;
00309 }
00310
00311
00312 void UniaxialFiber2d::Print(OPS_Stream &s, int flag)
00313 {
00314 s << "\nUniaxialFiber2d, tag: " << this->getTag() << endln;
00315 s << "\tArea: " << area << endln;
00316 s << "\tMatrix as: " << 1.0 << " " << y << endln;
00317 s << "\tMaterial, tag: " << theMaterial->getTag() << endln;
00318 }
00319
00320 Response*
00321 UniaxialFiber2d::setResponse(const char **argv, int argc, Information &info, OPS_Stream &s)
00322 {
00323 if (argc == 0)
00324 return 0;
00325
00326 if (strcmp(argv[0],"force") == 0 || strcmp(argv[0],"forces") == 0)
00327 return new FiberResponse(this, 1, Vector(2));
00328
00329 else
00330 return theMaterial->setResponse(argv, argc, info, s);
00331 }
00332
00333 int
00334 UniaxialFiber2d::getResponse(int responseID, Information &fibInfo)
00335 {
00336 switch(responseID) {
00337 case 1:
00338 return fibInfo.setVector(this->getFiberStressResultants());
00339
00340 default:
00341 return -1;
00342 }
00343 }
00344
00345 void
00346 UniaxialFiber2d::getFiberLocation(double &yLoc, double &zLoc)
00347 {
00348 yLoc = -y;
00349 zLoc = 0.0;
00350 }
00351
00352 int
00353 UniaxialFiber2d::setParameter(const char **argv, int argc, Parameter ¶m)
00354 {
00355 if (strcmp(argv[0],"A") == 0)
00356 return param.addObject(1, this);
00357
00358 if (strcmp(argv[0],"y") == 0)
00359 return param.addObject(2, this);
00360
00361 else
00362 return theMaterial->setParameter(argv, argc, param);
00363 }
00364
00365 int
00366 UniaxialFiber2d::updateParameter(int parameterID, Information &info)
00367 {
00368 switch(parameterID) {
00369 case 1:
00370 area = info.theDouble;
00371 return 0;
00372 case 2:
00373 y = -info.theDouble;
00374 return 0;
00375 default:
00376 return -1;
00377 }
00378 }
00379
00380 int
00381 UniaxialFiber2d::activateParameter(int parameterID)
00382 {
00383 return -1;
00384 }
00385
00386 const Vector&
00387 UniaxialFiber2d::getFiberSensitivity(int gradNumber, bool cond)
00388 {
00389 return Fiber::getFiberSensitivity(gradNumber, cond);
00390 }
00391
00392 int
00393 UniaxialFiber2d::commitSensitivity(const Vector &dedh, int gradNumber,
00394 int numGrads)
00395 {
00396 return -1;
00397 }
00398