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 #include <stdlib.h>
00035 #include <PathIndependentMaterial.h>
00036 #include <ID.h>
00037 #include <Channel.h>
00038 #include <FEM_ObjectBroker.h>
00039
00040 #include <OPS_Globals.h>
00041
00042 PathIndependentMaterial::PathIndependentMaterial(int tag, UniaxialMaterial &material)
00043 :UniaxialMaterial(tag,MAT_TAG_PathIndependent), theMaterial(0)
00044 {
00045 theMaterial = material.getCopy();
00046
00047 if (theMaterial == 0) {
00048 opserr << "PathIndependentMaterial::PathIndependentMaterial -- failed to get copy of material\n";
00049 exit(-1);
00050 }
00051 }
00052
00053 PathIndependentMaterial::PathIndependentMaterial()
00054 :UniaxialMaterial(0,MAT_TAG_PathIndependent), theMaterial(0)
00055 {
00056
00057 }
00058
00059 PathIndependentMaterial::~PathIndependentMaterial()
00060 {
00061 if (theMaterial)
00062 delete theMaterial;
00063 }
00064
00065 int
00066 PathIndependentMaterial::setTrialStrain(double strain, double strainRate)
00067 {
00068 return theMaterial->setTrialStrain(strain, strainRate);
00069 }
00070
00071 double
00072 PathIndependentMaterial::getStress(void)
00073 {
00074 return theMaterial->getStress();
00075 }
00076
00077
00078 double
00079 PathIndependentMaterial::getTangent(void)
00080 {
00081 return theMaterial->getTangent();
00082 }
00083
00084 double
00085 PathIndependentMaterial::getDampTangent(void)
00086 {
00087 return theMaterial->getDampTangent();
00088 }
00089
00090 double
00091 PathIndependentMaterial::getInitialTangent(void)
00092 {
00093 return theMaterial->getInitialTangent();
00094 }
00095
00096 double
00097 PathIndependentMaterial::getStrain(void)
00098 {
00099 return theMaterial->getStrain();
00100 }
00101
00102 double
00103 PathIndependentMaterial::getStrainRate(void)
00104 {
00105 return theMaterial->getStrainRate();
00106 }
00107
00108 int
00109 PathIndependentMaterial::commitState(void)
00110 {
00111 return 0;
00112 }
00113
00114 int
00115 PathIndependentMaterial::revertToLastCommit(void)
00116 {
00117 return 0;
00118 }
00119
00120 int
00121 PathIndependentMaterial::revertToStart(void)
00122 {
00123 return theMaterial->revertToStart();
00124 }
00125
00126 UniaxialMaterial *
00127 PathIndependentMaterial::getCopy(void)
00128 {
00129 PathIndependentMaterial *theCopy =
00130 new PathIndependentMaterial(this->getTag(), *theMaterial);
00131
00132 return theCopy;
00133 }
00134
00135
00136 int
00137 PathIndependentMaterial::sendSelf(int cTag, Channel &theChannel)
00138 {
00139 int res = 0;
00140
00141 static ID classTags(3);
00142
00143 int clTag = theMaterial->getClassTag();
00144 int dbTag = theMaterial->getDbTag();
00145
00146 classTags(0) = clTag;
00147
00148 if (dbTag == 0) {
00149 dbTag = theChannel.getDbTag();
00150 if (dbTag != 0)
00151 theMaterial->setDbTag(dbTag);
00152 }
00153
00154 classTags(1) = dbTag;
00155 classTags(2) = this->getTag();
00156
00157 res = theChannel.sendID(dbTag, cTag, classTags);
00158 if (res < 0) {
00159 opserr << "PathIndependentMaterial::sendSelf -- could not send ID\n";
00160 return res;
00161 }
00162
00163 res = theMaterial->sendSelf(cTag, theChannel);
00164 if (res < 0) {
00165 opserr << "PathIndependentMaterial::sendSelf -- could not send UniaxialMaterial\n";
00166 return res;
00167 }
00168
00169 return res;
00170 }
00171
00172 int
00173 PathIndependentMaterial::recvSelf(int cTag, Channel &theChannel,
00174 FEM_ObjectBroker &theBroker)
00175 {
00176 int res = 0;
00177
00178 static ID classTags(3);
00179
00180 int dbTag = this->getDbTag();
00181
00182 res = theChannel.recvID(dbTag, cTag, classTags);
00183 if (res < 0) {
00184 opserr << "PathIndependentMaterial::recvSelf -- could not receive ID\n";
00185 return res;
00186 }
00187
00188 this->setTag(int(classTags(2)));
00189
00190
00191 if (theMaterial == 0) {
00192 theMaterial = theBroker.getNewUniaxialMaterial(classTags(0));
00193 if (theMaterial == 0) {
00194 opserr << " PathIndependentMaterial::recvSelf -- could not get a UniaxialMaterial\n";
00195 return -1;
00196 }
00197 }
00198
00199
00200 if (theMaterial->getClassTag() != classTags(0)) {
00201 delete theMaterial;
00202 theMaterial = theBroker.getNewUniaxialMaterial(classTags(0));
00203 if (theMaterial == 0) {
00204 opserr << "PathIndependentMaterial::recvSelf -- could not get a UniaxialMaterial\n";
00205 exit(-1);
00206 }
00207 }
00208
00209
00210 theMaterial->setDbTag(classTags(1));
00211 res += theMaterial->recvSelf(cTag, theChannel, theBroker);
00212 if (res < 0) {
00213 opserr << "PathIndependentMaterial::recvSelf -- could not receive UniaxialMaterial\n";
00214 return res;
00215 }
00216
00217 return res;
00218 }
00219
00220 void
00221 PathIndependentMaterial::Print(OPS_Stream &s, int flag)
00222 {
00223 s << "PathIndependentMaterial tag: " << this->getTag() << endln;
00224 s << "\tmaterial: " << theMaterial->getTag() << endln;
00225 }