Add A New Element
To add a new Element into the interpreted applications, the developer must:
- provide a new C++ subclass of the Element class
- provide an interface function that will be used to parse the input and create the new element.
Element Class
The Element class itself is an abstract base class. It inherits from both the DomainComponent class, which is itself a subclass of TaggedObject class and the MovableObject class. The class has a large number of methods defined in the interface, not all these methods need to be included in a new Element class. The following is the minimal interface that should be considered:
The Element Class:
class Element : public DomainComponent
{
public:
Element(int tag, int classTag);
virtual ~Element();
// methods dealing with nodes and number of external dof
virtual int getNumExternalNodes(void) const =0;
virtual const ID &getExternalNodes(void) =0;
virtual Node **getNodePtrs(void) =0;
virtual int getNumDOF(void) =0;
// methods dealing with committed state and update
virtual int commitState(void);
virtual int revertToLastCommit(void) = 0;
virtual int revertToStart(void);
virtual int update(void);
virtual bool isSubdomain(void);
// methods dealing with element stiffness
virtual const Matrix &getTangentStiff(void) =0;
virtual const Matrix &getInitialStiff(void) =0;
// methods dealing with element forces
virtual void zeroLoad(void);
virtual int addLoad(ElementalLoad *theLoad, double loadFactor);
virtual const Vector &getResistingForce(void) =0;
// method for obtaining information specific to an element
virtual Response *setResponse(const char **argv, int argc, OPS_Stream &theHandler);
virtual int getResponse(int responseID, Information &eleInformation);
}
Example - Truss2D
In the following section we will provide all necessary code to add a new 2d planar truss element into an OpenSees interpreter. To demonstrate the power of object-oriented programming, the stress-strain relationship will be provided by a UniaxialMaterial object.