Skip to content

Commit 05ee6d6

Browse files
committed
Update docstrings
1 parent 923130f commit 05ee6d6

1 file changed

Lines changed: 84 additions & 16 deletions

File tree

openmc/mesh.py

Lines changed: 84 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,31 @@ def from_domain(
944944
mesh_id: int | None = None,
945945
name: str = '',
946946
**kwargs
947-
):
948-
"""Create a structured mesh from a domain using its bounding box."""
947+
) -> StructuredMesh:
948+
"""Create a structured mesh from a domain using its bounding box.
949+
950+
Parameters
951+
----------
952+
domain : HasBoundingBox | openmc.BoundingBox
953+
Object used as a template for the mesh extents. If ``domain`` has a
954+
``bounding_box`` attribute, that bounding box is used directly.
955+
dimension : Iterable of int or int, optional
956+
Number of mesh cells. When omitted, the subclass-specific default is
957+
used. If provided as a single integer, subclasses that support it
958+
interpret it as a target total number of mesh cells.
959+
mesh_id : int, optional
960+
Unique identifier for the mesh.
961+
name : str, optional
962+
Name of the mesh.
963+
**kwargs
964+
Additional keyword arguments forwarded to
965+
:meth:`from_bounding_box`.
966+
967+
Returns
968+
-------
969+
openmc.StructuredMesh
970+
Structured mesh instance.
971+
"""
949972
if isinstance(domain, BoundingBox):
950973
bbox = domain
951974
elif hasattr(domain, 'bounding_box'):
@@ -963,7 +986,35 @@ def from_domain(
963986

964987
@classmethod
965988
@abstractmethod
966-
def from_bounding_box(cls, bbox: openmc.BoundingBox, dimension=1000, mesh_id=None, name='', **kwargs):
989+
def from_bounding_box(
990+
cls,
991+
bbox: openmc.BoundingBox,
992+
dimension: Sequence[int] | int,
993+
mesh_id: int | None = None,
994+
name: str = '',
995+
**kwargs
996+
) -> StructuredMesh:
997+
"""Create a structured mesh from a bounding box.
998+
999+
Parameters
1000+
----------
1001+
bbox : openmc.BoundingBox
1002+
Bounding box used to define the mesh extents.
1003+
dimension : Iterable of int or int
1004+
Number of mesh cells. The interpretation and any default value are
1005+
defined by the concrete mesh type.
1006+
mesh_id : int, optional
1007+
Unique identifier for the mesh.
1008+
name : str, optional
1009+
Name of the mesh.
1010+
**kwargs
1011+
Additional keyword arguments accepted by specific subclasses.
1012+
1013+
Returns
1014+
-------
1015+
openmc.StructuredMesh
1016+
Structured mesh instance.
1017+
"""
9671018
pass
9681019

9691020
class HasBoundingBox(Protocol):
@@ -1219,13 +1270,33 @@ def from_rect_lattice(
12191270
return mesh
12201271

12211272
@classmethod
1222-
def from_bounding_box(cls,
1223-
bbox,
1224-
dimension=1000,
1225-
mesh_id=None,
1226-
name='',
1227-
**kwargs):
1228-
1273+
def from_bounding_box(
1274+
cls,
1275+
bbox: openmc.BoundingBox,
1276+
dimension: Sequence[int] | int = 1000,
1277+
mesh_id: int | None = None,
1278+
name: str = '',
1279+
) -> RegularMesh:
1280+
"""Create a RegularMesh from a bounding box.
1281+
1282+
Parameters
1283+
----------
1284+
bbox : openmc.BoundingBox
1285+
Bounding box used to set the mesh extents.
1286+
dimension : Iterable of int or int, optional
1287+
The number of mesh cells in each direction (x, y, z). If a single
1288+
integer is provided, the total number of cells is distributed
1289+
across directions to produce cells with roughly equal widths.
1290+
mesh_id : int, optional
1291+
Unique identifier for the mesh.
1292+
name : str, optional
1293+
Name of the mesh.
1294+
1295+
Returns
1296+
-------
1297+
openmc.RegularMesh
1298+
RegularMesh instance.
1299+
"""
12291300
mesh = cls(mesh_id=mesh_id, name=name)
12301301
mesh.lower_left = bbox[0]
12311302
mesh.upper_right = bbox[1]
@@ -1731,8 +1802,7 @@ def from_bounding_box(
17311802
dimension: Sequence[int] | int = 1000,
17321803
mesh_id: int | None = None,
17331804
name: str = '',
1734-
**kwargs
1735-
):
1805+
) -> RectilinearMesh:
17361806
"""Create a RectilinearMesh from a bounding box with uniform grids.
17371807
17381808
Parameters
@@ -2041,8 +2111,7 @@ def from_bounding_box(
20412111
name: str = '',
20422112
phi_grid_bounds: Sequence[float] = (0.0, 2*pi),
20432113
enclose_domain: bool = False,
2044-
**kwargs
2045-
):
2114+
) -> CylindricalMesh:
20462115
"""Create CylindricalMesh from a bounding box.
20472116
20482117
Parameters
@@ -2415,8 +2484,7 @@ def from_bounding_box(
24152484
phi_grid_bounds: Sequence[float] = (0.0, 2*pi),
24162485
theta_grid_bounds: Sequence[float] = (0.0, pi),
24172486
enclose_domain: bool = False,
2418-
**kwargs
2419-
):
2487+
) -> SphericalMesh:
24202488
"""Create SphericalMesh from a bounding box.
24212489
24222490
Parameters

0 commit comments

Comments
 (0)