NodeMask
NodeMask
Bases: _BaseMask
A mask of node IDs with chainable spatial and predicate-based filters.
All methods return a new NodeMask instance, ensuring immutability at the API level.
Example
import numpy as np
from femora.components.mask.mask_base import MeshIndex, NodeMask
mesh_index = MeshIndex(
node_ids=np.array([0, 1, 2, 3]),
node_coords=np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [2.0, 2.0, 2.0]]),
node_ndf=np.array([3, 3, 3, 3]),
node_core_map=[[0], [0], [0], [0]],
element_ids=np.array([0]),
element_connectivity=[np.array([0, 1, 2])],
element_centroids=np.array([[0.33, 0.33, 0.0]]),
element_types=np.array(["TRIANGLE"]),
material_tags=np.array([1]),
section_tags=np.array([1]),
region_tags=np.array([0]),
core_ids=np.array([0]),
element_id_to_index={0: 0}
)
all_nodes = NodeMask(mesh_index, mesh_index.node_ids)
filtered_nodes = all_nodes.by_bbox(0.5, 1.5, -0.5, 0.5, -0.5, 0.5)
print(filtered_nodes.to_list())
# Output: [1]
Methods:
by_ids
Intersects the current node mask with specific node IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
Sequence[int]
|
A sequence of node IDs to retain. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NodeMask |
'NodeMask'
|
A new mask containing the intersection of the current
mask's IDs and the provided |
by_bbox
Filters nodes inside an axis-aligned bounding box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xmin
|
float
|
The minimum x-coordinate of the bounding box. |
required |
xmax
|
float
|
The maximum x-coordinate of the bounding box. |
required |
ymin
|
float
|
The minimum y-coordinate of the bounding box. |
required |
ymax
|
float
|
The maximum y-coordinate of the bounding box. |
required |
zmin
|
float
|
The minimum z-coordinate of the bounding box. |
required |
zmax
|
float
|
The maximum z-coordinate of the bounding box. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NodeMask |
'NodeMask'
|
A new mask containing only nodes whose coordinates are within the specified bounding box. |
near_point
Filters nodes within a specified distance from a given point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Tuple[float, float, float]
|
The reference point (x, y, z) from which to measure the distance. |
required |
radius
|
float
|
The radial distance threshold. Nodes within this radius will be included. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NodeMask |
'NodeMask'
|
A new mask containing only nodes that are within the
specified radial distance from the |
along_line
along_line(point1: Tuple[float, float, float], point2: Tuple[float, float, float], radius: float) -> 'NodeMask'
Filters nodes within a specified distance from a line segment.
The line segment is defined by two endpoints. Nodes within a cylindrical region around this segment will be included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point1
|
Tuple[float, float, float]
|
The first endpoint of the line segment (x, y, z). |
required |
point2
|
Tuple[float, float, float]
|
The second endpoint of the line segment (x, y, z). |
required |
radius
|
float
|
The radial distance threshold from the line segment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NodeMask |
'NodeMask'
|
A new mask containing nodes that are within the cylindrical region around the line segment. |
to_tags
Converts selected node IDs to OpenSees node tags.
This method applies an offset to the internal zero-based node IDs to generate application-specific node tags, typically for OpenSees.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_tag
|
int | None
|
Optional. The starting node tag. If |
None
|
Returns:
| Type | Description |
|---|---|
List[int]
|
List[int]: A list of OpenSees-compatible node tags for the selected nodes. |