Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion anastruct/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from anastruct.fem.system import SystemElements
from anastruct.fem.util.load import LoadCase, LoadCombination
from anastruct.preprocess import truss
from anastruct.preprocess import beam, truss
from anastruct.vertex import Vertex
File renamed without changes.
2 changes: 1 addition & 1 deletion anastruct/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.6.2"
__version__ = "1.7.0"
2 changes: 1 addition & 1 deletion anastruct/fem/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from anastruct.basic import FEMException

if TYPE_CHECKING:
from anastruct._types import ElementType
from anastruct.fem.node import Node
from anastruct.fem.system import Spring
from anastruct.types import ElementType
from anastruct.vertex import Vertex

try:
Expand Down
31 changes: 23 additions & 8 deletions anastruct/fem/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
if TYPE_CHECKING:
from matplotlib.figure import Figure

from anastruct.fem.node import Node
from anastruct.types import (
from anastruct._types import (
AxisNumber,
Dimension,
LoadDirection,
Expand All @@ -40,6 +39,7 @@
SupportDirection,
VertexLike,
)
from anastruct.fem.node import Node


class SystemElements:
Expand Down Expand Up @@ -646,7 +646,7 @@ def insert_node(
element_id: int,
location: Optional["VertexLike"] = None,
factor: Optional[float] = None,
) -> None:
) -> dict[str, int]:
"""Insert a node into an existing structure.
This can be done by adding a new Vertex at any given location, or by setting
a factor of the elements length. E.g. if you want a node at 40% of the elements
Expand All @@ -658,6 +658,13 @@ def insert_node(
Defaults to None.
factor (Optional[float], optional): Fraction of distance from start to end of elmeent on which to
divide the element. Must be between 0 and 1. Defaults to None.

Returns:
dict[str, int]: Dictionary with keys:
'new_node_id': ID of the newly created node
'new_element_id1': ID of the first new element created
'new_element_id2': ID of the second new element created
'old_element_id': ID of the old element that was split
"""
element_id_to_split = _negative_index_to_id(element_id, self.element_map)
element_to_split = self.element_map[element_id_to_split]
Expand Down Expand Up @@ -753,6 +760,13 @@ def insert_node(
# Remove the old element from everywhere it's referenced
self.remove_element(element_id_to_split)

return {
"new_node_id": self.id_last_node,
"new_element_id1": element_id1,
"new_element_id2": element_id2,
"old_element_id": element_id_to_split,
}

def insert_node_old(
self,
element_id: int,
Expand Down Expand Up @@ -2114,12 +2128,14 @@ def get_node_result_range(self, unit: Literal["ux", "uy", "phi_z"]) -> List[floa
return [node.phi_z for node in self.node_map.values()]
raise NotImplementedError

def find_node_id(self, vertex: Union[Vertex, Sequence[float]]) -> Optional[int]:
def find_node_id(
self, vertex: Union[Vertex, Sequence[float]], tolerance: float = 1e-9
) -> Optional[int]:
"""Find the ID of a certain location.

Args:
vertex (Union[Vertex, Sequence[float]]): Vertex_xz, [x, y], (x, y)

tolerance (float): Tolerance for matching existing node locations (length units). Defaults to 1e-9.
Raises:
TypeError: vertex must be a list, tuple or Vertex

Expand All @@ -2128,11 +2144,10 @@ def find_node_id(self, vertex: Union[Vertex, Sequence[float]]) -> Optional[int]:
"""
vertex_v = Vertex(vertex)
try:
tol = 1e-9
return next(
filter(
lambda x: math.isclose(x.vertex.x, vertex_v.x, abs_tol=tol)
and math.isclose(x.vertex.y, vertex_v.y, abs_tol=tol),
lambda x: math.isclose(x.vertex.x, vertex_v.x, abs_tol=tolerance)
and math.isclose(x.vertex.y, vertex_v.y, abs_tol=tolerance),
self.node_map.values(),
)
).id
Expand Down
2 changes: 1 addition & 1 deletion anastruct/fem/system_components/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from anastruct.fem.elements import det_axial, det_moment, det_shear

if TYPE_CHECKING:
from anastruct._types import AxisNumber
from anastruct.fem.elements import Element
from anastruct.fem.system import SystemElements
from anastruct.types import AxisNumber


def set_force_vector(
Expand Down
2 changes: 1 addition & 1 deletion anastruct/fem/system_components/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from anastruct.vertex import Vertex

if TYPE_CHECKING:
from anastruct._types import VertexLike
from anastruct.fem.system import MpType, Spring, SystemElements
from anastruct.types import VertexLike


def check_internal_hinges(system: "SystemElements", node_id: int) -> None:
Expand Down
Loading