Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
repos:
- repo: https://github.com/psf/black
rev: 24.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
hooks:
- id: black
args: [--check]
- id: ruff # linter
name: Run ruff (linter for Python)
args: ["--fix", "--select", "I,TID252,F401"] # "I => sort imports, TID252 => ban relative imports, F401 => unused imports"
- id: ruff-format # formatter
name: Run ruff (formatter for Python)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "biomesh"
version = "0.5.0"
version = "0.5.1"
authors = [
{ name="The biomesh Authors" },
]
Expand Down Expand Up @@ -40,3 +40,6 @@ dependencies = [

[tool.hatch.build.targets.wheel]
packages = ["src/biomesh"]

[tool.ruff.lint.per-file-ignores]
"src/biomesh/__init__.py" = ["F401"]
17 changes: 8 additions & 9 deletions src/biomesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@
"""Biomesh is a Python package for working with 3D meshes, providing tools for
mesh generation, manipulation, and analysis tailored for finite element
simulations of biomechanical applications."""
from . import run_gmsh

import pathlib
from . import mesh
import lnmmeshio
import tempfile

import lnmmeshio
import meshio
from .reorder import reorder

from . import laplace, mesh, run_gmsh, utils
from .adapt import lin_to_quad
from .merge import merge
from .filter import (
filter_by_cellblock,
filter_by_block_ids,
filter_by_cellblock,
filter_by_cellblock_point_mapping,
)

from . import utils
from . import laplace
from .merge import merge
from .reorder import reorder


def combine_colored_stl_files(*stl_files: pathlib.Path) -> meshio.Mesh:
Expand Down
4 changes: 3 additions & 1 deletion src/biomesh/fe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
#
# SPDX-License-Identifier: MIT
"""Small utilities for finite elements."""
import numpy as np

import math

import meshio
import numpy as np
import symfem
import sympy as sp

Expand Down
3 changes: 2 additions & 1 deletion src/biomesh/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
# SPDX-License-Identifier: MIT
"""Filter for meshes to extract a subset."""

from typing import Callable

import meshio
import numpy as np
from typing import Callable


def filter_by_cellblock_point_mapping(
Expand Down
5 changes: 3 additions & 2 deletions src/biomesh/laplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#
# SPDX-License-Identifier: MIT
"""A simple dummy Laplace-solver."""
import numpy as np
import math

import meshio
import numpy as np
import scipy.sparse

from . import fe

_OPTIMAL_NUMBER_OF_INTEGRATION_POINTS = {
Expand Down
1 change: 1 addition & 0 deletions src/biomesh/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: MIT
"""A module to merge multuple meshes into one larger mesh."""

import meshio
import numpy as np

Expand Down
6 changes: 3 additions & 3 deletions src/biomesh/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
# SPDX-License-Identifier: MIT
"""A module for utils for generating meshes."""

import lnmmeshio
import pathlib
import numpy as np

import lnmmeshio
import meshio
import numpy as np
import scipy.spatial as sp


Expand Down Expand Up @@ -90,7 +91,6 @@ def merge_colored_stl(

# append cells
for cell_id, cell in enumerate(mesh.cells[0].data):

key = _sort_cell_node_ids([node_mapping[i] for i in cell])

if key not in cell_surface_ids:
Expand Down
7 changes: 4 additions & 3 deletions src/biomesh/reorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
# SPDX-License-Identifier: MIT
"""A module for reordering nodes in a finite element mesh."""

import copy
from collections import defaultdict

import meshio
import scipy.sparse as sp
import numpy as np
from collections import defaultdict
import copy
import scipy.sparse as sp


def reverse_permutation(perm: np.ndarray) -> np.ndarray:
Expand Down
5 changes: 3 additions & 2 deletions src/biomesh/run_gmsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"""A module controlling running the gmsh api if installed."""

import pathlib
import meshio
import tempfile
from types import TracebackType, ModuleType
from types import TracebackType

import meshio


class GmshApi:
Expand Down
1 change: 1 addition & 0 deletions src/biomesh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: MIT
"""Some small utilities."""

import numpy as np
import scipy.spatial as sp

Expand Down
5 changes: 4 additions & 1 deletion tests/test_adapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
#
# SPDX-License-Identifier: MIT
"""Testing mesh adaptation utilities."""

import pathlib

import meshio
import biomesh
import numpy as np

import biomesh


def test_lin_to_quad():
"""Testing converting linear cells to quadratic cells."""
Expand Down
7 changes: 5 additions & 2 deletions tests/test_fe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
#
# SPDX-License-Identifier: MIT
"""Tests for small finite element ulitities."""
import pytest

import pathlib

import meshio
import biomesh
import numpy as np
import pytest

import biomesh


@pytest.mark.parametrize("shape", ["tetra", "tetra10"])
Expand Down
5 changes: 4 additions & 1 deletion tests/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
#
# SPDX-License-Identifier: MIT
"""Testing filtering meshes."""
import biomesh

import pathlib

import meshio
import numpy as np

import biomesh


def test_filter_by_cellblock():
"""Test the filter by a specific cellblock filter."""
Expand Down
9 changes: 6 additions & 3 deletions tests/test_laplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
#
# SPDX-License-Identifier: MIT
"""A test suite for the dummy Laplace solver."""
import pytest
import biomesh
import numpy as np

import pathlib

import meshio
import numpy as np
import pytest

import biomesh


def test_cell_stiffness_hex():
Expand Down
6 changes: 4 additions & 2 deletions tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
# SPDX-License-Identifier: MIT
"""Test merge meshes."""

import meshio
import biomesh
import pathlib

import meshio
import numpy as np

import biomesh


def test_merge():
"""Test merging multiple meshes."""
Expand Down
6 changes: 3 additions & 3 deletions tests/test_mesh_stl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
# SPDX-License-Identifier: MIT
"""Tests for meshing stl-files."""

import biomesh
import pathlib
import meshio

import pytest
import numpy as np

import biomesh

_my_script_dir = pathlib.Path(__file__).parent

Expand Down
4 changes: 3 additions & 1 deletion tests/test_reorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"""Tests for reordering nodes/elements in a finite element mesh."""

import pathlib

import meshio
import biomesh
import numpy as np

import biomesh


def test_reorder():
"""Tests reordering the nodes in a finite element mesh."""
Expand Down
4 changes: 3 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
#
# SPDX-License-Identifier: MIT
"""Test small utilities."""

import numpy as np
import biomesh
import scipy.spatial as sp

import biomesh


def test_bislerp():
"""Test bislerp operation for rotations."""
Expand Down