Skip to content

Mesh.from_bounding_box method #3871

@pshriwise

Description

@pshriwise

Description

There's a handy set of methods for our structured mesh types, from_domain, which constructs the mesh object from the bounding box of the domain provided. It would be a nice refactor to make the from_domain an abstract method that calls a new concrete method, from_bounding_box, on the class subclass implementations.

This provides an option to generate our structured mesh classes directly from a bounding box rather than requiring a domain to do so.

openmc/openmc/mesh.py

Lines 1193 to 1210 in b3788f1

def from_domain(
cls,
domain: HasBoundingBox | BoundingBox,
dimension: Sequence[int] | int = 1000,
mesh_id: int | None = None,
name: str = ''
):
"""Create RegularMesh from a domain using its bounding box.
Parameters
----------
domain : HasBoundingBox | openmc.BoundingBox
The object passed in will be used as a template for this mesh. The
bounding box of the property of the object passed will be used to
set the lower_left and upper_right and of the mesh instance.
Alternatively, a :class:`openmc.BoundingBox` can be passed
directly.
dimension : Iterable of int | int

Alternatives

N/A

Compatibility

This should be a pure addition to the current interface.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions