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

Drop null prisms when converting a prism layer to pyvista #393

Merged
merged 7 commits into from
Mar 22, 2023

Conversation

santisoler
Copy link
Member

@santisoler santisoler commented Mar 14, 2023

Add an optional drop_null_prisms flag to the prism layer to_pyvista() method that ditches the prisms that have zero volume or nan values in their top or bottom boundaries. These null prisms won't be included in the PyVista Unstructured grid. By default the flag is set to True. Add a new test for this new feature.

Relevant issues/PRs:

Fixes #392

Copy link
Member

@mdtanker mdtanker 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 and will definitely be helpful! One question. Why not drop null prisms by default? It shouldn't change the results, but it will avoid errors if you pass a prism layer with nan's. We could drop the drop_null_prisms argument altogether and just check the prism layer for nans at each call to to_pyvista. Happy with your implementation just curious about your thought process.

@santisoler
Copy link
Member Author

This looks good and will definitely be helpful! One question. Why not drop null prisms by default? It shouldn't change the results, but it will avoid errors if you pass a prism layer with nan's.

Thanks! I wasn't 100% sure about it. I was thinking mainly when plotting a topography, it might be weird to have a "hole" where the prism has a zero thickness. Now that I put it into words, it's weird to say that I'm actually plotting a prism that has no volume 😕

We could drop the drop_null_prisms argument altogether and just check the prism layer for nans at each call to to_pyvista. Happy with your implementation just curious about your thought process.

Sure! I totally forgot that the top and bottom arrays could have nans. We should totally remove those prisms too. I'll push a commit to fix that right away.

Include prisms that have either a top or bottom boundary equal to nan
into the list of null prisms. Update tests to include them as well.
@santisoler
Copy link
Member Author

What do you think @mdtanker? Should we set drop_null_prisms=True as default?

@mdtanker
Copy link
Member

Those changes look good. I'd vote for drop_null_prisms=True by default. I just tried with a few grids and they look sort of strange with the null prisms included.

@santisoler
Copy link
Member Author

santisoler commented Mar 21, 2023

I've just changed the defaults to drop_null_prisms=True. @mdtanker, let me know what you think.

The documentation building is failing for some reason... I'll check that out before merging this.

@mdtanker
Copy link
Member

Looks good, merge away!

@santisoler santisoler changed the title Add option to drop prisms with zero volume when converting to pyvista Drop prisms with zero volume when converting to pyvista Mar 22, 2023
@santisoler santisoler changed the title Drop prisms with zero volume when converting to pyvista Drop prisms with zero volume when converting a prism layer to pyvista Mar 22, 2023
@santisoler santisoler changed the title Drop prisms with zero volume when converting a prism layer to pyvista Drop null prisms when converting a prism layer to pyvista Mar 22, 2023
@santisoler santisoler merged commit f6d6a1e into main Mar 22, 2023
@santisoler santisoler deleted the pyvista-prism-no-volume branch March 22, 2023 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pyvista plot zero volumn
2 participants