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 clean unstructured grid #4367

Merged
merged 3 commits into from
May 3, 2023
Merged

Add clean unstructured grid #4367

merged 3 commits into from
May 3, 2023

Conversation

akaszynski
Copy link
Member

Resolve #4345 by adding clean for UnstructuredGrid.

Also addresses the issues raised in #4357.

Demonstrate cleaning an UnstructuredGrid and show how it can be used to
average the point data across merged points.

>>> import pyvista as pv
>>> from pyvista import examples
>>> hexbeam = examples.load_hexbeam()
>>> hexbeam_shifted = hexbeam.translate([1, 0, 0])
>>> hexbeam.point_data['data'] = [0]*hexbeam.n_points
>>> hexbeam_shifted.point_data['data'] = [1]*hexbeam.n_points
>>> merged = hexbeam.merge(hexbeam_shifted, merge_points=False)
>>> cleaned = merged.clean(average_point_data=True)
>>> cleaned  # doctest:+SKIP
UnstructuredGrid (0x7f02930257e0)
  N Cells:    80
  N Points:   165
  X Bounds:   0.000e+00, 2.000e+00
  Y Bounds:   0.000e+00, 1.000e+00
  Z Bounds:   0.000e+00, 5.000e+00
  N Arrays:   5

Show how point averaging using the ``clean`` method with
``average_point_data=True`` results in averaged point data for merged
points.

>>> pl = pv.Plotter(shape=(1, 2))
>>> _ = pl.add_mesh(merged, scalars='data', show_scalar_bar=False)
>>> pl.subplot(0, 1)
>>> _ = pl.add_mesh(cleaned, scalars='data')
>>> pl.show()

image

@github-actions github-actions bot added the enhancement Changes that enhance the library label May 1, 2023
@codecov
Copy link

codecov bot commented May 1, 2023

Codecov Report

Merging #4367 (3c2a0f8) into main (caa1129) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #4367   +/-   ##
=======================================
  Coverage   95.81%   95.81%           
=======================================
  Files          97       97           
  Lines       20814    20828   +14     
=======================================
+ Hits        19942    19956   +14     
  Misses        872      872           

@akaszynski akaszynski mentioned this pull request May 1, 2023
6 tasks
@akaszynski akaszynski mentioned this pull request May 2, 2023
@akaszynski akaszynski merged commit d21e85c into main May 3, 2023
24 checks passed
@akaszynski akaszynski deleted the feat/clean-unstructured-grid branch May 3, 2023 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Changes that enhance the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants