Element

Understanding the ElementRegistry

The ElementRegistry is a core component of the Femora library that serves as a centralized system for creating, retrieving, tracking, and managing element objects throughout the mesh generation process. Similar to the MaterialManager, it implements the Singleton pattern to ensure a single, consistent point of element management across the entire application.

Elements defined in Femora are automatically tracked, tagged, and organized by the ElementRegistry, simplifying the process of creating complex models with multiple element types.

Accessing the ElementRegistry

There are two ways to access the ElementRegistry in your code:

  1. Direct Access: Import and use the ElementRegistry class directly

    from femora.components.Element.elementBase import ElementRegistry
    
    # Access the registry directly
    element_types = ElementRegistry.get_element_types()
    
    # Create an element using the registry
    my_element = ElementRegistry.create_element(...)
    
  2. Through Femora (Recommended): Access via the Femora class’s .element property

    import femora as fm
    
    # Create a Femora instance
    
    
    # Access the ElementRegistry through the .element property
    element_types = fm.element.get_element_types()
    my_element = fm.element.create_element(...)
    

The second approach is recommended as it provides a unified interface to all of Femora’s components and ensures proper initialization of all dependencies.

How ElementRegistry Works

The ElementRegistry provides several key capabilities:

  1. Element Creation: Creates element objects of various types with appropriate parameters

  2. Element Tracking: Keeps track of all elements by their tags

  3. Element Tagging: Automatically assigns sequential tags to elements for use in analysis

  4. Element Management: Provides methods to retrieve, update, and delete elements

When an element is created, the ElementRegistry:

  1. Assigns a unique numeric tag automatically (used by solvers like OpenSees)

  2. Validates that all required parameters are present and valid

  3. Associates the element with an appropriate material

  4. Sets the degrees of freedom (DOF) for the element

Note

Each element has a unique tag that is used for identification during mesh generation and analysis. The ElementRegistry ensures that these tags remain unique and sequential.

Element Tagging System

The Element class implements an intelligent tagging system that:

  • Assigns sequential tags to elements starting from 1.

  • Automatically retags elements when one is deleted to maintain sequential numbering

  • Ensures uniqueness of tags across the model

  • Maps between element objects and their assigned tags

# Example of setting a custom tag starting point
from femora.components.Element.elementBase import Element

ElementRegistry API Reference

class femora.components.Element.elementBase.ElementRegistry(*args, **kwargs)[source]

A singleton registry to manage element types and their creation with full dependency resolution.

classmethod clear_all_elements()[source]

Clear all elements.

classmethod create_element(element_type, **kwargs)[source]

Create a new element of a specific type with full dependency resolution.

Parameters:
  • element_type (str) – Type of element to create

  • **kwargs – All element parameters including ndof, material, section, transformation

Returns:

A new element instance

Return type:

Element

Raises:
  • KeyError – If the element type is not registered

  • ValueError – If dependencies cannot be resolved

classmethod get_element(tag)[source]

Get an element by its tag.

Parameters:

tag (int) – The tag of the element to retrieve

Returns:

The element with the given tag, or None if not found

Return type:

Optional[Element]

classmethod get_element_count()[source]

Get the total number of registered elements.

Returns:

Number of elements

Return type:

int

classmethod get_element_types()[source]

Get available element types.

Returns:

Available element types

Return type:

List[str]

classmethod is_element_type_registered(name)[source]

Check if an element type is registered.

Parameters:

name (str) – The element type name to check

Returns:

True if registered, False otherwise

Return type:

bool

classmethod register_element_type(name, element_class)[source]

Register a new element type for easy creation.

Parameters:
  • name (str) – The name of the element type

  • element_class (Type[Element]) – The class of the element

classmethod unregister_element_type(name)[source]

Unregister an element type.

Parameters:

name (str) – The name of the element type to remove

Element Creation

Creating elements is one of the primary functions of the ElementRegistry. When creating an element, you need to specify several key parameters:

  1. element_type: Specifies the type of element (e.g., ‘SSPQuad’, ‘stdBrick’, etc.)

  2. ndof: Number of degrees of freedom per node for this element

  3. material: The material to associate with the element (can be a Material object, material tag, or material name)

  4. Element-specific parameters: Each element type requires specific parameters

The ElementRegistry handles all the details of creating the appropriate element object based on these parameters, ensuring type safety and parameter validation.

Available Element Types

The element types available in Femora are organized by their geometric dimensionality and characteristics. Follow the links above to explore the various element models available in each category.

  • 3D Elements: For three-dimensional continuum modeling

  • 2D Elements: For two-dimensional plane stress/strain problems

Each element type has its own documentation page with detailed parameter descriptions and usage examples.