Skip to main content

Introduction

This blog post will describe a method to create Ansys result files when the geometry was not saved to the file and, for completeness, the method to write results minimized results files without geometry. We have had a couple customers come to us with the request to use the PyAnsys documentation tool PyDPF documentation to post process their Ansys Parametric Design Language (APDL) results. The customers in question are long time APDL users and their optimized workflows used the APDL /CONFIG command to not save the geometry to result file in order to save disc space. Using /CONFIG,NORSTGM,1 will cause the geometry not to be written to the .rst. However, using this command will create a .rst file that, by default, PyDPF can not post process. This challenge has been raised with the PyDPF team and, perhaps in the future, this will be natively possible. In the meantime, we have a work-around. The method is simply a modern Python adaptation of the known APDL method. For the script examples that follow, Python version 3.13 was used along with Ansys version 261, PyMAPDL 0.74, and PyDPF 0.16. The method itself is straightforward and no version dependency problems are expected.

PyMAPDL code to generate a .rst without geometry (not required)

If you want to see the useage of the /CONFIG command in PyMAPDL and then have a .rst file to test the rebuild method on, you can use the script below. It just creates a simple box model (blc4) and solves for n (here, 3) different displacements. The parameterization of the approximate number of elements (numElem) will help show the scale of the change of the .rst with the number of elements.
The simple analysis is sparsely documented since the only purpose is to generate a set of results that can be used in the second step. You can use the limit_rst parameter to see the difference between the scale of a .rst file with and without the geometry. Once this code snippet runs, you should have a .rst and a .db file in the same drive as the code or in the default Ansys directory.

PyMAPDL method to add geometry to a .rst file

The result file created using the script above will generate a .rst file without the geometry if the /CONFIG NORSTGM parameter is set to 1. By default, PyDPF can not post proccess that data. However, we can adapt the APDL method to rebuild a .rst with the geometry included in the .rst file. You will need to have the .db file and the .rst file to rebuild the .rst with geometry.
The snippet above rebuilds the .rst using the .db file to attach the geometry:
  • pymapdl.resume(.db) to bring in the geometry
  • mapdl.get(entity='ACTIVE',item1='SET',it1num='NSET') to return the number of steps to Python
  • mapdl.set(i) and mapd.reswrite(temp_name) to append the results to the new temp_name .rst
The result from this snippet is a new .rst with the geometry, which allows PyDPF to post process the file.

PyDPF method to generate results

The .rst generated from the snippet above is now readable in PyDPF and results can be generated. I posted some baseline script on the Ansys Developer Forum for getting started with PyDPF in PyDPF plots simplified and cannibalize that for a few lines of PyDPF to write images and comma-separated values (CSV) data to file. The method can be adapted to show the images on screen (change the offscreen to False and comment out the screenshot = save_name + '.png').
The snippet has a list of result types in the plot_types list. This is used with the getattr() command to append to the dpf.operators.result command. This will produce a .png file for every result type listed in the plot_types list and for each load or time step in the time_steps list. (If you have a large file, it will take time to write the .csv to file.)

Summary

Finite element analyses result files can become very large, especially with simulation results, meshes, computer-aided design (CAD) geometry and multiple design iterations. Keeping files as small as reasonably possible means removing redundant outputs, avoiding unnecessary duplication, using appropriate compression and saving only the resolution or result data that has continuing engineering value. This conserves shared disk capacity and makes files easier to move, archive and manage. By eliminating the geometry in the original .rst file post processing with PyDPF requires the extra step of re-generating new files with the geometry. But these can be generating on the fly, under a temporary name, and discarded after use. An optimized workflow would combine the 2nd and 3rd snippets above to generate the .rst with geometry and post process in the same loop. This example touches the surface of the possiblities to post process with PyDPF. For more involved result handling, please refer to the PyDPF documentation.