Skip to content

Commit

Permalink
📝 Doc raises for mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
je-cook committed Aug 5, 2024
1 parent f743bab commit 0e268f2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
22 changes: 22 additions & 0 deletions bluemira/mesh/meshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ def __init__(
def _check_meshfile(meshfile: str | list) -> list[str]:
"""
Check the mesh file input.
Raises
------
ValueError
Meshfile list is empty
TypeError
Meshfile must be a string or list of strings
"""
# todo: should be implemented also a check on the file extension. Only a
# limited type of file extensions is allowed by gmsh.
Expand All @@ -223,6 +230,11 @@ def meshfile(self, meshfile: str | list[str]):
def __call__(self, obj: Component | Meshable, dim: int = 2):
"""
Generate the mesh and save it to file.
Raises
------
TypeError
Objects not meshable
"""
bluemira_print("Starting mesh process...")

Expand Down Expand Up @@ -269,6 +281,11 @@ def __call__(self, obj: Component | Meshable, dim: int = 2):
def __mesh_obj(self, obj, dim: int):
"""
Function to mesh the object.
Raises
------
ValueError
Meshing not implemented for geometry type
"""
from bluemira.geometry.tools import serialise_shape # noqa: PLC0415

Expand Down Expand Up @@ -520,6 +537,11 @@ def get_gmsh_dict(
"""
Returns the gmsh dict in a default (only tags) or gmsh (tuple(dim,
tag)) format.
Raises
------
ValueError
No object to mesh
"""
if isinstance(file_format, str):
file_format = GmshFileType[file_format.upper()]
Expand Down
14 changes: 12 additions & 2 deletions bluemira/mesh/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def msh_to_xdmf(
Raises
------
MeshConversionError:
MeshConversionError
* If the file does not exist
* If the dimensionality != [2, 3]
* If no domain physical groups are found
Expand Down Expand Up @@ -113,6 +113,11 @@ def import_mesh(
Dolfin MeshFunctionSizet object containing the geometry
link_dict:
Link dictionary between MSH and XDMF objects
Raises
------
FileNotFoundError
no mesh file(s) found
"""
domain_file = Path(directory, f"{file_prefix}_{DOMAIN_SUFFIX}")
boundary_file = Path(directory, f"{file_prefix}_{BOUNDARY_SUFFIX}")
Expand All @@ -124,7 +129,7 @@ def import_mesh(
msg = "\n".join([
fn.as_posix() for fn, exist in zip(files, exists, strict=False) if not exist
])
raise MeshConversionError(f"No mesh file(s) found:\n {msg}")
raise FileNotFoundError(f"No mesh file(s) found:\n {msg}")

mesh = Mesh()

Expand Down Expand Up @@ -175,6 +180,11 @@ def _check_dimensions(dimensions: int | list[int]) -> tuple[int]:
def _export_domain(mesh, file_prefix, directory, dimensions):
"""
Export the domain of a mesh to XDMF.
Raises
------
MeshConversionError
No domain physical group found
"""
dimensions = _check_dimensions(dimensions)

Expand Down

0 comments on commit 0e268f2

Please sign in to comment.