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

Function printB

SRC/runtime/commands/analysis/analysis.cpp:641–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639}
640
641static int
642printB(ClientData clientData, Tcl_Interp *interp, Tcl_Size argc, TCL_Char ** const argv)
643{
644 assert(clientData != nullptr);
645 BasicAnalysisBuilder *builder = (BasicAnalysisBuilder*)clientData;
646
647 int res = 0;
648
649 FileStream outputFile;
650 OPS_Stream *output = &opserr;
651
652 bool ret = false;
653 int currentArg = 1;
654 while (currentArg < argc) {
655 if ((strcmp(argv[currentArg], "file") == 0) ||
656 (strcmp(argv[currentArg], "-file") == 0)) {
657 currentArg++;
658 if (currentArg == argc) {
659 opserr << G3_WARN_PROMPT << "-file missing argument\n";
660 return TCL_ERROR;
661 }
662
663 if (outputFile.setFile(argv[currentArg]) != 0) {
664 opserr << "print <filename> .. - failed to open file: "
665 << argv[currentArg] << endln;
666 return TCL_ERROR;
667 }
668 output = &outputFile;
669 } else if ((strcmp(argv[currentArg], "ret") == 0) ||
670 (strcmp(argv[currentArg], "-ret") == 0)) {
671 ret = true;
672 }
673 currentArg++;
674 }
675
676 LinearSOE *theSOE = builder->getLinearSOE();
677 if (theSOE != nullptr) {
678
679 // TODO
680 builder->formUnbalance();
681
682 if (theSOE->getNumEqn() == 0) {
683 opserr << OpenSees::PromptValueError << "System of equations is empty\n";
684 return TCL_ERROR;
685 }
686
687 const Vector &b = theSOE->getB();
688
689 if (ret) {
690 const int size = b.Size();
691 Tcl_Obj* list = Tcl_NewListObj(size, nullptr);
692 for (int i = 0; i < size; ++i)
693 Tcl_ListObjAppendElement(interp, list, Tcl_NewDoubleObj(b[i]));
694
695 Tcl_SetObjResult(interp, list);
696 } else {
697 *output << b;
698 outputFile.close();

Callers

nothing calls this directly

Calls 7

getBMethod · 0.80
setFileMethod · 0.45
getLinearSOEMethod · 0.45
formUnbalanceMethod · 0.45
getNumEqnMethod · 0.45
SizeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected