ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
424 stars 120 forks source link

Documentation / wrapping of the VTK interfaces #377

Open CesarRodriguezPereira opened 3 years ago

CesarRodriguezPereira commented 3 years ago

Pyansys already has great VTK export capabilities, as it uses VTK for representation already. But it doesn't have a documented way to export either geometries, meshes or results to vtk, which adds a lot of functionality (in my case, creating raytraced renders of my structure in paraview).

These exports are already possible. For area geometry you can export through the use of mapdl.geometry.generate_surface().save(), and at the mesh level you can export through the use of mapdl.mesh._grid.save() (I'm guessing the results are also exportable in this way, but I haven't gotten there yet).

Both of this interfaces to the unstructured grid object (and subsequently, its save() function) I found by looking at the code of mapdl.eplot() and mapdl.aplot(). My suggestion is to either document how to get these vtk objects (just giving "publicity" to the already existing interfaces) and then refering to the pyvistas documentation for further processing, or create a simple wrapper function of the save method at the geometry and mesh level (mapdl.geometry.export_vtk() and mapdl.mesh.export_vtk()). Giving publicity to these features through the docs (making it obvious that pyansys can already do this) would probably attract new users, as vtk is already widely used for postprocessing purposes.

PS: I know I'm making a lot of issues related to features and design of the library itself lately. If you want me to tone it down and keep the issue board only for functionality/serious issues, please tell me.

akaszynski commented 3 years ago

PS: I know I'm making a lot of issues related to features and design of the library itself lately. If you want me to tone it down and keep the issue board only for functionality/serious issues, please tell me.

The more the merrier. I just have to work on the documentation to make this useful. Good on you to dig through the code to figure out how to implement this on your own, but I need to clean up the APIs. Working on this right now in #376.

Results are indeed exportable via VTK, and those APIs need to be exposed as well. I feel these are critical features as we need to make MAPDL usable in a broad set of applications, not just confined to the MAPDL world.

akaszynski commented 3 years ago

Actually, along those lines, if you could create list of features you need to make MAPDL more accessible from VTK, I'd really appreciate that. GitHub lets you create cool lists with check boxes:

I can then either start ticking them off one at a time, or get them in one go with a single PR. Also, If possible I'd like you to look over the APIs to make sure they fit your needs.

CesarRodriguezPereira commented 3 years ago

As of now I haven't yet gotten to result exploration in my project, but I plan to have some initial results to explore in a couple of weeks, so I will make that checklist then, once I'm more familiar with how the existing VTK support works, so the list is as useful as I can make it.

akaszynski commented 3 years ago

I'll keep working on the API and add documentation/examples along the way. You can evaluate it in a few weeks once I've merged the PR, pushed the next minor/patch release, and let the dust settle.

akaszynski commented 3 years ago

Hi @CesarRodriguezPereira, would it be possible to add specific features you'd like documented or exposed? Ready to update the docs right now.

CesarRodriguezPereira commented 3 years ago

Hi @akaszynski.

I think the main thing to document as far as VTK goes would be how to work with mapdl.mesh._grid and storing model results in that grid. There is already an (example)[https://mapdldocs.pyansys.com/examples/00-mapdl-examples/transient_thermal.html] in the docs, where the nodal temperatures are saved to the grid, but explicit documentation would be great.

With this process of storing solutions in the VTK explained in the docs and a link to the pyvista docs (so people can learn about the object they're creating, how to save to a file, how to make custom plots, etc), I think the exporting process would be perfectly documented.

CesarRodriguezPereira commented 3 years ago

Hi @akaszynski After having worked longer with pyansys I finally have a few things that would make the VTK interfacing a bit better:

These are the main things that I think would make the vtk interface a lot better, giving a bit more control to the user, and would allow end users to make better stuff with these vtks (quicker export for postprocessing in programs such as paraview, or embeding vtk plots/animations on websites, these kinds of things).

PS: I don't know if any of these are already implemented, right now I'm using 0.58.5 so I'm a bit behind

natter1 commented 3 years ago

355

germa89 commented 2 years ago

Pinging @akaszynski for updates.

akaszynski commented 2 years ago

Pinging @akaszynski for updates.

We just need a separate section for this. Once I'm done with the SciPy tutorial ping me.

germa89 commented 2 years ago

pinging @akaszynski

germa89 commented 7 months ago

I think the main thing to document as far as VTK goes would be how to work with mapdl.mesh._grid and storing model results in that grid.

Key point here. It seems you want to have an easy way to take a model (pyvista mesh) and add values, and then later plot them. I agree we should document those.

@akaszynski @CesarRodriguezPereira I will taking over this issue (as all the others).

I'm not sure how much time I will be able to commit to this though.