Skip to main content

How to rebuild Ansys .rst files saved without geometry

mark.capellaro… | 10.27.2026

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.

from ansys.mapdl.core import launch_mapdl
import os
ansysVersion = 261
here = os.getcwd()
model_name = 'BOX'
limit_rst = 0 # 1 = Do not write geometry to file, else 0
# parameters
x = 1.000 # create a square block
numElem = 1000 # to control model size
loadDirection = 'x'
maxDisp = 10.0 # percentage of loadDirection dimension for maximum displacement
n_steps = 3 # number of load steps
### modeling
elemSize = ((x**3)/numElem)**(1/3)
### Launch pymapdl
mapdl = launch_mapdl(version = ansysVersion, run_location = here, override=True)
mapdl.filname(model_name)
mapdl.config(lab = 'NORSTGM', val = limit_rst )

mapdl.prep7()
### Materials
mapdl.mp('EX', 1, 200e9)
mapdl.mp('PRXY', 1, 0.3)
### Geometry
mapdl.blc4(0, 0,x, x, x)
#### Elements and meshing
mapdl.et(1, 'SOLID186')
mapdl.type(1)
mapdl.esize(elemSize)
mapdl.vmesh('ALL')
### Create some components/name selections
mapdl.nsel('S', 'LOC', loadDirection, x)
mapdl.cm('LOADNODES','NODE')
mapdl.allsel()
### Boundary Conditions: fixed
mapdl.nsel('S', 'LOC', loadDirection, 0)
mapdl.d('ALL','ALL')
mapdl.allsel()
#### Solve
mapdl.solution()
for i in range( 1 , n_steps + 1 ):
    mapdl.time(i)
    deformation = i * ( -maxDisp/100 * x ) / ( n_steps )
    mapdl.d('LOADNODES', 'UX', deformation)
    mapdl.solve()

mapdl.exit(force=True)

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.

from ansys.mapdl.core import launch_mapdl
import os
version = 261
file_name = 'BOX'
temp_rst = 'temp'
here  = os.getcwd()
mapdl = launch_mapdl(version = version, run_location = here,  override=True)
database = mapdl.resume(file_name + '.db')
mapdl.post1()
mapdl.inres('ALL')
mapdl.file(file_name + '.rst')
n_sets = int(mapdl.get(entity='ACTIVE',item1='SET',it1num='NSET'))
for i in range(1, n_sets + 1):
    mapdl.set(i)
    mapdl.reswrite(temp_rst)
mapdl.exit(force=True)

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').

from ansys.dpf import core as dpf
import os
version = 261
result_file = 'temp.rst'
here = os.getcwd()
path = os.path.join( here, result_file )
# start dpf
server = dpf.start_local_server(ansys_path=r"C:\\Program Files\\ANSYS Inc\\v{v}".format(v=version))
# What I want to plot
time_steps = [1 , 2] # Set to any existing time step
plot_types = ['displacement','stress_von_mises','elastic_strain_eqv'] # should be existing results
# import the model/rst using dpf
model = dpf.Model( path )
#print(model)
metadata1 = model.metadata
# use the model data to determine what is available in the .rst file
# The resultDict has the available data as key (category) and plottype (sub-category or item/value)
# In the end only the plottype is used for plotting below
resultsSets = model.metadata.time_freq_support.n_sets
resultSetList = [str(i) for i in range(resultsSets)]
results = [i.name for i in  metadata1.result_info.available_results]
fullList = dir(dpf.operators.result)
resultDict = {}
for resultkey in results:
    resultDict[resultkey] = [i for i in fullList if resultkey in i and 'compute' not in i]
# Export csv operator
export_csv_operator = dpf.operators.serialization.field_to_csv()
for plot_type in plot_types:
    for time_step in time_steps:
        # plot commands using data from above
        time_sets_scoping = dpf.time_freq_scoping_factory.scoping_by_sets([time_step])
        resOp = getattr(dpf.operators.result, plot_type)(data_sources = model, time_scoping = time_sets_scoping)
        resOpFieldContainer = resOp.outputs.fields_container()[0]
        save_name = plot_type + '_step_' + str(time_step)
        # Export image png
        model.metadata.meshed_region.plot(
            resOpFieldContainer,
            notebook = False,
            text = plot_type + ' - Time Step : '  + str(time_step),
            off_screen = True,
            screenshot = save_name + '.png'
            )
        # Export csv
        export_csv_operator.inputs.field_or_fields_container.connect(resOp)
        export_csv_operator.inputs.file_path.connect(save_name + '.csv')
        export_csv_operator.run()

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.

Connect with Ansys