Skip to content

Datastructures¤

The force density datastructures: COMPAS-based networks and meshes that carry force densities, supports, and loads, ready for an equilibrium calculation.

datastructures ¤

FDDatastructure ¤

A force density datastructure.

This is a mixin of force-density-specific methods layered onto a concrete COMPAS datastructure. FDNetwork and FDMesh reach Datastructure through Network and Mesh respectively, so this class does not inherit from it to avoid a redundant inheritance diamond. The typing-only base declares the COMPAS accessors this mixin calls.

edge_load ¤

edge_load(key: tuple[int, int], load: Iterable[float] | None = None) -> list[float] | None

Get or set the load vector on a single edge.

Parameters:

  • key (tuple[int, int]) –

    The edge to access.

  • load (Iterable[float] | None, default: None ) –

    The load vector to set. If None, the current load is returned.

Returns:

  • load ( list[float] | None ) –

    The edge's load vector.

edge_forcedensity ¤

edge_forcedensity(key: tuple[int, int]) -> float
edge_forcedensity(key: tuple[int, int], q: float) -> None
edge_forcedensity(key: tuple[int, int], q: float | None = None) -> float | None

Get or set the force density on a single edge.

Parameters:

  • key (tuple[int, int]) –

    The edge to access.

  • q (float | None, default: None ) –

    The force density to set. If None, the current value is returned.

Returns:

  • q ( float | None ) –

    The edge's force density.

edge_force ¤

edge_force(key: tuple[int, int]) -> float

Get the internal force in a single edge.

Parameters:

Returns:

  • force ( float ) –

    The edge's internal force.

edge_loadpath ¤

edge_loadpath(key: tuple[int, int]) -> float

Get the load path of a single edge.

Parameters:

Returns:

  • loadpath ( float ) –

    The absolute product of the edge's force and length.

edges_forcedensities ¤

edges_forcedensities(q: float | None = None, keys: Iterable[tuple[int, int]] | None = None) -> list[float] | None

Get or set the force densities on many edges.

Parameters:

  • q (float | None, default: None ) –

    The force density to set on every edge. If None, the current values are returned.

  • keys (Iterable[tuple[int, int]] | None, default: None ) –

    The edges to access. If None, all edges are used.

Returns:

  • q ( list[float] | None ) –

    The force density of each edge.

edges_forces ¤

edges_forces(keys: Iterable[tuple[int, int]] | None = None) -> list[float]

Get the internal forces of many edges.

Parameters:

  • keys (Iterable[tuple[int, int]] | None, default: None ) –

    The edges to access. If None, all edges are used.

Returns:

  • forces ( list[float] ) –

    The internal force of each edge.

edges_lengths ¤

edges_lengths(keys: Iterable[tuple[int, int]] | None = None) -> list[float]

Get the lengths of many edges.

Parameters:

  • keys (Iterable[tuple[int, int]] | None, default: None ) –

    The edges to access. If None, all edges are used.

Returns:

  • lengths ( list[float] ) –

    The length of each edge.

edges_loads ¤

edges_loads(load: Sequence[float] | None = None, keys: Iterable[tuple[int, int]] | None = None) -> list[list[float]] | None

Get or set the load vectors on many edges.

Parameters:

  • load (Sequence[float] | None, default: None ) –

    The load vector to set on each edge. If None, current loads are returned.

  • keys (Iterable[tuple[int, int]] | None, default: None ) –

    The edges to access. If None, all edges are used.

Returns:

  • loads ( list[list[float]] | None ) –

    The load vector of each edge.

edges_loadpaths ¤

edges_loadpaths(keys: Iterable[tuple[int, int]] | None = None) -> Iterator[float]

Iterate over the load path of many edges.

Parameters:

  • keys (Iterable[tuple[int, int]] | None, default: None ) –

    The edges to access. If None, all edges are used.

Yields:

  • loadpath ( float ) –

    The load path of each edge.

loadpath ¤

loadpath() -> float

Get the total load path summed over all edges.

Returns:

  • loadpath ( float ) –

    The sum of the per-edge load paths.

print_stats ¤

print_stats(other_stats: dict[str, list[float]] | None = None, ndigits: int = 3) -> None

Print summary statistics of the datastructure's equilibrium state.

Parameters:

  • other_stats (dict[str, list[float]] | None, default: None ) –

    Extra named value lists to summarize alongside the built-in ones.

  • ndigits (int, default: 3 ) –

    The number of digits to round the printed statistics to.

FDNetwork ¤

FDNetwork(*args: Any, **kwargs: Any)

A force density network.

Notes

The typing-only first base re-narrows the COMPAS constructors and accessors for static checkers; it is empty at runtime.

from_mesh classmethod ¤

from_mesh(mesh: Mesh) -> Self

Build a force density network from a mesh's vertices and edges.

Parameters:

  • mesh (Mesh) –

    The mesh to copy vertices, edges, and their attributes from.

Returns:

  • network ( Self ) –

    The network mirroring the mesh's connectivity and attributes.

nodes_coordinates ¤

nodes_coordinates(keys: Iterable[int] | None = None, axes: str = 'xyz') -> list[list[float]]

Get the coordinates of many nodes.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The nodes to access. If None, all nodes are used.

  • axes (str, default: 'xyz' ) –

    The coordinate axes to return, as a subset of "xyz".

Returns:

  • coordinates ( list[list[float]] ) –

    The selected coordinates of each node.

nodes_fixedcoordinates ¤

nodes_fixedcoordinates(keys: Iterable[int] | None = None, axes: str = 'xyz') -> list[list[float]]

Get the coordinates of the supported nodes.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The candidate nodes; only the supported ones are kept. If None, all supported nodes are used.

  • axes (str, default: 'xyz' ) –

    The coordinate axes to return, as a subset of "xyz".

Returns:

  • coordinates ( list[list[float]] ) –

    The selected coordinates of each supported node.

number_of_anchors ¤

number_of_anchors() -> int

The number of anchored nodes.

number_of_supports ¤

number_of_supports() -> int

The number of supported nodes.

node_support ¤

node_support(key: int) -> None

Mark a node as a support.

Parameters:

  • key (int) –

    The node to fix.

node_anchor ¤

node_anchor(key: int) -> None

Mark a node as a support.

Parameters:

  • key (int) –

    The node to fix.

Notes

An alias of node_support; anchor and support are synonyms here.

is_node_support ¤

is_node_support(key: int) -> bool

Test whether a node is a support.

Parameters:

  • key (int) –

    The node to test.

Returns:

  • is_support ( bool ) –

    True if the node is a support.

nodes_supports ¤

nodes_supports(keys: None = None) -> Iterator[int]
nodes_supports(keys: Iterable[int]) -> None
nodes_supports(keys: Iterable[int] | None = None) -> Iterator[int] | None

Get the support nodes, or mark nodes as supports.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The nodes to mark as supports. If None, the existing support nodes are returned instead.

Returns:

  • supports ( Iterator[int] | None ) –

    The support node keys when reading; None when setting.

nodes_fixed ¤

nodes_fixed(keys: None = None) -> Iterator[int]
nodes_fixed(keys: Iterable[int]) -> None
nodes_fixed(keys: Iterable[int] | None = None) -> Iterator[int] | None

Get the support nodes, or mark nodes as supports.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The nodes to mark as supports. If None, the existing support nodes are returned instead.

Returns:

  • supports ( Iterator[int] | None ) –

    The support node keys when reading; None when setting.

Notes

An alias of nodes_supports.

nodes_anchors ¤

nodes_anchors(keys: None = None) -> Iterator[int]
nodes_anchors(keys: Iterable[int]) -> None
nodes_anchors(keys: Iterable[int] | None = None) -> Iterator[int] | None

Get the support nodes, or mark nodes as supports.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The nodes to mark as supports. If None, the existing support nodes are returned instead.

Returns:

  • supports ( Iterator[int] | None ) –

    The support node keys when reading; None when setting.

Notes

An alias of nodes_supports.

nodes_free ¤

nodes_free() -> Iterator[int]

Iterate over the free (unsupported) nodes.

Returns:

  • nodes_free ( Iterator[int] ) –

    The keys of the nodes that are not supports.

node_load ¤

node_load(key: int, load: Iterable[float] | None = None) -> list[float] | None

Get or set the load vector on a single node.

Parameters:

  • key (int) –

    The node to access.

  • load (Iterable[float] | None, default: None ) –

    The load vector to set. If None, the current load is returned.

Returns:

  • load ( list[float] | None ) –

    The node's load vector.

nodes_loads ¤

nodes_loads(load: Sequence[float] | None = None, keys: Iterable[int] | None = None) -> list[list[float]] | None

Get or set the load vectors on many nodes.

Parameters:

  • load (Sequence[float] | None, default: None ) –

    The load vector to set on each node. If None, current loads are returned.

  • keys (Iterable[int] | None, default: None ) –

    The nodes to access. If None, all nodes are used.

Returns:

  • loads ( list[list[float]] | None ) –

    The load vector of each node.

nodes_residual ¤

nodes_residual(keys: Iterable[int] | None = None) -> list[list[float]]

Get the residual force vectors of many nodes.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The nodes to access. If None, all nodes are used.

Returns:

  • residuals ( list[list[float]] ) –

    The residual force vector of each node.

node_residual ¤

node_residual(key: int) -> list[float]

Get the residual force vector of a single node.

Parameters:

  • key (int) –

    The node to access.

Returns:

  • residual ( list[float] ) –

    The node's residual force vector.

nodes_reactions ¤

nodes_reactions(keys: Iterable[int] | None = None) -> list[list[float]]

Get the reaction force vectors of the support nodes.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The nodes to access. If None, all support nodes are used.

Returns:

  • reactions ( list[list[float]] ) –

    The reaction force vector of each selected node.

node_reaction ¤

node_reaction(key: int) -> list[float]

Get the reaction force vector of a single node.

Parameters:

  • key (int) –

    The node to access.

Returns:

  • reaction ( list[float] ) –

    The node's reaction force vector.

is_edge_supported ¤

is_edge_supported(key: tuple[int, int]) -> bool

Test whether either end node of an edge is a support.

Parameters:

Returns:

  • is_supported ( bool ) –

    True if at least one of the edge's nodes is a support.

is_edge_fully_supported ¤

is_edge_fully_supported(key: tuple[int, int]) -> bool

Test whether both end nodes of an edge are supports.

Parameters:

Returns:

  • is_fully_supported ( bool ) –

    True if both of the edge's nodes are supports.

parameters ¤

parameters() -> tuple[list[float], list[list[float]], list[list[float]]]

Return the force density design parameters of the network.

Returns:

FDMesh ¤

FDMesh(*args: Any, **kwargs: Any)

A force density mesh.

Notes

The typing-only first base re-narrows the COMPAS constructors and accessors for static checkers; it is empty at runtime.

is_vertex_support ¤

is_vertex_support(key: int) -> bool

Test whether a vertex is a support.

Parameters:

  • key (int) –

    The vertex to test.

Returns:

  • is_support ( bool ) –

    True if the vertex is a support.

number_of_supports ¤

number_of_supports() -> int

Count the supported vertices.

Returns:

  • count ( int ) –

    The number of support vertices.

vertex_support ¤

vertex_support(key: int) -> None

Mark a vertex as a support.

Parameters:

  • key (int) –

    The vertex to fix.

vertex_load ¤

vertex_load(key: int, load: Iterable[float] | None = None) -> list[float] | None

Get or set the load vector on a single vertex.

Parameters:

  • key (int) –

    The vertex to access.

  • load (Iterable[float] | None, default: None ) –

    The load vector to set. If None, the current load is returned.

Returns:

  • load ( list[float] | None ) –

    The vertex's load vector.

vertex_residual ¤

vertex_residual(key: int) -> list[float]

Get the residual force vector of a single vertex.

Parameters:

  • key (int) –

    The vertex to access.

Returns:

  • residual ( list[float] ) –

    The vertex's residual force vector.

vertex_reaction ¤

vertex_reaction(key: int) -> list[float]

Get the reaction force vector of a single vertex.

Parameters:

  • key (int) –

    The vertex to access.

Returns:

  • reaction ( list[float] ) –

    The vertex's reaction force, equal to its residual.

vertices_coordinates ¤

vertices_coordinates(keys: Iterable[int] | None = None, axes: str = 'xyz') -> list[list[float]]

Get the coordinates of many vertices.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The vertices to access. If None, all vertices are used.

  • axes (str, default: 'xyz' ) –

    The coordinate axes to return, as a subset of "xyz".

Returns:

  • coordinates ( list[list[float]] ) –

    The selected coordinates of each vertex.

vertices_fixedcoordinates ¤

vertices_fixedcoordinates(keys: Iterable[int] | None = None, axes: str = 'xyz') -> list[list[float]]

Get the coordinates of the supported vertices.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The candidate vertices; only the supported ones are kept. If None, all supported vertices are used.

  • axes (str, default: 'xyz' ) –

    The coordinate axes to return, as a subset of "xyz".

Returns:

  • coordinates ( list[list[float]] ) –

    The selected coordinates of each supported vertex.

vertices_supports ¤

vertices_supports(keys: None = None) -> Iterator[int]
vertices_supports(keys: Iterable[int]) -> None
vertices_supports(keys: Iterable[int] | None = None) -> Iterator[int] | None

Get the support vertices, or mark vertices as supports.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The vertices to mark as supports. If None, the existing support vertices are returned instead.

Returns:

  • supports ( Iterator[int] | None ) –

    The support vertex keys when reading; None when setting.

vertices_fixed ¤

vertices_fixed(keys: None = None) -> Iterator[int]
vertices_fixed(keys: Iterable[int]) -> None
vertices_fixed(keys: Iterable[int] | None = None) -> Iterator[int] | None

