| 494 | |
| 495 | |
| 496 | int |
| 497 | FileDatastore::sendMatrix(int dataTag, int commitTag, |
| 498 | const Matrix &theMatrix, |
| 499 | ChannelAddress *theAddress) |
| 500 | { |
| 501 | |
| 502 | if (currentCommitTag != commitTag) |
| 503 | this->resetFilePointers(); |
| 504 | |
| 505 | currentCommitTag = commitTag; |
| 506 | |
| 507 | FileDatastoreOutputFile *theFileStruct; |
| 508 | |
| 509 | // |
| 510 | // next we see if we already have this file; |
| 511 | // if not we need to create data structure & open it |
| 512 | // if we have data structure, need to check file is opened (we close in a commit) |
| 513 | // |
| 514 | |
| 515 | // we first ensure that the Matrix is not too big |
| 516 | int noMatCols= theMatrix.noCols(); |
| 517 | int noMatRows = theMatrix.noRows(); |
| 518 | int matSize = noMatRows * noMatCols;; |
| 519 | int stepSize = sizeof(int) + matSize*sizeof(double); |
| 520 | |
| 521 | theMatFilesIter = theMatFiles.find(matSize); |
| 522 | if (theMatFilesIter == theMatFiles.end()) { |
| 523 | |
| 524 | // we first check if we need to resize send buffer |
| 525 | if (matSize > currentMaxDouble) { |
| 526 | if (this->resizeDouble(matSize) < 0) { |
| 527 | opserr << "FileDatastore::sendMatrix() - failed in resizeInt()\n"; |
| 528 | return -1; |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | char *fileName = new char[strlen(dataBase)+21]; |
| 533 | theFileStruct = new FileDatastoreOutputFile; |
| 534 | |
| 535 | if (fileName == 0 || theFileStruct == 0) { |
| 536 | opserr << "FileDatastore::sendMatrix() - out of memory\n"; |
| 537 | return -1; |
| 538 | } |
| 539 | |
| 540 | static char intName[20]; |
| 541 | strcpy(fileName, dataBase); |
| 542 | sprintf(intName,"%d.%d",matSize,commitTag); |
| 543 | strcat(fileName,".MATs."); |
| 544 | strcat(fileName,intName); |
| 545 | |
| 546 | if (this->openFile(fileName, theFileStruct, stepSize) < 0) { |
| 547 | opserr << "FileDatastore::sendMatrix() - could not open file\n"; |
| 548 | delete [] fileName; |
| 549 | return -1; |
| 550 | } else |
| 551 | theMatFiles.insert(MAP_FILES_TYPE(matSize, theFileStruct)); |
| 552 | |
| 553 | delete [] fileName; |
nothing calls this directly
no test coverage detected