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 #include <GenericSectionNd.h>
00037 #include <NDMaterial.h>
00038 #include <Channel.h>
00039 #include <FEM_ObjectBroker.h>
00040 #include <Information.h>
00041
00042 #include <Matrix.h>
00043 #include <Vector.h>
00044 #include <ID.h>
00045
00046 #include <G3Globals.h>
00047 #include <classTags.h>
00048
00049 #include <string.h>
00050
00051 GenericSectionNd::GenericSectionNd(int tag, NDMaterial &m, const ID &mCode)
00052 :SectionForceDeformation(tag,SEC_TAG_GenericNd),
00053 otherDbTag(0), theModel(0), code(0)
00054 {
00055 theModel = m.getCopy();
00056
00057 if (theModel == 0) {
00058 g3ErrorHandler->fatal("%s -- failed to get copy of material model",
00059 "GenericSectionNd::GenericSectionNd");
00060 }
00061
00062 order = theModel->getOrder();
00063
00064 code = new ID(mCode);
00065
00066 if (code == 0) {
00067 g3ErrorHandler->fatal("%s -- failed to allocate section ID",
00068 "GenericSectionNd::GenericSectionNd");
00069 }
00070
00071 if (order != code->Size()) {
00072 g3ErrorHandler->warning("%s -- code size does not match order of material model",
00073 "GenericSectionNd::GenericSectionNd");
00074 }
00075 }
00076
00077 GenericSectionNd::GenericSectionNd()
00078 :SectionForceDeformation(0,SEC_TAG_GenericNd),
00079 otherDbTag(0), theModel(0), code(0), order(0)
00080 {
00081
00082 }
00083
00084 GenericSectionNd::~GenericSectionNd()
00085 {
00086 if (theModel)
00087 delete theModel;
00088
00089 if (code)
00090 delete code;
00091 }
00092
00093 int
00094 GenericSectionNd::setTrialSectionDeformation (const Vector& def)
00095 {
00096 return theModel->setTrialStrain(def);
00097 }
00098
00099 const Vector&
00100 GenericSectionNd::getSectionDeformation ()
00101 {
00102 return theModel->getStrain();
00103 }
00104
00105 const Vector&
00106 GenericSectionNd::getStressResultant ()
00107 {
00108 return theModel->getStress();
00109 }
00110
00111 const Matrix&
00112 GenericSectionNd::getSectionTangent ()
00113 {
00114 return theModel->getTangent();
00115 }
00116
00117 int
00118 GenericSectionNd::commitState ()
00119 {
00120 return theModel->commitState();
00121 }
00122
00123 int
00124 GenericSectionNd::revertToLastCommit ()
00125 {
00126 return theModel->revertToLastCommit();
00127 }
00128
00129 int
00130 GenericSectionNd::revertToStart ()
00131 {
00132 return theModel->revertToStart();
00133 }
00134
00135 const ID&
00136 GenericSectionNd::getType ()
00137 {
00138 return *code;
00139 }
00140
00141 int
00142 GenericSectionNd::getOrder () const
00143 {
00144 return order;
00145 }
00146
00147 SectionForceDeformation*
00148 GenericSectionNd::getCopy ()
00149 {
00150 GenericSectionNd *theCopy = new GenericSectionNd (this->getTag(),
00151 *theModel, *code);
00152
00153 theCopy->otherDbTag = otherDbTag;
00154
00155 return theCopy;
00156 }
00157
00158 int
00159 GenericSectionNd::sendSelf(int cTag, Channel &theChannel)
00160 {
00161 int res = 0;
00162
00163
00164 if (otherDbTag == 0)
00165 otherDbTag = theChannel.getDbTag();
00166
00167 static ID data(5);
00168
00169 data(0) = this->getTag();
00170 data(1) = order;
00171 data(2) = otherDbTag;
00172 data(3) = theModel->getClassTag();
00173
00174 int dbTag = theModel->getDbTag();
00175
00176 if (dbTag == 0) {
00177 dbTag = theChannel.getDbTag();
00178 if (dbTag != 0)
00179 theModel->setDbTag(dbTag);
00180 }
00181
00182 data(4) = dbTag;
00183
00184
00185 res += theChannel.sendID(this->getDbTag(), cTag, data);
00186 if (res < 0) {
00187 g3ErrorHandler->warning("%s -- could not send data ID",
00188 "GenericSectionNd::sendSelf");
00189 return res;
00190 }
00191
00192
00193 res += theChannel.sendID(otherDbTag, cTag, *code);
00194 if (res < 0) {
00195 g3ErrorHandler->warning("%s -- could not send code ID",
00196 "GenericSectionNd::sendSelf");
00197 return res;
00198 }
00199
00200
00201 res += theModel->sendSelf(cTag, theChannel);
00202 if (res < 0) {
00203 g3ErrorHandler->warning("%s -- could not send NDMaterial",
00204 "GenericSectionNd::sendSelf");
00205 return res;
00206 }
00207
00208 return res;
00209 }
00210
00211 int
00212 GenericSectionNd::recvSelf(int cTag, Channel &theChannel,
00213 FEM_ObjectBroker &theBroker)
00214 {
00215 int res = 0;
00216
00217 static ID data(5);
00218
00219
00220 res += theChannel.recvID(this->getDbTag(), cTag, data);
00221 if (res < 0) {
00222 g3ErrorHandler->warning("%s -- could not receive data ID",
00223 "GenericSectionNd::recvSelf");
00224 return res;
00225 }
00226
00227 this->setTag(data(0));
00228 order = data(1);
00229 otherDbTag = data(2);
00230
00231
00232 if (code == 0)
00233 code = new ID(order);
00234 else if (code->Size() != order) {
00235 delete code;
00236 code = new ID(order);
00237 }
00238 if (code == 0) {
00239 g3ErrorHandler->warning("%s -- could not allocate new code ID",
00240 "GenericSectionNd::recvSelf");
00241 return -1;
00242 }
00243
00244
00245 res += theChannel.recvID(otherDbTag, cTag, *code);
00246 if (res < 0) {
00247 g3ErrorHandler->warning("%s -- could not receive code ID",
00248 "GenericSectionNd::recvSelf");
00249 return res;
00250 }
00251
00252 int classTag = data(3);
00253
00254
00255 if (theModel == 0)
00256 theModel = theBroker.getNewNDMaterial(classTag);
00257
00258
00259
00260 else if (theModel->getClassTag() != classTag) {
00261 delete theModel;
00262 theModel = theBroker.getNewNDMaterial(classTag);
00263 }
00264
00265
00266 if (theModel == 0) {
00267 g3ErrorHandler->warning("%s -- could not get an NDMaterial",
00268 "GenericSectionNd::recvSelf");
00269 return -1;
00270 }
00271
00272
00273 theModel->setDbTag(data(4));
00274 res += theModel->recvSelf(cTag, theChannel, theBroker);
00275 if (res < 0) {
00276 g3ErrorHandler->warning("%s -- could not receive NDMaterial",
00277 "GenericSectionNd::recvSelf");
00278 return res;
00279 }
00280
00281 return res;
00282 }
00283
00284 void
00285 GenericSectionNd::Print (OPS_Stream &s, int flag)
00286 {
00287 s << "Generic Section Nd, tag: " << this->getTag() << endln;
00288 s << "\tsection code: " << code << endln;
00289 }