Skip to content

MeshPartManager

MeshPartManager

MeshPartManager(mesh_maker: Model)

Create and retrieve discretized components through model.meshpart.

A mesh part combines geometry with an element definition and a region. Factories construct the mesh and register the returned part by its unique user_name. If the part has no region, registration assigns the model's global region. Registry tags identify parts, not individual solver cells.

Attributes:

Name Type Description
line LineMeshNamespace

Single-line and structured-line factories.

volume VolumeMeshNamespace

Rectangular and radial volume meshes.

surface SurfaceMeshNamespace

Surface mesh factories.

general GeneralMeshNamespace

External and composite meshes.

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)
part = model.meshpart.volume.uniform_rectangular_grid(
    user_name="soil_block", element=brick,
    x_min=0, x_max=4, y_min=0, y_max=4, z_min=-4, z_max=0,
    nx=2, ny=2, nz=2,
)
assert model.meshpart.get("soil_block") is part
assert model.meshpart.get_by_tag(part.tag) is part
Warning

Assembly sections contain copied mesh data. Editing or removing a source part does not automatically refresh existing sections or the final mesh. Rebuild the affected assembly sections and assemble again.

Methods:

Name Description
add

Register a mesh part and assign a model-local part tag.

get

Return a part by exact user name, or None when absent.

get_by_tag

Find a part by its current integer-convertible registry tag.

resolve

Resolve an object, name, or integer part tag.

get_all

Return a shallow dictionary snapshot keyed by user name.

get_by_category

Return a shallow name-to-part mapping for a case-insensitive category.

remove

Detach a named part and compact remaining registry tags.

clear

Detach every part and clear its tag, without clearing other managers.

set_tag_start

Set the positive part-tag origin and retag registered parts.

Methods:

add

add(meshpart: MeshPart) -> MeshPart

Register a mesh part and assign a model-local part tag.

Parameters:

Name Type Description Default
meshpart MeshPart

Unmanaged part or one already registered here.

required

Returns:

Name Type Description
part MeshPart

Original object. A missing region is replaced by the model's global region; this method does not regenerate geometry.

Raises:

Type Description
TypeError

The input is not a MeshPart.

ValueError

Name/tag conflicts or the part belongs to another manager.

get

get(user_name: str) -> Optional[MeshPart]

Return a part by exact user name, or None when absent.

Parameters:

Name Type Description Default
user_name str

Case-sensitive registry key, not a filename or tag.

required

get_by_tag

get_by_tag(tag: int) -> Optional[MeshPart]

Find a part by its current integer-convertible registry tag.

Parameters:

Name Type Description Default
tag int

Part tag, not a node/cell tag. Conversion errors propagate when a populated registry is searched.

required

Returns:

Name Type Description
part MeshPart | None

Matching object, or None when absent.

resolve

resolve(item: Union[str, int, MeshPart]) -> Optional[MeshPart]

Resolve an object, name, or integer part tag.

Parameters:

Name Type Description Default
item str | int | MeshPart

Strings are names; integers are tags.

required

Returns:

Name Type Description
part MeshPart | None

Object unchanged, lookup result, or None for unsupported/missing values. Direct objects are not registered or checked for ownership by this helper.

get_all

get_all() -> Dict[str, MeshPart]

Return a shallow dictionary snapshot keyed by user name.

Part objects and their mesh arrays remain shared. Editing dictionary membership does not edit the manager's registry.

get_by_category

get_by_category(category: str) -> Dict[str, MeshPart]

Return a shallow name-to-part mapping for a case-insensitive category.

Parameters:

Name Type Description Default
category str

Category stored on parts, such as a mesh family's category. Matching is exact after lowercasing, not substring-based.

required

remove

remove(user_name: str) -> None

Detach a named part and compact remaining registry tags.

Parameters:

Name Type Description Default
user_name str

Exact part name; missing names are ignored.

required

Existing assembly sections, dependent interfaces, and exported files are not removed or refreshed. Cached part tags may become stale.

clear

clear() -> None

Detach every part and clear its tag, without clearing other managers.

Assembly sections can still hold old part references and mesh copies. Use model.clear_model() for a coordinated whole-model reset.

set_tag_start

set_tag_start(start_tag: int) -> None

Set the positive part-tag origin and retag registered parts.

Parameters:

Name Type Description Default
start_tag int

First part registry tag validated by the tagging policy.

required

Raises:

Type Description
ValueError

The origin is invalid. This setting does not change the exported solver node/element tag origins or update old mesh copies.