- Result files: Importing simulation results from supported file formats
- Direct user input: Creating DPF data structures programmatically from scratch
Import data from result files
What file formats are supported
DPF supports result files from multiple ANSYS solvers:
For the official list of supported file formats and versions, see the DPF Framework documentation.
Why this matters: DPF provides a unified interface for all these formats.
The same code can extract displacement from a MAPDL .rst file or temperature from a Fluent .cas.h5 file.
How to access result files: DataSources
A DataSources is an object that references result file locations and manages access to their data. It stores file paths and provides this information to DPF operators that need to read the files. What it does: Points to where your result files are located What it doesn’t do: It doesn’t load or parse the data itself (that’s done by operators) Example with a single file:When to use streams: StreamsContainer
A StreamsContainer is an object that keeps result files open and caches data to improve performance for repeated access. When to use it:- Working with large files where repeated file opening is slow
- Running multiple operations on the same data
- Performance is critical
- Single-pass operations
- Small files
- Quick data exploration
Streams keep files open
AStreamsContainer holds open file handles for every file it references, for as long as it exists.
This means the associated files cannot be moved, deleted, or written to by another process while the streams are open.
Streams are closed automatically when the StreamsContainer Python object is deleted (garbage collected).
If you need to release the files earlier, close the streams explicitly:
Exploring data with Model
A Model is a helper object that provides high-level access to result file contents. It automatically reads file metadata and creates convenient methods to extract results, mesh, and analysis information. What Model provides:- Automatic detection of available results
- Easy access to mesh information
- Analysis metadata (units, analysis type, time steps)
- Simplified syntax for common operations
- Automatic creation and management of streams
- Analysis type: Static, transient, modal, etc.
- Unit system: How values are measured (includes length, mass, force, time, voltage, current)
- Available results: Shows result name, location (Nodal/Elemental/ElementalNodal), and physical description
- Meshed Region: Node and element counts with spatial units
- Time/Freq Support: Information about time steps or frequencies in the analysis
Quick reference: When to use what
Recommended approach:
- Model: Use for interactive data exploration, prototyping, and common analysis tasks where convenience is prioritized over performance.
- DataSources + operators: Use for single-pass workflows or during workflow development when explicit control over data flow is required without implicit caching or optimizations.
- DataSources + Streams + operators: Use for production workflows requiring optimal performance through file caching and repeated data access.
Import data from user input
To create DPF data structures from scratch (without result files), you build fields, scopings, and supports programmatically. This allows you to use DPF for custom data or non-ANSYS sources. When you’d do this:- Importing experimental data
- Custom simulations outside ANSYS
- Synthetic test data
- Combining data from multiple sources
Exercise: Import and explore a result file
Task: Useexamples.download_transient_result() to get a transient mechanical result file, then practice creating a DataSources, a StreamsContainer, and a Model. Explore the model contents and extract key metadata.
- Import the necessary modules
- Get the result file path using
examples.download_transient_result() - Create a
DataSourcespointing to the file and print it - Create a
StreamsContainerfrom theDataSources - Create a
Modelfrom theDataSourcesand print it - Print the number of nodes in the mesh and the number of time steps