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

Function printNode

SRC/tcl/commands.cpp:2152–2214  ·  view source on GitHub ↗

printNode(): function to print out the nodal information contained in line print node input: nodeArg: integer equal to arg count to node plus 1 output: output stream to which the results are sent

Source from the content-addressed store, hash-verified

2150// output: output stream to which the results are sent
2151//
2152int
2153printNode(ClientData clientData, Tcl_Interp *interp, int argc,
2154 TCL_Char **argv, OPS_Stream &output)
2155{
2156 int flag = 0; // default flag sent to a nodes Print() method
2157 int nodeArg = 0;
2158
2159 // if just 'print <filename> node' print all the nodes - no flag
2160 if (argc == 0) {
2161 NodeIter &theNodes = theDomain.getNodes();
2162 Node *theNode;
2163 while ((theNode = theNodes()) != 0)
2164 theNode->Print(output);
2165 return TCL_OK;
2166 }
2167
2168 // if 'print <filename> node flag int <int int ..>' get the flag
2169 if ((strcmp(argv[0],"flag") == 0) ||
2170 (strcmp(argv[0],"-flag") == 0)) {
2171 // get the specified flag
2172 if (argc <= nodeArg) {
2173 opserr << "WARNING print <filename> node <flag int> no int specified \n";
2174 return TCL_ERROR;
2175 }
2176 if (Tcl_GetInt(interp, argv[1], &flag) != TCL_OK) {
2177 opserr << "WARNING print node failed to get integer flag: \n";
2178 opserr << argv[nodeArg] << endln;
2179 return TCL_ERROR;
2180 }
2181 nodeArg += 2;
2182 }
2183
2184 // now print the nodes with the specified flag, 0 by default
2185
2186 // if 'print <filename> node flag'
2187 // print out all the nodes in the domain with flag
2188 if (nodeArg == argc) {
2189 NodeIter &theNodes = theDomain.getNodes();
2190 Node *theNode;
2191 while ((theNode = theNodes()) != 0)
2192 theNode->Print(output, flag);
2193 return TCL_OK;
2194 } else {
2195 // otherwise print out the specified nodes i j k .. with flag
2196 int numNodes = argc-nodeArg;
2197 ID *theNodes = new ID(numNodes);
2198 for (int i= 0; i<numNodes; i++) {
2199 int nodeTag;
2200 if (Tcl_GetInt(interp, argv[nodeArg], &nodeTag) != TCL_OK) {
2201 opserr << "WARNING print node failed to get integer: " << argv[nodeArg] << endln;
2202 return TCL_ERROR;
2203 }
2204 (*theNodes)(i) = nodeTag;
2205 nodeArg++;
2206 }
2207
2208 theDomain.Print(output, theNodes, 0, flag);
2209 delete theNodes;

Callers 1

printModelFunction · 0.70

Calls 2

getNodesMethod · 0.80
PrintMethod · 0.45

Tested by

no test coverage detected