From 71957ca26d79b4c8a5206f996f20e5e15a723156 Mon Sep 17 00:00:00 2001 From: "Michael H. Scott" Date: Mon, 20 May 2024 12:21:52 -0700 Subject: [PATCH 1/2] Implementing send/recvSelf --- .../uniaxial/backbone/MultilinearBackbone.cpp | 72 ++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/SRC/material/uniaxial/backbone/MultilinearBackbone.cpp b/SRC/material/uniaxial/backbone/MultilinearBackbone.cpp index 66a818ee89..4dc20f6e3c 100644 --- a/SRC/material/uniaxial/backbone/MultilinearBackbone.cpp +++ b/SRC/material/uniaxial/backbone/MultilinearBackbone.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -235,12 +236,79 @@ MultilinearBackbone::getVariable (int varID, double &theValue) int MultilinearBackbone::sendSelf(int commitTag, Channel &theChannel) { - return -1; + int dbTag = this->getDbTag(); + + ID idata(2); + idata(0) = this->getTag(); + idata(1) = numPoints; + + if (theChannel.sendID(dbTag, commitTag, idata) < 0) { + opserr << "MultilinearBackbone::sendSelf - failed to send ID data" << endln; + return -1; + } + + Vector data(4*numPoints + 3); + for (int i = 0; i < numPoints; i++) { + data(i) = e[i]; + data(numPoints+1 + i) = s[i]; + data(2*(numPoints+1) + i) = c[i]; + data(3*(numPoints+1) + i) = E[i]; + } + data(numPoints) = e[numPoints]; + data(2*numPoints+1) = s[numPoints]; + data(3*numPoints+2) = c[numPoints]; + + if (theChannel.sendVector(dbTag, commitTag, data) < 0) { + opserr << "MultilinearBackbone::sendSelf - failed to send data" << endln; + return -2; + } + + return 0; } int MultilinearBackbone::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { - return -1; + int dbTag = this->getDbTag(); + + ID idata(2); + + if (theChannel.recvID(dbTag, commitTag, idata) < 0) { + opserr << "MultilinearBackbone::recvSelf -- could not receive ID data" << endln; + return -1; + } + + this->setTag(idata(0)); + numPoints = idata(1); + + Vector data(4*numPoints + 3); + if (theChannel.recvVector(dbTag, commitTag, data) < 0) { + opserr << "MultilinearBackbone::recvSelf -- could not receive data" << endln; + return -2; + } + + if (numPoints > 0) { + if (e != 0) delete [] e; + if (s != 0) delete [] s; + if (c != 0) delete [] c; + if (E != 0) delete [] E; + + e = new double[numPoints+1]; + s = new double[numPoints+1]; + c = new double[numPoints+1]; + E = new double[numPoints]; + + for (int i = 0; i < numPoints; i++) { + e[i] = data(i); + s[i] = data(numPoints+1 + i); + c[i] = data(2*(numPoints+1) + i); + E[i] = data(3*(numPoints+1) + i); + } + e[numPoints] = data(numPoints); + s[numPoints] = data(2*numPoints+1); + c[numPoints] = data(3*numPoints+2); + } + + return 0; } From e9cc9c677ed53f575ed1345b2386110bcbd3437d Mon Sep 17 00:00:00 2001 From: "Michael H. Scott" Date: Mon, 20 May 2024 12:22:06 -0700 Subject: [PATCH 2/2] Error message if send fails --- SRC/material/uniaxial/backbone/MaterialBackbone.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SRC/material/uniaxial/backbone/MaterialBackbone.cpp b/SRC/material/uniaxial/backbone/MaterialBackbone.cpp index 33d9b64995..90c28a916d 100644 --- a/SRC/material/uniaxial/backbone/MaterialBackbone.cpp +++ b/SRC/material/uniaxial/backbone/MaterialBackbone.cpp @@ -202,7 +202,11 @@ MaterialBackbone::sendSelf(int cTag, Channel &theChannel) } res += theMaterial->sendSelf(cTag, theChannel); - + if (res < 0) { + opserr << "MaterialBackbone::sendSelf -- failed to send material" << endln; + return res; + } + return res; }