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

Add get/set_mesh_smoothing to python bindings. #14549

Merged
merged 1 commit into from Dec 12, 2022

Conversation

adamqc
Copy link
Contributor

@adamqc adamqc commented Dec 8, 2022

No description provided.

Copy link
Member

@Rombur Rombur left a comment

Choose a reason for hiding this comment

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

This looks good. It would be nice if instead of exposing an integer, we would use an enum (see here). Do you think that you could do it?

@Rombur
Copy link
Member

Rombur commented Dec 8, 2022

/rebuild

@adamqc
Copy link
Contributor Author

adamqc commented Dec 9, 2022

I would like to have a try.

@adamqc
Copy link
Contributor Author

adamqc commented Dec 9, 2022

I added the enum dealii.MeshSmoothing to the python bindings. Besides, I added two default arguments mesh_smoothing and check_for_distorted_cells to the constructor of Triangulation. Note that I still use int as the type of smoothing. The reason is that sometimes we may use the bitwise or result of several enums, which can not be converted to python enum.

The following python code works on my machine.

import PyDealII.Release as dealii

tria = dealii.Triangulation('2D', '3D', mesh_smoothing=dealii.MeshSmoothing.none, check_for_distorted_cells=False)
print(tria.get_mesh_smoothing())
tria.set_mesh_smoothing(dealii.MeshSmoothing.maximum_smoothing)
print(tria.get_mesh_smoothing())

tria = dealii.Triangulation('3D')
print(tria.get_mesh_smoothing())
tria.set_mesh_smoothing(dealii.MeshSmoothing.limit_level_difference_at_vertices)
print(tria.get_mesh_smoothing())

tria = dealii.Triangulation('3D', dealii.MeshSmoothing.limit_level_difference_at_vertices | dealii.MeshSmoothing.do_not_produce_unrefined_islands)
print(tria.get_mesh_smoothing())

Feel free to point out if I am doing something wrong.

@Rombur
Copy link
Member

Rombur commented Dec 9, 2022

This is great. Can you take the python code you used to check the code and add it as a test here

@adamqc
Copy link
Contributor Author

adamqc commented Dec 10, 2022

This PR is ready for review now.

@Rombur
Copy link
Member

Rombur commented Dec 12, 2022

Thanks a lot for the PR

@Rombur Rombur merged commit e79fc0f into dealii:master Dec 12, 2022
@adamqc adamqc deleted the python-mesh-smoothing branch December 12, 2022 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants