Skip to content

MassManager

MassManager

MassManager(mesh_maker: 'Model')

Model-owned service for assigning nodal mass arrays.

Mass data lives on mesh parts before assembly and on the assembled mesh after assembly. This manager provides convenience helpers that modify those arrays without introducing separate mass objects or registries.

Attributes:

Name Type Description
meshpart

Source-part helpers used before section creation/assembly.

region

Assembled-node helpers selecting nodes of cells in a region.

global_

Helpers acting on the current assembled mesh; trailing underscore avoids the Python keyword global.

Mass vectors use nodal DOF order. Entries include translational mass and, where relevant, rotary inertia in consistent units. Vectors are flattened, zero-padded, or truncated to FEMORA_MAX_NDF and stored as float32; these helpers do not reject entries merely because a node has fewer active DOFs. They assign the supplied amount per selected node, not a total distributed across all nodes. No gravity force is created by assigning mass.

Example
from femora import Model

model = Model()
soil = model.material.nd.elastic_isotropic(user_name="soil", E=1e5, nu=0.3, rho=1.8)
brick = model.element.brick.std(ndof=3, material=soil)
model.meshpart.volume.uniform_rectangular_grid(
    user_name="block", element=brick,
    x_min=0, x_max=1, y_min=0, y_max=1, z_min=0, z_max=1,
    nx=1, ny=1, nz=1,
)
model.mass.meshpart.add_all("block", [1.0, 1.0, 1.0])
masses = model.mass.get_meshpart_mass_array("block")
assert masses[0, 0] == 1.0
Warning

Avoid double-counting element/material and explicit nodal mass. Source edits do not update existing section copies, and assembled edits are lost when the final mesh is rebuilt. Rebuild affected sections as well as the final mesh when source-part masses change after section creation.

Methods:

Name Description
get_meshpart_mass_array

Return the live Mass array on a source mesh part, creating zeros if absent.

get_assembled_mass_array

Return the live final-mesh Mass array, creating zeros when needed.

clear

Clear manager caches and remove Mass arrays from the current model.

Methods:

get_meshpart_mass_array

get_meshpart_mass_array(meshpart_name: str) -> np.ndarray

Return the live Mass array on a source mesh part, creating zeros if absent.

Parameters:

Name Type Description Default
meshpart_name str

Exact registered part name.

required

Returns:

Name Type Description
masses ndarray

Live float32 array shaped (part.mesh.n_points, FEMORA_MAX_NDF). Mutating it edits source data.

Raises:

Type Description
KeyError

The part is missing. Generated part geometry is required.

get_assembled_mass_array

get_assembled_mass_array() -> Optional[np.ndarray]

Return the live final-mesh Mass array, creating zeros when needed.

Returns:

Name Type Description
masses ndarray | None

Array shaped (assembled.n_points, FEMORA_MAX_NDF), or None without assembly. In-place changes affect the current assembled model, not source parts.

clear

clear() -> None

Clear manager caches and remove Mass arrays from the current model.

model.mass.meshpart

Modify meshpart mass arrays before assembly.

Meshpart Mass is authoritative pre-assembly. After assembly, edits here are not synced automatically; the user must reassemble manually.

Methods:

Name Description
add_all

Assign a mass vector independently to every selected source-part node.

closest_point

Assign mass to the nearest point in a source part, without distance cutoff.

add_nodes

Assign one mass vector per explicitly selected local source point.

_get_mp

Attributes:

Name Type Description
_mgr

Attributes

_mgr instance-attribute

_mgr = manager

Methods:

add_all

add_all(meshpart_name: str, mass_vec: ArrayLike, *, combine: str = 'sum', filter_fn: Callable[[int], bool] | None = None) -> None

Assign a mass vector independently to every selected source-part node.

Parameters:

Name Type Description Default
meshpart_name str

Exact part name.

required
mass_vec ArrayLike

Per-node mass/inertia vector in nodal DOF order.

required
combine str

sum adds to stored entries; override replaces them.

'sum'
filter_fn Callable | None

Optional predicate receiving a local zero-based point index; False excludes that point.

None

Raises:

Type Description
KeyError

Part not found.

ValueError

Invalid combination rule or vector conversion failure.

Section copies and final assembled arrays are not updated by this operation.

closest_point

closest_point(meshpart_name: str, xyz: Tuple[float, float, float], mass_vec: ArrayLike, *, combine: str = 'sum') -> int

Assign mass to the nearest point in a source part, without distance cutoff.

Parameters:

Name Type Description Default
meshpart_name str

Exact part name.

required
xyz tuple[float, float, float]

Query point in model coordinates.

required
mass_vec ArrayLike

Per-node vector in DOF order.

required
combine str

sum or override.

'sum'

Returns:

Name Type Description
index int

