Add A New Element: Difference between revisions

From OpenSeesWiki
Jump to navigation Jump to search
(Created page with ' 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 t...')
 
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
The OpenSees applications allows developers to use their own element modules to the application. Unlike most other programs, the elements are added at run-time and not at compile time. The advantage of this is the the developers:
# Do not need the OpenSees source files or libraries to compile and link the application.
# Can share their modules with others without having to provide the source code.


To add a new Element into the interpreted applications, the developer must:
The element modules can be written using either C++, C, or Fortran. Whatever the language the developer wishes to use,
# provide a new C++ subclass of the Element class
the element modules make use of the [[OpenSees API]] to for example find nodal coordinates and displacements, and make use of material modules
# provide an interface function that will be used to parse the input and create the new element.  
that exist in OpenSees or are also added as external routines.


=== Element Class ===
# [[Add a New Element C++]]
 
# [[Add a New Element C]]
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.
# [[Add a New Element Fortran]]
The following is the minimal interface that should be considered:
 
The Element Class:
 
<source lang="cpp">
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);
}
 
</source>
 
=== 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.

Latest revision as of 23:04, 13 July 2010

The OpenSees applications allows developers to use their own element modules to the application. Unlike most other programs, the elements are added at run-time and not at compile time. The advantage of this is the the developers:

  1. Do not need the OpenSees source files or libraries to compile and link the application.
  2. Can share their modules with others without having to provide the source code.

The element modules can be written using either C++, C, or Fortran. Whatever the language the developer wishes to use, the element modules make use of the OpenSees API to for example find nodal coordinates and displacements, and make use of material modules that exist in OpenSees or are also added as external routines.

  1. Add a New Element C++
  2. Add a New Element C
  3. Add a New Element Fortran