| 308 | } |
| 309 | |
| 310 | int |
| 311 | AutoConstraintHandler::handle(const ID* nodesLast) |
| 312 | { |
| 313 | // first check links exist to a Domain and an AnalysisModel object |
| 314 | Domain* theDomain = this->getDomainPtr(); |
| 315 | AnalysisModel* theModel = this->getAnalysisModelPtr(); |
| 316 | Integrator* theIntegrator = this->getIntegratorPtr(); |
| 317 | if ((theDomain == 0) || (theModel == 0) || (theIntegrator == 0)) { |
| 318 | opserr << "WARNING AutoConstraintHandler::handle() - "; |
| 319 | opserr << " setLinks() has not been called\n"; |
| 320 | return -1; |
| 321 | } |
| 322 | |
| 323 | // create a multimap (key = NodeID, value = SP_Constraint). |
| 324 | // multimap allows for duplicate keys because we may have multiple SP |
| 325 | // constraints on the same node. |
| 326 | // in this way we have : |
| 327 | // a) a fast access to the key (to tell whether a node is constrained or not) |
| 328 | // b) and a range of SP_Constraints acting on that node |
| 329 | std::unordered_multimap<int, SP_Constraint*> sp_map; |
| 330 | { |
| 331 | SP_ConstraintIter& theSPs = theDomain->getDomainAndLoadPatternSPs(); |
| 332 | SP_Constraint* theSP; |
| 333 | while ((theSP = theSPs()) != 0) |
| 334 | sp_map.emplace(std::make_pair(theSP->getNodeTag(), theSP)); |
| 335 | } |
| 336 | |
| 337 | // create a DOF_Group for each Node and add it to the AnalysisModel |
| 338 | // create a TrasformationDOF_Group for nodes constrained in SP_Constraints |
| 339 | int countDOF = 0; |
| 340 | { |
| 341 | NodeIter& theNodes = theDomain->getNodes(); |
| 342 | Node* nodPtr; |
| 343 | int numDofGrp = 0; |
| 344 | while ((nodPtr = theNodes()) != 0) { |
| 345 | |
| 346 | // process this node |
| 347 | DOF_Group* dofPtr = 0; |
| 348 | int nodeTag = nodPtr->getTag(); |
| 349 | |
| 350 | // if the node is constrained in an SP constraint |
| 351 | // handle it with the transformation method |
| 352 | auto it_range = sp_map.equal_range(nodeTag); |
| 353 | if (it_range.first != it_range.second) { |
| 354 | |
| 355 | // this node is constrained in 1 or more SP_Constraints. |
| 356 | // handle it with a TransformationDOF_Group. |
| 357 | // note: the TransformationConstraintHandler pointer is useless in TDOF... |
| 358 | TransformationDOF_Group* tDofPtr = |
| 359 | new TransformationDOF_Group(numDofGrp++, nodPtr, nullptr); |
| 360 | dofPtr = tDofPtr; |
| 361 | |
| 362 | // count and add all SP_Constraints. |
| 363 | // if verbose, keep track of conflicting constraints |
| 364 | int numSPs = 0; |
| 365 | for (auto it = it_range.first; it != it_range.second; it++) { |
| 366 | tDofPtr->addSP_Constraint(*(it->second)); |
| 367 | numSPs++; |
nothing calls this directly
no test coverage detected