本文整理汇总了C++中Domain::addMP_Constraint方法的典型用法代码示例。如果您正苦于以下问题:C++ Domain::addMP_Constraint方法的具体用法?C++ Domain::addMP_Constraint怎么用?C++ Domain::addMP_Constraint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domain
的用法示例。
在下文中一共展示了Domain::addMP_Constraint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: id
RigidBeam::RigidBeam(Domain &theDomain, int nR, int nC) {
// get a pointer to the retained and constrained nodes - make sure they exist
Node *nodeR = theDomain.getNode(nR);
if (nodeR == 0) {
opserr << "RigidBeam::RigidBeam - retained Node" << nR << "not in domain\n";
return;
}
Node *nodeC = theDomain.getNode(nC);
if (nodeR == 0) {
opserr << "RigidBeam::RigidBeam - constrained Node" << nC << "not in domain\n";
return;
}
// get the coordinates of the two nodes - check dimensions are the same FOR THE MOMENT
const Vector &crdR = nodeR->getCrds();
const Vector &crdC = nodeC->getCrds();
int dimR = crdR.Size();
int dimC = crdC.Size();
if (dimR != dimC) {
opserr << "RigidBeam::RigidBeam - mismatch in dimension " <<
"between constrained Node " << nC << " and Retained node" << nR << endln;
return;
}
// check the number of dof at each node is the same
int numDOF = nodeR->getNumberDOF();
if (numDOF != nodeC->getNumberDOF()) {
opserr << "RigidBeam::RigidBeam - mismatch in numDOF " <<
"between constrained Node " << nC << " and Retained node" << nR << endln;
return;
}
// check the number of dof at the nodes >= dimension of problem
if(numDOF < dimR) {
opserr << "RigidBeam::RigidBeam - numDOF at nodes " <<
nR << " and " << nC << "must be >= dimension of problem\n";
return;
}
// create the ID to identify the constrained dof
ID id(numDOF);
// construct the tranformation matrix Ccr, where Uc = Ccr Ur & set the diag, Ccr = I
Matrix mat(numDOF,numDOF);
mat.Zero();
// set the values
for (int i=0; i<numDOF; i++) {
mat(i,i) = 1.0;
id(i) = i;
}
// if there are rotational dof - we must modify Ccr DONE ASSUMING SMALL ROTATIONS
if (dimR != numDOF) {
if (dimR == 2 && numDOF == 3) {
double deltaX = crdC(0) - crdR(0);
double deltaY = crdC(1) - crdR(1);
mat(0,2) = -deltaY;
mat(1,2) = deltaX;
} else if (dimR == 3 && numDOF == 6) {
double deltaX = crdC(0) - crdR(0);
double deltaY = crdC(1) - crdR(1);
double deltaZ = crdC(2) - crdR(2);
// rotation about z/3 axis
mat(0,5) = -deltaY;
mat(1,5) = deltaX;
// rotation about y/2 axis
mat(0,4) = deltaZ;
mat(2,4) = -deltaX;
// rotation about x/1 axis
mat(1,3) = -deltaZ;
mat(2,3) = deltaY;
} else { // not valid
opserr << "RigidBeam::RigidBeam - for nodes " <<
nR << "and " << nC << "nodes do not have valid numDOF for their dimension\n";
return;
}
}
// create the MP_Constraint
MP_Constraint *newC = new MP_Constraint(nR, nC, mat, id, id);
if (newC == 0) {
opserr << "RigidBeam::RigidBeam - for nodes " << nC << " and " << nR << ", out of memory\n";
} else {
// add the constraint to the domain
if (theDomain.addMP_Constraint(newC) == false) {
opserr << "RigidBeam::RigidBeam - for nodes " << nC << " and " << nR << ", could not add to domain\n";
delete newC;
}
}
}
示例2: id
RigidRod::RigidRod(Domain &theDomain, int nR, int nC) {
// get a pointer to the retained node and constrained nodes - ensure these exist
Node *nodeR = theDomain.getNode(nR);
if (nodeR == 0) {
opserr << "RigidRod::RigidRod - retained Node" << nR << "not in domain\n";
return;
}
Node *nodeC = theDomain.getNode(nC);
if (nodeR == 0) {
opserr << "RigidRod::RigidRod - constrained Node" << nC << "not in domain\n";
return;
}
// get the coordinates of the two nodes - check dimensions are the same
const Vector &crdR = nodeR->getCrds();
const Vector &crdC = nodeC->getCrds();
int dimR = crdR.Size();
int dimC = crdC.Size();
if (dimR != dimC) {
opserr << "RigidRod::RigidRod - mismatch in dimension " <<
"between constrained Node " << nC << " and Retained node " << nR << endln;
return;
}
// check the number of dof at each node is the same
int numDOF = nodeR->getNumberDOF();
if (numDOF != nodeC->getNumberDOF()){
opserr << "RigidRod::RigidRod - mismatch in numDOF " <<
"between constrained Node " << nC << " and Retained node " << nR << endln;
return;
}
// check the number of dof at the nodes >= dimension of problem
if(numDOF < dimR){
opserr << "RigidRod::RigidRod - numDOF at nodes " << nR << " and " << nC <<
"must be >= dimension of problem\n";
return;
}
// create the ID to identify the constrained dof
ID id(dimR);
// construct the tranformation matrix Ccr, where Uc = Ccr Ur & set the diag
Matrix mat(dimR,dimR);
mat.Zero();
// set the values
for (int i=0; i<dimR; i++) {
mat(i,i) = 1.0;
id(i) = i;
}
// create the MP_Constraint
MP_Constraint *newC = new MP_Constraint(nR, nC, mat, id, id);
if (newC == 0) {
opserr << "RigidRod::RigidRod - for nodes " << nR << " and " << nC << " out of memory\n";
exit(-1);
} else {
// add the constraint to the domain
if (theDomain.addMP_Constraint(newC) == false) {
opserr << "RigidRod::RigidRod - for nodes " << nC << " and " << nR << " could not add to domain\n",
delete newC;
}
}
}