Skip to content

Commit

Permalink
Removing check on send/recv, sending vectors every time
Browse files Browse the repository at this point in the history
  • Loading branch information
mhscott committed Jun 18, 2024
1 parent 2217479 commit b7a2901
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 96 deletions.
140 changes: 46 additions & 94 deletions SRC/domain/pattern/PathTimeSeries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ using std::ios;
PathTimeSeries::PathTimeSeries()
:TimeSeries(TSERIES_TAG_PathTimeSeries),
thePath(0), time(0), currentTimeLoc(0), cFactor(0.0),
dbTag1(0), dbTag2(0), lastSendCommitTag(-1), lastChannel(0),
useLast(false)
dbTag1(0), dbTag2(0), useLast(false)
{
// does nothing
}
Expand All @@ -62,8 +61,7 @@ PathTimeSeries::PathTimeSeries(int tag,
bool last)
:TimeSeries(tag, TSERIES_TAG_PathTimeSeries),
thePath(0), time(0), currentTimeLoc(0), cFactor(theFactor),
dbTag1(0), dbTag2(0), lastSendCommitTag(-1), lastChannel(0),
useLast(last)
dbTag1(0), dbTag2(0), useLast(last)
{
// check vectors are of same size
if (theLoadPath.Size() != theTimePath.Size()) {
Expand Down Expand Up @@ -97,8 +95,7 @@ PathTimeSeries::PathTimeSeries(int tag,
bool last)
:TimeSeries(tag, TSERIES_TAG_PathTimeSeries),
thePath(0), time(0), currentTimeLoc(0), cFactor(theFactor),
dbTag1(0), dbTag2(0), lastSendCommitTag(-1), lastChannel(0),
useLast(last)
dbTag1(0), dbTag2(0), useLast(last)
{
// determine the number of data points
int numDataPoints1 =0;
Expand Down Expand Up @@ -205,8 +202,7 @@ PathTimeSeries::PathTimeSeries(int tag,
bool last)
:TimeSeries(tag, TSERIES_TAG_PathTimeSeries),
thePath(0), time(0), currentTimeLoc(0), cFactor(theFactor),
dbTag1(0), dbTag2(0), lastSendCommitTag(-1), lastChannel(0),
useLast(last)
dbTag1(0), dbTag2(0), useLast(last)
{
// determine the number of data points
int numDataPoints = 0;
Expand Down Expand Up @@ -408,25 +404,15 @@ PathTimeSeries::sendSelf(int commitTag, Channel &theChannel)
int dbTag = this->getDbTag();
Vector data(6+1);
data(0) = cFactor;
int size = -1;
int size = thePath->Size();
data(1) = size;

if (thePath != 0) {
size = thePath->Size();
data(1) = size;
if (dbTag1 == 0) {
dbTag1 = theChannel.getDbTag();
dbTag2 = theChannel.getDbTag();
}
data(2) = dbTag1;
data(3) = dbTag2;
if (dbTag1 == 0) {
dbTag1 = theChannel.getDbTag();
dbTag2 = theChannel.getDbTag();
}

if ((lastSendCommitTag == -1) && (theChannel.isDatastore() == 1)) {
lastSendCommitTag = commitTag;
}

data(4) = lastSendCommitTag;
data(2) = dbTag1;
data(3) = dbTag2;

if (useLast == true)
data(5) = 1;
Expand All @@ -441,45 +427,26 @@ PathTimeSeries::sendSelf(int commitTag, Channel &theChannel)

// we only send the vector data if this is the first time it is sent to the database
// or the channel is for sending the data to a remote process

if (lastChannel != &theChannel || (lastSendCommitTag == commitTag) || (theChannel.isDatastore() == 0)) {

lastChannel = &theChannel;

if (size > 0) {
Vector ddata(2*size);
for (int i = 0; i < size; i++)
ddata(i) = (*thePath)(i);
for (int i = 0; i < size; i++)
ddata(size+i) = (*time)(i);
result = theChannel.sendVector(dbTag, commitTag, ddata);
if (result < 0) {
opserr << "PathTimeSeries::sendSelf() - ";
opserr << "channel failed to send the Path Vector\n";
return result;
}
}

/*
if (thePath != 0) {
result = theChannel.sendVector(dbTag1, commitTag, *thePath);
if (result < 0) {
opserr << "PathTimeSeries::sendSelf() - ";
opserr << "channel failed to send the Path Vector\n";
return result;
}
// ...
// Now sending the vector data every time

if (thePath != 0) {
result = theChannel.sendVector(dbTag1, commitTag, *thePath);
if (result < 0) {
opserr << "PathTimeSeries::sendSelf() - ";
opserr << "channel failed to send the Path Vector\n";
return result;
}
if (time != 0) {
result = theChannel.sendVector(dbTag2, commitTag, *time);
if (result < 0) {
opserr << "PathTimeSeries::sendSelf() - ";
opserr << "channel failed to send the Path Vector\n";
return result;
}
}
if (time != 0) {
result = theChannel.sendVector(dbTag2, commitTag, *time);
if (result < 0) {
opserr << "PathTimeSeries::sendSelf() - ";
opserr << "channel failed to send the Path Vector\n";
return result;
}
*/
return 0;
}

return 0;
}

Expand All @@ -497,17 +464,14 @@ PathTimeSeries::recvSelf(int commitTag, Channel &theChannel,
}
cFactor = data(0);
int size = data(1);
lastSendCommitTag = data(4);

if (data(5) == 1)
useLast = true;
else
useLast = false;

// get the data cvector, only receive them once as they cannot change
if (thePath == 0 && size > 0) {
dbTag1 = data(2);
dbTag2 = data(3);
// allocate the data vector if needed
if ((thePath == 0 || time == 0) && size > 0) {

thePath = new Vector(size);
time = new Vector(size);
Expand All @@ -524,36 +488,24 @@ PathTimeSeries::recvSelf(int commitTag, Channel &theChannel,
time = 0;
return -1;
}

if (size > 0) {
Vector ddata(2*size);
result = theChannel.recvVector(dbTag, commitTag, ddata);
if (result < 0) {
opserr << "PathTimeSeries::recvSelf() - ";
opserr << "channel failed to receive the Path/time data Vector\n";
return result;
}
for (int i = 0; i < size; i++)
(*thePath)(i) = ddata(i);
for (int i = 0; i < size; i++)
(*time)(i) = ddata(size+i);
}

/*
result = theChannel.recvVector(dbTag1, lastSendCommitTag, *thePath);
if (result < 0) {
opserr << "PathTimeSeries::recvSelf() - ";
opserr << "channel failed to receive the Path Vector\n";
return result;
}
result = theChannel.recvVector(dbTag2, lastSendCommitTag, *time);
if (result < 0) {
opserr << "PathTimeSeries::recvSelf() - ";
opserr << "channel failed to receive the time Vector\n";
return result;
}
*/
}

dbTag1 = data(2);
dbTag2 = data(3);

result = theChannel.recvVector(dbTag1, commitTag, *thePath);
if (result < 0) {
opserr << "PathTimeSeries::recvSelf() - ";
opserr << "channel failed to receive the Path Vector\n";
return result;
}
result = theChannel.recvVector(dbTag2, commitTag, *time);
if (result < 0) {
opserr << "PathTimeSeries::recvSelf() - ";
opserr << "channel failed to receive the time Vector\n";
return result;
}

return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions SRC/domain/pattern/PathTimeSeries.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ class PathTimeSeries : public TimeSeries
int currentTimeLoc; // current location in time
double cFactor; // additional factor on the returned load factor
int dbTag1, dbTag2; // additional database tags needed for vector objects
int lastSendCommitTag;
Channel *lastChannel;
bool useLast;
};

Expand Down

0 comments on commit b7a2901

Please sign in to comment.