Local zero-based source point index, not a solver node tag.

Missing/empty mesh and KD-tree or vector errors propagate. Inspect the selected location when the query is far from the part.

add_nodes

add_nodes(meshpart_name: str, point_indices: List[int], mass_matrix: List[ArrayLike], *, combine: str = 'sum') -> None

Assign one mass vector per explicitly selected local source point.

Parameters:

Name Type Description Default
meshpart_name str

Exact part name.

required
point_indices list[int]

Local zero-based point indices, not solver tags.

required
mass_matrix list[ArrayLike]

One vector per index, in matching order.

required
combine str

sum or override.

'sum'

Raises:

Type Description
ValueError

Index/vector list lengths differ or combination is invalid.

KeyError

Part is missing.

IndexError

An index cannot access the source arrays.

Uses NumPy indexing semantics; negative indices are not explicitly rejected. Duplicate indices apply their operations repeatedly. Updates are not atomic.

_get_mp

_get_mp(name: str) -> MeshPart

model.mass.region

Modify final-mesh nodes attached to cells carrying a region tag.

Access through model.mass.region after assembly. Selection is based on the assembled cell-data Region array, not a separate node-region registry. Shared nodes can belong to multiple selections and receive repeated additions.

Methods:

Name Description
add_all

Assign a vector to every assembled node incident to region cells.

closest_point

Assign mass at the nearest assembled point incident to region cells.

_require_assembled
_get_region_point_ids
_add_to_points

Attributes:

Name Type Description
_mgr

Attributes

_mgr instance-attribute

_mgr = manager

Methods:

add_all

add_all(region_tag: int, mass_vec: ArrayLike, *, combine: str = 'sum') -> None

Assign a vector to every assembled node incident to region cells.

Parameters:

Name Type Description Default
region_tag int

Region value present in final cell data.

required
mass_vec ArrayLike

Per-node mass/inertia vector, not a regional total.

required
combine str

sum or override.

'sum'

Raises:

Type Description
RuntimeError

No assembled mesh exists.

KeyError

No cells carry the requested region tag.

ValueError

Invalid combination rule or vector conversion.

closest_point

closest_point(region_tag: int, xyz: Tuple[float, float, float], mass_vec: ArrayLike, *, combine: str = 'sum') -> int

Assign mass at the nearest assembled point incident to region cells.

Parameters:

Name Type Description Default
region_tag int

Region value in assembled cell data.

required
xyz tuple[float, float, float]

Query location in model coordinates.

required
mass_vec ArrayLike

Nodal mass/inertia vector.

required
combine str

sum or override.

'sum'

Returns:

Name Type Description
index int

Global assembled point index, not a solver node tag.

Raises:

Type Description
RuntimeError

Model is not assembled.

KeyError

Region has no assembled cells.

No maximum search distance is imposed; source-part arrays are unchanged.

_require_assembled

_require_assembled()

_get_region_point_ids

_get_region_point_ids(region_tag: int, asm)

_add_to_points

_add_to_points(point_ids: ndarray | List[int], mass_vec: ArrayLike, asm, combine: str) -> None

model.mass.global_

Modify the current final-mesh Mass array through model.mass.global_.

Assembly is required. These edits are not propagated to source mesh parts and must be reapplied after rebuilding the final mesh.

Methods:

Name Description
closest_point

Assign a vector at the nearest assembled point without a distance cutoff.

add_all

Assign the same vector independently to every assembled point.

_require_assembled
_add_to_points

Attributes:

Name Type Description
_mgr

Attributes

_mgr instance-attribute

_mgr = manager

Methods:

closest_point

closest_point(xyz: Tuple[float, float, float], mass_vec: ArrayLike, *, combine: str = 'sum') -> int

Assign a vector at the nearest assembled point without a distance cutoff.

Parameters:

Name Type Description Default
xyz tuple[float, float, float]

Query location in model coordinates.

required
mass_vec ArrayLike

Nodal mass/inertia vector.

required
combine str

sum or override.

'sum'

Returns:

Name Type Description
index int

Zero-based assembled point index, not a solver node tag.

Raises:

Type Description
RuntimeError

The model has no assembled mesh.

KD-tree, vector conversion, and invalid combination errors propagate.

add_all

add_all(mass_vec: ArrayLike, *, combine: str = 'sum') -> None

Assign the same vector independently to every assembled point.

Parameters:

Name Type Description Default
mass_vec ArrayLike

Per-node mass/inertia vector, not a model total.

required
combine str

sum adds; override replaces stored vectors.

'sum'

Raises:

Type Description
RuntimeError

The model has no assembled mesh.

ValueError

Invalid combination rule or vector conversion failure.

_require_assembled

_require_assembled()

_add_to_points

_add_to_points(ids, mass_vec, asm, combine) -> None