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

cython._binary_reader: cells_with_*_nodes: Generalize and simplify by directly using offset for next cell offset; close: _file_out does not exist; correct pyvista version check for version 0.32.dev0 #74

Merged
merged 8 commits into from
Nov 8, 2021

Conversation

beppo-dd
Copy link
Contributor

@beppo-dd beppo-dd commented Oct 13, 2021

Fixes of cython._binary_reader

  1. cells_with_*_nodes: Generalize and simplify by directly using offset for next cell offset

    • Therefore the function cell_lookup, which was limited to 3D cells, is no longer necessary.
    • Now, all cell types are supported, while the functions has even been simplified.
    • Now, the functions do not need the parameter celltypes any more. Since they are only used in rst.py in the private method Result._extract_node_components, I took the liberty to remove the parameter celltypes in the respective definition and the respective call.
    • This commit 62edb6a is written with minimal changes for a clear diff. Of course, one could optimize the speed by omitting the double call of offset[i+1] first and offset[i] in the next loop step.
    • Sorry: I make a mistake in commit 62edb6a (I can not compile locally, as a have no C++ compiler installed), ae3a88e is needed to correct this.
  2. close: _file_out does not exist: When you called AnsysFile.close() you got at line 255 del self._file_out: 'ansys.mapdl.reader._binary_reader.AnsysFile' object has no attribute '_file_out' as _file_out is never created (this line is the only occurrence). Thus, I removed this line in commit 1c6351e.

Remark: Only tested with a pure python version of the functions, please test the cython functions of this commit!

Fix of Result._plot_point_scalars (improvement for 1c00879)

  1. Result._plot_point_scalars: correct pyvista version check for version 0.32.dev0: The actual development version is 0.32.dev0: pv._version.version_info = (0, 32, "dev0"). There, the string "dev0" can not be compared with 0, so that comparison failed for this version. I removed the last element on the right-hand side expression of the comparison to solve this. Now, the new comparison (0, 32, "dev0") > (0, 32) works as expected. Commit 3f6e296 was tested manually.

... before, it was used only, when `if animate`. Now, it used in any case of the call `plotter.show`.
pyvista\plotting\plotting.py:4882: On Windows OS "in the event that the user hits
the exit-button on the GUI then it must be finalized and deleted as accessing it
will kill the kernel... proper screenshots cannot be saved if this happens"
Therefore, when you used ´_plot_point_scalars(..., screenshot=...)´, you got at
ansys\mapdl\reader\rst.py:2830:
´RuntimeError: This plotter is closed and unable to save a screenshot.´

The only solution is, to pass the ´screenshot´ argument to ´plotter.show´
as done in this patch.
... the old version would break with version 1.0.0.
I used the same compare operation as in
<https://github.com/rbarrois/python-semanticversion/blob/master/semantic_version/base.py>
tested manually.
…directly using `offset` for next cell offset

- Therefore the function `cell_lookup`, which was limited to 3D cells, is no longer necessary.
- Now, all cell types are supported, while the functions has even been simplified.
- Now, the functions do not need the parameter `celltypes` any more. Since they are only used in rst.py in the private method `Result._extract_node_components`, I took the liberty to remove the parameter A in the respective definition und the respective call.

Remark: Only tested with a pure python version of the functions, please test the cython function of the commit!
When you called `AnsysFile.close()` you got at line 255

   'ansys.mapdl.reader._binary_reader.AnsysFile' object has no attribute '_file_out'

as `_file_out` is never created (this line is the only occurrence).
@beppo-dd beppo-dd changed the title cython._binary_reader.cells_with_*_nodes: Generalize and simplify by directly using offset for next cell offset cython._binary_reader: cells_with_*_nodes: Generalize and simplify by directly using offset for next cell offset; close: _file_out does not exist Oct 25, 2021
… 0.32.dev0

The actual development version is 0.32.dev0: `pv._version.version_info = (0, 32, "dev0")`. There, the string `"dev0"` can not be compared with `0`, so that comparison failed for this version. To solve this, I removed the last element on the right-hand side expression of the comparison. The new comparison `(0, 32, "dev0") > (0, 32)` works now as expected. Tested manually.
@beppo-dd beppo-dd changed the title cython._binary_reader: cells_with_*_nodes: Generalize and simplify by directly using offset for next cell offset; close: _file_out does not exist cython._binary_reader: cells_with_*_nodes: Generalize and simplify by directly using offset for next cell offset; close: _file_out does not exist; correct pyvista version check for version 0.32.dev0 Oct 26, 2021
@akaszynski
Copy link
Collaborator

LGTM. With pyvista==0.32.0 out, I'm calling this good to merge.

@akaszynski akaszynski merged commit 5658ddf into ansys:main Nov 8, 2021
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.

2 participants