Skip to content

Commit

Permalink
bug: fix issue that boudnary condition was not properly beling applied
Browse files Browse the repository at this point in the history
  • Loading branch information
skim0119 committed Jun 25, 2024
1 parent d3ddc66 commit df8477a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
18 changes: 12 additions & 6 deletions elastica/boundary_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from elastica._linalg import _batch_matvec, _batch_matrix_transpose
from elastica._rotations import _get_rotation_matrix
from elastica.typing import SystemType, RodType, RigidBodyType
from elastica.typing import SystemType, RodType, RigidBodyType, ConstrainingIndex


S = TypeVar("S")
Expand All @@ -34,18 +34,24 @@ class ConstraintBase(ABC, Generic[S]):
"""

_system: S
_constrained_position_idx: np.ndarray
_constrained_director_idx: np.ndarray
_constrained_position_idx: NDArray[np.integer]
_constrained_director_idx: NDArray[np.integer]

def __init__(self, *args: Any, **kwargs: Any) -> None:
def __init__(
self,
*args: Any,
constrained_position_idx: ConstrainingIndex,
constrained_director_idx: ConstrainingIndex,
**kwargs: Any,
) -> None:
"""Initialize boundary condition"""
try:
self._system = kwargs["_system"]
self._constrained_position_idx = np.array(
kwargs.get("constrained_position_idx", []), dtype=int
constrained_position_idx, dtype=np.int_
)
self._constrained_director_idx = np.array(
kwargs.get("constrained_director_idx", []), dtype=int
constrained_director_idx, dtype=np.int_
)
except KeyError:
raise KeyError(
Expand Down
8 changes: 7 additions & 1 deletion elastica/modules/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ def instantiate(self, system: "RodType | RigidBodyType") -> ConstraintBase:
)
try:
bc = self._bc_cls(
*positions, *directors, *self._args, _system=system, **self._kwargs
*positions,
*directors,
*self._args,
_system=system,
constrained_position_idx=self.constrained_position_idx,
constrained_director_idx=self.constrained_director_idx,
**self._kwargs,
)
return bc
except (TypeError, IndexError):
Expand Down

0 comments on commit df8477a

Please sign in to comment.