Parts
Module: xfea.model.parts
PartBase
Section titled “PartBase”PartBase(**kwargs)
What every part has: its nodes and elements, its groups and geometry, and queries on them.
Parameters
| Name | Type | Description |
|---|---|---|
| name | str, optional | Unique identifier, generated if not given. A readable name makes a more readable input file. |
Attributes
| Name | Type | Description |
|---|---|---|
| model | Model | None |
The model the part is registered to. |
| nodes | NodesGroup | None |
The nodes of the part. |
| elements | ElementsGroup | None |
The elements of the part. |
| sections | SectionsGroup |
The sections of the part’s elements. |
| materials | MaterialsGroup |
The materials of those sections. |
| element_types | dict[type, list[ElementBase]] |
The elements of the part by element class. |
| boundary_mesh | Mesh | None |
The outer surface of the part’s mesh. |
Abstract base class; do not instantiate directly.
Properties
base_featuresdict[str, GeometryFeature]read-only
The named features of the base geometry, by name (empty without a base geometry).
base_geometryBaseGeometry | None
The geometry the part is meshed from, or None.
Set it to a STEP file path, another file path, a mesh, a line, a polyline or a list of lines or polylines: it is wrapped in the matching geometry class.
bb_centerPointread-only
The centre of the part’s bounding box.
bottom_planePlaneread-only
The bottom plane of the part’s bounding box.
boundary_facesFacesGroupread-only
The element faces on the outer surface of the part (cached).
A face is on the boundary when its nodes are those of no other element face: an internal face is shared by two neighbouring elements. The result is cached until nodes or elements change.
boundary_meshMeshread-only
The outer surface of the part’s mesh, as a Mesh, or None if it has no boundary faces.
bounding_boxBoxread-only
The bounding box of the part.
For parts with only 1D elements, the bounding box is expanded by the maximum section dimension to account for section depth/width.
centerPointread-only
The geometric (unweighted) center of the part’s nodes.
centroidPointread-only
Mass-weighted centroid of the part.
Falls back to the unweighted geometric centre (self.center)
when the part has no mass — e.g. a section/material with zero
density, or a rigid part where mass is intentionally not
defined. Without the fallback centroid_points_weighted
divides by zero and raises.
edgesEdgesGroupread-only
The edges of the part’s elements.
element_typesdict[type, list[ElementBase]]read-only
The elements of the part by element class.
elementsElementsGroup | Noneread-only
The elements of the part.
elements_centroidslist[list[float]]read-only
The centroids of the part’s elements (x, y, z in active length unit).
elements_connectivitylist[list[int]]read-only
The connectivity of the part’s elements.
elements_connectivity_groupeddict[int, list[list[float]]]read-only
The connectivity of the part’s elements grouped by element type.
elements_countintread-only
The number of elements in the part.
elements_facesdict[ElementBase, FacesGroup]read-only
The faces of the part’s elements grouped by element.
elements_faces_groupeddict[int, list[list[ForwardRef(Face)]]]read-only
The faces of the part’s elements grouped by element key.
elements_faces_indiceslist[list[list[float]]]read-only
The indices of the faces of the part’s elements.
elements_faces_indices_groupeddict[int, list[list[float]]]read-only
The indices of the faces of the part’s elements grouped by element key.
elements_groupeddict[type, list[ElementBase]]read-only
The elements of the part grouped by their element class’s base class.
elements_sortedlist[ElementBase]read-only
The elements of the part sorted by their part key.
facesFacesGroupread-only
The faces of the part’s elements.
gkey_nodedict[str, Node]read-only
Each node of the part by its geometric key.
graphread-only
The part’s connectivity graph (a networkx.DiGraph, an edge from each element to each of its nodes).
groupsset[ForwardRef(NodesGroup) | ForwardRef(ElementsGroup) | ForwardRef(EdgesGroup) | ForwardRef(FacesGroup) | ForwardRef(MaterialsGroup) | ForwardRef(SectionsGroup) | ForwardRef(InterfacesGroup) | ForwardRef(InteractionsGroup)]read-only
The groups of the part (nodes, elements, faces…), its all-nodes and all-elements groups among them.
keyAny | Noneread-only
The object’s key (its number) in what it is registered to; None until it is given one.
materialsMaterialsGroupread-only
The materials of the part’s sections.
For a part in a model, the model’s materials is faster.
materials_grouped_by_namedict[str, list[MaterialBase]]read-only
The materials of the part grouped by their name.
materials_sortedlist[MaterialBase]read-only
The materials of the part sorted by their name.
modelread-only
The model the part is registered to, or None.
namestr
The object’s name.
nodesNodesGroup | Noneread-only
The nodes of the part.
nodes_countintread-only
The number of nodes in the part.
nodes_sortedlist[Node]read-only
The nodes of the part sorted by their part key.
pointslist[Point]read-only
The points of the part’s nodes.
points_sortedlist[Point]read-only
The points of the part’s nodes sorted by their part key.
reference_nodeNode | None
The part’s reference node, or None: on a rigid part, the node that drives its motion.
Setting it adds the node to the part.
registrationAny | None
The object this one is registered to (a part, a model, a step, …), or None.
releases_fieldsReleaseFieldsGroup | Noneread-only
The part’s beam end releases, one field per call of add_beams_releases_fields.
sectionsSectionsGroupread-only
The sections of the part’s elements.
For a part in a model, the model’s sections is faster.
sections_grouped_by_elementdict[type, list[SectionBase]]read-only
The sections of the part grouped by their type.
sections_sortedlist[SectionBase]read-only
The sections of the part sorted by their key.
top_planePlaneread-only
The top plane of the part’s bounding box.
uidUUID | Noneread-only
The object’s unique id, a UUID.
volumefloatread-only
The total volume of the part’s elements, length cubed (mm3 for mm).
weightfloatread-only
The total weight of the part’s elements, a force in the active unit system.
Methods
add_base_feature(name, kind, data, **tags)→GeometryFeature
add_base_feature(name: str, kind: str, data: object, **tags) -> GeometryFeature
Add a named feature to the base geometry (one a meshing plugin can use, e.g. to refine it).
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | The feature’s name; it replaces a feature of the same name. |
| kind | str | The feature’s kind, e.g. "nodes", "edges", "faces" or one a plugin defines. |
| data | object | The feature’s payload: indices, geometry, or other data the plugin reads. |
| **tags | Extra settings for the meshing plugin. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.geometry.GeometryFeature |
The feature added. |
add_element(element)→ForwardRef(ElementBase) | ForwardRef(Element1DBase) | ForwardRef(Element2DBase) | ForwardRef(Element3DBase)
add_element(
element: ForwardRef(ElementBase) | ForwardRef(Element1DBase) | ForwardRef(Element2DBase) | ForwardRef(Element3DBase),
) -> ForwardRef(ElementBase) | ForwardRef(Element1DBase) | ForwardRef(Element2DBase) | ForwardRef(Element3DBase)
Add an element to the part, with its nodes, and return it.
Parameters
| Name | Type | Description |
|---|---|---|
| element | ElementBase |
The element, with its section; its nodes are added to the part too. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.ElementBase |
The element, now registered to the part. |
add_elements(elements)→list[ElementBase]
add_elements(elements: list[ElementBase]) -> list[ElementBase]
Add several elements to the part, with their nodes, and return them.
Parameters
| Name | Type | Description |
|---|---|---|
| elements | list[ElementBase] |
The elements, each with its section. |
Returns
| Name | Type | Description |
|---|---|---|
| list[ | class:xfea.model.ElementBase] |
The elements, now registered to the part. |
add_group(group)→ForwardRef(NodesGroup) | ForwardRef(ElementsGroup) | ForwardRef(EdgesGroup) | ForwardRef(FacesGroup) | ForwardRef(MaterialsGroup) | ForwardRef(SectionsGroup) | ForwardRef(InterfacesGroup) | ForwardRef(InteractionsGroup)
add_group(
group: ForwardRef(NodesGroup) | ForwardRef(ElementsGroup) | ForwardRef(EdgesGroup) | ForwardRef(FacesGroup) | ForwardRef(MaterialsGroup) | ForwardRef(SectionsGroup) | ForwardRef(InterfacesGroup) | ForwardRef(InteractionsGroup),
) -> ForwardRef(NodesGroup) | ForwardRef(ElementsGroup) | ForwardRef(EdgesGroup) | ForwardRef(FacesGroup) | ForwardRef(MaterialsGroup) | ForwardRef(SectionsGroup) | ForwardRef(InterfacesGroup) | ForwardRef(InteractionsGroup)
Add a group (of nodes, elements, faces…) to the part and return it.
Parameters
| Name | Type | Description |
|---|---|---|
| group | NodesGroup | ElementsGroup | FacesGroup |
The group; it is registered to the part. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.NodesGroup | ElementsGroup | FacesGroup |
The group. |
add_groups(groups)→list[ForwardRef(NodesGroup) | ForwardRef(ElementsGroup) | ForwardRef(EdgesGroup) | ForwardRef(FacesGroup) | ForwardRef(MaterialsGroup) | ForwardRef(SectionsGroup) | ForwardRef(InterfacesGroup) | ForwardRef(InteractionsGroup)]
add_groups(
groups: list[ForwardRef(NodesGroup) | ForwardRef(ElementsGroup) | ForwardRef(EdgesGroup) | ForwardRef(FacesGroup) | ForwardRef(MaterialsGroup) | ForwardRef(SectionsGroup) | ForwardRef(InterfacesGroup) | ForwardRef(InteractionsGroup)],
) -> list[ForwardRef(NodesGroup) | ForwardRef(ElementsGroup) | ForwardRef(EdgesGroup) | ForwardRef(FacesGroup) | ForwardRef(MaterialsGroup) | ForwardRef(SectionsGroup) | ForwardRef(InterfacesGroup) | ForwardRef(InteractionsGroup)]
Add several groups to the part and return them.
Parameters
| Name | Type | Description |
|---|---|---|
| groups | list | The groups (of nodes, elements, faces…). |
Returns
| Name | Type | Description |
|---|---|---|
| list | The groups. |
add_node(node)→Node
add_node(node: Node) -> Node
Add a node to the part and return it.
Parameters
| Name | Type | Description |
|---|---|---|
| node | Node |
The node; one already in the part is not added twice. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.Node |
The node, now registered to the part. |
add_nodes(nodes)→list[Node]
add_nodes(nodes: list[Node] | NodesGroup) -> list[Node]
Add several nodes to the part and return them.
Parameters
| Name | Type | Description |
|---|---|---|
| nodes | list[Node] | NodesGroup |
The nodes. |
Returns
| Name | Type | Description |
|---|---|---|
| list[ | class:xfea.model.Node] |
The nodes, now registered to the part. |
compute_nodal_masses()→list[float]
Set each node’s mass from the elements on it, and return the part’s total mass.
Each node gets the sum of the nodal masses of its elements, along x, y and z; its rotational masses are set to zero.
Returns
| Name | Type | Description |
|---|---|---|
| list[float] | The part’s total mass along x, y and z. |
Rotational masses are not considered.
contains_element(element)→bool
contains_element(element: ElementBase) -> bool
Whether an element is in the part.
Parameters
| Name | Type | Description |
|---|---|---|
| element | ElementBase |
The element to check. |
Returns
| Name | Type | Description |
|---|---|---|
| bool | True if the element is in the part, False otherwise. |
contains_material(material)→bool
contains_material(material: MaterialBase) -> bool
Whether a material is one of the part’s.
Parameters
| Name | Type | Description |
|---|---|---|
| material | MaterialBase |
The material to look for. |
Returns
| Name | Type | Description |
|---|---|---|
| bool | True if one of the part’s sections uses it. |
contains_node(node)→bool
contains_node(node: Node) -> bool
Whether a node is in the part.
Parameters
| Name | Type | Description |
|---|---|---|
| node | Node |
The node to check. |
Returns
| Name | Type | Description |
|---|---|---|
| bool | True if the node is in the part, False otherwise. |
contains_section(section)→bool
contains_section(section: SectionBase) -> bool
Whether a section is one of the part’s.
Parameters
| Name | Type | Description |
|---|---|---|
| section | SectionBase |
The section to look for. |
Returns
| Name | Type | Description |
|---|---|---|
| bool | True if one of the part’s elements uses it. |
elements_by_dimension(dimension=1)→Iterable[ForwardRef(ElementBase)]
elements_by_dimension(dimension: int = 1) -> Iterable[ForwardRef(ElementBase)]
The part’s elements of one dimension: 1 for beams and bars, 2 for shells and membranes, 3 for solids.
Parameters
| Name | Type | Description |
|---|---|---|
| dimension | int, optional | 1, 2 or 3. Default 1. |
Returns
| Name | Type | Description |
|---|---|---|
| set[ | class:xfea.model.ElementBase] |
The elements of that dimension. |
find_adjacent_elements(element)→ElementsGroup
find_adjacent_elements(element: ElementBase) -> ElementsGroup
The elements that share at least one node with a given element.
Parameters
| Name | Type | Description |
|---|---|---|
| element | ElementBase |
The element to query. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.ElementsGroup |
The adjacent elements, the element itself left out. |
find_boundary_edges()→EdgesGroup
The edges on the outline of a plane mesh: those of exactly one element.
The 2D analogue of find_boundary_faces(), used to put surface
fluxes (convection, radiation) on the outline.
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.EdgesGroup |
The boundary edges. |
find_boundary_faces()→FacesGroup
The same as boundary_faces, as a method like find_boundary_edges().
find_boundary_nodes()→NodesGroup
The nodes on the outer surface of the part: those of its boundary_faces.
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.NodesGroup |
The boundary nodes. |
find_closest_nodes_to_node(node, number_of_nodes=1, report=False, single=False)→NodesGroup | None | Dict[Node, float]
find_closest_nodes_to_node(
node: Node,
number_of_nodes: int = 1,
report: bool | None = False,
single: bool = False,
) -> NodesGroup | None | Dict[Node, float]
The part’s nodes closest to a given node, the node itself left out.
Parameters
| Name | Type | Description |
|---|---|---|
| node | Node |
The node to search around. |
| number_of_nodes | int, optional | How many nodes to find. Default 1. |
| report | bool, optional | Return each node with its distance, as a dict. Default False. |
| single | bool, optional | Return the closest node itself, not a group. Default False. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.NodesGroup | dict[Node, float] | Node | None |
The closest nodes, nearest first; {node: distance} with report; the closest node with single; None if none is found. |
find_closest_nodes_to_point(point, number_of_nodes=1, report=False, single=False)→NodesGroup | None | Dict[Node, float] | Node
find_closest_nodes_to_point(
point: Point | list[float],
number_of_nodes: int = 1,
report: bool | None = False,
single: bool = False,
) -> NodesGroup | None | Dict[Node, float] | Node
The part’s nodes closest to a point.
Parameters
| Name | Type | Description |
|---|---|---|
| point | Point | list[float] |
The point, or its x, y, z coordinates. |
| number_of_nodes | int, optional | How many nodes to find, capped to the part’s nodes. Default 1. |
| report | bool, optional | Return each node with its distance, as a dict. Default False. |
| single | bool, optional | With number_of_nodes=1, return the node itself, not a group. Default False. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.NodesGroup | dict[Node, float] | Node | None |
The closest nodes; {node: distance} with report; the node with single; None if number_of_nodes is 0. |
find_element_by_key(key)→ForwardRef(ElementBase) | ForwardRef(Element1DBase) | ForwardRef(Element2DBase) | ForwardRef(Element3DBase) | None
find_element_by_key(
key: int,
) -> ForwardRef(ElementBase) | ForwardRef(Element1DBase) | ForwardRef(Element2DBase) | ForwardRef(Element3DBase) | None
The part’s element with a given key, or None.
Parameters
| Name | Type | Description |
|---|---|---|
| key | int | The element’s key. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.ElementBase | None |
The element, or None if not found. |
find_element_by_name(name)→ForwardRef(ElementBase) | ForwardRef(Element1DBase) | ForwardRef(Element2DBase) | ForwardRef(Element3DBase) | None
find_element_by_name(
name: str,
) -> ForwardRef(ElementBase) | ForwardRef(Element1DBase) | ForwardRef(Element2DBase) | ForwardRef(Element3DBase) | None
The part’s first element with a given name, or None.
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | The name to look for. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.ElementBase | None |
The element, or None if not found. |
find_element_neighbors_by_layer(start_element, layers=1)→list[ForwardRef(ElementsGroup)]
find_element_neighbors_by_layer(
start_element: ElementBase,
layers: int = 1,
) -> list[ForwardRef(ElementsGroup)]
The elements around a starting element, in rings: those touching it, those touching them, and so on.
Layer 1 is the elements sharing a node with start_element; layer 2 those sharing a node with layer 1, the start element and layer 1 left out; and so on (a breadth-first search).
Parameters
| Name | Type | Description |
|---|---|---|
| start_element | ElementBase |
The element to start the search from. |
| layers | int, optional | The number of layers to search. Default 1. |
Returns
| Name | Type | Description |
|---|---|---|
| list[ | class:xfea.model.ElementsGroup] |
One group per layer; fewer than layers if the mesh ends first. |
find_elements_by_node(node)→ElementsGroup
find_elements_by_node(node: Node) -> ElementsGroup
The elements connected to a node.
Parameters
| Name | Type | Description |
|---|---|---|
| node | Node |
The node to query. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.ElementsGroup |
The elements that have the node; empty if it is not in the part. |
find_faces_in_polygon(polygon, tol=1.1)→FacesGroup
find_faces_in_polygon(polygon: Polygon, tol: float = 1.1) -> FacesGroup
The faces of the part’s shell and solid elements inside a planar polygon.
Parameters
| Name | Type | Description |
|---|---|---|
| polygon | Polygon |
The polygon for the search. |
| tol | float, optional | A scale factor on the polygon about its centre, not a distance. Default 1.1 (10% larger). |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.FacesGroup |
The faces whose nodes are all on the polygon’s plane and inside its outline. |
find_faces_on_plane(plane, tol=1)→FacesGroup
find_faces_on_plane(plane: Plane, tol: float = 1) -> FacesGroup
The faces of the part’s shell and solid elements that lie on a plane.
Parameters
| Name | Type | Description |
|---|---|---|
| plane | Plane |
The plane. |
| tol | float, optional | The largest distance of a face’s nodes from the plane, a length (mm for mm). Default 1. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.FacesGroup |
The faces whose nodes are all on the plane. |
find_group_by_name(name)→ForwardRef(NodesGroup) | ForwardRef(ElementsGroup) | ForwardRef(EdgesGroup) | ForwardRef(FacesGroup) | ForwardRef(MaterialsGroup) | ForwardRef(SectionsGroup) | ForwardRef(InterfacesGroup) | ForwardRef(InteractionsGroup) | None
find_group_by_name(
name: str,
) -> ForwardRef(NodesGroup) | ForwardRef(ElementsGroup) | ForwardRef(EdgesGroup) | ForwardRef(FacesGroup) | ForwardRef(MaterialsGroup) | ForwardRef(SectionsGroup) | ForwardRef(InterfacesGroup) | ForwardRef(InteractionsGroup) | None
The part’s group with a given name, or None.
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | The name of the group. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.NodesGroup | ElementsGroup | FacesGroup | None |
The group with that name, or None if not found. |
find_material_by_name(name)→MaterialBase | None
find_material_by_name(name: str) -> MaterialBase | None
The part’s material with a given name, or None.
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | The name to look for. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.MaterialBase | None |
The material, or None if none has that name. |
find_material_by_uid(uid)→MaterialBase | None
find_material_by_uid(uid: str) -> MaterialBase | None
The part’s material with a given unique identifier, or None.
Parameters
| Name | Type | Description |
|---|---|---|
| uid | str | The material’s unique identifier. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.MaterialBase | None |
The material, or None if not found. |
find_materials_by_name(name)→set[MaterialBase]
find_materials_by_name(name: str) -> set[MaterialBase]
The part’s materials with a given name.
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | The name to look for. |
Returns
| Name | Type | Description |
|---|---|---|
| set[ | class:xfea.model.MaterialBase] |
The materials with that name. |
find_node_by_key(key)→Node | None
find_node_by_key(key: int) -> Node | None
The part’s node with a given key, or None.
Parameters
| Name | Type | Description |
|---|---|---|
| key | int | The node’s key. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.Node | None |
The node, or None if not found. |
find_node_by_name(name)→set[Node]
find_node_by_name(name: str) -> set[Node]
The part’s nodes with a given name.
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | The name to look for. |
Returns
| Name | Type | Description |
|---|---|---|
| set[ | class:xfea.model.Node] |
The nodes with that name; empty if none. |
find_node_by_uid(uid)→Node | None
find_node_by_uid(uid: str) -> Node | None
The part’s node with a given unique identifier, or None.
Parameters
| Name | Type | Description |
|---|---|---|
| uid | str | The node’s unique identifier. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.Node | None |
The node, or None if not found. |
find_nodes_around_point(point, distance=1.0)→NodesGroup | None | Dict[Node, float]
find_nodes_around_point(
point: Point,
distance: float = 1.0,
) -> NodesGroup | None | Dict[Node, float]
The part’s nodes within a distance of a point.
Parameters
| Name | Type | Description |
|---|---|---|
| point | Point |
The point to search around. |
| distance | float, optional | The search radius, a length (mm for mm). Default 1.0. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.NodesGroup | Node | None |
The nodes found: a group of several, the node itself if only one, None if none (or distance is 0). |
find_nodes_by_box(box)→NodesGroup
find_nodes_by_box(box: Box) -> NodesGroup
The part’s nodes inside a box, its faces included; the box may be turned any way.
Parameters
| Name | Type | Description |
|---|---|---|
| box | Box |
The box to search in. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.NodesGroup |
The nodes inside the box. |
find_nodes_in_polygon(polygon, tol=1.1)→NodesGroup | None
find_nodes_in_polygon(polygon: Polygon, tol: float = 1.1) -> NodesGroup | None
The part’s nodes inside a planar polygon: on its plane and within its outline.
Parameters
| Name | Type | Description |
|---|---|---|
| polygon | Polygon |
The polygon for the search. |
| tol | float, optional | A scale factor on the polygon about its centre, not a distance. Default 1.1 (10% larger). |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.NodesGroup |
The nodes inside the polygon. |
find_nodes_on_plane(plane, tol=1.0)→NodesGroup
find_nodes_on_plane(plane: Plane, tol: float = 1.0) -> NodesGroup
The part’s nodes on a plane, within a distance of it.
Parameters
| Name | Type | Description |
|---|---|---|
| plane | Plane |
The plane. |
| tol | float, optional | The largest distance from the plane, a length (mm for mm). Default 1.0. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.NodesGroup |
The nodes on the plane. |
find_section_by_name(name)→SectionBase | None
find_section_by_name(name: str) -> SectionBase | None
The part’s section with a given name, or None.
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | The name to look for. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.SectionBase | None |
The section, or None if none has that name. |
find_section_by_uid(uid)→SectionBase | None
find_section_by_uid(uid: str) -> SectionBase | None
The part’s section with a given unique identifier, or None.
Parameters
| Name | Type | Description |
|---|---|---|
| uid | str | The section’s unique identifier. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.SectionBase | None |
The section, or None if not found. |
find_sections_by_name(name)→set[SectionBase]
find_sections_by_name(name: str) -> set[SectionBase]
The part’s sections with a given name.
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | The name to look for. |
Returns
| Name | Type | Description |
|---|---|---|
| set[ | class:xfea.model.SectionBase] |
The sections with that name. |
find_shortest_path_between_nodes(start_node, end_node)→NodesGroup
find_shortest_path_between_nodes(start_node: Node, end_node: Node) -> NodesGroup
The shortest path of nodes through the mesh between two nodes, from element to element.
Parameters
| Name | Type | Description |
|---|---|---|
| start_node | Node |
The starting node of the path. |
| end_node | Node |
The ending node of the path. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.NodesGroup |
The nodes along the path, or an empty group if there is none. |
get_boundary_mesh_data()
The outer surface of the part’s mesh as (vertices, faces) lists, or None, without building a mesh.
get_connected_components()→list[ForwardRef(NodesGroup)]
The part’s mesh split into its connected pieces (“islands”), as groups of nodes.
Returns
| Name | Type | Description |
|---|---|---|
| list[ | class:xfea.model.NodesGroup] |
One group per island: a single group when the mesh is fully connected. |
is_element_on_boundary(element)→bool
is_element_on_boundary(element: ElementBase) -> bool
Whether an element is on the outer surface of the part; the answer is stored on the element.
Parameters
| Name | Type | Description |
|---|---|---|
| element | ElementBase |
The element to check. |
Returns
| Name | Type | Description |
|---|---|---|
| bool | True if the element is on the boundary, False otherwise. |
mesh(settings, section, algorithm=None, **kwargs)
Mesh the part’s base geometry with a meshing plugin: its nodes and elements are replaced.
Parameters
| Name | Type | Description |
|---|---|---|
| settings | MeshingSettings | dict |
Element sizes and order, passed to the meshing plugin. |
| section | SectionBase |
The section given to every element made. |
| algorithm | str | Mesher | type[Mesher], optional | The meshing plugin, by name or class; None takes the one installed (Gmsh). |
| **kwargs | Options for the meshing plugin; they override settings. Among them groups, {name: Select}: a node group of the part for each selection of the geometry (the nodes on a face, along an edge), to put supports and loads on. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.Part |
The part, meshed. |
remove_element(element)
remove_element(element: ElementBase)
Remove an element from the part; its nodes stay.
Parameters
| Name | Type | Description |
|---|---|---|
| element | ElementBase |
The element to remove. |
Removing elements can leave the part inconsistent.
remove_elements(elements)
remove_elements(elements: list[ElementBase])
Remove several elements from the part; their nodes stay.
Parameters
| Name | Type | Description |
|---|---|---|
| elements | list[ElementBase] |
The elements to remove. |
Removing elements can leave the part inconsistent.
remove_node(node)
remove_node(node: Node)
Remove a node from the part; a node not in it is left alone.
Parameters
| Name | Type | Description |
|---|---|---|
| node | Node |
The node to remove. |
The elements on the node are not removed: removing nodes can leave the part inconsistent.
remove_nodes(nodes)
remove_nodes(nodes: list[Node])
Remove several nodes from the part.
Parameters
| Name | Type | Description |
|---|---|---|
| nodes | list[Node] |
The nodes to remove. |
The elements on the nodes are not removed: removing nodes can leave the part inconsistent.
to_meshio(filepath, point_data=None, **kwargs)
to_meshio(filepath: str, point_data=None, **kwargs)
Export the full volume mesh (nodes + elements) via meshio.
The format is auto-detected from the file extension:
.vtu (VTK), .msh (Gmsh), .med (Salome), .inp
(Abaqus), .xdmf, etc.
Parameters
| Name | Type | Description |
|---|---|---|
| filepath | str | Destination file path. The extension determines the format. |
| point_data | dict, optional | Node-based field data to include in the export. Keys are field names (str), values are 1-D numpy arrays of length len(self.nodes) ordered consistently with the sorted nodes array (i.e. sorted by part_key). Example:: point_data={“Temperature”: temp_array} |
| **kwargs | Forwarded to meshio.Mesh.write(). |
to_obj(filepath)
to_obj(filepath: str)
Export the boundary surface mesh to OBJ.
Parameters
| Name | Type | Description |
|---|---|---|
| filepath | str | Destination .obj file path. |
to_step(filepath, solid=True)
to_step(filepath: str, solid: bool = True)
Write the part’s outer surface to a STEP file, as a faceted solid any CAD tool opens.
Each boundary face becomes plane facets through its corner nodes (a
quad two triangles; midside nodes are left out), sewn into a closed
shell and, with solid, a solid, with Open CASCADE through the Gmsh
worker (xfea.meshing.gmsh_worker).
Parameters
| Name | Type | Description |
|---|---|---|
| filepath | str | The .step (or .stp) file; its folders are created. |
| solid | bool, optional | Make a solid of the sewn shell (default True), or keep the surface only. |
to_stl(filepath, binary=True)
to_stl(filepath: str, binary: bool = True)
Export the boundary surface mesh to STL.
Parameters
| Name | Type | Description |
|---|---|---|
| filepath | str | Destination .stl file path. |
| binary | bool, optional | Write a binary STL (smaller, faster), the default. False writes an ASCII STL that can be read in a text editor. |
transform(transformation)
transform(transformation: Transformation)
Move, turn or scale the part in place by transforming its nodes.
Parameters
| Name | Type | Description |
|---|---|---|
| transformation | Transformation |
The transformation to apply. |
transformed(transformation)→PartBase
transformed(transformation: Transformation) -> PartBase
A transformed copy of the part; the part itself is left as it is.
Parameters
| Name | Type | Description |
|---|---|---|
| transformation | Transformation |
The transformation to apply. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.PartBase |
The transformed copy. |
Part(**kwargs)
A deformable part: a piece of the structure with its own nodes and elements.
Build it node by node (add_node(), add_element()) or mesh a
geometry (mesh()), and add it to a model with model.add_part.
Parameters
| Name | Type | Description |
|---|---|---|
| name | str, optional | Unique identifier, generated if not given. |
Guidance (model)
- Select nodes by place:
part.nodes.subgroup(lambda n: n.x < 1e-3), orpart.find_nodes_on_plane(plane).
Properties
base_featuresdict[str, GeometryFeature]read-only
The named features of the base geometry, by name (empty without a base geometry).
base_geometryBaseGeometry | None
The geometry the part is meshed from, or None.
Set it to a STEP file path, another file path, a mesh, a line, a polyline or a list of lines or polylines: it is wrapped in the matching geometry class.
bb_centerPointread-only
The centre of the part’s bounding box.
bottom_planePlaneread-only
The bottom plane of the part’s bounding box.
boundary_facesFacesGroupread-only
The element faces on the outer surface of the part (cached).
A face is on the boundary when its nodes are those of no other element face: an internal face is shared by two neighbouring elements. The result is cached until nodes or elements change.
boundary_meshMeshread-only
The outer surface of the part’s mesh, as a Mesh, or None if it has no boundary faces.
bounding_boxBoxread-only
The bounding box of the part.
For parts with only 1D elements, the bounding box is expanded by the maximum section dimension to account for section depth/width.
centerPointread-only
The geometric (unweighted) center of the part’s nodes.
centroidPointread-only
Mass-weighted centroid of the part.
Falls back to the unweighted geometric centre (self.center)
when the part has no mass — e.g. a section/material with zero
density, or a rigid part where mass is intentionally not
defined. Without the fallback centroid_points_weighted
divides by zero and raises.
edgesEdgesGroupread-only
The edges of the part’s elements.
element_typesdict[type, list[ElementBase]]read-only
The elements of the part by element class.
elementsElementsGroup | Noneread-only
The elements of the part.
elements_centroidslist[list[float]]read-only
The centroids of the part’s elements (x, y, z in active length unit).
elements_connectivitylist[list[int]]read-only
The connectivity of the part’s elements.
elements_connectivity_groupeddict[int, list[list[float]]]read-only
The connectivity of the part’s elements grouped by element type.
elements_countintread-only
The number of elements in the part.
elements_facesdict[ElementBase, FacesGroup]read-only
The faces of the part’s elements grouped by element.
elements_faces_groupeddict[int, list[list[ForwardRef(Face)]]]read-only
The faces of the part’s elements grouped by element key.
elements_faces_indiceslist[list[list[float]]]read-only
The indices of the faces of the part’s elements.
elements_faces_indices_groupeddict[int, list[list[float]]]read-only
The indices of the faces of the part’s elements grouped by element key.
elements_groupeddict[type, list[ElementBase]]read-only
The elements of the part grouped by their element class’s base class.
elements_sortedlist[ElementBase]read-only
The elements of the part sorted by their part key.
facesFacesGroupread-only
The faces of the part’s elements.
gkey_nodedict[str, Node]read-only
Each node of the part by its geometric key.
graphread-only
The part’s connectivity graph (a networkx.DiGraph, an edge from each element to each of its nodes).
groupsset[ForwardRef(NodesGroup) | ForwardRef(ElementsGroup) | ForwardRef(EdgesGroup) | ForwardRef(FacesGroup) | ForwardRef(MaterialsGroup) | ForwardRef(SectionsGroup) | ForwardRef(InterfacesGroup) | ForwardRef(InteractionsGroup)]read-only
The groups of the part (nodes, elements, faces…), its all-nodes and all-elements groups among them.
keyAny | Noneread-only
The object’s key (its number) in what it is registered to; None until it is given one.
materialsMaterialsGroupread-only
The materials of the part’s sections.
For a part in a model, the model’s materials is faster.
materials_grouped_by_namedict[str, list[MaterialBase]]read-only
The materials of the part grouped by their name.
materials_sortedlist[MaterialBase]read-only
The materials of the part sorted by their name.
modelread-only
The model the part is registered to, or None.
namestr
The object’s name.
nodesNodesGroup | Noneread-only
The nodes of the part.
nodes_countintread-only
The number of nodes in the part.
nodes_sortedlist[Node]read-only
The nodes of the part sorted by their part key.
pointslist[Point]read-only
The points of the part’s nodes.
points_sortedlist[Point]read-only
The points of the part’s nodes sorted by their part key.
reference_nodeNode | None
The part’s reference node, or None: on a rigid part, the node that drives its motion.
Setting it adds the node to the part.
registrationAny | None
The object this one is registered to (a part, a model, a step, …), or None.
releases_fieldsReleaseFieldsGroup | Noneread-only
The part’s beam end releases, one field per call of add_beams_releases_fields.
sectionsSectionsGroupread-only
The sections of the part’s elements.
For a part in a model, the model’s sections is faster.
sections_grouped_by_elementdict[type, list[SectionBase]]read-only
The sections of the part grouped by their type.
sections_sortedlist[SectionBase]read-only
The sections of the part sorted by their key.
top_planePlaneread-only
The top plane of the part’s bounding box.
uidUUID | Noneread-only
The object’s unique id, a UUID.
volumefloatread-only
The total volume of the part’s elements, length cubed (mm3 for mm).
weightfloatread-only
The total weight of the part’s elements, a force in the active unit system.
Methods
add_beams_releases_fields(elements, end, release)→BeamEndReleaseBase
add_beams_releases_fields(
elements: ElementsGroup,
end: str,
release: BeamEndReleaseBase,
) -> BeamEndReleaseBase
Release one end of each of the given beam elements: a pin, a slider or a semi-rigid joint.
Parameters
| Name | Type | Description |
|---|---|---|
| elements | ElementsGroup | list[BeamElement] |
The beam elements to release. |
| end | str | "start", "end" or "both": the end released, at the element’s first or last node, or both. |
| release | BeamEndReleaseBase |
The release to apply, such as BeamEndPinRelease(m1=True). |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.BeamEndReleaseBase |
The release. |
Guidance (releases)
- m1 is the rotation about the element’s local y axis (its
orientation), m2 about local z, t is torsion. Withorientation=[0, 1, 0]on a beam along x, vertical loads bend it about y: release m1. - A semi-rigid release is a spring between the beam end and its node, so that node must be held against the rotation (a support, or the column it joins): on a pinned support it does nothing.
- Its stiffness is moment per radian in the session’s units (N mm/rad for N and mm);
0is a pin,Nonekeeps that rotation rigid. - At a joint, release the ends of all its members but one: if every end there is released, nothing holds the node’s rotation (a mechanism) unless a support does.
RigidPart
Section titled “RigidPart”RigidPart(reference_node: Node | None = None, **kwargs)
A rigid part: it moves as one body, driven by its reference node.
Its elements must be rigid. Connections to it go to its reference node.
Parameters
| Name | Type | Description |
|---|---|---|
| reference_node | Node, optional |
The node that drives the part’s motion. Default None. |
| name | str, optional | Unique identifier, generated if not given. |
Properties
base_featuresdict[str, GeometryFeature]read-only
The named features of the base geometry, by name (empty without a base geometry).
base_geometryBaseGeometry | None
The geometry the part is meshed from, or None.
Set it to a STEP file path, another file path, a mesh, a line, a polyline or a list of lines or polylines: it is wrapped in the matching geometry class.
bb_centerPointread-only
The centre of the part’s bounding box.
bottom_planePlaneread-only
The bottom plane of the part’s bounding box.
boundary_facesFacesGroupread-only
The element faces on the outer surface of the part (cached).
A face is on the boundary when its nodes are those of no other element face: an internal face is shared by two neighbouring elements. The result is cached until nodes or elements change.
boundary_meshMeshread-only
The outer surface of the part’s mesh, as a Mesh, or None if it has no boundary faces.
bounding_boxBoxread-only
The bounding box of the part.
For parts with only 1D elements, the bounding box is expanded by the maximum section dimension to account for section depth/width.
centerPointread-only
The geometric (unweighted) center of the part’s nodes.
centroidPointread-only
Mass-weighted centroid of the part.
Falls back to the unweighted geometric centre (self.center)
when the part has no mass — e.g. a section/material with zero
density, or a rigid part where mass is intentionally not
defined. Without the fallback centroid_points_weighted
divides by zero and raises.
edgesEdgesGroupread-only
The edges of the part’s elements.
element_typesdict[type, list[ElementBase]]read-only
The elements of the part by element class.
elementsElementsGroup | Noneread-only
The elements of the part.
elements_centroidslist[list[float]]read-only
The centroids of the part’s elements (x, y, z in active length unit).
elements_connectivitylist[list[int]]read-only
The connectivity of the part’s elements.
elements_connectivity_groupeddict[int, list[list[float]]]read-only
The connectivity of the part’s elements grouped by element type.
elements_countintread-only
The number of elements in the part.
elements_facesdict[ElementBase, FacesGroup]read-only
The faces of the part’s elements grouped by element.
elements_faces_groupeddict[int, list[list[ForwardRef(Face)]]]read-only
The faces of the part’s elements grouped by element key.
elements_faces_indiceslist[list[list[float]]]read-only
The indices of the faces of the part’s elements.
elements_faces_indices_groupeddict[int, list[list[float]]]read-only
The indices of the faces of the part’s elements grouped by element key.
elements_groupeddict[type, list[ElementBase]]read-only
The elements of the part grouped by their element class’s base class.
elements_sortedlist[ElementBase]read-only
The elements of the part sorted by their part key.
facesFacesGroupread-only
The faces of the part’s elements.
gkey_nodedict[str, Node]read-only
Each node of the part by its geometric key.
graphread-only
The part’s connectivity graph (a networkx.DiGraph, an edge from each element to each of its nodes).
groupsset[ForwardRef(NodesGroup) | ForwardRef(ElementsGroup) | ForwardRef(EdgesGroup) | ForwardRef(FacesGroup) | ForwardRef(MaterialsGroup) | ForwardRef(SectionsGroup) | ForwardRef(InterfacesGroup) | ForwardRef(InteractionsGroup)]read-only
The groups of the part (nodes, elements, faces…), its all-nodes and all-elements groups among them.
keyAny | Noneread-only
The object’s key (its number) in what it is registered to; None until it is given one.
materialsMaterialsGroupread-only
The materials of the part’s sections.
For a part in a model, the model’s materials is faster.
materials_grouped_by_namedict[str, list[MaterialBase]]read-only
The materials of the part grouped by their name.
materials_sortedlist[MaterialBase]read-only
The materials of the part sorted by their name.
modelread-only
The model the part is registered to, or None.
namestr
The object’s name.
nodesNodesGroup | Noneread-only
The nodes of the part.
nodes_countintread-only
The number of nodes in the part.
nodes_sortedlist[Node]read-only
The nodes of the part sorted by their part key.
pointslist[Point]read-only
The points of the part’s nodes.
points_sortedlist[Point]read-only
The points of the part’s nodes sorted by their part key.
reference_nodeNode | None
The part’s reference node, or None: on a rigid part, the node that drives its motion.
Setting it adds the node to the part.
registrationAny | None
The object this one is registered to (a part, a model, a step, …), or None.
releases_fieldsReleaseFieldsGroup | Noneread-only
The part’s beam end releases, one field per call of add_beams_releases_fields.
sectionsSectionsGroupread-only
The sections of the part’s elements.
For a part in a model, the model’s sections is faster.
sections_grouped_by_elementdict[type, list[SectionBase]]read-only
The sections of the part grouped by their type.
sections_sortedlist[SectionBase]read-only
The sections of the part sorted by their key.
top_planePlaneread-only
The top plane of the part’s bounding box.
uidUUID | Noneread-only
The object’s unique id, a UUID.
volumefloatread-only
The total volume of the part’s elements, length cubed (mm3 for mm).
weightfloatread-only
The total weight of the part’s elements, a force in the active unit system.
Methods
add_element(element)→ElementBase
add_element(element: ElementBase) -> ElementBase
Add a rigid element to the part, with its nodes, and return it.
Parameters
| Name | Type | Description |
|---|---|---|
| element | ElementBase |
The element; it must be rigid (rigid=True) and have a section. |
Returns
| Name | Type | Description |
|---|---|---|
class:xfea.model.ElementBase |
The element, now registered to the part. |
© 2026 Francesco Ranaudo · Text and pictures CC BY 4.0 · Code Elastic License 2.0 · how to reuse them