export_tcl
export_tcl
Classes
GhostNodeElement
Bases: Element
Virtual element that owns mesh nodes without creating OpenSees elements.
GhostNodeElement keeps nodes in the Femora mesh and Tcl export pipeline
without emitting a structural element command. It is commonly used for
center-of-mass nodes, control or reference nodes, and mass application
points that should not participate in element stiffness.
Note
- Each instance receives a unique sentinel
ndfvalue so mesh merging does not combine ghost nodes with structural nodes or with one another. At export, the sentinel is mapped back to the real DOF count throughresolve_ndf. to_tclreturns a Tcl comment rather than an OpenSees element command; the owning nodes are still written by the export loop.
Example
Create a GhostNodeElement with merge-protected sentinel DOF metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ndof
|
int
|
Real number of DOFs per node written during Tcl export. Must be 3 or 6. |
3
|
**kwargs
|
Additional keyword arguments forwarded to the base element constructor. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Attributes
Methods:
resolve_ndf
classmethod
Map a mesh ndf value to the real DOF count for Tcl export.
If ndf_value is a ghost sentinel, it is resolved through the
internal map. Otherwise the input is returned unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ndf_value
|
int
|
Raw |
required |
Returns:
| Type | Description |
|---|---|
int
|
The real DOF count to write into the Tcl |
is_ghost_ndf
classmethod
Check whether an ndf value is a ghost-node sentinel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ndf_value
|
int
|
The |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
to_tcl
Return a Tcl comment instead of an OpenSees element command.
The owning node(s) are still written by the export loop; only the
element line is replaced with a comment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
int
|
Element tag assigned by the manager. |
required |
nodes
|
List[int]
|
Node tags owned by this ghost element. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Tcl comment describing the ghost element. |
FemoraEvent
Bases: Enum
Lifecycle signals emitted by Femora runtime subsystems.
These enum values describe when a callback is being invoked. They are not ordinary modeling commands. Instead, they mark important stages in the runtime lifecycle so advanced components can react at the right time.
The most important practical events are:
PRE_ASSEMBLE: emitted before the final assembled mesh is builtPOST_ASSEMBLE: emitted after the final assembled mesh existsRESOLVE_CORE_CONFLICTS: emitted after assembly when partition/core ownership updates may need follow-up workPRE_EXPORTandPOST_EXPORT: emitted around export-time workflows
More specialized events such as EMBEDDED_BEAM_SOLID_TCL are used by
advanced exporters and interface-specific integrations.
Progress
Manages a global progress bar for reporting operation progress.
This singleton class provides a consistent way to display progress using
tqdm across different parts of the Femora package. It ensures only
one progress bar is active at a time and provides methods for updating
and closing it.
Attributes:
| Name | Type | Description |
|---|---|---|
_bar |
Optional[tqdm]
|
The internal |
_last_value |
int
|
The last integer progress value reported (0-100). |
Example:rn python`r`n from femora.utils.progress import Progress`r`n`r`n Progress.callback(value=0, desc="Loading Data")`r`n Progress.callback(value=50, message="Processing chunk 1")`r`n Progress.callback(value=100)`r`n 100%|██████████| 100/100 [...]
Methods:
callback
classmethod
Updates the progress bar with the given value and message.
This method ensures the progress bar is initialized (if not already)
and updates its current value and postfix message. If the value
reaches 100, the bar is automatically closed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
The current progress, a float between 0 and 100. It will be cast to an integer for display. |
required |
message
|
str
|
An optional short status string to display next to the bar. Defaults to an empty string. |
''
|
desc
|
str
|
The description for the progress bar. This is only used when the bar is created for the first time. Defaults to "Processing". |
'Processing'
|
Example:rn python`r`n from femora.utils.progress import Progress`r`n`r`n Progress.callback(value=0, desc="File Transfer")`r`n Progress.callback(value=25, message="Downloading part A")`r`n Progress.callback(value=75, message="Verifying checksum")`r`n Progress.callback(value=100, message="Complete")`r`n 100%|██████████| 100/100 [...] Complete
close
classmethod
Closes the internal tqdm progress bar and resets its state.
This method should be called explicitly if a progress operation is
aborted or finishes without value reaching 100 (which automatically
closes the bar). It ensures that no lingering tqdm bar remains open.
Example:rn python`r`n from femora.utils.progress import Progress`r`n`r`n Progress.callback(value=0, desc="Long Operation")`r`n Progress.close()`r`n
Functions:
_progress_callback
Default progress reporter that uses the shared Progress utility.
_get_tcl_helper_functions
Return TCL helper functions as a string.
This method contains all the TCL helper functions needed for the exported model. Embedding them directly in the code ensures they're always available and makes the package more professional and self-contained.
Returns:
| Name | Type | Description |
|---|---|---|
str |
TCL helper functions |
export_to_tcl
Export the model to a TCL file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Femora Model instance with an assembled mesh. |
required | |
filename
|
str
|
The filename to export to. If None, uses model_name in model_path |
None
|
progress_callback
|
callable
|
Callback function to report progress. If None, uses tqdm progress bar. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if export was successful, False otherwise |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no filename is provided and model_name/model_path are not set |