int FiberSection2d::sendSelf(int commitTag, Channel &theChannel) { int res = 0; // create an id to send objects tag and numFibers, // size 3 so no conflict with matData below if just 1 fiber static ID data(3); data(0) = this->getTag(); data(1) = numFibers; int dbTag = this->getDbTag(); res += theChannel.sendID(dbTag, commitTag, data); if (res < 0) { opserr << "FiberSection2d::sendSelf - failed to send ID data\n"; return res; } if (numFibers != 0) { // create an id containingg classTag and dbTag for each material & send it ID materialData(2*numFibers); for (int i=0; i<numFibers; i++) { UniaxialMaterial *theMat = theMaterials[i]; materialData(2*i) = theMat->getClassTag(); int matDbTag = theMat->getDbTag(); if (matDbTag == 0) { matDbTag = theChannel.getDbTag(); if (matDbTag != 0) theMat->setDbTag(matDbTag); } materialData(2*i+1) = matDbTag; } res += theChannel.sendID(dbTag, commitTag, materialData); if (res < 0) { opserr << "FiberSection2d::sendSelf - failed to send material data\n"; return res; } // send the fiber data, i.e. area and loc Vector fiberData(matData, 2*numFibers); res += theChannel.sendVector(dbTag, commitTag, fiberData); if (res < 0) { opserr << "FiberSection2d::sendSelf - failed to send material data\n"; return res; } // now invoke send(0 on all the materials for (int j=0; j<numFibers; j++) theMaterials[j]->sendSelf(commitTag, theChannel); } return res; }
int ParallelMaterial::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { int res = 0; static ID data(3); int dbTag = this->getDbTag(); res = theChannel.recvID(dbTag, cTag, data); if (res < 0) { opserr << "ParallelMaterial::recvSelf() - failed to receive data\n"; return res; } this->setTag(int(data(0))); int numMaterialsSent = int(data(1)); if (numMaterials != numMaterialsSent) { numMaterials = numMaterialsSent; if (theModels != 0) { for (int i=0; i<numMaterials; i++) delete theModels[i]; delete [] theModels; } theModels = new UniaxialMaterial *[numMaterials]; if (theModels == 0) { opserr << "FATAL ParallelMaterial::recvSelf() - ran out of memory"; opserr << " for array of size: " << numMaterials << "\n"; return -2; } for (int i=0; i<numMaterials; i++) theModels[i] = 0; } if (data(2) == 1) { theFactors = new Vector(numMaterials); res = theChannel.recvVector(dbTag, cTag, *theFactors); if (res < 0) { opserr << "ParallelMaterial::recvSelf() - failed to receive factors\n"; return res; } } // create and receive an ID for the classTags and dbTags of the local // MaterialModel objects ID classTags(numMaterials*2); res = theChannel.recvID(dbTag, cTag, classTags); if (res < 0) { opserr << "ParallelMaterial::recvSelf() - failed to receive classTags\n"; return res; } // now for each of the MaterialModel objects, create a new object // and invoke recvSelf() on it for (int i=0; i<numMaterials; i++) { int matClassTag = classTags(i); if (theModels[i] == 0 || theModels[i]->getClassTag() != matClassTag) { if (theModels[i] == 0) delete theModels[i]; UniaxialMaterial *theMaterialModel = theBroker.getNewUniaxialMaterial(matClassTag); if (theMaterialModel != 0) { theModels[i] = theMaterialModel; theMaterialModel->setDbTag(classTags(i+numMaterials)); } else { opserr << "FATAL ParallelMaterial::recvSelf() "; opserr << " could not get a UniaxialMaterial \n"; exit(-1); } } theModels[i]->recvSelf(cTag, theChannel, theBroker); } return 0; }