ansys / pyensight

Python API for EnSight
http://ensight.docs.pyansys.com
MIT License
6 stars 2 forks source link

Move the net_force tool from EnSight to PyEnSight #353

Closed mariostieriansys closed 8 months ago

mariostieriansys commented 8 months ago

This is the first step of moving the net_force tool from EnSight to PyEnSight.

All the functions needed for computing the forces and exporting the forces to a csv file have been converted to PyEnSight functions.

As part of the process:

  1. Some ens_utils functions needed porting, so you will find them among the new functions
  2. I choose to make some functions "private", mostly the ones that are actually doing the force computation in EnSight. This is because I then created a one, centralized function "compute_forces" which is the one customers should use. The net_force tool in EnSight will call the "private" functions to do the computation
  3. There are, anyway, some functions which I kept "public", like get_const_val and similar. They have a purpose for customers so it was nice to leave them public

You will find some area where I had to do odd tricks to make mypy happy. Mostly this has been happening with the output of functions like "get_const_val", which can either output a float or a List of floats. mypy just doesn't know what will get so, depending on the moment it got called, where I knew the kind of output, I just made mypy understand what was the right return type. There are other examples though, and I believe I have added comments in the code to highlight it. So don't panic if some code seems weird or "useless"

The second step after this will be to heavily simplify the extension in EnSight so that it calls this new code instead of doing the computations by itself

I have also created a unit test exercising it, using the RC Plane which is downloaded from the example-data repo. Since in this case we are downloading a folder, and not just a file, I have modified the download_pyansys_example interface so that you can tell it to download the full folder supplied, and change the script executed remotely accordingly