Get the support vertices, or mark vertices as supports.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The vertices to mark as supports. If None, the existing support vertices are returned instead.

Returns:

  • supports ( Iterator[int] | None ) –

    The support vertex keys when reading; None when setting.

Notes

An alias of vertices_supports.

vertices_free ¤

vertices_free() -> Iterator[int]

Iterate over the free (unsupported) vertices.

Returns:

  • vertices_free ( Iterator[int] ) –

    The keys of the vertices that are not supports.

vertices_loads ¤

vertices_loads(load: Sequence[float] | None = None, keys: Iterable[int] | None = None) -> list[list[float]] | None

Get or set the load vectors on many vertices.

Parameters:

  • load (Sequence[float] | None, default: None ) –

    The load vector to set on each vertex. If None, current loads are returned.

  • keys (Iterable[int] | None, default: None ) –

    The vertices to access. If None, all vertices are used.

Returns:

  • loads ( list[list[float]] | None ) –

    The load vector of each vertex.

vertices_residual ¤

vertices_residual(keys: Iterable[int] | None = None) -> list[list[float]]

Get the residual force vectors of many vertices.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The vertices to access. If None, all vertices are used.

Returns:

  • residuals ( list[list[float]] ) –

    The residual force vector of each vertex.

vertices_reactions ¤

vertices_reactions(keys: Iterable[int] | None = None) -> list[list[float]]

Get the reaction force vectors of the support vertices.

Parameters:

  • keys (Iterable[int] | None, default: None ) –

    The vertices to access. If None, all support vertices are used.

Returns:

  • reactions ( list[list[float]] ) –

    The reaction force vector of each selected vertex.

is_edge_supported ¤

is_edge_supported(key: tuple[int, int]) -> bool

Test whether either end vertex of an edge is a support.

Parameters:

Returns:

  • is_supported ( bool ) –

    True if at least one of the edge's vertices is a support.

is_edge_fully_supported ¤

is_edge_fully_supported(key: tuple[int, int]) -> bool

Test whether both end vertices of an edge are supports.

Parameters:

Returns:

  • is_fully_supported ( bool ) –

    True if both of the edge's vertices are supports.

face_lcs ¤

face_lcs(key: int) -> list[list[float]]

Compute the local coordinate frame of a face.

Parameters:

  • key (int) –

    The face to access.

Returns:

  • lcs ( list[list[float]] ) –

    The three axes of the face's local coordinate system.

face_load ¤

face_load(key: int, load: list[float] | None = None) -> list[float] | None

Get or set the load vector on a single face.

Parameters:

  • key (int) –

    The face to access.

  • load (list[float] | None, default: None ) –

    The load vector to set. If None, the current load is returned.

Returns:

  • load ( list[float] | None ) –

    The face's load vector.

is_face_supported ¤

is_face_supported(key: int) -> bool

Test whether any vertex of a face is a support.

Parameters:

  • key (int) –

    The face to test.

Returns:

  • is_supported ( bool ) –

    True if at least one of the face's vertices is a support.

is_face_fully_supported ¤

is_face_fully_supported(key: int) -> bool

Test whether every vertex of a face is a support.

Parameters:

  • key (int) –

    The face to test.

Returns:

  • is_fully_supported ( bool ) –

    True if all of the face's vertices are supports.

faces_loads ¤

faces_loads(load: list[float] | None = None, keys: Iterable[int] | None = None) -> list[list[float]] | None

Get or set the load vectors on many faces.

Parameters:

  • load (list[float] | None, default: None ) –

    The load vector to set on each face. If None, current loads are returned.

  • keys (Iterable[int] | None, default: None ) –

    The faces to access. If None, all faces are used.

Returns:

  • loads ( list[list[float]] | None ) –

    The load vector of each face.

parameters ¤

parameters() -> tuple[list[float], list[list[float]], list[list[float]]]

Return the force density design parameters of the mesh.

Returns:

index_edge ¤

index_edge() -> dict[int, tuple[int, int]]

Map each edge's enumeration index to its vertex key pair.

Returns:

  • index_edge ( dict[int, tuple[int, int]] ) –

    A mapping from edge index to its (u, v) vertex key pair.

Notes

Mirrors compas.datastructures.Graph.index_edge, which COMPAS 2.x does not provide on Mesh, so FDMesh and FDNetwork share the API.

uv_index ¤

uv_index() -> dict[tuple[int, int], int]

Map each edge's vertex key pair to its enumeration index.

Returns:

  • uv_index ( dict[tuple[int, int], int] ) –

    A mapping from each (u, v) vertex key pair to its edge index.