Skip to content

hertzforge.core.mates

mates

Mated surfaces: where element groups' meshes lie on each other, and how they are joined there (Mate Surfaces).

A mated set is a definition the geometry holds, not elements: two element groups, the nodes on each side of the patch where they meet, and how the sides are joined, rigidly or by springs with a stiffness normal and shear to the surface. The links are made when a model is built from the geometry (fem.Model.from_geometry), each node of the first side joined to the nearest node of the second, so a set can be edited or deleted at any time and leaves nothing behind.

detect finds the patches: the nodes of one group's outer faces that lie on another's outer faces, within a tolerance, split into the pieces their faces connect. The side with more nodes on the patch, the finer mesh, is the first side and follows the second.

Classes:

Name Description
MatedSet

Two element groups joined where their surfaces mate.

Functions:

Name Description
near_surface

Which of nodes lie within distance of the faces: the band a

offered

The nodes each side of a mate between groups may hold: each

detect

The patches where the given element groups' surfaces mate.

links

The ties a set makes, as (the second side's nodes the point moves

shared

The nodes on both groups' outer faces: where the two meshes are

next_id

The id a new set takes: one past the highest.

default_name

'post on base', or 'post on base 2' where that name is taken.

add

Add a mated set to the geometry, in place, and return it.

find

The set mate_id, refused with ValueError when there is none.

change

Change a set's fields (name, nodes_a, nodes_b,

delete

Remove sets by id, in place; returns how many went.

naming_groups

The sets that join any of these element groups, by id.

Classes

MatedSet dataclass

MatedSet(id: int, name: str, groups: tuple[int, int], nodes_a: tuple[int, ...], nodes_b: tuple[int, ...], normal_mode: str = 'rigid', shear_mode: str = 'rigid', normal_stiffness: float = 0.0, shear_stiffness: float = 0.0)

Two element groups joined where their surfaces mate.

Each node of the first side is tied to the nearest node of the second, in a frame of its own: along the normal of the second side's surface where the node lies on it, and across it, in the surface's plane (shear). Each of the two is held rigidly, by a spring, or not at all.

Attributes:

Name Type Description
id int

The set's number, unique in its geometry.

name str

What the tree calls it.

groups (int, int)

The element groups, by id: the first side's and the second's.

nodes_a tuple of int

The first side's nodes, which follow the second.

nodes_b tuple of int

The second side's nodes, which the first side's are tied to.

normal_mode, shear_mode {'rigid', 'stiffness', 'free'}

How the normal and the shear are held.

normal_stiffness, shear_stiffness float

Each tie's stiffness along the normal and in the plane, in N/m, where its mode is 'stiffness'.

Methods:

Name Description
describe

How the set holds, in a few words: 'rigid', 'stiffness', or

as_record

The set as plain values, for a file.

from_record

A set from as_record's values. A record written before the

followed

The set after the geometry's ids changed: nodes and

Methods:
describe
describe() -> str

How the set holds, in a few words: 'rigid', 'stiffness', or 'normal rigid, shear free' where the two differ.

as_record
as_record() -> dict

The set as plain values, for a file.

from_record classmethod
from_record(record: Mapping[str, Any]) -> MatedSet

A set from as_record's values. A record written before the normal and the shear were set apart says 'how': rigid holds both rigidly, spring both by their stiffness.

followed
followed(nodes: Mapping[int, int | None] | None = None, groups: Mapping[int, int | None] | None = None) -> MatedSet | None

The set after the geometry's ids changed: nodes and groups map an old id to its new one, or to None where it is gone. A node gone leaves its side; a side left empty, or a group gone, ends the set (None).

Functions:

near_surface

near_surface(geometry: Any, nodes: Any, faces: list, distance: float) -> ndarray

Which of nodes lie within distance of the faces: the band a node may be picked in, around a mated surface.

offered

offered(geometry: Any, groups: tuple[int, int], reach: float | None = None) -> tuple[tuple[int, ...], tuple[int, ...]]

The nodes each side of a mate between groups may hold: each group's outer-face nodes within reach of the other group's outer faces. reach is the groups' finest node spacing when omitted, so the band takes the patch and the nodes about one element around it.

detect

detect(geometry: Any, groups: Any = None, tolerance: float | None = None) -> list[dict]

The patches where the given element groups' surfaces mate.

For each pair of the groups, the nodes on one's outer faces that lie on the other's outer faces, within tolerance, facing them, and are not the other's own nodes already; split into the pieces their faces connect, so the four legs standing on a table top are four patches. The side with more nodes on the other is the first side, the finer mesh, and its nodes follow; the second side's nodes are the corners that carry the points the first side's nodes lie on (_support).

Parameters:

Name Type Description Default
geometry Geometry

Whose elements.

required
groups sequence of int

The element groups, by id; every group of plates or solids when omitted.

None
tolerance float

How far a node may be from the other's faces, as the geometry holds its coordinates; a millionth of the geometry's size when omitted.

None

Returns:

Type Description
list of dict

Each patch's 'groups' (first side's, second side's), 'nodes_a' and 'nodes_b' (tuples of node ids).

links(geometry: Any, mated: MatedSet) -> list[tuple]

The ties a set makes, as (the second side's nodes the point moves with, their weights, the first side's node, the normal, the point).

Each first-side node is tied to the point it lies on, of the second side's faces: the point moves as the face's corners around it do, weighted by where it sits in its triangle (_support), the corners taken off the second side carrying none, so a rigid motion of the two is carried exactly however their meshes differ (a tie to the nearest node instead held the whole model against turning, 2026-10-20). The normal is the second side's surface's there, the face facing the node as detect picks it, smoothed over that surface's faces around it, so a curved surface ties each node along its own normal. A node with no such face within reach is tied to the nearest second-side node, and its point is where it is. A node of the second group's own (shared) is one with it already and makes none.

Raises ValueError, naming the set, when it names a node the geometry no longer has.

shared

shared(geometry: Any, groups: tuple[int, int]) -> set[int]

The nodes on both groups' outer faces: where the two meshes are one node already (a seam the mesher joined, or nodes merged), held tighter than any tie, and never tied.

next_id

next_id(geometry: Any) -> int

The id a new set takes: one past the highest.

default_name

default_name(geometry: Any, groups: tuple[int, int]) -> str

'post on base', or 'post on base 2' where that name is taken.

add

add(geometry: Any, groups: tuple[int, int], nodes_a: Any, nodes_b: Any, normal_mode: str = 'rigid', shear_mode: str = 'rigid', normal_stiffness: float = 0.0, shear_stiffness: float = 0.0, name: str | None = None) -> MatedSet

Add a mated set to the geometry, in place, and return it.

Refused with ValueError when a side is empty, when a node or a group is not in the geometry, when both the normal and the shear are free, or when a stiffness asked for is not above zero.

find

find(geometry: Any, mate_id: int) -> MatedSet

The set mate_id, refused with ValueError when there is none.

change

change(geometry: Any, mate_id: int, **fields: Any) -> MatedSet

Change a set's fields (name, nodes_a, nodes_b, normal_mode, shear_mode, normal_stiffness, shear_stiffness), in place; refused as add refuses.

delete

delete(geometry: Any, mate_ids: Any) -> int

Remove sets by id, in place; returns how many went.

naming_groups

naming_groups(geometry: Any, groups: Any) -> list[int]

The sets that join any of these element groups, by id.