MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / sendMatrix

Method sendMatrix

SRC/database/FileDatastore.cpp:496–658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494
495
496int
497FileDatastore::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;

Callers

nothing calls this directly

Calls 8

resetFilePointersMethod · 0.95
resizeDoubleMethod · 0.95
openFileMethod · 0.95
noColsMethod · 0.45
noRowsMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected