int LoadPattern::sendSelf(int cTag, Channel &theChannel) { // get my current database tag // NOTE - dbTag equals 0 if not sending to a database OR has not yet been sent int myDbTag = this->getDbTag(); // into an ID we place all info needed to determine state of LoadPattern int numNodLd, numEleLd, numSPs; ID lpData(11); numNodLd = theNodalLoads->getNumComponents(); numEleLd = theElementalLoads->getNumComponents(); numSPs = theSPs->getNumComponents(); lpData(10) = this->getTag(); lpData(0) = currentGeoTag; lpData(1) = numNodLd; lpData(2) = numEleLd; lpData(3) = numSPs; if (dbNod == 0) { dbNod = theChannel.getDbTag(); dbEle = theChannel.getDbTag(); dbSPs = theChannel.getDbTag(); } lpData(4) = dbNod; lpData(5) = dbEle; lpData(6) = dbSPs; lpData(7) = isConstant; if (theSeries != 0) { int dbtag = theSeries->getDbTag(); int classtag = theSeries->getClassTag(); if (dbtag == 0) { dbtag = theChannel.getDbTag(); theSeries->setDbTag(dbtag); } lpData(8) = classtag; lpData(9) = dbtag; } else lpData(8) = -1; // see if we can save sending the vector containing just the load factor // will happen in parallel if sending the loadPattern .. not in database if (theChannel.sendID(myDbTag, cTag, lpData) < 0) { opserr << "LoadPattern::sendSelf - channel failed to send the initial ID\n"; return -1; } if (isConstant == 0) { Vector data(2); data(0) = loadFactor; data(1) = scaleFactor; if (theChannel.sendVector(myDbTag, cTag, data) < 0) { opserr << "LoadPattern::sendSelf - channel failed to send the Vector\n"; return -2; } } if (theSeries != 0) if (theSeries->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - the TimeSeries failed to send\n"; return -3; } // now check if data defining the objects in the LoadPAttern needs to be sent // NOTE THIS APPROACH MAY NEED TO CHANGE FOR VERY LARGE PROBLEMS IF CHANNEL CANNOT // HANDLE VERY LARGE ID OBJECTS. /* if (theChannel.isDatastore() == 1) { static ID theLastSendTag(1); if (theChannel.recvID(myDbTag,0,theLastSendTag) == 0) lastGeoSendTag = theLastSendTag(0); else lastGeoSendTag = -1; } */ if (lastChannel != theChannel.getTag() || lastGeoSendTag != currentGeoTag || theChannel.isDatastore() == 0) { lastChannel = theChannel.getTag(); // // into an ID we are gonna place the class and db tags for each node so can rebuild // this ID we then send to the channel // // create the ID and get the node iter if (numNodLd != 0) { ID nodeData(numNodLd*2); NodalLoad *theNode; NodalLoadIter &theNodes = this->getNodalLoads(); int loc =0; // loop over nodes in domain adding their classTag and dbTag to the ID while ((theNode = theNodes()) != 0) { nodeData(loc) = theNode->getClassTag(); int dbTag = theNode->getDbTag(); // if dbTag still 0 get one from Channel; // if this tag != 0 set the dbTag in node if (dbTag == 0 && myDbTag != 0) {// go get a new tag and setDbTag in ele if this not 0 dbTag = theChannel.getDbTag(); if (dbTag != 0) theNode->setDbTag(dbTag); } nodeData(loc+1) = dbTag; loc+=2; } // now send the ID if (theChannel.sendID(dbNod, currentGeoTag, nodeData) < 0) { opserr << "LoadPattern::sendSelf - channel failed to send the NodalLoads ID\n"; return -4; } } // we do the same for elemental loads as we did for nodal loads above .. see comments above! if (numEleLd != 0) { ID elementData(numEleLd*2); ElementalLoad *theEle; ElementalLoadIter &theElements = this->getElementalLoads(); int loc = 0; while ((theEle = theElements()) != 0) { elementData(loc) = theEle->getClassTag(); int dbTag = theEle->getDbTag(); if (dbTag == 0 && myDbTag != 0) {// go get a new tag and setDbTag in ele if this not 0 dbTag = theChannel.getDbTag(); if (dbTag != 0) theEle->setDbTag(dbTag); } elementData(loc+1) = dbTag; loc+=2; } // now send the ID if (theChannel.sendID(dbEle, currentGeoTag, elementData) < 0) { opserr << "Domain::send - channel failed to send the element ID\n"; return -5; } } // we do the same for SP_Constraints as for NodalLoads above .. see comments above! if (numSPs != 0) { ID spData(numSPs*2); SP_Constraint *theSP; SP_ConstraintIter &theSPs = this->getSPs(); int loc = 0; while ((theSP = theSPs()) != 0) { spData(loc) = theSP->getClassTag(); int dbTag = theSP->getDbTag(); if (dbTag == 0 && myDbTag != 0) {// go get a new tag and setDbTag in ele if this not 0 dbTag = theChannel.getDbTag(); if (dbTag != 0) theSP->setDbTag(dbTag); } spData(loc+1) = dbTag; loc+=2; } if (theChannel.sendID(dbSPs, currentGeoTag, spData) < 0) { opserr << "LoadPAttern::sendSelf - channel failed sending SP_Constraint ID\n"; return -6; } } // set the lst send db tag so we don't have to do all that again lastGeoSendTag = currentGeoTag; if (theChannel.isDatastore() == 1) { static ID theLastSendTag(1); theLastSendTag(0) = lastGeoSendTag; theChannel.sendID(myDbTag,0, theLastSendTag); } } // now we invoke sendSelf on all the NodalLoads, ElementalLoads and SP_Constraints // which have been added to the LoadCase NodalLoad *theNode; NodalLoadIter &theNodes = this->getNodalLoads(); while ((theNode = theNodes()) != 0) { if (theNode->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - node with tag " << theNode->getTag() << " failed in sendSelf\n"; return -7; } } ElementalLoad *theEle; ElementalLoadIter &theElements = this->getElementalLoads(); while ((theEle = theElements()) != 0) { if (theEle->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - element with tag " << theEle->getTag() << " failed in sendSelf\n"; return -8; } } SP_Constraint *theSP; SP_ConstraintIter &theSPs = this->getSPs(); while ((theSP = theSPs()) != 0) { if (theSP->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - SP_Constraint: " << *theSP << " failed sendSelf\n"; return -9; } } // if we get here we are successfull return 0; }