void SelectLoadInitialStaticAnalysis::recoverLoads() { if(!modified){ opserr << "===== FATAL Error =====\n"; opserr << "It is attemped to recover loads\n"; opserr << "although they are not modified \n"; exit(-1); } modified=false; LoadPattern* thePattern; LoadPattern* thePat; LoadPatternIter& thePatterns = theDomain->getLoadPatterns(); while((thePattern = thePatterns()) != NULL){ int tag=thePattern->getTag(); thePat=theDomain->removeLoadPattern(tag); } theOrgPatternIter->reset(); while((thePattern = (*theOrgPatternIter)()) != NULL){ theDomain->addLoadPattern(thePattern); } if(print){ output << "\n"; output << " after recover load in theDomain \n"; output << "\n"; LoadPatternIter& thePatterns = theDomain->getLoadPatterns(); while((thePattern = thePatterns()) != 0){ int tag=thePattern->getTag(); output << " load pattern " << tag <<"\n"; } } }
void Analyzer::recoverLoads() { LoadPattern* thePattern; LoadPattern* thePat; LoadPatternIter& thePatterns = theDomain->getLoadPatterns(); ///// remove all currently in the domain ///// while((thePattern = thePatterns()) != 0){ int tag=thePattern->getTag(); thePat=theDomain->removeLoadPattern(tag); } //// add all original ///// for( int i=0; i<numOrgPatterns; i++){ thePattern=theOrgPatterns[i]; theDomain->addLoadPattern(thePattern); } if(print){ output << "\n"; output << " after recover load in theDomain \n"; output << "\n"; LoadPatternIter& thePatterns = theDomain->getLoadPatterns(); while((thePattern = thePatterns()) != 0){ int tag=thePattern->getTag(); output << " load pattern " << tag <<"\n"; } } }
void* OPS_LoadPattern() { if(OPS_GetNumRemainingInputArgs() < 2) { opserr<<"insufficient number of args\n"; return 0; } LoadPattern *thePattern = 0; // get tags int tags[2]; int numData = 2; if(OPS_GetIntInput(&numData, &tags[0]) < 0) { opserr << "WARNING failed to get load pattern tag\n"; return 0; } // get factor double fact = 1.0; if(OPS_GetNumRemainingInputArgs() > 1) { std::string type = OPS_GetString(); if(type=="-fact" || type=="-factor") { numData = 1; if(OPS_GetDoubleInput(&numData,&fact) < 0) { opserr << "WARNING failed to get load pattern factor\n"; return 0; } } } // create pattern thePattern = new LoadPattern(tags[0], fact); TimeSeries *theSeries = OPS_getTimeSeries(tags[1]); // check if(thePattern == 0 || theSeries == 0) { if(thePattern == 0) { opserr << "WARNING - out of memory creating LoadPattern \n"; } else { opserr << "WARNING - problem creating TimeSeries for LoadPattern \n"; } // clean up the memory and return an error if(thePattern != 0) delete thePattern; return 0; } thePattern->setTimeSeries(theSeries); return thePattern; }
mObject patternsToJSON(void) { LoadPatternIter &thePatterns = theDomain.getLoadPatterns(); LoadPattern *thePattern; TimeSeries *theSeries; NodalLoadIter *nli; NodalLoad *nload; const Vector *load_vec; // TODO: // ElementalLoadIter *eli; // SP_ConstraintIter *spci; mObject patterns, pattern, nloads; mArray arr; mValue tmp, tmp2, tmp3; char tag_str[15]; int i, size; patterns.clear(); while ((thePattern = thePatterns()) != 0) { pattern.clear(); // TODO: tmp = thePattern->getClassType(); pattern["type"] = tmp; theSeries = thePattern->getTimeSeries(); tmp2 = theSeries->getTag(); sprintf(tag_str, "%d", tmp2.get_int()); pattern["tsTag"] = tag_str; nli = &(thePattern->getNodalLoads()); nloads.clear(); while((nload = (*nli)()) != 0) { tmp2 = nload->getNodeTag(); sprintf(tag_str, "%d", tmp2.get_int()); load_vec = nload->getLoadValue(); size = load_vec->Size(); arr.clear(); for (i = 0; i < size; i++) { tmp3 = (*load_vec)(i); arr.push_back(tmp3); } nloads[tag_str] = arr; } pattern["nodalLoads"] = nloads; tmp2 = thePattern->getTag(); sprintf(tag_str, "%d", tmp2.get_int()); patterns[tag_str] = pattern; } return patterns; }
void SelectLoadInitialStaticAnalysis::modifyLoads() { modified=true; LoadPattern* thePattern; LoadPattern* thePat; if(NumLoadPatterns != 0){ LoadPatternIter& thePatterns = theDomain->getLoadPatterns(); while((thePattern = thePatterns()) != NULL){ int tag=thePattern->getTag(); thePat=theDomain->removeLoadPattern(tag); } theOrgPatternIter->reset(); while((thePattern = (*theOrgPatternIter)()) != NULL){ int tag=thePattern->getTag(); bool found=false; for(int i=0; i<NumLoadPatterns; i++){ if(tag == StaticLoadPatterns[i]){ found=true; break; } } if(found) theDomain->addLoadPattern(thePattern); } } else{ opserr<< "!!!!! WARNING !!!!\n"; opserr<< "No Load is selected in the initialstatic analysis\n"; opserr<< "all Loads are applied to the model\n"; } if(print){ output << "\n"; output << " after modify load in theDomain \n"; output << "\n"; LoadPatternIter& thePatterns = theDomain->getLoadPatterns(); while((thePattern = thePatterns()) != NULL){ int tag=thePattern->getTag(); output << " load pattern " << tag <<"\n"; } output << "\n"; output << " after modify load in theOrgPatterns \n"; output << "\n"; theOrgPatternIter->reset(); while((thePattern = (*theOrgPatternIter)()) != NULL){ int tag=thePattern->getTag(); output << " load pattern " << tag <<"\n"; } } }
void Analyzer::modifyLoads() { LoadPattern* thePattern; LoadPattern* thePat; if(NumLoadPatterns != 0){ LoadPatternIter& thePatterns = theDomain->getLoadPatterns(); ///// remove all ///// while((thePattern = thePatterns()) != 0){ int tag=thePattern->getTag(); thePat=theDomain->removeLoadPattern(tag); } for( int i=0; i<numOrgPatterns; i++){ thePattern=theOrgPatterns[i]; int tag=thePattern->getTag(); bool found=false; for(int i=0; i<NumLoadPatterns; i++){ if(tag == LoadPatterns[i]){ found=true; break; } } if(found) theDomain->addLoadPattern(thePattern); } } if(print){ output << "\n"; output << " after modify load in theDomain \n"; output << "\n"; LoadPatternIter& thePatterns = theDomain->getLoadPatterns(); while((thePattern = thePatterns()) != 0){ int tag=thePattern->getTag(); output << " load pattern " << tag <<"\n"; } output << "\n"; output << " after modify load in theOrgPatterns \n"; output << "\n"; for( int i=0; i<numOrgPatterns; i++){ thePattern=theOrgPatterns[i]; int tag=thePattern->getTag(); output << " load pattern " << tag <<"\n"; } } }
void SelectLoadInitialStaticAnalysis::constandrecoverLoads(double time=0.0) { theDomain->setLoadConstant(); theDomain->setCurrentTime(time); theDomain->setCommittedTime(time); if(!modified){ opserr << "===== FATAL Error =====\n"; opserr << "It is attemped to recover loads\n"; opserr << "although they are not modified \n"; exit(-1); } modified=false; LoadPattern* thePatternOrg; LoadPattern* thePattern; theOrgPatternIter->reset(); LoadPatternIter& thePatterns = theDomain->getLoadPatterns(); while((thePatternOrg = (*theOrgPatternIter)()) != NULL){ bool found=false; int id=thePatternOrg->getTag(); thePatterns.reset(); while((thePattern = thePatterns()) != NULL){ int tag=thePattern->getTag(); if(id==tag){ found=true; break; } } if(!found){ theDomain->addLoadPattern(thePatternOrg); } } if(print){ output << "\n"; output << " after recover load in theDomain \n"; output << "\n"; LoadPatternIter& thePatterns = theDomain->getLoadPatterns(); while((thePattern = thePatterns()) != 0){ int tag=thePattern->getTag(); output << " load pattern " << tag <<"\n"; } } }
SP_Constraint * ShadowSubdomain::removeSP_Constraint(int loadTag, int loadPattern) { // remove the object from the container TaggedObject *mc = theShadowLPs->getComponentPtr(loadPattern); if (mc == 0) return 0; LoadPattern *theLoadPattern = (LoadPattern *)mc; SP_Constraint *res = theLoadPattern->removeSP_Constraint(loadTag); if (res == 0) return 0; msgData(0) = ShadowActorSubdomain_removeSP_ConstraintFromPattern; msgData(1) = loadTag; msgData(2) = loadPattern; this->sendID(msgData); return res; }
int ActorSubdomain::run(void) { static Vector theVect(4); static Vector theVect1(1); bool exitYet = false; int res = 0; while (exitYet == false) { int action; res = this->recvID(msgData); if (res != 0) { opserr << "ActorSubdomain::run - error receiving msgData\n"; exitYet = true; action = ShadowActorSubdomain_DIE; } else { action = msgData(0); } bool change; int theType, theOtherType, tag, dbTag, loadPatternTag; int startTag, endTag, axisDirn, numSP, i, numMode, dof; Element *theEle; Node *theNod; SP_Constraint *theSP; MP_Constraint *theMP; LoadPattern *theLoadPattern; NodalLoad *theNodalLoad; ElementalLoad *theElementalLoad; DomainDecompositionAnalysis *theDDAnalysis; const Matrix *theMatrix; const Vector *theVector; Matrix *theM; Vector *theV; ID *theI, *theNodeTags, *theEleTags; PartitionedModelBuilder *theBuilder; IncrementalIntegrator *theIntegrator; EquiSolnAlgo *theAlgorithm; LinearSOE *theSOE; EigenSOE *theEigenSOE; ConvergenceTest *theTest; Recorder *theRecorder; bool res, generalized, findSmallest; double doubleRes; int intRes; NodeResponseType nodeResponseType; Parameter *theParameter; int argc; char **argv; char *allResponseArgs; char *currentLoc; int argLength, msgLength; Message theMessage; const ID *theID; // opserr << "ActorSubdomain ACTION: " << action << endln; switch (action) { case ShadowActorSubdomain_setTag: tag = msgData(1); // subdomain tag this->setTag(tag); this->Actor::setCommitTag(tag); break; case ShadowActorSubdomain_analysisStep: this->recvVector(theVect); this->analysisStep(theVect(0)); break; case ShadowActorSubdomain_eigenAnalysis: numMode = msgData(1); if (msgData(2) == 0) generalized = true; else generalized = false; if (msgData(3) == 0) findSmallest = true; else findSmallest = false; this->eigenAnalysis(numMode, generalized, findSmallest); break; /* case ShadowActorSubdomain_buildSubdomain: theType = msgData(1); tag = msgData(3); // subdomain tag this->setTag(tag); tag = msgData(2); // numSubdomains theBuilder = theBroker->getPtrNewPartitionedModelBuilder(*this, theType); this->recvObject(*theBuilder); this->buildSubdomain(tag, *theBuilder); break; */ case ShadowActorSubdomain_getRemoteData: theID = &(this->getExternalNodes()); msgData(0) = theID->Size(); msgData(1) = this->getNumDOF(); this->sendID(msgData); if (theID->Size() != 0) this->sendID(*theID); break; case ShadowActorSubdomain_getCost: theVect(0) = this->getCost(); // have to use [] for Sun's CC! this->sendVector(theVect); break; case ShadowActorSubdomain_addElement: theType = msgData(1); dbTag = msgData(2); theEle = theBroker->getNewElement(theType); if (theEle != 0) { theEle->setDbTag(dbTag); this->recvObject(*theEle); bool result = this->addElement(theEle); if (result == true) msgData(0) = 0; else msgData(0) = -1; } else msgData(0) = -1; /* this->recvID(msgData); opserr << "ActorSubdomain::addElement() : " << msgData; msgData(0) = 1; msgData(1) = 2; msgData(2) = 3; msgData(3) = 4; this->sendID(msgData); */ break; case ShadowActorSubdomain_hasNode: theType = msgData(1); res = this->hasNode(theType); if (res == true) msgData(0) = 0; else msgData(0) = -1; this->sendID(msgData); break; case ShadowActorSubdomain_hasElement: theType = msgData(1); res = this->hasElement(theType); if (res == true) msgData(0) = 0; else msgData(0) = -1; this->sendID(msgData); break; case ShadowActorSubdomain_addNode: theType = msgData(1); dbTag = msgData(2); theNod = theBroker->getNewNode(theType); if (theNod != 0) { theNod->setDbTag(dbTag); this->recvObject(*theNod); bool result = this->addNode(theNod); if (result == true) msgData(0) = 0; else msgData(0) = -1; } else msgData(0) = -1; // opserr << "ActorSubdomain::add node: " << *theNod; break; case ShadowActorSubdomain_addExternalNode: theType = msgData(1); dbTag = msgData(2); theNod = theBroker->getNewNode(theType); if (theNod != 0) { theNod->setDbTag(dbTag); this->recvObject(*theNod); bool result = this->Subdomain::addExternalNode(theNod); delete theNod; /* Node *dummy = new Node(*theNod); delete theNod; opserr << *dummy; opserr << dummy->getMass(); */ if (result == true) msgData(0) = 0; else msgData(0) = -1; } else msgData(0) = -1; break; case ShadowActorSubdomain_addSP_Constraint: theType = msgData(1); dbTag = msgData(2); theSP = theBroker->getNewSP(theType); if (theSP != 0) { theSP->setDbTag(dbTag); this->recvObject(*theSP); bool result = this->addSP_Constraint(theSP); if (result == true) msgData(0) = 0; else msgData(0) = -1; } else msgData(0) = -1; break; case ShadowActorSubdomain_addSP_ConstraintAXIS: axisDirn = msgData(1); theI = new ID(msgData(2)); theV = new Vector(2); SP_Constraint_SetNextTag(msgData(3)); endTag = 0; this->recvID(*theI); this->recvVector(*theV); msgData(0) = 0; numSP = this->addSP_Constraint(axisDirn, (*theV)(0), *theI, (*theV)(1)); endTag = SP_Constraint_GetNextTag(); msgData(1) = numSP; msgData(2) = endTag; this->domainChange(); this->sendID(msgData); delete theV; delete theI; /* DONT BOTHER SENDING if (numSP > 0) { theI = new ID(numSP); for (i = 0; i<numSP; i++) { theSP = this->getSP_Constraint(i+startTag); (*theI)(i) = theSP->getClassTag(); } this->sendID(*theI); opserr << "Actor: sent: " << *theI; for (i = 0; i<numSP; i++) { theSP = this->getSP_Constraint(i+startTag); if (theSP != 0) this->sendObject(*theSP); else opserr << "ActorSubdomain::addSP_AXIS :: PROBLEMS\n"; } delete theI; } opserr << "ActorSubdomain::addSP_AXIS :: DONE\n"; */ break; case ShadowActorSubdomain_addMP_Constraint: theType = msgData(1); dbTag = msgData(2); theMP = theBroker->getNewMP(theType); if (theMP != 0) { theMP->setDbTag(dbTag); this->recvObject(*theMP); bool result = this->addMP_Constraint(theMP); if (result == true) msgData(0) = 0; else msgData(0) = -1; } else msgData(0) = -1; break; case ShadowActorSubdomain_addLoadPattern: theType = msgData(1); dbTag = msgData(2); theLoadPattern = theBroker->getNewLoadPattern(theType); if (theLoadPattern != 0) { theLoadPattern->setDbTag(dbTag); this->recvObject(*theLoadPattern); bool result = this->addLoadPattern(theLoadPattern); if (result == true) msgData(0) = 0; else msgData(0) = -1; } else msgData(0) = -1; break; case ShadowActorSubdomain_addNodalLoadToPattern: theType = msgData(1); dbTag = msgData(2); loadPatternTag = msgData(3); theNodalLoad = theBroker->getNewNodalLoad(theType); if (theNodalLoad != 0) { theNodalLoad->setDbTag(dbTag); this->recvObject(*theNodalLoad); bool result = this->addNodalLoad(theNodalLoad, loadPatternTag); if (result == true) msgData(0) = 0; else msgData(0) = -1; } else msgData(0) = -1; break; case ShadowActorSubdomain_addElementalLoadToPattern: theType = msgData(1); dbTag = msgData(2); loadPatternTag = msgData(3); theElementalLoad = theBroker->getNewElementalLoad(theType); if (theElementalLoad != 0) { theElementalLoad->setDbTag(dbTag); this->recvObject(*theElementalLoad); bool result = this->addElementalLoad(theElementalLoad, loadPatternTag); if (result == true) msgData(0) = 0; else msgData(0) = -1; } else msgData(0) = -1; break; case ShadowActorSubdomain_addSP_ConstraintToPattern: theType = msgData(1); dbTag = msgData(2); loadPatternTag = msgData(3); theSP = theBroker->getNewSP(theType); if (theSP != 0) { theSP->setDbTag(dbTag); this->recvObject(*theSP); bool result = this->addSP_Constraint(theSP, loadPatternTag); if (result == true) msgData(0) = 0; else msgData(0) = -1; } else msgData(0) = -1; break; case ShadowActorSubdomain_removeElement: tag = msgData(1); theEle = this->removeElement(tag); if (theEle != 0) msgData(0) = theEle->getClassTag(); else msgData(0) = -1; this->sendID(msgData); if (theEle != 0) { this->sendObject(*theEle); delete theEle; } msgData(0) = 0; break; case ShadowActorSubdomain_removeNode: tag = msgData(1); theNod = this->removeNode(tag); if (theNod != 0) msgData(0) = theNod->getClassTag(); else msgData(0) = -1; this->sendID(msgData); if (theNod != 0) { this->sendObject(*theNod); delete theNod; } msgData(0) = 0; break; case ShadowActorSubdomain_removeSP_Constraint: tag = msgData(1); theSP = this->removeSP_Constraint(tag); break; case ShadowActorSubdomain_removeSP_ConstraintNoTag: tag = msgData(1); dof = msgData(2); loadPatternTag = msgData(3); msgData(0) = this->removeSP_Constraint(tag, dof, loadPatternTag); this->sendID(msgData); break; case ShadowActorSubdomain_removeMP_Constraint: tag = msgData(1); theMP = this->removeMP_Constraint(tag); break; case ShadowActorSubdomain_removeLoadPattern: tag = msgData(1); theLoadPattern = this->removeLoadPattern(tag); break; case ShadowActorSubdomain_removeNodalLoadFromPattern: tag = msgData(1); theType = msgData(2); theNodalLoad = this->removeNodalLoad(tag, theType); break; case ShadowActorSubdomain_removeElementalLoadFromPattern: tag = msgData(1); theType = msgData(2); theElementalLoad = this->removeElementalLoad(tag, theType); break; case ShadowActorSubdomain_removeSP_ConstraintFromPattern: tag = msgData(1); theType = msgData(2); theSP = this->removeSP_Constraint(tag, theType); break; case ShadowActorSubdomain_getElement: tag = msgData(1); theEle = this->getElement(tag); if (theEle != 0) msgData(0) = theEle->getClassTag(); else msgData(0) = -1; this->sendID(msgData); if (theEle != 0) { this->sendObject(*theEle); } msgData(0) = 0; break; case ShadowActorSubdomain_getNode: tag = msgData(1); theNod = this->getNode(tag); if (theNod != 0) msgData(0) = theNod->getClassTag(); else msgData(0) = -1; this->sendID(msgData); if (theNod != 0) { this->sendObject(*theNod); } msgData(0) = 0; break; case ShadowActorSubdomain_Print: this->Print(opserr, msgData(3)); this->sendID(msgData); break; case ShadowActorSubdomain_PrintNodeAndEle: theNodeTags = 0; theEleTags = 0; if (msgData(1) != 0) { theNodeTags = new ID(msgData(1)); this->recvID(*theNodeTags); } if (msgData(2) != 0) { theEleTags = new ID(msgData(2)); this->recvID(*theEleTags); } this->Print(opserr, theNodeTags, theEleTags, msgData(3)); if (theNodeTags != 0) delete theNodeTags; if (theEleTags != 0) delete theEleTags; this->sendID(msgData); break; case ShadowActorSubdomain_applyLoad: this->recvVector(theVect); this->applyLoad(theVect(0)); break; case ShadowActorSubdomain_setCommittedTime: this->recvVector(theVect); this->setCurrentTime(theVect(0)); this->setCommittedTime(theVect(0)); break; case ShadowActorSubdomain_setLoadConstant: this->setLoadConstant(); break; case ShadowActorSubdomain_update: this->update(); break; case ShadowActorSubdomain_updateTimeDt: this->updateTimeDt(); break; case ShadowActorSubdomain_computeNodalResponse: tag = msgData(1); if (lastResponse == 0) lastResponse = new Vector(tag); else if (lastResponse->Size() != tag) { delete lastResponse; lastResponse = new Vector(tag); } this->recvVector(*lastResponse); this->computeNodalResponse(); break; case ShadowActorSubdomain_record: this->record(); break; case ShadowActorSubdomain_commit: this->commit(); break; case ShadowActorSubdomain_revertToLastCommit: this->revertToLastCommit(); break; case ShadowActorSubdomain_revertToStart: this->revertToStart(); this->sendID(msgData); break; case ShadowActorSubdomain_addRecorder: theType = msgData(1); theRecorder = theBroker->getPtrNewRecorder(theType); if (theRecorder != 0) { this->recvObject(*theRecorder); this->addRecorder(*theRecorder); } break; case ShadowActorSubdomain_removeRecorders: this->removeRecorders(); this->barrierCheck(1); break; case ShadowActorSubdomain_removeRecorder: theType = msgData(1); this->removeRecorder(theType); break; case ShadowActorSubdomain_wipeAnalysis: this->wipeAnalysis(); break; case ShadowActorSubdomain_setDomainDecompAnalysis: theType = msgData(1); theDDAnalysis = theBroker->getNewDomainDecompAnalysis(theType, *this); if (theDDAnalysis != 0) { this->recvObject(*theDDAnalysis); this->setDomainDecompAnalysis(*theDDAnalysis); msgData(0) = 0; } else msgData(0) = -1; break; case ShadowActorSubdomain_setAnalysisAlgorithm: theType = msgData(1); theAlgorithm = theBroker->getNewEquiSolnAlgo(theType); if (theAlgorithm != 0) { this->recvObject(*theAlgorithm); this->setAnalysisAlgorithm(*theAlgorithm); msgData(0) = 0; } else msgData(0) = -1; break; case ShadowActorSubdomain_setAnalysisIntegrator: theType = msgData(1); theIntegrator = theBroker->getNewIncrementalIntegrator(theType); if (theIntegrator != 0) { this->recvObject(*theIntegrator); this->setAnalysisIntegrator(*theIntegrator); msgData(0) = 0; } else msgData(0) = -1; this->sendID(msgData); break; case ShadowActorSubdomain_setAnalysisLinearSOE: theType = msgData(1); theSOE = theBroker->getNewLinearSOE(theType); if (theSOE != 0) { this->recvObject(*theSOE); this->setAnalysisLinearSOE(*theSOE); msgData(0) = 0; } else msgData(0) = -1; break; case ShadowActorSubdomain_setAnalysisEigenSOE: theType = msgData(1); theEigenSOE = theBroker->getNewEigenSOE(theType); if (theEigenSOE != 0) { this->recvObject(*theEigenSOE); this->setAnalysisEigenSOE(*theEigenSOE); msgData(0) = 0; } else msgData(0) = -1; break; case ShadowActorSubdomain_setAnalysisConvergenceTest: theType = msgData(1); theTest = theBroker->getNewConvergenceTest(theType); if (theTest != 0) { this->recvObject(*theTest); this->setAnalysisConvergenceTest(*theTest); msgData(0) = 0; } else msgData(0) = -1; break; case ShadowActorSubdomain_domainChange: this->domainChange(); tag = this->getNumDOF(); if (tag != 0) { if (lastResponse == 0) lastResponse = new Vector(tag); else if (lastResponse->Size() != tag) { delete lastResponse; lastResponse = new Vector(tag); } } break; case ShadowActorSubdomain_getDomainChangeFlag: change = this->getDomainChangeFlag(); if (change == true) msgData(0) = 0; else msgData(0) = 1; this->sendID(msgData); break; case ShadowActorSubdomain_clearAnalysis: // this->clearAnalysis(); break; /* case 50: const Matrix *theMatrix1 = &(this->getStiff()); this->sendMatrix(*theMatrix1); break; case 51: const Matrix *theMatrix2 = &(this->getDamp()); this->sendMatrix(*theMatrix2); break; case 52: const Matrix *theMatrix3 = &(this->getMass()); this->sendMatrix(*theMatrix3); break; */ case ShadowActorSubdomain_getTang: theMatrix = &(this->getTang()); this->sendMatrix(*theMatrix); break; case ShadowActorSubdomain_getResistingForce: theVector = &(this->getResistingForce()); this->sendVector(*theVector); break; case ShadowActorSubdomain_computeTang: tag = msgData(1); this->setTag(tag); this->computeTang(); break; case ShadowActorSubdomain_computeResidual: this->computeResidual(); break; case ShadowActorSubdomain_clearAll: this->clearAll(); this->sendID(msgData); break; case ShadowActorSubdomain_getNodeDisp: tag = msgData(1); // nodeTag dbTag = msgData(2); // dof doubleRes = this->getNodeDisp(tag, dbTag, intRes); msgData(0) = intRes; this->sendID(msgData); if (intRes == 0) { theV = new Vector(1); (*theV)(0) = doubleRes; this->sendVector(*theV); delete theV; } break; case ShadowActorSubdomain_setMass: tag = msgData(1); // nodeTag dbTag = msgData(2); // noRows theOtherType = msgData(3); // noRows theM = new Matrix(dbTag, theOtherType); this->recvMatrix(*theM); intRes = this->setMass(*theM, tag); delete theM; msgData(0) = intRes; this->sendID(msgData); break; case ShadowActorSubdomain_getNodeResponse: tag = msgData(1); // nodeTag nodeResponseType = (NodeResponseType)msgData(2); theVector = this->getNodeResponse(tag, nodeResponseType); if (theVector == 0) msgData(0) = 0; else { msgData(0) = 1; msgData(1) = theVector->Size(); } this->sendID(msgData); if (theVector != 0) this->sendVector(*theVector); break; case ShadowActorSubdomain_getElementResponse: tag = msgData(1); // eleTag argc = msgData(2); msgLength = msgData(3); if (msgLength == 0) { opserr << "ElementRecorder::recvSelf() - 0 sized string for responses\n"; return -1; } allResponseArgs = new char[msgLength]; if (allResponseArgs == 0) { opserr << "ElementRecorder::recvSelf() - out of memory\n"; return -1; } theMessage.setData(allResponseArgs, msgLength); if (this->recvMessage(theMessage) < 0) { opserr << "ElementRecorder::recvSelf() - failed to recv message\n"; return -1; } // // now break this single array into many // argv = new char *[argc]; if (argv == 0) { opserr << "ElementRecorder::recvSelf() - out of memory\n"; return -1; } currentLoc = allResponseArgs; for (int j=0; j<argc; j++) { argv[j] = currentLoc; argLength = strlen(currentLoc)+1; currentLoc += argLength; } theVector = this->getElementResponse(tag, (const char**)argv, argc); delete [] argv; delete [] allResponseArgs; if (theVector == 0) msgData(0) = 0; else { msgData(0) = 1; msgData(1) = theVector->Size(); } this->sendID(msgData); if (theVector != 0) this->sendVector(*theVector); break; case ShadowActorSubdomain_calculateNodalReactions: if (msgData(0) == 0) this->calculateNodalReactions(true); else this->calculateNodalReactions(false); break; case ShadowActorSubdomain_setRayleighDampingFactors: theV = new Vector(4); this->recvVector(*theV); intRes = this->Subdomain::setRayleighDampingFactors((*theV)(0), (*theV)(1), (*theV)(2), (*theV) (3)); delete theV; break; case ShadowActorSubdomain_addParameter: theType = msgData(1); dbTag = msgData(2); theParameter = theBroker->getParameter(theType); if (theParameter != 0) { theParameter->setDbTag(dbTag); this->recvObject(*theParameter); //bool result = true; bool result = this->addParameter(theParameter); if (result == true) msgData(0) = 0; else { opserr << "Actor::addParameter - FAILED\n"; msgData(0) = -1; } } else msgData(0) = -1; break; case ShadowActorSubdomain_removeParameter: theType = msgData(1); this->removeParameter(theType); this->sendID(msgData); break; case ShadowActorSubdomain_updateParameterINT: theType = msgData(1); // tag dbTag = msgData(2); // value msgData(0) = this->Domain::updateParameter(theType, dbTag); this->sendID(msgData); break; case ShadowActorSubdomain_updateParameterDOUBLE: theType = msgData(1); // tag this->recvVector(theVect1); msgData(0) = this->Domain::updateParameter(theType, theVect1(0)); this->sendID(msgData); break; case ShadowActorSubdomain_DIE: exitYet = true; break; default: opserr << "ActorSubdomain::invalid action " << action << "received\n"; msgData(0) = -1; } // opserr << "DONE ACTION: " << action << endln; } // this->sendID(msgData); return 0; }
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; }
int RemoveRecorder::elimNode(int theNodeTag, double timeStamp) { // remove from domain but do not delete yet! Node *theNode = theDomain->removeNode(theNodeTag); // go through all load patterns and remove associated loads and constraints LoadPatternIter &theLoadPatterns = theDomain->getLoadPatterns(); LoadPattern *thePattern; while ((thePattern = theLoadPatterns()) != 0) { // start with nodal laods NodalLoadIter theLoads = thePattern->getNodalLoads(); NodalLoad *theLoad; // ID theLoadTags(0,12); // int cnt=0; while ((theLoad = theLoads()) != 0) { int NodeTag = theLoad->getNodeTag(); if (NodeTag == theNodeTag) { // theLoadTags[cnt] = theLoad->getTag(); // cnt++; #ifdef MMTDEBUG opserr<<"identified load pattern "<<theLoad->getTag()<<" acting on node "<<theNode<<endln; #endif NodalLoad *theNodalLoad = thePattern->removeNodalLoad(theLoad->getTag()); if (theNodalLoad != 0) { #ifdef MMTDEBUG opserr<<"deleting nodal load pattern "<<theLoad->getTag()<<endln; #endif delete theNodalLoad; } } } // for (int i=0; i<cnt; i++) { // NodalLoad *theNodalLoad = thePattern->removeNodalLoad(theLoadTags[i]); // if (theNodalLoad != 0) { // delete theNodalLoad; // #ifdef MMTDEBUG // opserr<<"deleting nodal load pattern "<<theLoadTags(i)<<endln; // #endif // } // } // follow with sp constraints SP_ConstraintIter &theSPs = thePattern->getSPs(); SP_Constraint *theSP; while ((theSP = theSPs()) != 0) { int spNode = theSP->getNodeTag(); if (spNode == theNodeTag) { // theSPTags[cnt] = theSP->getTag(); // cnt++; #ifdef MMTDEBUG opserr<<"identified SP_Constraint "<<theSP->getTag()<<" acting on node "<<spNode<<endln; #endif SP_Constraint *theSPConstraint = thePattern->removeSP_Constraint(theSP->getTag()); if (theSPConstraint != 0) { #ifdef MMTDEBUG opserr<<"deleting SP_Constraint "<<theSP->getTag()<<endln; #endif delete theSPConstraint; } } } } // we also have to remove any sp constraints from the domain that do not belong to load patterns (support fixity) SP_ConstraintIter &theSPs = theDomain->getSPs(); SP_Constraint *theSP; // ID theSPTags(0,12); // int cnt=0; while ((theSP = theSPs()) != 0) { int spNode = theSP->getNodeTag(); if (spNode == theNodeTag) { // theSPTags[cnt] = theSP->getTag(); // cnt++; #ifdef MMTDEBUG opserr<<"identified SP_Constraint "<<theSP->getTag()<<" acting on node "<<spNode<<endln; #endif SP_Constraint *theSPConstraint = theDomain->removeSP_Constraint(theSP->getTag()); if (theSPConstraint != 0) { #ifdef MMTDEBUG opserr<<"deleting SP_Constraint "<<theSP->getTag()<<endln; #endif delete theSPConstraint; } } } // for (int i=0; i<cnt; i++) { // SP_Constraint *theSPconstraint = theDomain->removeSP_Constraint(theSPTags[i]); // if (theSPconstraint != 0) { // delete theSPconstraint; // } // } if (theNode != 0) { // delete theNode; /////////////////// M.Talaat : Again, avoid recorder trouble theNode->revertToStart(); } RemoveRecorder::remNodeList[numRemNodes] = theNode->getTag(); // RemoveRecorder::remNodes[numRemNodes] = theNode; // RemoveRecorder::numRemNodes ++; Node **newRemNodes = new Node *[numRemNodes+1]; for (int ii=0; ii<numRemNodes; ii++) newRemNodes[ii] = remNodes[ii]; newRemNodes[numRemNodes] = theNode; if (remNodes != 0) delete [] remNodes; remNodes = newRemNodes; numRemNodes++; // now give us some notice of what happened if (fileName != 0) theFile<<timeStamp<<" Node "<<theNode->getTag()<<"\n"; if (echoTimeFlag == true) opserr<<"Node "<<theNode->getTag()<<" removed, Time/Load Factor = " <<timeStamp<<endln; return 0; }
int RemoveRecorder::elimElem(int theEleTag, double timeStamp) { #ifdef MMTDEBUG opserr << "RemoveRecorder::elimElem() remving ele: " << theEleTag << " at timeStamp: " << timeStamp << endln;; #endif Element *theEle = theDomain->removeElement(theEleTag); if (theEle != 0) { // we also have to remove any elemental loads from the domain LoadPatternIter &theLoadPatterns = theDomain->getLoadPatterns(); LoadPattern *thePattern; // go through all load patterns while ((thePattern = theLoadPatterns()) != 0) { ElementalLoadIter theEleLoads = thePattern->getElementalLoads(); ElementalLoad *theLoad; // go through all elemental loads in the pattern while ((theLoad = theEleLoads()) != 0) { // remove & destroy elemental from elemental load if there // Note - if last element in load, remove the load and delete it int loadEleTag = theLoad->getElementTag(); if (loadEleTag == theEleTag) { opserr << "RemoveRecorder::elimElem() -3 removing eleLoad\n"; ElementalLoad *theElementalLoad = thePattern->removeElementalLoad(theLoad->getTag()); if (theElementalLoad != 0) { delete theElementalLoad; } } } } // finally invoke the destructor on the element // delete theEle; /////////////// M.Talaat : Avoid recorder trouble at element removal and just set it to zero after removing it from the domain! theEle->revertToStart(); RemoveRecorder::remEleList[RemoveRecorder::numRemEles] = theEle->getTag(); Element **newRemEles = new Element *[numRemEles+1]; for (int ii=0; ii<numRemEles; ii++) newRemEles[ii] = remEles[ii]; newRemEles[numRemEles] = theEle; if (remEles != 0) delete [] remEles; remEles = newRemEles; numRemEles ++; // now give us some notice of what happened if (fileName != 0) theFile<<timeStamp<<" Elem "<<theEle->getTag()<<"\n"; if (echoTimeFlag == true) #ifdef MMTDEBUG opserr<< " element "<<theEle->getTag()<<" removed automatically"<<endln; #endif ; } return 0; }
int main(int argc, char **argv) { // first build our error handler g3ErrorHandler = new ConsoleErrorHandler(); // // now create a domain and a modelbuilder // and build the model // // Domain *theDomain = new Domain(); MapOfTaggedObjects theStorage; // ArrayOfTaggedObjects theStorage(32); Domain *theDomain = new Domain(theStorage); // create the nodes using constructor: // Node(tag, ndof, crd1, crd2) // and then add them to the domain Node *node1 = new Node(1, 3, 1.0, 1.0, 0.0 ); Node *node2 = new Node(2, 3, 0.0, 1.0, 0.0 ); Node *node3 = new Node(3, 3, 0.0, 0.0, 0.0 ); Node *node4 = new Node(4, 3, 1.0, 0.0, 0.0 ); Node *node5 = new Node(5, 3, 1.0, 1.0, 1.0 ); Node *node6 = new Node(6, 3, 0.0, 1.0, 1.0 ); Node *node7 = new Node(7, 3, 0.0, 0.0, 1.0 ); Node *node8 = new Node(8, 3, 1.0, 0.0, 1.0 ); theDomain->addNode(node1); theDomain->addNode(node2); theDomain->addNode(node3); theDomain->addNode(node4); theDomain->addNode(node5); theDomain->addNode(node6); theDomain->addNode(node7); theDomain->addNode(node8); // create an elastic material using constriuctor: // ElasticMaterialModel(tag, E) //UniaxialMaterial *theMaterial = new ElasticMaterial(1, 3000); double PIo3 = PI/3.0; PIo3 = 0.0; //Drucker-Prager Model DPYieldSurface DP_YS; DPPotentialSurface DP_PS(0.05); //EvolutionLaw_NL_Eeq DP_ELS1; EvolutionLaw_L_Eeq DP_ELS1(10.0); EvolutionLaw_T DP_ELT; double scalars[] = {0.3, 0.0}; //alfa1, k double NOS = 2; //Number of scalar vars double NOT = 1; //Number of tensorial vars stresstensor startstress; straintensor startstrain, otherstrain; startstrain = startstrain.pqtheta2strain( 0.000, 0.0000, 0.0); otherstrain = otherstrain.pqtheta2strain( 0.000, 0.0000, 0.0); stresstensor *tensors = new stresstensor[1]; EPState EPS(3000.0, 3000.0, 0.3, 0.0, startstress, otherstrain, otherstrain, otherstrain, NOS, scalars, NOT, tensors); Template3Dep MP(1, &DP_YS, &DP_PS, &EPS, &DP_ELS1, &DP_ELT); NDMaterial *theMaterial = &MP; //NDMaterial *theMaterial = new ElasticIsotropic3D(1, 3000, 0.3); // create the truss elements using constructor: // Truss(tag, dim, nd1, nd2, Material &,A) // and then add them to the domain //Truss *truss1 = new Truss(1, 2, 1, 4, *theMaterial, 10.0); //Truss *truss2 = new Truss(2, 2, 2, 4, *theMaterial, 5.0); //EPState *eps = 0; EightNodeBrick *brick = new EightNodeBrick(1, 5, 6, 7, 8, 1, 2, 3, 4, theMaterial, "Template3Dep", 0.0, 0.0, 0.0, 1.8, &EPS); //theDomain->addElement(truss1); //theDomain->addElement(truss2); theDomain->addElement( brick ); // create the single-point constraint objects using constructor: // SP_Constraint(tag, nodeTag, dofID, value) // and then add them to the domain SP_Constraint *sp1 = new SP_Constraint(1, 1, 0, 0.0259999); SP_Constraint *sp2 = new SP_Constraint(2, 1, 1, 0.0259999); SP_Constraint *sp3 = new SP_Constraint(3, 1, 2, -0.1213350); SP_Constraint *sp4 = new SP_Constraint(4, 2, 0, -0.0259999); SP_Constraint *sp5 = new SP_Constraint(5, 2, 1, 0.0259999); SP_Constraint *sp6 = new SP_Constraint(6, 2, 2, -0.1213350); SP_Constraint *sp7 = new SP_Constraint(7, 3, 0, -0.0259999); SP_Constraint *sp8 = new SP_Constraint(8, 3, 1, -0.0259999); SP_Constraint *sp9 = new SP_Constraint(9, 3, 2, -0.1213350); SP_Constraint *sp10 = new SP_Constraint(10, 4, 0, 0.0259999); SP_Constraint *sp11 = new SP_Constraint(11, 4, 1, -0.0259999); SP_Constraint *sp12 = new SP_Constraint(12, 4, 2, -0.1213350); SP_Constraint *sp13 = new SP_Constraint(13, 5, 0, 0.0); SP_Constraint *sp14 = new SP_Constraint(14, 5, 1, 0.0); SP_Constraint *sp15 = new SP_Constraint(15, 5, 2, 0.0); SP_Constraint *sp16 = new SP_Constraint(16, 6, 0, 0.0); SP_Constraint *sp17 = new SP_Constraint(17, 6, 1, 0.0); SP_Constraint *sp18 = new SP_Constraint(18, 6, 2, 0.0); SP_Constraint *sp19 = new SP_Constraint(19, 7, 0, 0.0); SP_Constraint *sp20 = new SP_Constraint(20, 7, 1, 0.0); SP_Constraint *sp21 = new SP_Constraint(21, 7, 2, 0.0); SP_Constraint *sp22 = new SP_Constraint(22, 8, 0, 0.0); SP_Constraint *sp23 = new SP_Constraint(23, 8, 1, 0.0); SP_Constraint *sp24 = new SP_Constraint(24, 8, 2, 0.0); //Add penalty constraint theDomain->addSP_Constraint(sp1 ); theDomain->addSP_Constraint(sp2 ); theDomain->addSP_Constraint(sp3 ); theDomain->addSP_Constraint(sp4 ); theDomain->addSP_Constraint(sp5 ); theDomain->addSP_Constraint(sp6 ); theDomain->addSP_Constraint(sp7 ); theDomain->addSP_Constraint(sp8 ); theDomain->addSP_Constraint(sp9 ); theDomain->addSP_Constraint(sp10); theDomain->addSP_Constraint(sp11); theDomain->addSP_Constraint(sp12); theDomain->addSP_Constraint(sp13); theDomain->addSP_Constraint(sp14); theDomain->addSP_Constraint(sp15); theDomain->addSP_Constraint(sp16); theDomain->addSP_Constraint(sp17); theDomain->addSP_Constraint(sp18); theDomain->addSP_Constraint(sp19); theDomain->addSP_Constraint(sp20); theDomain->addSP_Constraint(sp21); theDomain->addSP_Constraint(sp22); theDomain->addSP_Constraint(sp23); theDomain->addSP_Constraint(sp24); // construct a linear time series object using constructor: // LinearSeries() TimeSeries *theSeries = new LinearSeries(); // construct a load pattren using constructor: // LoadPattern(tag) // and then set it's TimeSeries and add it to the domain LoadPattern *theLoadPattern = new LoadPattern(1); theLoadPattern->setTimeSeries(theSeries); theDomain->addLoadPattern(theLoadPattern); // construct a nodal load using constructor: // NodalLoad(tag, nodeID, Vector &) // first construct a Vector of size 2 and set the values NOTE C INDEXING // then construct the load and add it to the domain Vector theLoadValues(3); theLoadValues(0) = 0.0; theLoadValues(1) = 0.0; //theLoadValues(2) = -100.0; theLoadValues(2) = 0.0; NodalLoad *theLoad = new NodalLoad(1, 5, theLoadValues); theDomain->addNodalLoad(theLoad, 1); theLoad = new NodalLoad(2, 6, theLoadValues); theDomain->addNodalLoad(theLoad, 1); theLoad = new NodalLoad(3, 7, theLoadValues); theDomain->addNodalLoad(theLoad, 1); theLoad = new NodalLoad(4, 8, theLoadValues); theDomain->addNodalLoad(theLoad, 1); // create an Analysis object to perform a static analysis of the model // - constructs: // AnalysisModel of type AnalysisModel, // EquiSolnAlgo of type Linear // StaticIntegrator of type LoadControl // ConstraintHandler of type Penalty // DOF_Numberer which uses RCM // LinearSOE of type Band SPD // and then the StaticAnalysis object AnalysisModel *theModel = new AnalysisModel(); EquiSolnAlgo *theSolnAlgo = new Linear(); StaticIntegrator *theIntegrator = new LoadControl(1.0, 1.0, 1.0, 1.0); ConstraintHandler *theHandler = new PenaltyConstraintHandler(1.0e8,1.0e8); RCM *theRCM = new RCM(); DOF_Numberer *theNumberer = new DOF_Numberer(*theRCM); BandSPDLinSolver *theSolver = new BandSPDLinLapackSolver(); LinearSOE *theSOE = new BandSPDLinSOE(*theSolver); StaticAnalysis theAnalysis(*theDomain, *theHandler, *theNumberer, *theModel, *theSolnAlgo, *theSOE, *theIntegrator); // perform the analysis & print out the results for the domain int numSteps = 1; theAnalysis.analyze(numSteps); cerr << *theDomain; //brick->displaySelf(); exit(0); }
int main(int argc, char **argv) { // first build our error handler g3ErrorHandler = new ConsoleErrorHandler(); // // now create a domain and a modelbuilder // and build the model // // Domain *theDomain = new Domain(); MapOfTaggedObjects theStorage; // ArrayOfTaggedObjects theStorage(32); Domain *theDomain = new Domain(theStorage); // create the nodes using constructor: // Node(tag, ndof, crd1, crd2, crd3 ) // and then add them to the domain Node *node1 = new Node(1, 3, 1.0, 1.0, 0.0 ); Node *node2 = new Node(2, 3, 0.0, 1.0, 0.0 ); Node *node3 = new Node(3, 3, 0.0, 0.0, 0.0 ); Node *node4 = new Node(4, 3, 1.0, 0.0, 0.0 ); Node *node5 = new Node(5, 3, 1.0, 1.0, 1.0 ); Node *node6 = new Node(6, 3, 0.0, 1.0, 1.0 ); Node *node7 = new Node(7, 3, 0.0, 0.0, 1.0 ); Node *node8 = new Node(8, 3, 1.0, 0.0, 1.0 ); theDomain->addNode(node1); theDomain->addNode(node2); theDomain->addNode(node3); theDomain->addNode(node4); theDomain->addNode(node5); theDomain->addNode(node6); theDomain->addNode(node7); theDomain->addNode(node8); // create an elastic isotropic 3D material using constriuctor: // ElasticIsotropic3D(tag, E, v) NDMaterial *theMaterial = new ElasticIsotropic3D(1, 3000, 0.3); // create the EightNodeBrick elements using constructor: // EightNodeBrick(tag, nd1, nd2, nd3, nd4, nd5, nd6, nd7, nd8, // Material &, const *char type, double bodyforce1, double bodyforce2, // double pressure, double rho, EPState *InitEPS) // and then add them to the domain // For elastic material, no EPState, just supply null. EPState *eps = 0; EightNodeBrick *brick = new EightNodeBrick(1, 5, 6, 7, 8, 1, 2, 3, 4, theMaterial, "ElasticIsotropic3D", 0.0, 0.0, 0.0, 1.8, eps); theDomain->addElement( brick ); // create the single-point constraint objects using constructor: // SP_Constraint(tag, nodeTag, dofID, value) // and then add them to the domain SP_Constraint *sp1 = new SP_Constraint(1, 1, 0, 0.0); SP_Constraint *sp2 = new SP_Constraint(2, 1, 1, 0.0); SP_Constraint *sp3 = new SP_Constraint(3, 1, 2, 0.0); SP_Constraint *sp4 = new SP_Constraint(4, 2, 0, 0.0); SP_Constraint *sp5 = new SP_Constraint(5, 2, 1, 0.0); SP_Constraint *sp6 = new SP_Constraint(6, 2, 2, 0.0); SP_Constraint *sp7 = new SP_Constraint(7, 3, 0, 0.0); SP_Constraint *sp8 = new SP_Constraint(8, 3, 1, 0.0); SP_Constraint *sp9 = new SP_Constraint(9, 3, 2, 0.0); SP_Constraint *sp10 = new SP_Constraint(10, 4, 0, 0.0); SP_Constraint *sp11 = new SP_Constraint(11, 4, 1, 0.0); SP_Constraint *sp12 = new SP_Constraint(12, 4, 2, 0.0); theDomain->addSP_Constraint(sp1 ); theDomain->addSP_Constraint(sp2 ); theDomain->addSP_Constraint(sp3 ); theDomain->addSP_Constraint(sp4 ); theDomain->addSP_Constraint(sp5 ); theDomain->addSP_Constraint(sp6 ); theDomain->addSP_Constraint(sp7 ); theDomain->addSP_Constraint(sp8 ); theDomain->addSP_Constraint(sp9 ); theDomain->addSP_Constraint(sp10); theDomain->addSP_Constraint(sp11); theDomain->addSP_Constraint(sp12); // construct a linear time series object using constructor: // LinearSeries() TimeSeries *theSeries = new LinearSeries(); // construct a load pattren using constructor: // LoadPattern(tag) // and then set it's TimeSeries and add it to the domain LoadPattern *theLoadPattern = new LoadPattern(1); theLoadPattern->setTimeSeries(theSeries); theDomain->addLoadPattern(theLoadPattern); // construct a nodal load using constructor: // NodalLoad(tag, nodeID, Vector &) // first construct a Vector of size 3 and set the values NOTE C INDEXING // then construct the load and add it to the domain Vector theLoadValues(3); theLoadValues(0) = 0.0; theLoadValues(1) = 0.0; theLoadValues(2) = -100.0; NodalLoad *theLoad = new NodalLoad(1, 5, theLoadValues); theDomain->addNodalLoad(theLoad, 1); theLoad = new NodalLoad(2, 6, theLoadValues); theDomain->addNodalLoad(theLoad, 1); theLoad = new NodalLoad(3, 7, theLoadValues); theDomain->addNodalLoad(theLoad, 1); theLoad = new NodalLoad(4, 8, theLoadValues); theDomain->addNodalLoad(theLoad, 1); // create an Analysis object to perform a static analysis of the model // - constructs: // AnalysisModel of type AnalysisModel, // EquiSolnAlgo of type Linear // StaticIntegrator of type LoadControl // ConstraintHandler of type Penalty // DOF_Numberer which uses RCM // LinearSOE of type Band SPD // and then the StaticAnalysis object AnalysisModel *theModel = new AnalysisModel(); EquiSolnAlgo *theSolnAlgo = new Linear(); StaticIntegrator *theIntegrator = new LoadControl(1.0, 1.0, 1.0, 1.0); ConstraintHandler *theHandler = new PenaltyConstraintHandler(1.0e8,1.0e8); RCM *theRCM = new RCM(); DOF_Numberer *theNumberer = new DOF_Numberer(*theRCM); BandSPDLinSolver *theSolver = new BandSPDLinLapackSolver(); LinearSOE *theSOE = new BandSPDLinSOE(*theSolver); StaticAnalysis theAnalysis(*theDomain, *theHandler, *theNumberer, *theModel, *theSolnAlgo, *theSOE, *theIntegrator); // perform the analysis & print out the results for the domain int numSteps = 1; theAnalysis.analyze(numSteps); cerr << *theDomain; //brick->displaySelf(); exit(0); }
int DomainPartitioner::partition(int numParts, bool usingMain, int mainPartitionTag, int specialElementTag) { usingMainDomain = usingMain; mainPartition = mainPartitionTag; // first we ensure the partitioned domain has numpart subdomains // with tags 1 through numparts for (int i=1; i<=numParts; i++) { if (i != mainPartition) { Subdomain *subdomainPtr = myDomain->getSubdomainPtr(i); if (subdomainPtr == 0) { opserr << "DomainPartitioner::partition - No Subdomain: "; opserr << i << " exists\n"; return -1; } } } // we get the ele graph from the domain and partition it // Graph &theEleGraph = myDomain->getElementGraph(); // theElementGraph = new Graph(myDomain->getElementGraph()); theElementGraph = &(myDomain->getElementGraph()); int theError = thePartitioner.partition(*theElementGraph, numParts); if (theError < 0) { opserr << "DomainPartitioner::partition"; opserr << " - the graph partioner failed to partition the "; opserr << "element graph\n"; return -10+theError; } /* print graph */ // opserr << "DomainPartitioner::partition - eleGraph: \n"; // theElementGraph->Print(opserr, 4); VertexIter &theVertices1 = theElementGraph->getVertices(); Vertex *vertexPtr = 0; bool moreThanOne = false; vertexPtr = theVertices1(); int vertexOnePartition = 0; if (vertexPtr != 0) vertexOnePartition = vertexPtr->getColor(); while ((moreThanOne == false) && ((vertexPtr = theVertices1()) != 0)) { int partition = vertexPtr->getColor(); if (partition != vertexOnePartition ) { moreThanOne = true; } } if (moreThanOne == false) { opserr <<"DomainPartitioner::partition - too few elements for model to be partitioned\n"; return -1; } int specialElementColor = 1; if (specialElementTag != 0) { bool found = false; VertexIter &theVerticesSpecial = theElementGraph->getVertices(); while ((found == false) && ((vertexPtr = theVerticesSpecial()) != 0)) { int eleTag = vertexPtr->getRef(); if (eleTag == specialElementTag) { found = true; int vertexColor = vertexPtr->getColor(); if (vertexColor != 1) // specialElementColor = vertexColor; vertexPtr->setColor(1); } } } // we create empty graphs for the numParts subdomains, // in the graphs we place the vertices for the elements on the boundaries // we do not invoke the destructor on the individual graphs as // this would invoke the destructor on the individual vertices if (theBoundaryElements != 0) delete [] theBoundaryElements; theBoundaryElements = new Graph * [numParts]; if (theBoundaryElements == 0) { opserr << "DomainPartitioner::partition(int numParts)"; opserr << " - ran out of memory\n"; numPartitions = 0; return -1; } for (int l=0; l<numParts; l++) { theBoundaryElements[l] = new Graph(2048); // graphs can grow larger; just an estimate if (theBoundaryElements[l] == 0) { opserr << "DomainPartitioner::partition(int numParts)"; opserr << " - ran out of memory\n"; numPartitions = 0; return -1; } } numPartitions = numParts; // opserr << "DomainPartitioner::partition() - nodes \n"; // we now create a MapOfTaggedObjectStorage to store the NodeLocations // and create a new NodeLocation for each node; adding it to the map object theNodeLocations = new MapOfTaggedObjects(); if (theNodeLocations == 0) { opserr << "DomainPartitioner::partition(int numParts)"; opserr << " - ran out of memory creating MapOfTaggedObjectStorage for node locations\n"; numPartitions = 0; return -1; } NodeIter &theNodes = myDomain->getNodes(); Node *nodePtr; while ((nodePtr = theNodes()) != 0) { NodeLocations *theNodeLocation = new NodeLocations(nodePtr->getTag()); if (theNodeLocation == 0) { opserr << "DomainPartitioner::partition(int numParts)"; opserr << " - ran out of memory creating NodeLocation for node: " << nodePtr->getTag() << endln; numPartitions = 0; return -1; } if (theNodeLocations->addComponent(theNodeLocation) == false) { opserr << "DomainPartitioner::partition(int numParts)"; opserr << " - failed to add NodeLocation to Map for Node: " << nodePtr->getTag() << endln; numPartitions = 0; return -1; } } // // we now iterate through the vertices of the element graph // to see if the vertex is a boundary vertex or not - if it is // we add to the appropriate graph created above. We also set the // value the color variable of each of the external nodes connected // to the element to a value which will indicate that that node will // have to be added to the subdomain. // VertexIter &theVertexIter = theElementGraph->getVertices(); while ((vertexPtr = theVertexIter()) != 0) { int eleTag = vertexPtr->getRef(); int vertexColor = vertexPtr->getColor(); const ID &adjacency = vertexPtr->getAdjacency(); int size = adjacency.Size(); for (int i=0; i<size; i++) { Vertex *otherVertex = theElementGraph->getVertexPtr(adjacency(i)); if (otherVertex->getColor() != vertexColor) { theBoundaryElements[vertexColor-1]->addVertex(vertexPtr,false); i = size; } } Element *elePtr = myDomain->getElement(eleTag); const ID &nodes = elePtr->getExternalNodes(); size = nodes.Size(); for (int j=0; j<size; j++) { int nodeTag = nodes(j); TaggedObject *theTaggedObject = theNodeLocations->getComponentPtr(nodeTag); if (theTaggedObject == 0) { opserr << "DomainPartitioner::partition(int numParts)"; opserr << " - failed to find NodeLocation in Map for Node: " << nodePtr->getTag() << " -- A BUG!!\n"; numPartitions = 0; return -1; } NodeLocations *theNodeLocation = (NodeLocations *)theTaggedObject; theNodeLocation->addPartition(vertexColor); } } // now go through the MP_Constraints and ensure the retained node is in every // partition the constrained node is in MP_ConstraintIter &theMPs = myDomain->getMPs(); MP_Constraint *mpPtr; while ((mpPtr = theMPs()) != 0) { int retained = mpPtr->getNodeRetained(); int constrained = mpPtr->getNodeConstrained(); TaggedObject *theRetainedObject = theNodeLocations->getComponentPtr(retained); TaggedObject *theConstrainedObject = theNodeLocations->getComponentPtr(constrained); if (theRetainedObject == 0 || theConstrainedObject == 0) { opserr << "DomainPartitioner::partition(int numParts)"; if (theRetainedObject == 0) opserr << " - failed to find NodeLocation in Map for Node: " << retained << " -- A BUG!!\n"; if (theConstrainedObject == 0) opserr << " - failed to find NodeLocation in Map for Node: " << constrained << " -- A BUG!!\n"; numPartitions = 0; return -1; } NodeLocations *theRetainedLocation = (NodeLocations *)theRetainedObject; NodeLocations *theConstrainedLocation = (NodeLocations *)theConstrainedObject; ID &theConstrainedNodesPartitions = theConstrainedLocation->nodePartitions; int numPartitions = theConstrainedNodesPartitions.Size(); for (int i=0; i<numPartitions; i++) { theRetainedLocation->addPartition(theConstrainedNodesPartitions(i)); } } // we now add the nodes, TaggedObjectIter &theNodeLocationIter = theNodeLocations->getComponents(); TaggedObject *theNodeObject; while ((theNodeObject = theNodeLocationIter()) != 0) { NodeLocations *theNodeLocation = (NodeLocations *)theNodeObject; int nodeTag = theNodeLocation->getTag(); ID &nodePartitions = theNodeLocation->nodePartitions; int numPartitions = theNodeLocation->numPartitions; for (int i=0; i<numPartitions; i++) { int partition = nodePartitions(i); if (partition != mainPartition) { Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition); if (numPartitions == 1) { Node *nodePtr = myDomain->removeNode(nodeTag); theSubdomain->addNode(nodePtr); } else { Node *nodePtr = myDomain->getNode(nodeTag); theSubdomain->addExternalNode(nodePtr); } } } } // we now move the elements VertexIter &theVertices = theElementGraph->getVertices(); while ((vertexPtr = theVertices()) != 0) { // move the element int partition = vertexPtr->getColor(); if (partition != mainPartition) { int eleTag = vertexPtr->getRef(); // opserr << "removing ele: " << eleTag << endln; Element *elePtr = myDomain->removeElement(eleTag); // opserr << *elePtr; if (elePtr != 0) { // opserr << "adding ele - start\n"; Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition); theSubdomain->addElement(elePtr); // opserr << "adding ele - done\n"; } else { opserr << "DomainPartitioner::partioner - element GONE! - eleTag " << eleTag << endln; } } } // now we go through the load patterns and move NodalLoad // 1) make sure each subdomain has a copy of the partitioneddomains load patterns. // 2) move nodal loads // 3) move SP_Constraints LoadPatternIter &theLoadPatterns = myDomain->getLoadPatterns(); LoadPattern *theLoadPattern; while ((theLoadPattern = theLoadPatterns()) != 0) { int loadPatternTag = theLoadPattern->getTag(); // check that each subdomain has a loadPattern with a similar tag and class tag for (int i=1; i<=numParts; i++) { if (i != mainPartition) { Subdomain *theSubdomain = myDomain->getSubdomainPtr(i); LoadPattern *loadPatternCopy = theSubdomain->getLoadPattern(loadPatternTag); if (loadPatternCopy == 0) { LoadPattern *newLoadPattern = theLoadPattern->getCopy(); if (newLoadPattern == 0) { opserr << "DomaiPartitioner::partition - out of memory creating LoadPatterns\n"; return -1; } theSubdomain->addLoadPattern(newLoadPattern); } } } // now remove any nodal loads that correspond to internal nodes in a subdomain // and add them to the appropriate loadpattern in the subdomain NodalLoadIter &theNodalLoads = theLoadPattern->getNodalLoads(); NodalLoad *theNodalLoad; while ((theNodalLoad = theNodalLoads()) != 0) { int nodeTag = theNodalLoad->getNodeTag(); TaggedObject *theTaggedObject = theNodeLocations->getComponentPtr(nodeTag); if (theTaggedObject == 0) { opserr << "DomainPartitioner::partition(int numParts)"; opserr << " - failed to find NodeLocation in Map for Node: " << nodeTag << " -- A BUG!!\n"; numPartitions = 0; return -1; } NodeLocations *theNodeLocation = (NodeLocations *)theTaggedObject; ID &nodePartitions = theNodeLocation->nodePartitions; int numPartitions = theNodeLocation->numPartitions; for (int i=0; i<numPartitions; i++) { int partition = nodePartitions(i); if (partition != mainPartition) { if (numPartitions == 1) { Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition); theLoadPattern->removeNodalLoad(theNodalLoad->getTag()); if ((theSubdomain->addNodalLoad(theNodalLoad, loadPatternTag)) != true) opserr << "DomainPartitioner::partition() - failed to add Nodal Load\n"; } } } } SP_ConstraintIter &theSPs = theLoadPattern->getSPs(); SP_Constraint *spPtr; while ((spPtr = theSPs()) != 0) { int nodeTag = spPtr->getNodeTag(); TaggedObject *theTaggedObject = theNodeLocations->getComponentPtr(nodeTag); if (theTaggedObject == 0) { opserr << "DomainPartitioner::partition(int numParts)"; opserr << " - failed to find NodeLocation in Map for Node: " << nodeTag << " -- A BUG!!\n"; numPartitions = 0; return -1; } NodeLocations *theNodeLocation = (NodeLocations *)theTaggedObject; ID &nodePartitions = theNodeLocation->nodePartitions; int numPartitions = theNodeLocation->numPartitions; for (int i=0; i<numPartitions; i++) { int partition = nodePartitions(i); if (partition != mainPartition) { Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition); if (numPartitions == 1) theLoadPattern->removeSP_Constraint(spPtr->getTag()); int res = theSubdomain->addSP_Constraint(spPtr, loadPatternTag); if (res < 0) opserr << "DomainPartitioner::partition() - failed to add SP Constraint\n"; } } } ElementalLoadIter &theLoads = theLoadPattern->getElementalLoads(); ElementalLoad *theLoad; while ((theLoad = theLoads()) != 0) { int loadEleTag = theLoad->getElementTag(); SubdomainIter &theSubdomains = myDomain->getSubdomains(); Subdomain *theSub; bool added = false; while (((theSub = theSubdomains()) != 0) && (added == false)) { bool res = theSub->hasElement(loadEleTag); if (res == true) { theLoadPattern->removeElementalLoad(theLoad->getTag()); theSub->addElementalLoad(theLoad, loadPatternTag); if (res < 0) opserr << "DomainPartitioner::partition() - failed to add ElementalLoad\n"; added = true; } } } } // add the single point constraints, SP_ConstraintIter &theDomainSP = myDomain->getSPs(); SP_Constraint *spPtr; while ((spPtr = theDomainSP()) != 0) { int nodeTag = spPtr->getNodeTag(); TaggedObject *theTaggedObject = theNodeLocations->getComponentPtr(nodeTag); if (theTaggedObject == 0) { opserr << "DomainPartitioner::partition(int numParts)"; opserr << " - failed to find NodeLocation in Map for Node: " << nodeTag << " -- A BUG!!\n"; numPartitions = 0; return -1; } NodeLocations *theNodeLocation = (NodeLocations *)theTaggedObject; ID &nodePartitions = theNodeLocation->nodePartitions; int numPartitions = theNodeLocation->numPartitions; for (int i=0; i<numPartitions; i++) { int partition = nodePartitions(i); if (partition != mainPartition) { Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition); if (numPartitions == 1) { myDomain->removeSP_Constraint(spPtr->getTag()); } int res = theSubdomain->addSP_Constraint(spPtr); if (res < 0) opserr << "DomainPartitioner::partition() - failed to add SP Constraint\n"; } } } // move MP_Constraints - add an MP_Constraint to every partition a constrained node is in MP_ConstraintIter &moreMPs = myDomain->getMPs(); while ((mpPtr = moreMPs()) != 0) { int constrained = mpPtr->getNodeConstrained(); TaggedObject *theConstrainedObject = theNodeLocations->getComponentPtr(constrained); NodeLocations *theConstrainedLocation = (NodeLocations *)theConstrainedObject; ID &theConstrainedNodesPartitions = theConstrainedLocation->nodePartitions; int numPartitions = theConstrainedLocation->numPartitions; for (int i=0; i<numPartitions; i++) { int partition = theConstrainedNodesPartitions(i); if (partition != mainPartition) { Subdomain *theSubdomain = myDomain->getSubdomainPtr(partition); if (numPartitions == 1) myDomain->removeMP_Constraint(mpPtr->getTag()); int res = theSubdomain->addMP_Constraint(mpPtr); if (res < 0) opserr << "DomainPartitioner::partition() - failed to add MP Constraint\n"; } } } // now we go through all the subdomains and tell them to update // their analysis for the new layouts SubdomainIter &theSubDomains = myDomain->getSubdomains(); Subdomain *theSubDomain; while ((theSubDomain = theSubDomains()) != 0) theSubDomain->domainChange(); // we invoke change on the PartitionedDomain myDomain->domainChange(); myDomain->clearElementGraph(); // we are done partitionFlag = true; return 0; }
int ImposedMotionSP::applyConstraint(double time) { // on first if (theGroundMotion == 0 || theNode == 0 || theNodeResponse == 0) { Domain *theDomain = this->getDomain(); theNode = theDomain->getNode(nodeTag); if (theNode == 0) { opserr << "ImposedMotionSP::applyConstraint() - node " << nodeTag << " does not exist\n"; return -1; } int numNodeDOF = theNode->getNumberDOF(); if (dofNumber < 0 || numNodeDOF <= dofNumber) { opserr << "ImposedMotionSP::applyConstraint() - dof number " << dofNumber++ << " at node " << nodeTag << " not valid\n"; return -2; } theNodeResponse = new Vector(numNodeDOF); if (theNodeResponse == 0) { opserr << "ImposedMotionSP::applyConstraint() - out of memory\n"; return -2; } LoadPattern *theLoadPattern = theDomain->getLoadPattern(patternTag); if (theLoadPattern == 0) return -3; theGroundMotion = theLoadPattern->getMotion(groundMotionTag); if (theGroundMotion == 0) return -4; } if (theNodeResponse == 0) return -1; // now get the response from the ground motion theGroundMotionResponse = theGroundMotion->getDispVelAccel(time); // // now set the responses at the node // /* *********************************************************** * disp response the responsibility of constraint handler *theNodeResponse = theNode->getTrialDisp(); (*theNodeResponse)(dofNumber) = theGroundMotionResponse(0); theNode->setTrialDisp(*theNodeResponse); *************************************************************/ *theNodeResponse = theNode->getTrialVel(); (*theNodeResponse)(dofNumber) = theGroundMotionResponse(1); theNode->setTrialVel(*theNodeResponse); *theNodeResponse = theNode->getTrialAccel(); (*theNodeResponse)(dofNumber) = theGroundMotionResponse(2); theNode->setTrialAccel(*theNodeResponse); return 0; }
// main routine int main(int argc, char **argv) { // // now create a domain and a modelbuilder // and build the model // Domain *theDomain = new Domain(); // create the nodes using constructor: // Node(tag, ndof, crd1, crd2) // and then add them to the domain Node *node1 = new Node(1, 2, 0.0, 0.0); Node *node2 = new Node(2, 2, 144.0, 0.0); Node *node3 = new Node(3, 2, 168.0, 0.0); Node *node4 = new Node(4, 2, 72.0, 96.0); theDomain->addNode(node1); theDomain->addNode(node2); theDomain->addNode(node3); theDomain->addNode(node4); // create an elastic material using constriuctor: // ElasticMaterialModel(tag, E) UniaxialMaterial *theMaterial = new ElasticMaterial(1, 3000); // create the truss elements using constructor: // Truss(tag, dim, nd1, nd2, Material &,A) // and then add them to the domain Truss *truss1 = new Truss(1, 2, 1, 4, *theMaterial, 10.0); Truss *truss2 = new Truss(2, 2, 2, 4, *theMaterial, 5.0); Truss *truss3 = new Truss(3, 2, 3, 4, *theMaterial, 5.0); theDomain->addElement(truss1); theDomain->addElement(truss2); theDomain->addElement(truss3); // create the single-point constraint objects using constructor: // SP_Constraint(tag, nodeTag, dofID, value) // and then add them to the domain SP_Constraint *sp1 = new SP_Constraint(1, 1, 0, 0.0); SP_Constraint *sp2 = new SP_Constraint(2, 1, 1, 0.0); SP_Constraint *sp3 = new SP_Constraint(3, 2, 0, 0.0); SP_Constraint *sp4 = new SP_Constraint(4, 2, 1, 0.0); SP_Constraint *sp5 = new SP_Constraint(5, 3, 0, 0.0); SP_Constraint *sp6 = new SP_Constraint(6, 3, 1, 0.0); theDomain->addSP_Constraint(sp1); theDomain->addSP_Constraint(sp2); theDomain->addSP_Constraint(sp3); theDomain->addSP_Constraint(sp4); theDomain->addSP_Constraint(sp5); theDomain->addSP_Constraint(sp6); // construct a linear time series object using constructor: // LinearSeries() TimeSeries *theSeries = new LinearSeries(); // construct a load pattren using constructor: // LoadPattern(tag) // and then set it's TimeSeries and add it to the domain LoadPattern *theLoadPattern = new LoadPattern(1); theLoadPattern->setTimeSeries(theSeries); theDomain->addLoadPattern(theLoadPattern); // construct a nodal load using constructor: // NodalLoad(tag, nodeID, Vector &) // first construct a Vector of size 2 and set the values NOTE C INDEXING // then construct the load and add it to the domain Vector theLoadValues(2); theLoadValues(0) = 100.0; theLoadValues(1) = -50.0; NodalLoad *theLoad = new NodalLoad(1, 4, theLoadValues); theDomain->addNodalLoad(theLoad, 1); // create an Analysis object to perform a static analysis of the model // - constructs: // AnalysisModel of type AnalysisModel, // EquiSolnAlgo of type Linear // StaticIntegrator of type LoadControl // ConstraintHandler of type Penalty // DOF_Numberer which uses RCM // LinearSOE of type Band SPD // and then the StaticAnalysis object AnalysisModel *theModel = new AnalysisModel(); EquiSolnAlgo *theSolnAlgo = new Linear(); StaticIntegrator *theIntegrator = new LoadControl(1.0, 1, 1.0, 1.0); ConstraintHandler *theHandler = new PenaltyConstraintHandler(1.0e8,1.0e8); RCM *theRCM = new RCM(); DOF_Numberer *theNumberer = new DOF_Numberer(*theRCM); BandSPDLinSolver *theSolver = new BandSPDLinLapackSolver(); LinearSOE *theSOE = new BandSPDLinSOE(*theSolver); StaticAnalysis theAnalysis(*theDomain, *theHandler, *theNumberer, *theModel, *theSolnAlgo, *theSOE, *theIntegrator); // perform the analysis & print out the results for the domain int numSteps = 1; theAnalysis.analyze(numSteps); opserr << *theDomain; exit(0); }