int PFEMIntegrator::newStep(double deltaT) { if (deltaT <= 0.0) { opserr << "PFEMIntegrator::newStep() - error in variable\n"; opserr << "dT = " << deltaT << endln; return -2; } // get a pointer to the AnalysisModel and Domain AnalysisModel *theModel = this->getAnalysisModel(); if(theModel == 0) { opserr << "Analysis model has not been linked - PFEMIntegrator::newStep()\n"; return -1; } Domain* theDomain = theModel->getDomainPtr(); if(theDomain == 0) { opserr<<"WARNING: no domain is set for the model"; opserr<<" -- PFEMIntegrator::newStep()\n"; return -1; } // set the constants c1 = deltaT; c2 = 1.0; c3 = 1.0/deltaT; c4 = deltaT*deltaT; c5 = deltaT; c6 = 1.0; // check if domainchange() is called if (U == 0) { opserr << "PFEMIntegrator::newStep() - domainChange() failed or hasn't been called\n"; return -3; } // set response at t to be that at t+deltaT of previous step (*Ut) = *U; (*Utdot) = *Udot; (*Utdotdot) = *Udotdot; // determinte new disps and accels U->addVector(1.0, *Utdot, deltaT); Udotdot->Zero(); // set states theModel->setDisp(*U); theModel->setAccel(*Udotdot); // increment the time to t+deltaT and apply the load double time = theModel->getCurrentDomainTime(); time += deltaT; if (theModel->updateDomain(time, deltaT) < 0) { opserr << "PFEMIntegrator::newStep() - failed to update the domain\n"; return -4; } return 0; }
int XC::ParallelNumberer::numberDOF(int lastDOF) { int result = 0; // get a pointer to the model & check its not null AnalysisModel *theModel = this->getAnalysisModelPtr(); Domain *theDomain = 0; if(theModel) theDomain = theModel->getDomainPtr(); if(theModel == 0 || theDomain == 0) { std::cerr << "WARNING XC::ParallelNumberer::numberDOF(int) -"; std::cerr << " - no AnalysisModel.\n"; return -1; } if(lastDOF != -1) { std::cerr << "WARNING XC::ParallelNumberer::numberDOF(int lastDOF):"; std::cerr << " does not use the lastDOF as requested\n"; } Graph &theGraph= theModel->getDOFGroupGraph(); // if subdomain, collect graph, send it off, get // ID back containing dof tags & start id numbers. if(processID != 0) { CommParameters cp(0,*theChannels[0]); const int numVertex = theGraph.getNumVertex(); /* static XC::ID test(2); test(0) = processID; test(1) = 25; theChannel->recvID(0, 0, test); */ cp.sendMovable(theGraph,DistributedObj::getDbTagData(),CommMetaData(1)); // recv iD ID theID(2*numVertex); cp.receiveID(theID,DistributedObj::getDbTagData(),CommMetaData(2)); // set vertex numbering based on ID received for(int i=0; i<numVertex; i ++) { const int vertexTag= theID(i); int startID= theID(i+numVertex); //Vertex *vertexPtr = theGraph.getVertexPtr(vertexTag); const int dofTag= vertexTag; DOF_Group *dofPtr= theModel->getDOF_GroupPtr(dofTag); if(!dofPtr) { std::cerr << "WARNING ParallelNumberer::numberDOF - "; std::cerr << "DOF_Group " << dofTag << "not in XC::AnalysisModel!\n"; result= -4; } else { const ID &theDOFID= dofPtr->getID(); //std::cerr << "P: " << processID << " dofTag: " << dofTag << " " << "start: " << startID << " " << theDOFID; const int idSize= theDOFID.Size(); for(int j=0; j<idSize; j++) if(theDOFID(j) == -2 || theDOFID(j) == -3) dofPtr->setID(j, startID++); } //const ID &theDOFID= dofPtr->getID(); } cp.sendID(theID,DistributedObj::getDbTagData(),CommMetaData(2)); } else { // if XC::main domain, collect graphs from all subdomains, // merge into 1, number this one, send to subdomains the // id containing dof tags & start id's. // for P0 domain determine original vertex and ref tags const int numVertex= theGraph.getNumVertex(); const int numVertexP0= numVertex; ID vertexTags(numVertex); ID vertexRefs(numVertex); Vertex *vertexPtr; int loc= 0; VertexIter &theVertices= theGraph.getVertices(); while((vertexPtr= theVertices()) != 0) { vertexTags[loc]= vertexPtr->getTag(); vertexRefs[loc]= vertexPtr->getRef(); loc++; } const int numChannels= theChannels.size(); std::vector<ID> theSubdomainIDs(numChannels); FEM_ObjectBroker theBroker; // for each subdomain we receive graph, create an XC::ID (to store // subdomain graph to merged graph vertex mapping and the final // subdoain graph vertex to startDOF mapping) and finally merge the // subdomain graph for(int j=0; j<numChannels; j++) { CommParameters cp(0,*theChannels[j]); Graph theSubGraph; /* static XC::ID test(2); test(0)= processID; test(1)= 25; theChannel->sendID(0, 0, test); */ cp.receiveMovable(theSubGraph,DistributedObj::getDbTagData(),CommMetaData(3)); theSubdomainIDs[j]= ID(theSubGraph.getNumVertex()*2); this->mergeSubGraph(theGraph, theSubGraph, vertexTags, vertexRefs, theSubdomainIDs[j]); } // we use graph numberer if one was provided in constructor, // otherwise we number based on subdomains (all in subdomain 1 numbered first, // then those in 2 not in 1 and so on till done. // GraphNumberer *theNumberer= this->getGraphNumbererPtr(); ID theOrderedRefs(theGraph.getNumVertex()); if(theNumberer) { // use the supplied graph numberer to number the merged graph theOrderedRefs= theNumberer->number(theGraph, lastDOF); } else { // assign numbers based on the subdomains int loc= 0; for(int l=0; l<numChannels; l++) { const ID &theSubdomain= theSubdomainIDs[l]; int numVertexSubdomain= theSubdomain.Size()/2; for(int i=0; i<numVertexSubdomain; i++) { const int vertexTagMerged= theSubdomain(i+numVertexSubdomain); // int refTag= vertexRefs[vertexTags.getLocation(vertexTagMerged)]; if(theOrderedRefs.getLocation(vertexTagMerged) == -1) theOrderedRefs[loc++]= vertexTagMerged; } } // now order those not yet ordered in p0 for(int j=0; j<numVertexP0; j++) { int refTagP0= vertexTags[j]; if(theOrderedRefs.getLocation(refTagP0) == -1) theOrderedRefs[loc++]= refTagP0; } } int count= 0; for(int i=0; i<theOrderedRefs.Size(); i++) { int vertexTag= theOrderedRefs(i); // int vertexTag= vertexTags[vertexRefs.getLocation(tag)]; Vertex *vertexPtr= theGraph.getVertexPtr(vertexTag); int numDOF= vertexPtr->getColor(); vertexPtr->setTmp(count); count += numDOF; } // number own dof's for(int i=0; i<numVertexP0; i++ ) { int vertexTag= vertexTags(i); Vertex *vertexPtr= theGraph.getVertexPtr(vertexTag); int startID= vertexPtr->getTmp(); int dofTag= vertexTag; DOF_Group *dofPtr; dofPtr= theModel->getDOF_GroupPtr(dofTag); if(dofPtr == 0) { std::cerr << "WARNING XC::ParallelNumberer::numberDOF - "; std::cerr << "DOF_Group (P0) " << dofTag << "not in XC::AnalysisModel!\n"; result= -4; } else { const ID &theDOFID= dofPtr->getID(); int idSize= theDOFID.Size(); for(int j=0; j<idSize; j++) if(theDOFID(j) == -2 || theDOFID(j) == -3) dofPtr->setID(j, startID++); } } // now given the ordered refs we determine the mapping for each subdomain // and send the id with the information back to the subdomain, which it uses to order // it's own graph for(int k=0; k<numChannels; k++) { CommParameters cp(0,*theChannels[k]); ID &theSubdomain= theSubdomainIDs[k]; int numVertexSubdomain= theSubdomain.Size()/2; for(int i=0; i<numVertexSubdomain; i++) { int vertexTagMerged= theSubdomain[numVertexSubdomain+i]; Vertex *vertexPtr= theGraph.getVertexPtr(vertexTagMerged); int startDOF= vertexPtr->getTmp(); theSubdomain[i+numVertexSubdomain]= startDOF; } cp.sendID(theSubdomain,DistributedObj::getDbTagData(),CommMetaData(4)); cp.receiveID(theSubdomain,DistributedObj::getDbTagData(),CommMetaData(4)); } } // iterate through the XC::FE_Element getting them to set their IDs FE_EleIter &theEle= theModel->getFEs(); FE_Element *elePtr; while ((elePtr= theEle()) != 0) elePtr->setID(); return result; }
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; }
int PFEMIntegrator::formSensitivityRHS(int passedGradNumber) { sensitivityFlag = 1; // Set a couple of data members gradNumber = passedGradNumber; // Get pointer to the SOE LinearSOE *theSOE = this->getLinearSOE(); // Get the analysis model AnalysisModel *theModel = this->getAnalysisModel(); // Randomness in external load (including randomness in time series) // Get domain Domain *theDomain = theModel->getDomainPtr(); // Loop through nodes to zero the unbalaced load Node *nodePtr; NodeIter &theNodeIter = theDomain->getNodes(); while ((nodePtr = theNodeIter()) != 0) nodePtr->zeroUnbalancedLoad(); // Loop through load patterns to add external load sensitivity LoadPattern *loadPatternPtr; LoadPatternIter &thePatterns = theDomain->getLoadPatterns(); double time; while((loadPatternPtr = thePatterns()) != 0) { time = theDomain->getCurrentTime(); loadPatternPtr->applyLoadSensitivity(time); } // Randomness in element/material contributions // Loop through FE elements FE_Element *elePtr; FE_EleIter &theEles = theModel->getFEs(); while((elePtr = theEles()) != 0) { theSOE->addB( elePtr->getResidual(this), elePtr->getID() ); } // Loop through DOF groups (IT IS IMPORTANT THAT THIS IS DONE LAST!) DOF_Group *dofPtr; DOF_GrpIter &theDOFs = theModel->getDOFs(); while((dofPtr = theDOFs()) != 0) { theSOE->addB( dofPtr->getUnbalance(this), dofPtr->getID() ); } // Reset the sensitivity flag sensitivityFlag = 0; return 0; }