| 511 | // |
| 512 | |
| 513 | bool |
| 514 | Domain::addSP_Constraint(SP_Constraint *spConstraint) |
| 515 | { |
| 516 | //#ifdef _G3DEBUG |
| 517 | // check the Node exists in the Domain |
| 518 | int nodeTag = spConstraint->getNodeTag(); |
| 519 | int dof = spConstraint->getDOF_Number(); |
| 520 | |
| 521 | Node *nodePtr = this->getNode(nodeTag); |
| 522 | if (nodePtr == 0) { |
| 523 | opserr << "Domain::addSP_Constraint - cannot add as node node with tag" << |
| 524 | nodeTag << "does not exist in model\n"; |
| 525 | return false; |
| 526 | } |
| 527 | |
| 528 | // check that the DOF specified exists at the Node |
| 529 | int numDOF = nodePtr->getNumberDOF(); |
| 530 | if (numDOF < dof) { |
| 531 | opserr << "Domain::addSP_Constraint - cannot add as node with tag" << |
| 532 | nodeTag << "does not have associated constrained DOF\n"; |
| 533 | return false; |
| 534 | } |
| 535 | // #endif |
| 536 | |
| 537 | // check if an existing SP_COnstraint exists for that dof at the node |
| 538 | bool found = false; |
| 539 | SP_ConstraintIter &theExistingSPs = this->getSPs(); |
| 540 | SP_Constraint *theExistingSP = 0; |
| 541 | while ((found == false) && ((theExistingSP = theExistingSPs()) != 0)) { |
| 542 | int spNodeTag = theExistingSP->getNodeTag(); |
| 543 | int spDof = theExistingSP->getDOF_Number(); |
| 544 | if (nodeTag == spNodeTag && spDof == dof) { |
| 545 | found = true; |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | if (found == true) { |
| 550 | opserr << "Domain::addSP_Constraint - cannot add as node already constrained in that dof by existing SP_Constraint\n"; |
| 551 | spConstraint->Print(opserr); |
| 552 | return false; |
| 553 | } |
| 554 | |
| 555 | // check that no other object with similar tag exists in model |
| 556 | int tag = spConstraint->getTag(); |
| 557 | TaggedObject *other = theSPs->getComponentPtr(tag); |
| 558 | if (other != 0) { |
| 559 | opserr << "Domain::addSP_Constraint - cannot add as constraint with tag " << |
| 560 | tag << "already exists in model\n"; |
| 561 | spConstraint->Print(opserr); |
| 562 | |
| 563 | return false; |
| 564 | } |
| 565 | |
| 566 | bool result = theSPs->addComponent(spConstraint); |
| 567 | if (result == false) { |
| 568 | opserr << "Domain::addSP_Constraint - cannot add constraint with tag" << |
| 569 | tag << "to the container\n"; |
| 570 | return false; |
no test coverage detected