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:
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(...)
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:
Element Creation: Creates element objects of various types with appropriate parameters
Element Tracking: Keeps track of all elements by their tags
Element Tagging: Automatically assigns sequential tags to elements for use in analysis
Element Management: Provides methods to retrieve, update, and delete elements
When an element is created, the ElementRegistry:
Assigns a unique numeric tag automatically (used by solvers like OpenSees)
Validates that all required parameters are present and valid
Associates the element with an appropriate material
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 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
Element Creation
Creating elements is one of the primary functions of the ElementRegistry. When creating an element, you need to specify several key parameters:
element_type: Specifies the type of element (e.g., ‘SSPQuad’, ‘stdBrick’, etc.)
ndof: Number of degrees of freedom per node for this element
material: The material to associate with the element (can be a Material object, material tag, or material name)
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.