| 3419 | |
| 3420 | |
| 3421 | int |
| 3422 | TclCommand_addNodalMass(ClientData clientData, Tcl_Interp *interp, int argc, |
| 3423 | TCL_Char **argv) |
| 3424 | { |
| 3425 | // ensure the destructor has not been called - |
| 3426 | if (theTclBuilder == 0) { |
| 3427 | opserr << "WARNING builder has been destroyed - load \n"; |
| 3428 | return TCL_ERROR; |
| 3429 | } |
| 3430 | |
| 3431 | // int ndf = theTclBuilder->getNDF(); |
| 3432 | int ndf = argc - 2; |
| 3433 | |
| 3434 | // make sure at least one other argument to contain type of system |
| 3435 | if (argc < (2 + ndf)) { |
| 3436 | opserr << "WARNING bad command - want: mass nodeId " << ndf << " mass values\n"; |
| 3437 | printCommand(argc, argv); |
| 3438 | return TCL_ERROR; |
| 3439 | } |
| 3440 | |
| 3441 | // get the id of the node |
| 3442 | int nodeId; |
| 3443 | if (Tcl_GetInt(interp, argv[1], &nodeId) != TCL_OK) { |
| 3444 | opserr << "WARNING invalid nodeId: " << argv[1]; |
| 3445 | opserr << " - mass nodeId " << ndf << " forces\n"; |
| 3446 | return TCL_ERROR; |
| 3447 | } |
| 3448 | |
| 3449 | // check for mass terms |
| 3450 | Matrix mass(ndf,ndf); |
| 3451 | double theMass; |
| 3452 | for (int i=0; i<ndf; i++) |
| 3453 | { |
| 3454 | if (Tcl_GetDouble(interp, argv[i+2], &theMass) != TCL_OK) |
| 3455 | { |
| 3456 | opserr << "WARNING invalid nodal mass term\n"; |
| 3457 | opserr << "node: " << nodeId << ", dof: " << i+1 << endln; |
| 3458 | return TCL_ERROR; |
| 3459 | } |
| 3460 | mass(i,i) = theMass; |
| 3461 | } |
| 3462 | |
| 3463 | if (theTclDomain->setMass(mass, nodeId) != 0) { |
| 3464 | opserr << "WARNING failed to set mass at node " << nodeId << endln; |
| 3465 | return TCL_ERROR; |
| 3466 | } |
| 3467 | |
| 3468 | // if get here we have successfully created the node and added it to the domain |
| 3469 | return TCL_OK; |
| 3470 | } |
| 3471 | |
| 3472 | |
| 3473 |
nothing calls this directly
no test coverage detected