Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RodMeshSurfaceContact class init #294

Conversation

Rahul-JOON
Copy link
Contributor

@Rahul-JOON Rahul-JOON commented Aug 24, 2023

This PR attempts to add the Rod - Mesh Surface contact class init function in elastica.
The approach for the class has been sourced from dev_snake_contact branch as mentioned in #290

@codecov-commenter
Copy link

codecov-commenter commented Aug 24, 2023

Codecov Report

Patch coverage is 19.65% of modified lines.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files Changed Coverage
elastica/surface/__init__.py ø
elastica/contact_utils.py 7.27%
elastica/contact_forces.py 12.24%
elastica/mesh/mesh_initializer.py 100.00%
elastica/surface/mesh_surface.py 100.00%

📢 Thoughts on this report? Let us know!.

@Rahul-JOON Rahul-JOON marked this pull request as ready for review August 24, 2023 16:21
@bhosale2 bhosale2 requested a review from Ali-7800 August 24, 2023 17:20
@bhosale2 bhosale2 added enhancement New feature or request prio:high Priority level: high labels Aug 24, 2023
@armantekinalp
Copy link
Contributor

@Rahul-JOON can you format the code and push again. We resolve one conflict on browser and did not run the formatting

elastica/contact_forces.py Outdated Show resolved Hide resolved
elastica/contact_forces.py Outdated Show resolved Hide resolved
self.face_idx_array,
self.element_position,
) = find_contact_faces_idx(
self.facets_grid,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently your contact class has no facets_grid or grid_size attributes. Look at surface_import_and_grid.py in dev_snake_contact to see how to create the grid and calculate the grid_size. Basically what the grid does is that it allows us to determine which surface faces are in contact with the rod without doing a search. This is done by making the grid_size small enough so that only one rod element at most can fit in the grid square, which means we can figure out which grid squares the rod element is in by knowing only the rod element position. Since the surface does not move we know exactly where the faces are in relation to the grid, hence we can figure which faces are in contact with each element.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the insight! I'll add the attributes.

elastica/contact_utils.py Outdated Show resolved Hide resolved
elastica/surface/mesh_surface.py Outdated Show resolved Hide resolved
elastica/contact_forces.py Outdated Show resolved Hide resolved
elastica/contact_forces.py Outdated Show resolved Hide resolved
elastica/contact_forces.py Show resolved Hide resolved
Copy link
Contributor

@armantekinalp armantekinalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments

lengths,
):
"""
This function computes the plane force response on the element, in the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I will update this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update this doc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on what should we update?

elastica/contact_utils.py Outdated Show resolved Hide resolved
examples/Binder/1_Timoshenko_Beam.ipynb Outdated Show resolved Hide resolved
examples/Binder/2_Slithering_Snake.ipynb Outdated Show resolved Hide resolved
@armantekinalp armantekinalp removed the request for review from skim0119 August 29, 2023 13:26
@Rahul-JOON Rahul-JOON mentioned this pull request Sep 8, 2023
@Rahul-JOON Rahul-JOON mentioned this pull request Sep 9, 2023
elastica/contact_utils.py Outdated Show resolved Hide resolved
Copy link
Contributor

@armantekinalp armantekinalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good one minor comment

lengths,
):
"""
This function computes the plane force response on the element, in the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update this doc

Copy link
Collaborator

@Ali-7800 Ali-7800 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of changes.

return dict(
surface_grid_numba(
faces, grid_size, face_x_left, face_x_right, face_y_down, face_y_up
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better if you made this a function of both the mesh_surface and the rod instead of faces and grid_size. First, calculate the grid size based on the rod dimensions (calculation is in surface_import_and_grid.py, you can use it to write a function for that). Second, get the faces from the mesh_surface and use that with the grid_size in surface_grid_numba. Lastly, add the metadata for the grid from the mesh_surface before returning. Something like:
faces_grid["grid_size"] = grid_size
faces_grid["model_path"] = model_path
faces_grid["mesh_scale"] = mesh_scale
faces_grid["surface_orientation"] = surface_orientation

self.k = k
self.nu = nu
self.faces_grid = faces_grid
self.grid_size = grid_size
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of requesting grid_size as input for the class, include it in the faces_grid "metadata". I explain it later in a different comment on the faces_grid generation. This should be something like self.grid_size = faces_grid["grid_size"]

)
)

elif not faces_grid["grid_size"] == grid_size:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I would do here is check if the faces_grid["grid_size"] == max(2*system_one.radius[0],system_one.rest_lengths[0]). Essentially, checking if the grid_size of faces_grid is appropriate for the given rod.

"Imported grid's model path does not match with the current mesh_surface model path. "
)

elif not faces_grid["surface_reorient"] == system_two.mesh_orientation:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change "surface_reorient" to "mesh_orientation"


elif not faces_grid["surface_reorient"] == system_two.mesh_orientation:
raise TypeError(
"Imported grid's surface orientation does not match with the current mesh_surface rientation. "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Imported grid's surface orientation does not match with the current mesh_surface rientation. "
"Imported grid's surface orientation does not match with the current mesh_surface orientation. "

@Ali-7800 Ali-7800 changed the base branch from update-0.3.2 to 290_Mesh_Demonstration_temp October 2, 2023 22:55
@Ali-7800 Ali-7800 merged commit 1092485 into GazzolaLab:290_Mesh_Demonstration_temp Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request prio:high Priority level: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants