Skip to content
Draft
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
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ convention = "numpy"
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["D"]

[tool.ty.rules]
unused-type-ignore-comment = "ignore"

[tool.mypy]
python_version = "3.11"
show_error_codes = true
Expand Down
102 changes: 50 additions & 52 deletions src/gpgi/_boundaries.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
from collections.abc import Callable
from threading import Lock
from typing import Any, Literal, cast
from typing import Any, Literal

from numpy.typing import NDArray

from gpgi._typing import FloatT
from gpgi._typing import DH, F, FArray

BoundaryRecipeT = Callable[
[
NDArray[FloatT],
NDArray[FloatT],
NDArray[FloatT],
NDArray[FloatT],
NDArray[FloatT],
NDArray[FloatT],
NDArray[FloatT],
NDArray[FloatT],
FArray[DH, F],
FArray[DH, F],
FArray[DH, F],
FArray[DH, F],
FArray[DH, F],
FArray[DH, F],
FArray[DH, F],
FArray[DH, F],
Literal["left", "right"],
dict[str, Any],
],
NDArray[FloatT],
FArray[DH, F],
]


Expand Down Expand Up @@ -125,64 +123,64 @@ def __contains__(self, key: str) -> bool:

# basic recipes
def open_boundary(
same_side_active_layer: NDArray[FloatT],
same_side_ghost_layer: NDArray[FloatT],
opposite_side_active_layer: NDArray[FloatT],
opposite_side_ghost_layer: NDArray[FloatT],
weight_same_side_active_layer: NDArray[FloatT],
weight_same_side_ghost_layer: NDArray[FloatT],
weight_opposite_side_active_layer: NDArray[FloatT],
weight_opposite_side_ghost_layer: NDArray[FloatT],
same_side_active_layer: FArray[DH, F],
same_side_ghost_layer: FArray[DH, F],
opposite_side_active_layer: FArray[DH, F],
opposite_side_ghost_layer: FArray[DH, F],
weight_same_side_active_layer: FArray[DH, F],
weight_same_side_ghost_layer: FArray[DH, F],
weight_opposite_side_active_layer: FArray[DH, F],
weight_opposite_side_ghost_layer: FArray[DH, F],
side: Literal["left", "right"],
metadata: dict[str, Any],
) -> NDArray[FloatT]:
) -> FArray[DH, F]:
# return the active layer unchanged
return same_side_active_layer


def wall_boundary(
same_side_active_layer: NDArray[FloatT],
same_side_ghost_layer: NDArray[FloatT],
opposite_side_active_layer: NDArray[FloatT],
opposite_side_ghost_layer: NDArray[FloatT],
weight_same_side_active_layer: NDArray[FloatT],
weight_same_side_ghost_layer: NDArray[FloatT],
weight_opposite_side_active_layer: NDArray[FloatT],
weight_opposite_side_ghost_layer: NDArray[FloatT],
same_side_active_layer: FArray[DH, F],
same_side_ghost_layer: FArray[DH, F],
opposite_side_active_layer: FArray[DH, F],
opposite_side_ghost_layer: FArray[DH, F],
weight_same_side_active_layer: FArray[DH, F],
weight_same_side_ghost_layer: FArray[DH, F],
weight_opposite_side_active_layer: FArray[DH, F],
weight_opposite_side_ghost_layer: FArray[DH, F],
side: Literal["left", "right"],
metadata: dict[str, Any],
) -> NDArray[FloatT]:
return cast("NDArray[FloatT]", same_side_active_layer + same_side_ghost_layer)
) -> FArray[DH, F]:
return same_side_active_layer + same_side_ghost_layer # pyright: ignore[reportReturnType]


def antisymmetric_boundary(
same_side_active_layer: NDArray[FloatT],
same_side_ghost_layer: NDArray[FloatT],
opposite_side_active_layer: NDArray[FloatT],
opposite_side_ghost_layer: NDArray[FloatT],
weight_same_side_active_layer: NDArray[FloatT],
weight_same_side_ghost_layer: NDArray[FloatT],
weight_opposite_side_active_layer: NDArray[FloatT],
weight_opposite_side_ghost_layer: NDArray[FloatT],
same_side_active_layer: FArray[DH, F],
same_side_ghost_layer: FArray[DH, F],
opposite_side_active_layer: FArray[DH, F],
opposite_side_ghost_layer: FArray[DH, F],
weight_same_side_active_layer: FArray[DH, F],
weight_same_side_ghost_layer: FArray[DH, F],
weight_opposite_side_active_layer: FArray[DH, F],
weight_opposite_side_ghost_layer: FArray[DH, F],
side: Literal["left", "right"],
metadata: dict[str, Any],
) -> NDArray[FloatT]:
return cast("NDArray[FloatT]", same_side_active_layer - same_side_ghost_layer)
) -> FArray[DH, F]:
return same_side_active_layer - same_side_ghost_layer # pyright: ignore[reportReturnType]


def periodic_boundary(
same_side_active_layer: NDArray[FloatT],
same_side_ghost_layer: NDArray[FloatT],
opposite_side_active_layer: NDArray[FloatT],
opposite_side_ghost_layer: NDArray[FloatT],
weight_same_side_active_layer: NDArray[FloatT],
weight_same_side_ghost_layer: NDArray[FloatT],
weight_opposite_side_active_layer: NDArray[FloatT],
weight_opposite_side_ghost_layer: NDArray[FloatT],
same_side_active_layer: FArray[DH, F],
same_side_ghost_layer: FArray[DH, F],
opposite_side_active_layer: FArray[DH, F],
opposite_side_ghost_layer: FArray[DH, F],
weight_same_side_active_layer: FArray[DH, F],
weight_same_side_ghost_layer: FArray[DH, F],
weight_opposite_side_active_layer: FArray[DH, F],
weight_opposite_side_ghost_layer: FArray[DH, F],
side: Literal["left", "right"],
metadata: dict[str, Any],
) -> NDArray[FloatT]:
return cast("NDArray[FloatT]", same_side_active_layer + opposite_side_ghost_layer)
) -> FArray[DH, F]:
return same_side_active_layer + opposite_side_ghost_layer # pyright: ignore[reportReturnType]


_base_registry: dict[str, BoundaryRecipeT] = {
Expand Down
Loading
Loading