本文整理汇总了C++中Domain::getElements方法的典型用法代码示例。如果您正苦于以下问题:C++ Domain::getElements方法的具体用法?C++ Domain::getElements怎么用?C++ Domain::getElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domain
的用法示例。
在下文中一共展示了Domain::getElements方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: elementsToJSON
mObject elementsToJSON(void) {
ElementIter &theEles = theDomain.getElements();
Element *theEle;
mObject eles;
mValue tag, ele;
char tag_str[15];
eles.clear();
while ((theEle = theEles()) != 0) {
tag = theEle->getTag();
ele = theEle->toJSON();
sprintf(tag_str, "%d", tag.get_int());
eles[tag_str] = ele;
}
return eles;
};
示例2: while
int
Mesh::nextEleTag()
{
Domain* domain = OPS_GetDomain();
if (domain == 0) {
opserr << "WARNING: domain is not created\n";
return -1;
}
ElementIter& eles = domain->getElements();
Element* ele = 0;
int etag = 0;
while((ele = eles()) != 0) {
etag = ele->getTag();
}
return etag+1;
}
示例3: OPS_PFEMElement2D
int OPS_PFEMElement2D(Domain& theDomain, const ID& elenodes, ID& eletags)
{
int numdata = OPS_GetNumRemainingInputArgs();
if(numdata < 4) {
opserr<<"WARNING: insufficient number of arguments\n";
return 0;
}
// rho, mu, b1, b2, (thickness, kappa, lumped)
numdata = OPS_GetNumRemainingInputArgs();
if(numdata > 7) numdata = 7;
double data[7] = {0,0,0,0,1.0,-1,1};
if(OPS_GetDoubleInput(&numdata,data) < 0) return 0;
// create elements
ElementIter& theEles = theDomain.getElements();
Element* theEle = theEles();
int currTag = 0;
if (theEle != 0) {
currTag = theEle->getTag();
}
eletags.resize(elenodes.Size()/3);
for (int i=0; i<eletags.Size(); i++) {
theEle = new PFEMElement2D(--currTag,elenodes(3*i),elenodes(3*i+1),elenodes(3*i+2),
data[0],data[1],data[2],data[3],data[4],data[5],data[6]);
if (theEle == 0) {
opserr<<"WARNING: run out of memory for creating element\n";
return -1;
}
if (theDomain.addElement(theEle) == false) {
opserr<<"WARNING: failed to add element to domain\n";
delete theEle;
return -1;
}
eletags(i) = currTag;
}
return 0;
}
示例4: getClassName
//.........这里部分代码省略.........
<< " non-varying assumed\n";
const Matrix &C = mpPtr->getConstraint();
int numRows = C.noRows();
int numCols = C.noCols();
if(numRows != numCols)
std::cerr << getClassName() << "::" << __FUNCTION__
<< " constraint matrix not diagonal,"
<< " ignoring constraint for node "
<< nodeID << std::endl;
else
{
int ok = 0;
for(int i=0; i<numRows; i++)
{
if(C(i,i) != 1.0) ok = 1;
for(int j=0; j<numRows; j++)
if(i != j)
if(C(i,j) != 0.0)
ok = 1;
}
if(ok != 0)
std::cerr << getClassName() << "::" << __FUNCTION__
<< "; constraint matrix not identity,"
<< " ignoring constraint for node "
<< nodeID << std::endl;
else
{
const ID &dofs = mpPtr->getConstrainedDOFs();
const ID &id = dofPtr->getID();
for(int i=0; i<dofs.Size(); i++)
{
int dof = dofs(i);
if(id(dof) == -2)
{
dofPtr->setID(dof,-4);
countDOF--;
}
else
std::cerr << getClassName() << "::" << __FUNCTION__
<< "; constraint at dof " << dof
<< " already specified for constrained node"
<< " in MFreedom_Constraint at node "
<< nodeID << std::endl;
}
}
}
}
}
// loop through the MFreedom_Constraints to see if any of the
// DOFs are constrained, note constraint matrix must be diagonal
// with 1's on the diagonal
MRMFreedom_ConstraintIter &theMRMPs = theDomain->getConstraints().getMRMPs();
MRMFreedom_Constraint *mrmpPtr;
while((mrmpPtr = theMRMPs()) != 0)
{
std::cerr << getClassName() << "::" << __FUNCTION__
<< "; loop through the MRMFreedom_Constraints."
<< std::endl;
}
}
// set the number of eqn in the model
theModel->setNumEqn(countDOF);
// now see if we have to set any of the dof's to -3
// int numLast = 0;
if(nodesLast != 0)
for(int i=0; i<nodesLast->Size(); i++)
{
int nodeID = (*nodesLast)(i);
Node *nodPtr = theDomain->getNode(nodeID);
if(nodPtr != 0)
{
dofPtr = nodPtr->getDOF_GroupPtr();
const ID &id = dofPtr->getID();
// set all the dof values to -3
for (int j=0; j < id.Size(); j++)
if(id(j) == -2)
{
dofPtr->setID(j,-3);
count3++;
}
else
std::cerr << getClassName() << "::" << __FUNCTION__
<< "; boundary sp constraint in subdomain"
<< " this should not be - results suspect \n";
}
}
// initialise the FE_Elements and add to the XC::AnalysisModel.
ElementIter &theEle = theDomain->getElements();
Element *elePtr;
int numFe = 0;
FE_Element *fePtr;
while((elePtr = theEle()) != 0)
{ fePtr= theModel->createFE_Element(numFe++, elePtr); }
return count3;
}
示例5: setLinks
int
LagrangeConstraintHandler::handle(const ID *nodesLast)
{
// first check links exist to a Domain and an AnalysisModel object
Domain *theDomain = this->getDomainPtr();
AnalysisModel *theModel = this->getAnalysisModelPtr();
Integrator *theIntegrator = this->getIntegratorPtr();
if ((theDomain == 0) || (theModel == 0) || (theIntegrator == 0)) {
opserr << "WARNING LagrangeConstraintHandler::handle() - ";
opserr << " setLinks() has not been called\n";
return -1;
}
// get number ofelements and nodes in the domain
// and init the theFEs and theDOFs arrays
int numConstraints = 0;
SP_ConstraintIter &theSPss = theDomain->getDomainAndLoadPatternSPs();
SP_Constraint *spPtr;
while ((spPtr = theSPss()) != 0)
numConstraints++;
numConstraints += theDomain->getNumMPs();
//create a DOF_Group for each Node and add it to the AnalysisModel.
// : must of course set the initial IDs
NodeIter &theNod = theDomain->getNodes();
Node *nodPtr;
MP_Constraint *mpPtr;
DOF_Group *dofPtr;
int numDofGrp = 0;
int count3 = 0;
int countDOF =0;
while ((nodPtr = theNod()) != 0) {
if ((dofPtr = new DOF_Group(numDofGrp++, nodPtr)) == 0) {
opserr << "WARNING LagrangeConstraintHandler::handle() ";
opserr << "- ran out of memory";
opserr << " creating DOF_Group " << numDofGrp++ << endln;
return -4;
}
// initially set all the ID value to -2
const ID &id = dofPtr->getID();
for (int j=0; j < id.Size(); j++) {
dofPtr->setID(j,-2);
countDOF++;
}
nodPtr->setDOF_GroupPtr(dofPtr);
theModel->addDOF_Group(dofPtr);
}
// create the FE_Elements for the Elements and add to the AnalysisModel
ElementIter &theEle = theDomain->getElements();
Element *elePtr;
int numFeEle = 0;
FE_Element *fePtr;
while ((elePtr = theEle()) != 0) {
// only create an FE_Element for a subdomain element if it does not
// do independent analysis .. then subdomain part of this analysis so create
// an FE_element & set subdomain to point to it.
if (elePtr->isSubdomain() == true) {
Subdomain *theSub = (Subdomain *)elePtr;
if (theSub->doesIndependentAnalysis() == false) {
if ((fePtr = new FE_Element(numFeEle++, elePtr)) == 0) {
opserr << "WARNING PlainHandler::handle() - ran out of memory";
opserr << " creating FE_Element " << elePtr->getTag() << endln;
return -5;
}
theModel->addFE_Element(fePtr);
theSub->setFE_ElementPtr(fePtr);
} // if (theSub->doesIndependentAnalysis() == false) {
} else {
// just a regular element .. create an FE_Element for it & add to AnalysisModel
if ((fePtr = new FE_Element(numFeEle++, elePtr)) == 0) {
opserr << "WARNING PlainHandler::handle() - ran out of memory";
opserr << " creating FE_Element " << elePtr->getTag() << endln;
return -5;
}
theModel->addFE_Element(fePtr);
}
}
// create the LagrangeSP_FE for the SP_Constraints and
// add to the AnalysisModel
SP_ConstraintIter &theSPs = theDomain->getDomainAndLoadPatternSPs();
while ((spPtr = theSPs()) != 0) {
if ((dofPtr = new LagrangeDOF_Group(numDofGrp++, *spPtr)) == 0) {
opserr << "WARNING LagrangeConstraintHandler::handle()";
opserr << " - ran out of memory";
//.........这里部分代码省略.........
示例6: transformedNode
//.........这里部分代码省略.........
tDofPtr->addSP_Constraint(*(sps[i]));
numSPs++;
}
}
// add the DOF to the array
theDOFs[numDOF++] = dofPtr;
numConstrainedNodes++;
countDOF+= numNodalDOF - numSPs;
}
}
// create an ordinary DOF_Group object if no dof constrained
if (createdDOF == 0) {
if ((dofPtr = new DOF_Group(numDofGrp++, nodPtr)) == 0) {
opserr << "WARNING TransformationConstraintHandler::handle() ";
opserr << "- ran out of memory";
opserr << " creating DOF_Group " << i << endln;
if (mps != 0) delete [] mps;
if (sps != 0) delete [] sps;
return -4;
}
countDOF+= numNodalDOF;
}
if (dofPtr == 0)
opserr << "TransformationConstraintHandler::handle() - error in logic\n";
nodPtr->setDOF_GroupPtr(dofPtr);
theModel->addDOF_Group(dofPtr);
}
// create the FE_Elements for the Elements and add to the AnalysisModel
ElementIter &theEle = theDomain->getElements();
Element *elePtr;
FE_Element *fePtr;
numFE = 0;
ID transformedEle(0, 64);
while ((elePtr = theEle()) != 0) {
int flag = 0;
if (elePtr->isSubdomain() == true) {
Subdomain *theSub = (Subdomain *)elePtr;
if (theSub->doesIndependentAnalysis() == true)
flag = 1;
}
if (flag == 0) {
const ID &nodes = elePtr->getExternalNodes();
int nodesSize = nodes.Size();
int isConstrainedNode = 0;
for (int i=0; i<nodesSize; i++) {
int nodeTag = nodes(i);
if (numMPConstraints != 0) {
int loc = constrainedNodesMP.getLocation(nodeTag);
if (loc >= 0) {
isConstrainedNode = 1;
i = nodesSize;
}
}
if (numSPConstraints != 0 && isConstrainedNode == 0) {
int loc = constrainedNodesSP.getLocation(nodeTag);
if (loc >= 0) {
isConstrainedNode = 1;
示例7: OPS_ElasticBeam2d
int OPS_ElasticBeam2d(Domain& theDomain, const ID& elenodes, ID& eletags)
{
if(OPS_GetNumRemainingInputArgs() < 4) {
opserr<<"insufficient arguments:A,E,Iz,transfTag\n";
return -1;
}
// inputs:
double data[3];
int numData = 3;
if(OPS_GetDoubleInput(&numData,&data[0]) < 0) return -1;
numData = 1;
int transfTag;
if(OPS_GetIntInput(&numData,&transfTag) < 0) return -1;
// options
double mass = 0.0, alpha=0.0, depth=0.0;
int cMass = 0;
while(OPS_GetNumRemainingInputArgs() > 0) {
std::string type = OPS_GetString();
if(type == "-alpha") {
if(OPS_GetNumRemainingInputArgs() > 0) {
if(OPS_GetDoubleInput(&numData,&alpha) < 0) return -1;
}
} else if(type == "-depth") {
if(OPS_GetNumRemainingInputArgs() > 0) {
if(OPS_GetDoubleInput(&numData,&depth) < 0) return -1;
}
} else if(type == "-mass") {
if(OPS_GetNumRemainingInputArgs() > 0) {
if(OPS_GetDoubleInput(&numData,&mass) < 0) return -1;
}
} else if(type == "-cMass") {
cMass = 1;
}
}
// check transf
CrdTransf* theTransf = OPS_getCrdTransf(transfTag);
if(theTransf == 0) {
opserr<<"coord transfomration not found\n";
return -1;
}
// create elements
ElementIter& theEles = theDomain.getElements();
Element* theEle = theEles();
int currTag = 0;
if (theEle != 0) {
currTag = theEle->getTag();
}
eletags.resize(elenodes.Size()/2);
for (int i=0; i<elenodes.Size()/2; i++) {
theEle = new ElasticBeam2d(--currTag,data[0],data[1],data[2],elenodes(2*i),elenodes(2*i+1),
*theTransf,alpha,depth,mass,cMass);
if (theEle == 0) {
opserr<<"WARING: run out of memory for creating element\n";
return -1;
}
if (theDomain.addElement(theEle) == false) {
opserr<<"WARNING: failed to add element to domain\n";
delete theEle;
return -1;
}
eletags(i) = currTag;
}
return 0;
}
示例8: ID
int
MeshRegion::setNodes(const ID &theNods)
{
// destroy the old lists
if (theNodes != 0)
delete theNodes;
if (theElements != 0)
delete theElements;
//
// create new element & node lists
//
// create empty lists
Domain *theDomain = this->getDomain();
if (theDomain == 0) {
opserr << "MeshRegion::setNodes() - no domain yet set\n";
return -1;
}
int numNodes = theNods.Size();
theNodes = new ID(0, numNodes);
theElements = new ID(0, numNodes);
if (theNodes == 0 || theElements == 0) {
opserr << "MeshRegion::setElements() - ran out of memory\n";
return -1;
}
// add nodes to the node list if in the domain
int loc = 0;
for (int i=0; i<numNodes; i++) {
int nodeTag = theNods(i);
Node *theNode = theDomain->getNode(nodeTag);
if (theNode != 0) {
if (theNodes->getLocation(nodeTag) < 0)
(*theNodes)[loc++] = nodeTag;
}
}
// now loop over the ele to create the ele list
// NOTE - ele added to list if all it's nodes are in the region
loc = 0;
ElementIter &theEles = theDomain->getElements();
Element *theEle;
// loop over all ele
while ((theEle = theEles()) != 0) {
int eleTag = theEle->getTag();
// check to see if all external nodes in node list
bool in = true;
const ID &theEleNodes = theEle->getExternalNodes();
int numNodes = theEleNodes.Size();
for (int i=0; i<numNodes; i++) {
int nodeTag = theEleNodes(i);
if (theNodes->getLocation(nodeTag) < 0) {
in = false;
i = numNodes;
}
}
// if they are all in the node list add the ele to ele list
if (in == true)
(*theElements)[loc++] = eleTag;
}
return 0;
}
示例9: OPS_Tri31
int OPS_Tri31(Domain& theDomain, const ID& elenodes, ID& eletags)
{
// get inputs
int numRemainingInputArgs = OPS_GetNumRemainingInputArgs();
if (numRemainingInputArgs < 3) {
opserr << "Invalid #args, want: thk? type? matTag? <pressure? rho? b1? b2?>\n";
return -1;
}
int matID;
double thk;
char *theType;
double dData[4];
dData[0] = 0.0;
dData[1] = 0.0;
dData[2] = 0.0;
dData[3] = 0.0;
int numData = 1;
if (OPS_GetDoubleInput(&numData, &thk) != 0) {
opserr << "WARNING invalid thickness data: element Tri31 \n";
return -1;
}
theType = (char*)OPS_GetString();
numData = 1;
if (OPS_GetIntInput(&numData, &matID) != 0) {
opserr << "WARNING invalid integer data: element Tri31\n";
return -1;
}
NDMaterial *theMaterial = OPS_getNDMaterial(matID);
if (theMaterial == 0) {
opserr << "WARNING element Tri31 \n";
opserr << " Material: " << matID << "not found\n";
return -1;
}
if (OPS_GetNumRemainingInputArgs() >= 4) {
numData = 4;
if (OPS_GetDoubleInput(&numData, &dData[0]) != 0) {
opserr << "WARNING invalid optional data: element Tri31\n";
return -1;
}
}
// create elements
ElementIter& theEles = theDomain.getElements();
Element* theEle = theEles();
int currTag = 0;
if (theEle != 0) {
currTag = theEle->getTag();
}
eletags.resize(elenodes.Size()/3);
for (int i=0; i<eletags.Size(); i++) {
theEle = new Tri31(--currTag,elenodes(3*i),elenodes(3*i+1),elenodes(3*i+2),
*theMaterial, theType, thk,
dData[0], dData[1], dData[2], dData[3]);
if (theEle == 0) {
opserr<<"WARNING: run out of memory for creating element\n";
return -1;
}
if (theDomain.addElement(theEle) == false) {
opserr<<"WARNING: failed to add element to domain\n";
delete theEle;
return -1;
}
eletags(i) = currTag;
}
return 0;
}