PenaltyMP_FE::PenaltyMP_FE(int tag, Domain &theDomain, MP_Constraint &TheMP, double Alpha) :FE_Element(tag, 2,(TheMP.getConstrainedDOFs()).Size()+ (TheMP.getRetainedDOFs()).Size()), theMP(&TheMP), theConstrainedNode(0) , theRetainedNode(0), tang(0), resid(0), C(0), alpha(Alpha) { int size; const ID &id1 = theMP->getConstrainedDOFs(); size = id1.Size(); const ID &id2 = theMP->getRetainedDOFs(); size += id2.Size(); tang = new Matrix(size,size); resid = new Vector(size); C = new Matrix(id1.Size(),size); if (tang == 0 || resid == 0 || C == 0 || tang->noCols() != size || C->noCols() != size || resid->Size() != size) { opserr << "FATAL PenaltyMP_FE::PenaltyMP_FE() - out of memory\n"; exit(-1); } theRetainedNode = theDomain.getNode(theMP->getNodeRetained()); theConstrainedNode = theDomain.getNode(theMP->getNodeConstrained()); if (theRetainedNode == 0 || theConstrainedNode == 0) { opserr << "FATAL PenaltyMP_FE::PenaltyMP_FE() - Constrained or Retained"; opserr << " Node does not exist in Domain\n"; opserr << theMP->getNodeRetained() << " " << theMP->getNodeConstrained() << endln; exit(-1); } // set up the dof groups tags DOF_Group *dofGrpPtr = 0; dofGrpPtr = theRetainedNode->getDOF_GroupPtr(); if (dofGrpPtr != 0) myDOF_Groups(0) = dofGrpPtr->getTag(); else opserr << "WARNING PenaltyMP_FE::PenaltyMP_FE() - node no Group yet?\n"; dofGrpPtr = theConstrainedNode->getDOF_GroupPtr(); if (dofGrpPtr != 0) myDOF_Groups(1) = dofGrpPtr->getTag(); else opserr << "WARNING PenaltyMP_FE::PenaltyMP_FE() - node no Group yet?\n"; if (theMP->isTimeVarying() == false) { this->determineTangent(); // we can free up the space taken by C as it is no longer needed if (C != 0) delete C; C = 0; } }
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; }