Graph & AnalysisModel::getDOFGroupGraph(void) { if (myGroupGraph == 0) { int numVertex = this->getNumDOF_Groups(); if (numVertex == 0) { opserr << "WARNING AnalysisMode::getGroupGraph"; opserr << " - 0 vertices, has the Domain been populated?\n"; exit(-1); } // myGroupGraph = new Graph(numVertex); MapOfTaggedObjects *graphStorage = new MapOfTaggedObjects(); myGroupGraph = new Graph(*graphStorage); if (numVertex == 0) { opserr << "WARNING AnalysisMode::getGroupGraph"; opserr << " - out of memory\n"; exit(-1); } DOF_Group *dofPtr; // now create the vertices with a reference equal to the DOF_Group number. // and a tag which ranges from 0 through numVertex-1 DOF_GrpIter &dofIter2 = this->getDOFs(); int count = START_VERTEX_NUM; while ((dofPtr = dofIter2()) != 0) { int DOF_GroupTag = dofPtr->getTag(); int DOF_GroupNodeTag = dofPtr->getNodeTag(); int numDOF = dofPtr->getNumFreeDOF(); Vertex *vertexPtr = new Vertex(DOF_GroupTag, DOF_GroupNodeTag, 0, numDOF); if (vertexPtr == 0) { opserr << "WARNING DOF_GroupGraph::DOF_GroupGraph"; opserr << " - Not Enough Memory to create "; opserr << count << "th Vertex\n"; return *myGroupGraph; } myGroupGraph->addVertex(vertexPtr); } // now add the edges, by looping over the Elements, getting their // IDs and adding edges between DOFs for equation numbers >= START_EQN_NUM FE_Element *elePtr; FE_EleIter &eleIter = this->getFEs(); while((elePtr = eleIter()) != 0) { const ID &id = elePtr->getDOFtags(); int size = id.Size(); for (int i=0; i<size; i++) { int dof1 = id(i); for (int j=0; j<size; j++) if (i != j) { int dof2 = id(j); myGroupGraph->addEdge(dof1,dof2); } } } } return *myGroupGraph; }
int PlainNumberer::numberDOF(int lastDOF) { int eqnNumber = 0; // start equation number = 0 // get a pointer to the model & check its not null AnalysisModel *theModel = this->getAnalysisModelPtr(); Domain *theDomain = 0; if (theModel != 0) theDomain = theModel->getDomainPtr(); if (theModel == 0 || theDomain == 0) { opserr << "WARNING PlainNumberer::numberDOF(int) -"; opserr << " - no AnalysisModel - has setLinks() been invoked?\n"; return -1; } if (lastDOF != -1) { opserr << "WARNING PlainNumberer::numberDOF(int lastDOF):"; opserr << " does not use the lastDOF as requested\n"; } // iterate throgh the DOFs first time setting -2 values DOF_GrpIter &theDOFs = theModel->getDOFs(); DOF_Group *dofPtr; while ((dofPtr = theDOFs()) != 0) { const ID &theID = dofPtr->getID(); for (int i=0; i<theID.Size(); i++) if (theID(i) == -2) dofPtr->setID(i,eqnNumber++); } // iterate throgh the DOFs second time setting -3 values DOF_GrpIter &moreDOFs = theModel->getDOFs(); while ((dofPtr = moreDOFs()) != 0) { const ID &theID = dofPtr->getID(); for (int i=0; i<theID.Size(); i++) if (theID(i) == -3) dofPtr->setID(i,eqnNumber++); } // iterate through the DOFs one last time setting any -4 values DOF_GrpIter &tDOFs = theModel->getDOFs(); while ((dofPtr = tDOFs()) != 0) { const ID &theID = dofPtr->getID(); int have4s = 0; for (int i=0; i<theID.Size(); i++) if (theID(i) == -4) have4s = 1; if (have4s == 1) { int nodeID = dofPtr->getNodeTag(); // loop through the MP_Constraints to see if any of the // DOFs are constrained, note constraint matrix must be diagonal // with 1's on the diagonal MP_ConstraintIter &theMPs = theDomain->getMPs(); MP_Constraint *mpPtr; while ((mpPtr = theMPs()) != 0 ) { // note keep looping over all in case multiple constraints // are used to constrain a node -- can't assume intelli user if (mpPtr->getNodeConstrained() == nodeID) { int nodeRetained = mpPtr->getNodeRetained(); Node *nodeRetainedPtr = theDomain->getNode(nodeRetained); DOF_Group *retainedDOF = nodeRetainedPtr->getDOF_GroupPtr(); const ID&retainedDOFIDs = retainedDOF->getID(); const ID&constrainedDOFs = mpPtr->getConstrainedDOFs(); const ID&retainedDOFs = mpPtr->getRetainedDOFs(); for (int i=0; i<constrainedDOFs.Size(); i++) { int dofC = constrainedDOFs(i); int dofR = retainedDOFs(i); int dofID = retainedDOFIDs(dofR); dofPtr->setID(dofC, dofID); } } } } } eqnNumber--; int numEqn = eqnNumber - START_EQN_NUMBER +1; // iterate through the FE_Element getting them to set their IDs FE_EleIter &theEle = theModel->getFEs(); FE_Element *elePtr; while ((elePtr = theEle()) != 0) elePtr->setID(); // set the numOfEquation in the Model theModel->setNumEqn(numEqn); return numEqn; }