Skip to content

CustomRectangularGrid3D

CustomRectangularGrid3D

CustomRectangularGrid3D(user_name: str, element: Element, region: Optional[RegionBase] = None, *, x_coords: str, y_coords: str, z_coords: str)

Bases: MeshPart

Custom 3D rectangular mesh part discretized using comma-separated coordinates list strings.

This mesh part defines a 3D rectangular solid grid with customized element spacing. The node spacing along the X, Y, and Z axes is defined directly via lists of coordinates supplied as comma-separated string inputs.

Example
from femora.core.model import Model

model = Model()
mat = model.material.nd.elastic_isotropic(user_name="soil", e_mod=30000.0, nu=0.3, rho=2.0)
ele = model.element.brick.std(ndof=3, material=mat)

# Discretize a 3D grid with refinement near the origin
block = model.meshpart.volume.custom_rectangular_grid(
    user_name="refined_block",
    element=ele,
    x_coords="0.0,1.0,3.0,6.0,10.0",
    y_coords="0.0,1.0,3.0,6.0,10.0",
    z_coords="0.0,2.0,5.0,10.0",
)
print(block.tag)

Create a custom-discretized 3D rectangular grid mesh part.

Parameters:

Name Type Description Default
user_name str

Unique user-defined name for this mesh part.

required
element Element

Associated Element template used for discretization.

required
region Optional[RegionBase]

Physical Region where this mesh part is added.

None
x_coords str

Comma-separated floats representing X-coordinate positions in ascending order.

required
y_coords str

Comma-separated floats representing Y-coordinate positions in ascending order.

required
z_coords str

Comma-separated floats representing Z-coordinate positions in ascending order.

required

Raises:

Type Description
TypeError

If coordinates inputs are not string types.

ValueError

If coordinate lists contain fewer than two coordinates, if coordinates fail to parse, or are not in strictly ascending order.

Methods:

generate_mesh

generate_mesh() -> pv.UnstructuredGrid

Calculate custom grid coordinates and compile a PyVista UnstructuredGrid.

Returns:

Type Description
UnstructuredGrid

pv.UnstructuredGrid: The generated custom UnstructuredGrid mesh.