XObjectPtr FunctionGenerateID::execute( XPathExecutionContext& executionContext, XalanNode* context, const LocatorType* locator) const { if (context == 0) { executionContext.error( XalanMessageLoader::getMessage(XalanMessages::FunctionRequiresNonNullContextNode_1Param,"generate-id()"), context, locator); return XObjectPtr(); } else { XPathExecutionContext::GetAndReleaseCachedString theID(executionContext); theID.get() = XalanUnicode::charLetter_N; getSuffix(context, theID.get()); return executionContext.getXObjectFactory().createString(theID); } }
void PlantMgr::addPluginFactory(const QString& libName, PlantMgr::PGIN_TYPE theType) { QObject* thePlugInRef=0; QString theID=""; QPluginLoader loader(libName); thePlugInRef=loader.instance(); qDebug()<< thePlugInRef->metaObject()->className(); if(thePlugInRef != 0) { switch(theType) { case PLANT: { PlantFactory* theFact = qobject_cast<PlantFactory*>(thePlugInRef); if(theFact != 0) { theID = theFact->getFactoryID(); if(m_plantFactList.contains(theID)>0) { qWarning()<<"Error a plugin with the same ID has been already loaded: "<<libName; } else { m_plantFactList.insert(theID, theFact); qDebug()<<"Loaded the plugin library: "<<libName; } } else { qWarning()<<"Error loading factory for plugin: "; } break; } case DEVICE: { DeviceFactory* theFact = qobject_cast<DeviceFactory*>(thePlugInRef); if(theFact != 0) { QString deviceIDs(theFact->getFactoryID()); QStringList devicesLstIDs = deviceIDs.split('|', QString::SkipEmptyParts); foreach (QString deviceID, devicesLstIDs) { QString theID(deviceID); if(m_devFactList.contains(theID)>0) { qWarning()<<"Error a plugin with the same ID has been already loaded: "<<libName; } else { m_devFactList.insert(theID, theFact); qDebug()<<"Loaded the plugin library: "<<libName; } } } else { qWarning()<<"Error loading factory for plugin: "<<libName; } break; }
int ShadowSubdomain::addSP_Constraint(int axisDirn, double axisValue, const ID &fixityCodes, double tol) { #ifdef _G3DEBUG // do all the checking stuff #endif msgData(0) = ShadowActorSubdomain_addSP_ConstraintAXIS; msgData(2) = axisDirn; msgData(3) = fixityCodes.Size(); this->sendID(msgData); this->sendID(fixityCodes); static Vector data(2); data(0) = axisValue; data(1) = tol; this->sendVector(data); // this->Domain::domainChange(); this->recvID(msgData); // now if we have created any in the actor we have to add them here int endTag = msgData(1); int numSP = endTag; if (numSP != 0) { ID theID(numSP); this->recvID(theID); for (int i=0; i<numSP; i++) { SP_Constraint *theSP = theObjectBroker->getNewSP(theID(i)); if (theSP != 0) { this->recvObject(*theSP); numSPs++; theShadowSPs->addComponent(theSP); } } } return endTag; }
OT_BOOL OT_API_getAssetType(int iIndex, const char * THE_ID, const char * THE_NAME) { OT_ASSERT(NULL != THE_ID); OT_ASSERT(NULL != THE_NAME); OT_ASSERT(iIndex > 0); OTIdentifier theID(THE_ID); OTString strName(THE_NAME); bool bGetAssetType = g_OT_API.getAssetType(iIndex, theID, strName); if (bGetAssetType) return OT_TRUE; return OT_FALSE; }
void DatapadFactory::handleObjectReady(Object* object,DispatchClient* client) { Datapad* datapad(0); uint64 theID(0); switch(object->getType()) { case ObjType_Waypoint: { theID = object->getParentId()+3; mIlc = _getObject(theID); datapad = dynamic_cast<Datapad*>(mIlc->mObject); mIlc->mLoadCounter--; datapad->addWaypoint(dynamic_cast<WaypointObject*>(object)); } break; case ObjType_Tangible: { Item* item = dynamic_cast<Item*>(object); if(item->getItemType()== ItemType_ManSchematic) { theID = object->getParentId(); mIlc = _getObject(theID); if(!mIlc) { LOG(warning) << "Failed getting ilc during ObjType_Tangible where ItemType_ManSchematic"; return; } datapad = dynamic_cast<Datapad*>(mIlc->mObject); //parentId of schematics is the datapad! //add the msco to the datapad datapad->addManufacturingSchematic(dynamic_cast<ManufacturingSchematic*>(object)); //now load the associated item QueryContainerBase* asContainer = new(mQueryContainerPool.ordered_malloc()) QueryContainerBase(this,DPFQuery_ItemId,NULL); asContainer->mObject = datapad; asContainer->mId = item->getId();//queryContainer.mId; int8 sql[256]; sprintf(sql,"SELECT items.id FROM %s.items WHERE (parent_id=%" PRIu64 ")",mDatabase->galaxy(),item->getId()); mDatabase->executeSqlAsync(this,asContainer,sql); mObjectLoadMap.insert(std::make_pair(item->getId(),new(mILCPool.ordered_malloc()) InLoadingContainer(datapad,0,0,1))); } else { uint64 id = object->getParentId(); //we are loading the corresponding tangible object to have all the items attributes available for display/usage //find the corresponding schematic //temp mILc InLoadingContainer*mIlcDPad = _getObject(id); if(!mIlcDPad) { LOG(warning) << "Failed getting mIlcDPad during ObjType_Tangible"; return; } datapad = dynamic_cast<Datapad*>(mIlcDPad->mObject); _removeFromObjectLoadMap(id); mILCPool.free(mIlcDPad); //regular mIlc theID = datapad->getId(); mIlc = _getObject(theID); if(!mIlc) { LOG(warning) << "Failed getting ilc during ObjType_Tangible"; return; } ManufacturingSchematic* schem = datapad->getManufacturingSchematicById(id); //this is the item associated to the Man schematic //set the man schematic pointer and decrease the loadcount mIlc->mLoadCounter--; schem->setItem(dynamic_cast<Item*>(object)); } } break; case ObjType_Intangible: { theID = object->getParentId(); mIlc = _getObject(theID); if(!mIlc)//sanity { LOG(warning) << "Failed getting ilc during ObjType_Intangible"; return; } if((datapad = dynamic_cast<Datapad*>(mIlc->mObject))) { mIlc->mLoadCounter--; if(IntangibleObject* itno = dynamic_cast<IntangibleObject*>(object)) { if(datapad->getCapacity()) { datapad->addData(itno); Object* ob = gWorldManager->getObjectById(object->getId()); if(!ob) gWorldManager->addObject(object,true); } else { LOG(warning) << "Datapad at max Capacity"; delete(object); } } } } break; default: break; } if(!mIlc) return; if(!(mIlc->mLoadCounter)) { if(!(_removeFromObjectLoadMap(theID))) LOG(warning) << "Failed removing object from loadmap"; mIlc->mOfCallback->handleObjectReady(datapad,mIlc->mClient); mILCPool.free(mIlc); } }
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 XC::ParallelNumberer::numberDOF(ID &lastDOFs) { int result= 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) { std::cerr << "WARNING ParallelNumberer::numberDOF(int) -"; std::cerr << " - no AnalysisModel.\n"; return -1; } 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]); int numVertex= theGraph.getNumVertex(); cp.sendMovable(theGraph,DistributedObj::getDbTagData(),CommMetaData(5)); ID theID(2*numVertex); cp.receiveID(theID,DistributedObj::getDbTagData(),CommMetaData(6)); for(int i=0; i<numVertex; i += 2) { int dofTag= theID(i); int startID= theID(i+1); DOF_Group *dofPtr; dofPtr= theModel->getDOF_GroupPtr(dofTag); if(dofPtr == 0) { std::cerr << "WARNING XC::ParallelNumberer::numberDOF - "; std::cerr << "DOF_Group " << dofTag << "not in XC::AnalysisModel!\n"; result= -4; } else { const ID &theID= dofPtr->getID(); int idSize= theID.Size(); for(int j=0; j<idSize; j++) if(theID(j) == -2) dofPtr->setID(j, startID++); } } } // 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. else { // determine original vertex and ref tags int numVertex= theGraph.getNumVertex(); 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; // merge all subdomain graphs for(int j=0; j<numChannels; j++) { CommParameters cp(0,*theChannels[j]); Graph theSubGraph; cp. receiveMovable(theSubGraph,DistributedObj::getDbTagData(),CommMetaData(6)); theSubdomainIDs[j]= ID(theSubGraph.getNumVertex()*2); this->mergeSubGraph(theGraph, theSubGraph, vertexTags, vertexRefs, theSubdomainIDs[j]); } // number the merged graph // result= this->XC::DOF_Numberer::number(theGraph); // send results of numbered back to subdomains for(int k=0; k<numChannels; k++) { Channel *theChannel= theChannels[k]; // this->determineSubIDs theChannel->sendID(0, 0, theSubdomainIDs[k]); } } 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 DisplacementControl::domainChanged(void) { // we first create the Vectors needed AnalysisModel *theModel = this->getAnalysisModel(); LinearSOE *theLinSOE = this->getLinearSOE(); if (theModel == 0 || theLinSOE == 0) { opserr << "WARNING DisplacementControl::update() "; opserr << "No AnalysisModel or LinearSOE has been set\n"; return -1; } int size = theModel->getNumEqn(); // ask model in case N+1 space if (deltaUhat == 0 || deltaUhat->Size() != size) { // create new Vector if (deltaUhat != 0) delete deltaUhat; // delete the old deltaUhat = new Vector(size); if (deltaUhat == 0 || deltaUhat->Size() != size) { // check got it opserr << "FATAL DisplacementControl::domainChanged() - ran out of memory for"; opserr << " deltaUhat Vector of size " << size << endln; exit(-1); } } if (deltaUbar == 0 || deltaUbar->Size() != size) { // create new Vector if (deltaUbar != 0) delete deltaUbar; // delete the old deltaUbar = new Vector(size); if (deltaUbar == 0 || deltaUbar->Size() != size) { // check got it opserr << "FATAL DisplacementControl::domainChanged() - ran out of memory for"; opserr << " deltaUbar Vector of size " << size << endln; exit(-1); } } if (deltaU == 0 || deltaU->Size() != size) { // create new Vector if (deltaU != 0) delete deltaU; // delete the old deltaU = new Vector(size); if (deltaU == 0 || deltaU->Size() != size) { // check got it opserr << "FATAL DisplacementControl::domainChanged() - ran out of memory for"; opserr << " deltaU Vector of size " << size << endln; exit(-1); } } if (deltaUstep == 0 || deltaUstep->Size() != size) { if (deltaUstep != 0) delete deltaUstep; deltaUstep = new Vector(size); if (deltaUstep == 0 || deltaUstep->Size() != size) { opserr << "FATAL DisplacementControl::domainChanged() - ran out of memory for"; opserr << " deltaUstep Vector of size " << size << endln; exit(-1); } } if (phat == 0 || phat->Size() != size) { if (phat != 0) delete phat; phat = new Vector(size); if (phat == 0 || phat->Size() != size) { opserr << "FATAL DisplacementControl::domainChanged() - ran out of memory for"; opserr << " phat Vector of size " << size << endln; exit(-1); } } // now we have to determine phat // do this by incrementing lambda by 1, applying load // and getting phat from unbalance. currentLambda = theModel->getCurrentDomainTime(); currentLambda += 1.0; theModel->applyLoadDomain(currentLambda); this->formUnbalance(); // NOTE: this assumes unbalance at last was 0 (*phat) = theLinSOE->getB(); currentLambda -= 1.0; theModel->setCurrentDomainTime(currentLambda); // check there is a reference load int haveLoad = 0; for (int i=0; i<size; i++) if ( (*phat)(i) != 0.0 ) { haveLoad = 1; i = size; } if (haveLoad == 0) { opserr << "WARNING DisplacementControl::domainChanged() - zero reference load"; return -1; } // lastly we determine the id of the nodal dof // EXTRA CODE TO DO SOME ERROR CHECKING REQUIRED Node *theNodePtr = theDomain->getNode(theNode); if (theNodePtr == 0) { opserr << "DisplacementControl::domainChanged - no node\n"; return -1; } DOF_Group *theGroup = theNodePtr->getDOF_GroupPtr(); if (theGroup == 0) { return 0; } const ID &theID = theGroup->getID(); theDofID = theID(theDof); return 0; }