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 <ParallelMaterial.h>
00039 #include <ID.h>
00040 #include <Vector.h>
00041 #include <Channel.h>
00042 #include <FEM_ObjectBroker.h>
00043 #include <stdlib.h>
00044
00045
00046 ParallelMaterial::ParallelMaterial(
00047 int tag,
00048 int num,
00049 UniaxialMaterial ** theMaterialModels,
00050 double min, double max)
00051 :UniaxialMaterial(tag,MAT_TAG_ParallelMaterial),
00052 trialStrain(0.0), numMaterials(num), otherDbTag(0), theModels(0),
00053 epsmin(min), epsmax(max), Cfailed(0), Tfailed(0)
00054 {
00055
00056 theModels = new UniaxialMaterial *[num];
00057
00058 if (theModels == 0) {
00059 cerr << "FATAL ParallelMaterial::ParallelMaterial() ";
00060 cerr << " ran out of memory for array of size: " << num << "\n";
00061 exit(-1);
00062 }
00063
00064
00065
00066 for (int i=0; i<num; i++) {
00067 theModels[i] = theMaterialModels[i]->getCopy();
00068 }
00069 }
00070
00071
00072
00073
00074
00075
00076 ParallelMaterial::ParallelMaterial()
00077 :UniaxialMaterial(0,MAT_TAG_ParallelMaterial),
00078 trialStrain(0.0), numMaterials(0), otherDbTag(0), theModels(0),
00079 epsmin(NEG_INF_STRAIN), epsmax(POS_INF_STRAIN), Cfailed(0), Tfailed(0)
00080 {
00081
00082 }
00083
00084
00085 ParallelMaterial::~ParallelMaterial()
00086 {
00087
00088 for (int i=0; i<numMaterials; i++)
00089 delete theModels[i];
00090
00091
00092 if (theModels != 0)
00093 delete [] theModels;
00094 }
00095
00096
00097
00098 int
00099 ParallelMaterial::setTrialStrain(double strain, double strainRate)
00100 {
00101
00102
00103 Tfailed = Cfailed;
00104 trialStrain = strain;
00105 trialStrainRate = strainRate;
00106
00107 if (trialStrain < epsmin || trialStrain > epsmax)
00108 Tfailed = 1;
00109
00110 if (!Tfailed) {
00111 for (int i=0; i<numMaterials; i++)
00112 theModels[i]->setTrialStrain(strain, strainRate);
00113 }
00114
00115 return 0;
00116 }
00117
00118
00119 double
00120 ParallelMaterial::getStrain(void)
00121 {
00122 return trialStrain;
00123 }
00124
00125 double
00126 ParallelMaterial::getStrainRate(void)
00127 {
00128 return trialStrainRate;
00129 }
00130
00131 double
00132 ParallelMaterial::getStress(void)
00133 {
00134
00135 double stress = 0.0;
00136 if (!Tfailed) {
00137 for (int i=0; i<numMaterials; i++)
00138 stress +=theModels[i]->getStress();
00139 }
00140
00141 return stress;
00142 }
00143
00144
00145
00146 double
00147 ParallelMaterial::getTangent(void)
00148 {
00149
00150 double E = 0.0;
00151 if (!Tfailed) {
00152 for (int i=0; i<numMaterials; i++)
00153 E +=theModels[i]->getTangent();
00154 }
00155
00156 return E;
00157 }
00158
00159 double
00160 ParallelMaterial::getDampTangent(void)
00161 {
00162
00163 double eta = 0.0;
00164 if (!Tfailed) {
00165 for (int i=0; i<numMaterials; i++)
00166 eta +=theModels[i]->getDampTangent();
00167 }
00168
00169 return eta;
00170 }
00171
00172 double ParallelMaterial::getSecant ()
00173 {
00174
00175 double S = 0.0;
00176 if (!Tfailed) {
00177 for (int i=0; i<numMaterials; i++)
00178 S +=theModels[i]->getSecant();
00179 }
00180
00181 return S;
00182 }
00183
00184 int
00185 ParallelMaterial::commitState(void)
00186 {
00187 Cfailed = Tfailed;
00188
00189
00190 for (int i=0; i<numMaterials; i++)
00191 if (theModels[i]->commitState() != 0) {
00192 cerr << "WARNING ParallelMaterial::commitState() ";
00193 cerr << "MaterialModel failed to commitState():" ;
00194 theModels[i]->Print(cerr);
00195 }
00196
00197 return 0;
00198 }
00199
00200 int
00201 ParallelMaterial::revertToLastCommit(void)
00202 {
00203 Tfailed = Cfailed;
00204
00205
00206 for (int i=0; i<numMaterials; i++)
00207 if (theModels[i]->revertToLastCommit() != 0) {
00208 cerr << "WARNING ParallelMaterial::revertToLastCommit() ";
00209 cerr << "MaterialModel failed to revertToLastCommit():" ;
00210 theModels[i]->Print(cerr);
00211 }
00212
00213 return 0;
00214 }
00215
00216
00217 int
00218 ParallelMaterial::revertToStart(void)
00219 {
00220 Cfailed = 0;
00221
00222
00223 for (int i=0; i<numMaterials; i++)
00224 if (theModels[i]->revertToStart() != 0) {
00225 cerr << "WARNING ParallelMaterial::revertToStart() ";
00226 cerr << "MaterialModel failed to revertToStart():" ;
00227 theModels[i]->Print(cerr);
00228 }
00229
00230 return 0;
00231 }
00232
00233
00234
00235 UniaxialMaterial *
00236 ParallelMaterial::getCopy(void)
00237 {
00238 ParallelMaterial *theCopy = new
00239 ParallelMaterial(this->getTag(),numMaterials,theModels,epsmin,epsmax);
00240
00241 theCopy->trialStrain = trialStrain;
00242 theCopy->trialStrainRate = trialStrainRate;
00243 theCopy->Cfailed = Cfailed;
00244 theCopy->Tfailed = Tfailed;
00245
00246 return theCopy;
00247 }
00248
00249
00250 int
00251 ParallelMaterial::sendSelf(int cTag, Channel &theChannel)
00252 {
00253 Vector data(6);
00254
00255
00256
00257 if (otherDbTag == 0)
00258 otherDbTag = theChannel.getDbTag();
00259
00260 data(0) = this->getTag();
00261 data(1) = numMaterials;
00262 data(2) = otherDbTag;
00263 data(3) = epsmin;
00264 data(4) = epsmax;
00265 data(5) = Cfailed;
00266
00267 theChannel.sendVector(this->getDbTag(), cTag, data);
00268
00269
00270
00271
00272 ID classTags(numMaterials*2);
00273 for (int i=0; i<numMaterials; i++) {
00274 classTags(i) = theModels[i]->getClassTag();
00275 int matDbTag = theModels[i]->getDbTag();
00276 if (matDbTag == 0) {
00277 matDbTag = theChannel.getDbTag();
00278 if (matDbTag != 0)
00279 theModels[i]->setDbTag(matDbTag);
00280 }
00281 classTags(i+numMaterials) = matDbTag;
00282 }
00283 theChannel.sendID(otherDbTag, cTag, classTags);
00284 for (int j=0; j<numMaterials; j++)
00285 theModels[j]->sendSelf(cTag, theChannel);
00286
00287 return 0;
00288 }
00289
00290 int
00291 ParallelMaterial::recvSelf(int cTag, Channel &theChannel,
00292 FEM_ObjectBroker &theBroker)
00293 {
00294 Vector data(6);
00295 theChannel.recvVector(this->getDbTag(), cTag, data);
00296 this->setTag(int(data(0)));
00297 numMaterials = int(data(1));
00298 otherDbTag = int(data(2));
00299 epsmin = data(3);
00300 epsmax = data(4);
00301 Cfailed = int(data(5));
00302
00303
00304
00305 ID classTags(numMaterials*2);
00306 theChannel.recvID(otherDbTag, cTag, classTags);
00307 theModels = new UniaxialMaterial *[numMaterials];
00308
00309
00310 if (theModels == 0) {
00311 cerr << "FATAL ParallelMaterial::recvSelf() ";
00312 cerr << " ran out of memory for array of size: " << numMaterials << "\n";
00313 exit(-1);
00314 }
00315
00316
00317
00318 for (int i=0; i<numMaterials; i++) {
00319 UniaxialMaterial *theMaterialModel =
00320 theBroker.getNewUniaxialMaterial(classTags(i));
00321 if (theMaterialModel != 0) {
00322 theModels[i] = theMaterialModel;
00323 theMaterialModel->setDbTag(classTags(i+numMaterials));
00324 }
00325 else {
00326 cerr << "FATAL ParallelMaterial::recvSelf() ";
00327 cerr << " could not get a UniaxialMaterial \n";
00328 exit(-1);
00329 }
00330 theMaterialModel->recvSelf(cTag, theChannel, theBroker);
00331 }
00332 return 0;
00333 }
00334
00335 void
00336 ParallelMaterial::Print(ostream &s, int flag)
00337 {
00338 s << "Parallel tag: " << this->getTag() << endl;
00339 if (epsmin != NEG_INF_STRAIN)
00340 s << " epsmin: " << epsmin << endl;
00341 if (epsmax != POS_INF_STRAIN)
00342 s << " epsmax: " << epsmax << endl;
00343 for (int i=0; i<numMaterials; i++) {
00344 s << ' ';
00345 theModels[i]->Print(s, flag);
00346 }
00347
00348 }