Exemple #1
0
// void setID(int index, int value);
//	Method to set the correSPonding index of the ID to value.
int
LagrangeSP_FE::setID(void)
{
    int result = 0;

    // first determine the IDs in myID for those DOFs marked
    // as constrained DOFs, this is obtained from the DOF_Group
    // associated with the constrained node
    DOF_Group *theNodesDOFs = theNode->getDOF_GroupPtr();
    if (theNodesDOFs == 0) {
	opserr << "WARNING LagrangeSP_FE::setID(void)";
	opserr << " - no DOF_Group with Constrained Node\n";
	return -1;
    }    

    int restrainedDOF = theSP->getDOF_Number();
    const ID &theNodesID = theNodesDOFs->getID();
    
    if (restrainedDOF < 0 || restrainedDOF >= theNodesID.Size()) {
	opserr << "WARNING LagrangeSP_FE::setID(void)";
	opserr << " - restrained DOF invalid\n";
	return -2;
    }    	
    
    myID(0) = theNodesID(restrainedDOF);
    myID(1) = (theDofGroup->getID())(0);
    
    return result;
}
Exemple #2
0
int
DOF_Group::getNumFreeDOF(void) const
{
    int numFreeDOF = numDOF;
    for (int i=0; i<numDOF; i++)
	if (myID(i) == -1 || myID(i) == -4)
	    numFreeDOF--;
    
    return numFreeDOF;
}
Exemple #3
0
void
DOF_Group::incrNodeDisp(const Vector &u)
{
    if (myNode == 0) {
	opserr << "DOF_Group::setNodeDisp: 0 Node Pointer\n";
	exit(-1);
    }

    Vector &disp = *unbalance;;

    if (disp.Size() == 0) {
      opserr << "DOF_Group::setNodeIncrDisp - out of space\n";
      return;
    }
    int i;

    // get disp for my dof out of vector u
    for (i=0; i<numDOF; i++) {
	int loc = myID(i);	    			
	if (loc >= 0)
	    disp(i) = u(loc);  
	else disp(i) = 0.0;  
    }

    myNode->incrTrialDisp(disp);
}
Exemple #4
0
void
DOF_Group::addD_ForceSensitivity(const Vector &Udot, double fact)
{
    if (myNode == 0) {
        opserr << "DOF_Group::addD_ForceSensitivity() - no Node associated";
        opserr << " subclass should not call this method \n";
        return;
    }

    Vector vel(numDOF);
    // get velocity for the unconstrained dof
    for (int i=0; i<numDOF; i++) {
        int loc = myID(i);
        if (loc >= 0)
            vel(i) = Udot(loc);
        else vel(i) = 0.0;
    }

    if (unbalance->addMatrixVector(1.0, myNode->getDampSensitivity(), vel, fact) < 0) {
        opserr << "DOF_Group::addD_ForceSensitivity() ";
        opserr << " invoking addMatrixVector() on the unbalance failed\n";
    }
    else {

    }
}
Exemple #5
0
const Vector &
DOF_Group::getM_Force(const Vector &Udotdot, double fact)
{
    if (myNode == 0) {
	opserr << "DOF_Group::getM_Force() - no Node associated";	
	opserr << " subclass should not call this method \n";	    
	return *unbalance;
    }

    Vector accel(numDOF);
    // get accel for the unconstrained dof
    for (int i=0; i<numDOF; i++) {
	int loc = myID(i);
	if (loc >= 0)
	    accel(i) = Udotdot(loc); 
	else accel(i) = 0.0;
    }
	
    if (unbalance->addMatrixVector(0.0, myNode->getMass(), accel, fact) < 0) {  
	opserr << "DOF_Group::getM_Force() ";
	opserr << " invoking addMatrixVector() on the unbalance failed\n";
    }
    
    return *unbalance;
}
 // The analyzeSubtree() method is called for every defining function declaration in the AST. Its second argument is the
 // inherited attribute computed for this node by the pre-traversal, the value it returns becomes the synthesized
 // attribute used by the post-traversal.
    std::string analyzeSubtree(SgFunctionDeclaration *funcDecl, int depth)
    {
        std::string funcName = funcDecl->get_name().str();
        std::stringstream s;
        s << "process " << myID() << ": at depth " << depth << ": function " << funcName;
        return s.str();
    }
