Skip to content

MaterialManager

MaterialManager

MaterialManager(mesh_maker: Model)

Local manager for Material lifecycle and tag assignment.

The manager is intentionally not a singleton. Each :class:Model instance owns one MaterialManager with an independent tag space.

Parameters:

Name Type Description Default
mesh_maker Model

The :class:Model that owns this manager.

required

Raises:

Type Description
TypeError

If mesh_maker is not a :class:Model instance.

Attributes:

Name Type Description
nd NDMaterialManager

Factories available through model.material.nd.

uniaxial UniaxialMaterialManager

Factories through model.material.uniaxial. Both namespaces share this registry.

Example
from femora import Model

model = Model()
steel = model.material.uniaxial.elastic(user_name="steel", E=200e6)
assert model.material.get(steel.tag) is steel
assert model.material.get_by_name("steel") is steel
Warning

Removal and start-tag changes can retag surviving objects. Do not treat a cached integer tag as a persistent identifier across edits. Use object references or unique names while constructing the model.

Methods:

Name Description
add

Add an existing material and assign a tag if needed.

get

Look up a material by its current manager-assigned tag.

get_by_name

Look up a registered material by its exact user name.

get_all

Return a shallow registry snapshot keyed by current integer tag.

remove

Remove a managed material and compact the remaining tags.

clear

Detach every material, clear its tag, and empty both lookup indices.

set_tag_start

Set the first tag used by this manager and retag existing objects.

Methods:

add

add(material: Material) -> Material

Add an existing material and assign a tag if needed.

Parameters:

Name Type Description Default
material Material

Unmanaged or already-managed :class:Material instance.

required

Returns:

Type Description
Material

The same material instance after it is stored by this manager.

Raises:

Type Description
TypeError

If material is not a :class:Material instance.

ValueError

If its preassigned tag conflicts with a different object already managed here, or if it already belongs to another manager.

get

get(tag: int) -> Optional[Material]

Look up a material by its current manager-assigned tag.

Parameters:

Name Type Description Default
tag int

Tag, converted with int(tag) before lookup.

required

Returns:

Type Description
Optional[Material]

Material | None: Registered object, or None if the tag is absent.

Raises:

Type Description
TypeError

The supplied value cannot be converted to an integer.

ValueError

Integer conversion fails for the supplied value.

get_by_name

get_by_name(name: str) -> Optional[Material]

Look up a registered material by its exact user name.

Parameters:

Name Type Description Default
name str

Case-sensitive registered user_name.

required

Returns:

Type Description
Optional[Material]

Material | None: Matching object or None. No material is created.

get_all

get_all() -> Dict[int, Material]

Return a shallow registry snapshot keyed by current integer tag.

Returns:

Type Description
Dict[int, Material]

dict[int, Material]: New dictionary containing the original objects.

Dict[int, Material]

Editing its keys does not edit the manager; changing an object does.

remove

remove(tag: int) -> None

Remove a managed material and compact the remaining tags.

Parameters:

Name Type Description Default
tag int

Tag of the material to remove. Missing tags are ignored.

required

clear

clear() -> None

Detach every material, clear its tag, and empty both lookup indices.

This does not remove elements or sections referring to those objects, clear the whole Model, or execute an OpenSees command. Detached objects must be registered again before rendering tag-dependent definitions.

set_tag_start

set_tag_start(start_tag: int) -> None

Set the first tag used by this manager and retag existing objects.

Parameters:

Name Type Description Default
start_tag int

Positive integer for the first assigned tag.

required

Raises:

Type Description
ValueError

If start_tag is less than 1.