| 661 | |
| 662 | |
| 663 | int |
| 664 | FileDatastore::recvMatrix(int dataTag, int commitTag, |
| 665 | Matrix &theMatrix, |
| 666 | ChannelAddress *theAddress) |
| 667 | { |
| 668 | |
| 669 | if (currentCommitTag != commitTag) |
| 670 | this->resetFilePointers(); |
| 671 | |
| 672 | currentCommitTag = commitTag; |
| 673 | |
| 674 | FileDatastoreOutputFile *theFileStruct; |
| 675 | |
| 676 | // |
| 677 | // next we see if we already have this file; |
| 678 | // if not we need to create data structure & open it |
| 679 | // if we have data structure, need to check file is opened (we close in a commit) |
| 680 | // |
| 681 | |
| 682 | // we first check Matrix not too big |
| 683 | int noMatCols= theMatrix.noCols(); |
| 684 | int noMatRows = theMatrix.noRows(); |
| 685 | int matSize = noMatRows * noMatCols;; |
| 686 | int stepSize = sizeof(int) + matSize*sizeof(double); |
| 687 | |
| 688 | theMatFilesIter = theMatFiles.find(matSize); |
| 689 | if (theMatFilesIter == theMatFiles.end()) { |
| 690 | |
| 691 | // we first check if we need to resize recv buffer |
| 692 | if (matSize > currentMaxDouble) { |
| 693 | if (this->resizeDouble(matSize) < 0) { |
| 694 | opserr << "FileDatastore::recvMatrix() - failed in resizeDouble()\n"; |
| 695 | return -1; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | char *fileName = new char[strlen(dataBase)+21]; |
| 700 | theFileStruct = new FileDatastoreOutputFile; |
| 701 | |
| 702 | if (fileName == 0 || theFileStruct == 0) { |
| 703 | opserr << "FileDatastore::recvMatrix() - out of memory\n"; |
| 704 | return -1; |
| 705 | } |
| 706 | |
| 707 | static char intName[20]; |
| 708 | strcpy(fileName, dataBase); |
| 709 | sprintf(intName,"%d.%d",matSize,commitTag); |
| 710 | strcat(fileName,".MATs."); |
| 711 | strcat(fileName,intName); |
| 712 | |
| 713 | if (this->openFile(fileName, theFileStruct, stepSize) < 0) { |
| 714 | opserr << "FileDatastore::recvMatrix() - could not open file\n"; |
| 715 | delete [] fileName; |
| 716 | return -1; |
| 717 | } else |
| 718 | theMatFiles.insert(MAP_FILES_TYPE(matSize, theFileStruct)); |
| 719 | |
| 720 | delete [] fileName; |
nothing calls this directly
no test coverage detected