Exemple #7
0
int
DOF_Group::getNumConstrainedDOF(void) const
{   
    int numConstr = 0;
    for (int i=0; i<numDOF; i++)
	if (myID(i) < 0)
	    numConstr++;    

    return numConstr;
}    
Exemple #8
0
void
DOF_Group::setID(int index, int value)
{
    if ((index >= 0) && (index < numDOF))
	myID(index) = value;
    else {
	opserr << "WARNING DOF_Group::setID - invalid location ";
	opserr << index << " in ID of size " << numDOF << endln;
    }	
}
Exemple #9
0
const Vector &
LagrangeSP_FE::getTangForce(const Vector &disp, double fact)
{
    double constraint = theSP->getValue();
    int constrainedID = myID(1);
    if (constrainedID < 0 || constrainedID >= disp.Size()) {
	opserr << "WARNING LagrangeSP_FE::getTangForce() - ";	
	opserr << " constrained DOF " << constrainedID << " outside disp\n";
	(*resid)(1) = constraint*alpha;
	return *resid;
    }
    (*resid)(1) = disp(constrainedID);
    return *resid;    
}
Exemple #10
0
int 
DOF_Group::saveAccSensitivity(const Vector &v, int gradNum, int numGrads)
{
  Vector &dudh = *unbalance;

  for (int i = 0; i < numDOF; i++) {
    int loc = myID(i);
    if (loc >= 0)
      dudh(i) = v(loc);
    else
      dudh(i) = 0.0;
  }

  return myNode->saveAccelSensitivity(dudh, gradNum, numGrads);
}
Exemple #11
0
void
DOF_Group::setEigenvector(int mode, const Vector &theVector)
{

    if (myNode == 0) {
	opserr << "DOF_Group::setNodeAccel: 0 Node Pointer\n";
	exit(-1);
    }

    Vector &eigenvector = *unbalance;
    int i;
    
    // get disp for the unconstrained dof
    for (i=0; i<numDOF; i++) {
	int loc = myID(i);
	if (loc >= 0)
	    eigenvector(i) = theVector(loc); 
	else eigenvector(i) = 0.0;
    }    
    myNode->setEigenvector(mode, eigenvector);
}
Exemple #12
0
void
DOF_Group::incrNodeAccel(const Vector &udotdot)
{

    if (myNode == 0) {
	opserr << "DOF_Group::setNodeAccel: 0 Node Pointer\n";
	exit(-1);
    }

    Vector &accel = *unbalance;
    int i;
    
    // get disp for the unconstrained dof
    for (i=0; i<numDOF; i++) {
	int loc = myID(i);
	if (loc >= 0)
	    accel(i) = udotdot(loc); 
	else accel(i) = 0.0;
    }    
    myNode->incrTrialAccel(accel);
}
Exemple #13
0
void
DOF_Group::incrNodeVel(const Vector &udot)
{

    if (myNode == 0) {
	opserr << "DOF_Group::setNodeVel: 0 Node Pointer\n";
	exit(-1);
    }
    
    Vector &vel = *unbalance;
    int i;
    
    // get vel for my dof out of vector udot
    for (i=0; i<numDOF; i++) {
	int loc = myID(i);
	if (loc >= 0)
	    vel(i) = udot(loc);  // -1 for dof labelled 1 through ndof
	else  vel(i) = 0.0;
    }
    myNode->incrTrialVel(vel);
}
Exemple #14
0
void
DOF_Group::setNodeDisp(const Vector &u)
{
    if (myNode == 0) {
	opserr << "DOF_Group::setNodeDisp: no associated Node\n";
	return;
    }
    
    Vector &disp = *unbalance;
    disp = myNode->getTrialDisp();
    int i;
    
    // get disp for my dof out of vector u
    for (i=0; i<numDOF; i++) {
	int loc = myID(i);
	if (loc >= 0)
	    disp(i) = u(loc);  
    }

    myNode->setTrialDisp(disp);
}
Exemple #15
0
void
DOF_Group::setNodeAccel(const Vector &udotdot)
{

    if (myNode == 0) {
	opserr << "DOF_Group::setNodeAccel: 0 Node Pointer\n";
	return;
    }

    Vector &accel = *unbalance;;
    accel = myNode->getTrialAccel();
    int i;
    
    // get disp for the unconstrained dof
    for (i=0; i<numDOF; i++) {
	int loc = myID(i);	    		
	if (loc >= 0)
	    accel(i) = udotdot(loc); 
    }

    myNode->setTrialAccel(accel);
}
Exemple #16
0
void
DOF_Group::setNodeVel(const Vector &udot)
{

    if (myNode == 0) {
	opserr << "DOF_Group::setNodeVel: 0 Node Pointer\n";
	return;
    }
    
    Vector &vel = *unbalance;
    vel = myNode->getTrialVel();
    int i;
    
    // get vel for my dof out of vector udot
    for (i=0; i<numDOF; i++) {
	int loc = myID(i);	    	
	if (loc >= 0) 
	    vel(i) = udot(loc);  
    }

    myNode->setTrialVel(vel);

}
Exemple #17
0
// void setID(int index, int value);
//	Method to set the correMPonding index of the ID to value.
int
PenaltyMP_FE::setID(void)
{
    int result = 0;

    // first determine the IDs in myID for those DOFs marked
    // as constrained DOFs, this is obtained from the DOF_Group
    // associated with the constrained node
    DOF_Group *theConstrainedNodesDOFs = theConstrainedNode->getDOF_GroupPtr();
    if (theConstrainedNodesDOFs == 0) {
	opserr << "WARNING PenaltyMP_FE::setID(void)";
	opserr << " - no DOF_Group with Constrained Node\n";
	return -2;
    }    

    const ID &constrainedDOFs = theMP->getConstrainedDOFs();
    const ID &theConstrainedNodesID = theConstrainedNodesDOFs->getID();    
    
    int size1 = constrainedDOFs.Size();
    for (int i=0; i<size1; i++) {
	int constrained = constrainedDOFs(i);
	if (constrained < 0 || 
	    constrained >= theConstrainedNode->getNumberDOF()) {
	    
	    opserr << "WARNING PenaltyMP_FE::setID(void) - unknown DOF ";
	    opserr << constrained << " at Node\n";
	    myID(i) = -1; // modify so nothing will be added to equations
	    result = -3;
	}    	
	else {
	    if (constrained >= theConstrainedNodesID.Size()) {
		opserr << "WARNING PenaltyMP_FE::setID(void) - ";
		opserr << " Nodes DOF_Group too small\n";
		myID(i) = -1; // modify so nothing will be added to equations
		result = -4;
	    }
	    else
		myID(i) = theConstrainedNodesID(constrained);
	}
    }
    
    // now determine the IDs for the retained dof's
    DOF_Group *theRetainedNodesDOFs = theRetainedNode->getDOF_GroupPtr();
    if (theRetainedNodesDOFs == 0) {
	opserr << "WARNING PenaltyMP_FE::setID(void)";
	opserr << " - no DOF_Group with Retained Node\n";
	return -2;
    }    
    
    const ID &RetainedDOFs = theMP->getRetainedDOFs();
    const ID &theRetainedNodesID = theRetainedNodesDOFs->getID();    

    int size2 = RetainedDOFs.Size();
    for (int j=0; j<size2; j++) {
	int retained = RetainedDOFs(j);
	if (retained < 0 || retained >= theRetainedNode->getNumberDOF()) {
	    opserr << "WARNING PenaltyMP_FE::setID(void) - unknown DOF ";
	    opserr << retained << " at Node\n";
	    myID(j+size1) = -1; // modify so nothing will be added
	    result = -3;
	}    	
	else {
	    if (retained >= theRetainedNodesID.Size()) {
		opserr << "WARNING PenaltyMP_FE::setID(void) - ";
		opserr << " Nodes DOF_Group too small\n";
		myID(j+size1) = -1; // modify so nothing will be added 
		result = -4;
	    }
	    else
		myID(j+size1) = theRetainedNodesID(retained);
	}
    }

    myDOF_Groups(0) = theConstrainedNodesDOFs->getTag();
    myDOF_Groups(1) = theRetainedNodesDOFs->getTag();

    return result;
}
Exemple #18
0
DOF_Group::DOF_Group(int tag, Node *node)
:TaggedObject(tag),
 unbalance(0), tangent(0), myNode(node), 
 myID(node->getNumberDOF()), 
 numDOF(node->getNumberDOF())
{
    // get number of DOF & verify valid
    int numDOF = node->getNumberDOF();
    if (numDOF <= 0) {
	opserr << "DOF_Group::DOF_Group(Node *) ";
	opserr << " node must have at least 1 dof " << *node;
	exit(-1);
    }	

    // check the ID created is of appropriate size
    if (myID.Size() != numDOF) {
	opserr << "DOF_Group::DOF_Group(Node *) ";
	opserr << " ran out of memory creating ID for node " << *node;
	exit(-1);
    }

    // initially set all the IDs to be -2
    for (int i=0; i<numDOF; i++)
	myID(i) = -2;
    
    // if this is the first DOF_Group we now
    // create the arrays used to store pointers to class wide
    // matrix and vector objects used to return tangent and residual
    if (numDOFs == 0) {
	theMatrices = new Matrix *[MAX_NUM_DOF+1];
	theVectors  = new Vector *[MAX_NUM_DOF+1];
	
	if (theMatrices == 0 || theVectors == 0) {
	    opserr << "DOF_Group::DOF_Group(Node *) ";
	    opserr << " ran out of memory";	    
	}
	for (int i=0; i<MAX_NUM_DOF; i++) {
	    theMatrices[i] = 0;
	    theVectors[i] = 0;
	}
    }    
    
    // set the pointers for the tangent and residual
    if (numDOF <= MAX_NUM_DOF) {
	// use class wide objects
	if (theVectors[numDOF] == 0) {
	    // have to create matrix and vector of size as none yet created
	    theVectors[numDOF] = new Vector(numDOF);
	    theMatrices[numDOF] = new Matrix(numDOF,numDOF);
	    unbalance = theVectors[numDOF];
	    tangent = theMatrices[numDOF];
	    if (unbalance == 0 || unbalance->Size() != numDOF ||	
		tangent == 0 || tangent->noCols() != numDOF)	{  
		opserr << "DOF_Group::DOF_Group(Node *) ";
		opserr << " ran out of memory for vector/Matrix of size :";
		opserr << numDOF << endln;
		exit(-1);
	    }
	} else {
	    unbalance = theVectors[numDOF];
	    tangent = theMatrices[numDOF];
	}
    } else {
	// create matrices and vectors for each object instance
	unbalance = new Vector(numDOF);
	tangent = new Matrix(numDOF, numDOF);
	if (unbalance == 0 || unbalance->Size() ==0 ||
	    tangent ==0 || tangent->noRows() ==0) {
	    
	    opserr << "DOF_Group::DOF_Group(Node *) ";
	    opserr << " ran out of memory for vector/Matrix of size :";
	    opserr << numDOF << endln;
	    exit(-1);
	}
    }
    
    numDOFs++;
}