Skip to content

Commit

Permalink
removed *args and *kwargs from apply_contact(), removed normal force …
Browse files Browse the repository at this point in the history
…in rod-cylinder and rod-sphere contact
  • Loading branch information
Ali-7800 committed Oct 3, 2023
1 parent cfa6d02 commit 4c10f38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 36 deletions.
35 changes: 4 additions & 31 deletions elastica/contact_forces.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,6 @@ def _calculate_contact_forces_rod_cylinder(
if gamma < -1e-5:
continue

rod_elemental_forces = 0.5 * (
external_forces_rod[..., i]
+ external_forces_rod[..., i + 1]
+ internal_forces_rod[..., i]
+ internal_forces_rod[..., i + 1]
)
equilibrium_forces = -rod_elemental_forces + external_forces_cylinder[..., 0]

normal_force = _dot_product(equilibrium_forces, distance_vector)
# Following line same as np.where(normal_force < 0.0, -normal_force, 0.0)
normal_force = abs(min(normal_force, 0.0))

# CHECK FOR GAMMA > 0.0, heaviside but we need to overload it in numba
# As a quick fix, use this instead
mask = (gamma > 0.0) * 1.0
Expand Down Expand Up @@ -292,6 +280,7 @@ def _calculate_contact_forces_rod_rod(

equilibrium_forces = -rod_one_elemental_forces + rod_two_elemental_forces

"""FIX ME: Remove normal force and tune rod-rod contact example"""
normal_force = _dot_product(equilibrium_forces, distance_vector)
# Following line same as np.where(normal_force < 0.0, -normal_force, 0.0)
normal_force = abs(min(normal_force, 0.0))
Expand Down Expand Up @@ -472,18 +461,6 @@ def _calculate_contact_forces_rod_sphere(
if gamma < -1e-5:
continue

rod_elemental_forces = 0.5 * (
external_forces_rod[..., i]
+ external_forces_rod[..., i + 1]
+ internal_forces_rod[..., i]
+ internal_forces_rod[..., i + 1]
)
equilibrium_forces = -rod_elemental_forces + external_forces_sphere[..., 0]

normal_force = _dot_product(equilibrium_forces, distance_vector)
# Following line same as np.where(normal_force < 0.0, -normal_force, 0.0)
normal_force = abs(min(normal_force, 0.0))

# CHECK FOR GAMMA > 0.0, heaviside but we need to overload it in numba
# As a quick fix, use this instead
mask = (gamma > 0.0) * 1.0
Expand Down Expand Up @@ -623,7 +600,7 @@ def _check_systems_validity(
"If you want self contact, use RodSelfContact instead"
)

def apply_contact(self, system_one: RodType, system_two: RodType, *args, **kwargs):
def apply_contact(self, system_one: RodType, system_two: RodType):
# First, check for a global AABB bounding box, and see whether that
# intersects

Expand Down Expand Up @@ -742,9 +719,7 @@ def _check_systems_validity(
)
)

def apply_contact(
self, system_one: RodType, system_two: SystemType, *args, **kwargs
):
def apply_contact(self, system_one: RodType, system_two: SystemType):
# First, check for a global AABB bounding box, and see whether that
# intersects
if _prune_using_aabbs_rod_cylinder(
Expand Down Expand Up @@ -846,9 +821,7 @@ def _check_systems_validity(
)
)

def apply_contact(
self, system_one: RodType, system_two: RodType, *args, **kwargs
) -> None:
def apply_contact(self, system_one: RodType, system_two: RodType) -> None:
_calculate_contact_forces_self_rod(
system_one.position_collection[
..., :-1
Expand Down
6 changes: 1 addition & 5 deletions elastica/modules/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _finalize_contact(self) -> None:
self._systems[second_sys_idx],
)

def _call_contacts(self, *args, **kwargs):
def _call_contacts(self):
for (
first_sys_idx,
second_sys_idx,
Expand All @@ -83,8 +83,6 @@ def _call_contacts(self, *args, **kwargs):
contact.apply_contact(
self._systems[first_sys_idx],
self._systems[second_sys_idx],
*args,
**kwargs,
)


Expand Down Expand Up @@ -118,8 +116,6 @@ def __init__(
self.first_sys_idx = first_sys_idx
self.second_sys_idx = second_sys_idx
self._contact_cls = None
self._args = ()
self._kwargs = {}

def using(self, contact_cls: object, *args, **kwargs):
"""
Expand Down

0 comments on commit 4c10f38

Please sign in to comment.