I'm developing a new element for OpenSees. My element is defined by 2 nodes. However, to get all the information for my algorithm, I need the global displacement and global velocity of 4 nodes more of my structure. Those 4 nodes don't belong to my element, I only need their coordinates and velocities in order to apply the algorithm.
For example, my element is defined between Node 1 and Node 2, however I need the global displacements and velocities of Node 3, 4, 5 and 6. My question is the following:
The command to call the connected nodes (1 and 2) is:
connectedExternalNodes(0) = Nd1;
connectedExternalNodes(1) = Nd2;
But, HOW and in WHAT part of the code can I get the global displacement and velocities of the other 4 nodes? At the end of the procedure, I would like to have (for my new element) a vector of basic system (6), stiffness matrix in basic system (6,6), displacement in local system (12).
Obviously, my input are the 6 nodes and the material properties.
Thank you so much beforehand.
New Element - Call nodes
Moderators: silvia, selimgunay, Moderators
Re: New Element - Call nodes
you obviously need to learn a little about c++ programming.
1) the above only stores the tags of nodes 1 and 2 in an integer array. they are stored in such because they are needed later. you could store nodes 3 and 4 as 2 integer variables in your new class.
i.e. int node3, node4 in your header file
2) pointers to the nodes are typically obtained in setDomain
i.e. if "Node *node3Ptr, *node4Ptr" was in the header file, you could write:
node3Ptr = theDomain->getNode(node3)
node4Ptr = theDomain->getNode(node4)
3) and then in update you could go get the displacements:
Vector &node3Disp = node3Ptr->getTrialDisp();
Vector &node4Disp = node4Ptr->getTrialDisp();
BUT AS I SAID YOU REALLY NEED TO LEARN SOME C++ AS THIS IS BASIC AND SHOULD BE OBVIOUS IF YOU KNEW ANY
1) the above only stores the tags of nodes 1 and 2 in an integer array. they are stored in such because they are needed later. you could store nodes 3 and 4 as 2 integer variables in your new class.
i.e. int node3, node4 in your header file
2) pointers to the nodes are typically obtained in setDomain
i.e. if "Node *node3Ptr, *node4Ptr" was in the header file, you could write:
node3Ptr = theDomain->getNode(node3)
node4Ptr = theDomain->getNode(node4)
3) and then in update you could go get the displacements:
Vector &node3Disp = node3Ptr->getTrialDisp();
Vector &node4Disp = node4Ptr->getTrialDisp();
BUT AS I SAID YOU REALLY NEED TO LEARN SOME C++ AS THIS IS BASIC AND SHOULD BE OBVIOUS IF YOU KNEW ANY
Re: New Element - Call nodes
Thank you. Problem solved. That's true, I'm beginner of C++.
Thank you for answering.
Thank you for answering.
Re: New Element - Call nodes
I have a new doubt related OpenSees. Which is the difference between "connectedExternalNodes" and "externalNodes" ?
In my header file I have:
// Public methods to obtain information about dof & connectivity
int getNumExternalNodes() const;
const ID &getExternalNodes();
Node **getNodePtrs();
int getNumDOF();
void setDomain(Domain *theDomain);
// Private attributes - a copy for each object of the class
ID externalNodes;
ID connectedExternalNodes;
Node *theNodes[10];
UniaxialMaterial *theMaterials[4];
And in my CPP file I have:
connectedExternalNodes(0) = node1;
connectedExternalNodes(1) = node2;
externalNodes(0) = node3;
externalNodes(1) = node4;
externalNodes(2) = node5;
externalNodes(3) = node6;
externalNodes(4) = node7;
externalNodes(5) = node8;
externalNodes(6) = node9;
externalNodes(7) = node10;
Then:
int NCM3D::getNumExternalNodes() const
{
return 10;
}
const ID& NCM3D::getExternalNodes()
{
return connectedExternalNodes;
return externalNodes;
}
Node** NCM3D::getNodePtrs()
{
return theNodes;
}
int NCM3D::getNumDOF()
{
return 60; //each node 6 dof, so in total 60 dof for both the nodes
}
And then:
// first set the node pointers
theNodes[0] = theDomain->getNode(connectedExternalNodes(0));
theNodes[1] = theDomain->getNode(connectedExternalNodes(1));
theNodes[2] = theDomain->getNode(externalNodes(0));
theNodes[3] = theDomain->getNode(externalNodes(1));
theNodes[4] = theDomain->getNode(externalNodes(2));
theNodes[5] = theDomain->getNode(externalNodes(3));
theNodes[6] = theDomain->getNode(externalNodes(4));
theNodes[7] = theDomain->getNode(externalNodes(5));
theNodes[8] = theDomain->getNode(externalNodes(6));
theNodes[9] = theDomain->getNode(externalNodes(7));
If I only use connectedExternalNodes, my element "works". If I use the externalNodes to know the coordinates of certain nodes, it doesn't work. What I'm doing wrong?
In my header file I have:
// Public methods to obtain information about dof & connectivity
int getNumExternalNodes() const;
const ID &getExternalNodes();
Node **getNodePtrs();
int getNumDOF();
void setDomain(Domain *theDomain);
// Private attributes - a copy for each object of the class
ID externalNodes;
ID connectedExternalNodes;
Node *theNodes[10];
UniaxialMaterial *theMaterials[4];
And in my CPP file I have:
connectedExternalNodes(0) = node1;
connectedExternalNodes(1) = node2;
externalNodes(0) = node3;
externalNodes(1) = node4;
externalNodes(2) = node5;
externalNodes(3) = node6;
externalNodes(4) = node7;
externalNodes(5) = node8;
externalNodes(6) = node9;
externalNodes(7) = node10;
Then:
int NCM3D::getNumExternalNodes() const
{
return 10;
}
const ID& NCM3D::getExternalNodes()
{
return connectedExternalNodes;
return externalNodes;
}
Node** NCM3D::getNodePtrs()
{
return theNodes;
}
int NCM3D::getNumDOF()
{
return 60; //each node 6 dof, so in total 60 dof for both the nodes
}
And then:
// first set the node pointers
theNodes[0] = theDomain->getNode(connectedExternalNodes(0));
theNodes[1] = theDomain->getNode(connectedExternalNodes(1));
theNodes[2] = theDomain->getNode(externalNodes(0));
theNodes[3] = theDomain->getNode(externalNodes(1));
theNodes[4] = theDomain->getNode(externalNodes(2));
theNodes[5] = theDomain->getNode(externalNodes(3));
theNodes[6] = theDomain->getNode(externalNodes(4));
theNodes[7] = theDomain->getNode(externalNodes(5));
theNodes[8] = theDomain->getNode(externalNodes(6));
theNodes[9] = theDomain->getNode(externalNodes(7));
If I only use connectedExternalNodes, my element "works". If I use the externalNodes to know the coordinates of certain nodes, it doesn't work. What I'm doing wrong?
Re: New Element - Call nodes
your problem is you don't know c++ .. opensees does not require the user to have objects with names externalNodes and connectedExternalNodes .. the Element.h defines the interface, you the developer need to meet the interface. many elements might use these names for their variables, but only because they typically have copied from some element that used these variables in the implementation.
if you only have 2 external nodes, then the getNumExternalNodes should only return 2! and your second return in getExternalNodes will never be reached. i am sure you have more erros but these are the ones that jump out at me!
if you only have 2 external nodes, then the getNumExternalNodes should only return 2! and your second return in getExternalNodes will never be reached. i am sure you have more erros but these are the ones that jump out at me!