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

PoC / Paraview integration for mesh_doctor #2790

Closed
wants to merge 4 commits into from

Conversation

jafranc
Copy link
Contributor

@jafranc jafranc commented Nov 1, 2023

This is a test to leverage mesh_doctor in Paraview either as a Python Programmable Filter or a python plugin
A example is given for element_volumes check.
It is run over the unstructured version of spe11a join here.

screenshot-PVMeshDoctor

spe11a_mesh.zip

As a programmable filter

mesh_doctor has to be deploy in the Paraview python hierarchy so it is able to get the import path

As a python plugin

As examplified here, going through the loading procedure allow load and access to Mesh Doctor(GEOS) as a new filter (for now only volume check is available).

@jafranc jafranc requested a review from TotoGaz November 1, 2023 11:37
@jafranc jafranc marked this pull request as draft November 1, 2023 11:37
@jafranc jafranc self-assigned this Nov 1, 2023
@jafranc jafranc added type: feature New feature or request type: new A new issue has been created and requires attention labels Nov 1, 2023
@jafranc jafranc changed the title First steps of meshDoctor as a Programmable filter meshDoctor as a Paraview Python Programmable filter Nov 1, 2023
Copy link
Contributor

@TotoGaz TotoGaz left a comment

Choose a reason for hiding this comment

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

Thanks @jafranc, a really good start!
@jeannepellerin you may be interested in this PR!?

from checks import element_volumes
import vtk
#
res = element_volumes.__check(inputs[0].VTKObject, element_volumes.Options(tol))
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll need to change the name of __check 🤣
Also, if using inputs[0] is an issue, maybe mesh_doctor can evolve?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, going into private function is hacky 😛

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that will definitely be interesting for GEOS user working with external meshes.
@jafranc Have you considered Paraview Python plugin instead of Programmable Filter in Paraview?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not yet but will have a look

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps @AntoineMazuyer might be able to help on this

src/docs/sphinx/pythonTools/mesh_doctor.rst Outdated Show resolved Hide resolved
:linenos:

input0 = inputs[0]
tol = 1.2e-6
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know how to define tol from the GUI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That I think would remain to be set from the script. This would maybe possible via Plugin to have a QLineEdit (just guessing though)

print("There are {} cells under {} m3 vol".format(extracted.GetOutput().GetNumberOfCells(), tol))
output.ShallowCopy(extracted.GetOutput())

Here we rely on ``pyvtk`` interface more than on Paraview adaptation, for legacy and reusability reasons. This is the reason
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean that we cannot access vtkSelectionNode from within paraview?
We may want to find a way to detect that we're in the "paraview plugin env" to rely on the paraview vtk not to risk any conflict.
But the requirements.txt part remains. However, we'll move forward!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is exactly that. As I tried to launched it having from paraview import vtk instead of import vtk, I bumped into an error saying that there was no vtkSelectionNode. As Paraview is able to do the operation, I guess this is just that this is not exposed but wrapped. But there must be a way through Paraview, it is just a question of 1. I started from a pyvtk script, which I found more versatile but not Paraview compativle and 2. we might want to rewrite the script in a more Paraview way then.

Comment on lines +134 to +136
.. note::
``pip`` is installing the ``mesh_doctor`` package from the test.pypi repo, which is intended to test package deployment.
Once stabilized and ``mesh_doctor`` uploaded onto the main package repo, this should be dropped out.
Copy link
Contributor

Choose a reason for hiding this comment

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

image 😱 🤣

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hacky I said 😝

Copy link
Collaborator

Choose a reason for hiding this comment

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

is installing it like this working for you? When I tried it seemed to me that there were some issue in the setup.py that did not allow for this to work. Basically I could not find the modules when trying to import them.

Copy link
Contributor Author

@jafranc jafranc Nov 1, 2023

Choose a reason for hiding this comment

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

I got this output

Looking in indexes: https://test.pypi.org/simple/
Collecting mesh_doctor
  Downloading https://test-files.pythonhosted.org/packages/97/cc/1ece6916f6e87f95cff4b887f2e6ce50488b146a2e025a959c3665a12d6e/mesh_doctor-0.0.1-py3-none-any.whl (42 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.4/42.4 KB 2.1 MB/s eta 0:00:00
Installing collected packages: mesh_doctor
Successfully installed mesh_doctor-0.0.1

and I can checked afterwards that checks is in `/path/to/Paraview/lib/PythonX.X' but this need refactor/cleanup obv.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As a workaround you can try while being in mesh_doctor directory conatining the .toml

python3 -m pip install --upgrade build
python3 -m build

which should produce de dist/ directory with .whl and .tar.gz.

The install command on the .tar.gz might also work, as

python3 -m pip install dist/mesh_doctor-0.0.1.tar.gz --target /path/to/paraview/lib/pythonX.X'

@TotoGaz TotoGaz mentioned this pull request Nov 1, 2023
15 tasks
@TotoGaz TotoGaz added the EPIC - Mesh/mesh_doctor Improving the `mesh_doctor` tool label Nov 1, 2023
@jafranc jafranc changed the title meshDoctor as a Paraview Python Programmable filter PoC / Paraview integration for mesh_doctor Mar 27, 2024
@untereiner
Copy link
Contributor

mesh-doctor moved to https://github.com/GEOS-DEV/geosPythonPackages
I would suggest to move this PV plugin also their ? What do you think ?

@jafranc
Copy link
Contributor Author

jafranc commented Mar 27, 2024

mesh-doctor moved to https://github.com/GEOS-DEV/geosPythonPackages I would suggest to move this PV plugin also their ? What do you think ?

Of course, I am still figuring out few things but I definitively should move that there

@jafranc
Copy link
Contributor Author

jafranc commented Mar 27, 2024 via email

@jafranc jafranc assigned jafranc and unassigned jafranc Mar 27, 2024
@jafranc
Copy link
Contributor Author

jafranc commented Mar 27, 2024

Closed and moved to GEOS-DEV/geosPythonPackages#16

@jafranc jafranc closed this Mar 27, 2024
@jafranc jafranc deleted the jafranc/docs/meshDoctor-PVplugin branch April 11, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EPIC - Mesh/mesh_doctor Improving the `mesh_doctor` tool type: feature New feature or request type: new A new issue has been created and requires attention
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants