AssemblySection
AssemblySection
AssemblySection(meshpart_manager, meshparts: List[str], num_partitions: int = 1, partition_algorithm: str = 'kd-tree', partitioner: Optional[str] = None, merge_points: bool = True, merge_in_final: bool = True, progress_callback=None, mass_merging: str = 'sum', tolerance: float = 1e-05)
A class representing a group of mesh parts combined into a single mesh.
The AssemblySection class takes multiple mesh parts, combines them into a single
mesh, and optionally partitions the mesh for parallel computing. Section
registration with the assembler is performed by Assembler.create_section(...),
which assigns a unique tag for identification.
This class is responsible for: - Validating mesh parts before assembly - Merging mesh parts with appropriate metadata - Managing degrees of freedom consistency - Partitioning the mesh for parallel processing - Storing references to elements and materials
Attributes:
| Name | Type | Description |
|---|---|---|
meshparts_list |
List[MeshPart]
|
List of MeshPart objects in this section |
num_partitions |
int
|
Number of partitions for parallel processing |
partition_algorithm |
str
|
Algorithm used for partitioning the mesh |
merge_points |
bool
|
Whether points are merged during assembly |
mesh |
UnstructuredGrid
|
The assembled mesh |
elements |
List[Element]
|
Elements used in this assembly section |
materials |
List[Material]
|
Materials used in this assembly section |
actor |
PyVista actor for visualization |
|
_tag |
int
|
Unique tag assigned by the Assembler |
Initialize an AssemblySection by combining multiple mesh parts.
This constructor takes a list of mesh part names, validates them, combines them
into a single mesh, and optionally partitions the result. Registration with
the assembler happens in Assembler.create_section(...).
If the partition algorithm is "kd-tree" and num_partitions is not a power of 2, it will be automatically rounded up to the next power of 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meshparts
|
List[str]
|
List of mesh part names to be assembled. These must be names of previously created MeshPart instances. |
required |
num_partitions
|
int
|
Number of partitions for parallel processing. For kd-tree, will be rounded to next power of 2. Defaults to 1 (no partitioning). |
1
|
partition_algorithm
|
str
|
Backward-compatible name for the mesh partitioner.
Prefer using |
'kd-tree'
|
partitioner
|
str
|
Mesh partitioner name (Femora terminology), e.g. "kd-tree",
"morton", "geometric".
If provided, it overrides |
None
|
mass_merging
|
str
|
Method for merging mass properties of mesh parts. Options are "sum" or "average". Defaults to "sum". |
'sum'
|
merge_points
|
bool
|
Whether to merge points that are within a tolerance distance when assembling mesh parts. Defaults to True. |
True
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no valid mesh parts are provided, if the partition algorithm is invalid, or if mesh assembly fails |
Attributes
tag
property
Get the unique tag for this AssemblySection.
The tag is a unique identifier assigned by the assembler when the section
is registered through Assembler.create_section(...). It can be used to
retrieve the section from the assembler later.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Unique tag assigned by the Assembler |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the section hasn't been successfully added to the Assembler |
meshparts
property
Get the names of mesh parts in this AssemblySection.
This property returns a list of the user-friendly names of all mesh parts included in this assembly section. These are the names that were originally provided when creating the mesh parts.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Names of mesh parts included in this assembly section |
Methods:
_validate_mesh_parts
Validate and retrieve mesh parts.
This internal method checks that all specified mesh part names exist in the MeshPart registry and retrieves the corresponding MeshPart objects. It also verifies that at least one valid mesh part is provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meshpart_names
|
List[str]
|
List of mesh part names to validate |
required |
Returns:
| Type | Description |
|---|---|
List[MeshPart]
|
List[MeshPart]: List of validated MeshPart objects |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any specified mesh part doesn't exist or if no valid mesh parts are found |
_snap_points
staticmethod
Snap points within tolerance to the first representative point using KDTree.
_ensure_ndf_array
Ensures the mesh has an 'ndf' point data array. If missing, it attempts to derive it from 'ElementTag' cell data to respect unique sentinels (e.g., for GhostNodeElements).
_assemble_mesh
Assemble mesh parts into a single mesh.
This internal method performs the actual assembly of mesh parts into a single PyVista UnstructuredGrid. It: 1. Validates degrees of freedom consistency 2. Starts with the first mesh part as the base 3. Adds metadata to the mesh (ElementTag, MaterialTag, Region, etc.) 4. Merges subsequent mesh parts one by one 5. Optionally partitions the resulting mesh for parallel processing
The assembled mesh is stored in the 'mesh' attribute, with cell data arrays for ElementTag, MaterialTag, Region, and Core (partition ID).
Raises:
| Type | Description |
|---|---|
ValueError
|
If mesh parts have different degrees of freedom and this causes assembly to fail, or if any other error occurs during assembly |
assign_actor
Assign a PyVista actor to the assembly section.
This method associates a visualization actor with the assembly section, which can be used for rendering the mesh in a visualization pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
actor
|
PyVista actor to assign to this assembly section for visualization |
required |
plot
Plot the assembled mesh using PyVista.
This method visualizes the assembled mesh for the assembly section. It uses the PyVista plotting capabilities to render the mesh with optional parameters for customization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
off_screen
|
bool
|
Render off-screen. |
False
|
screenshot
|
str
|
File path to save the screenshot. |
None
|
**kwargs
|
Additional keyword arguments to customize the plot (e.g., color, opacity) |
{}
|