Read CFX .res files#

This example demonstrates how to read Ansys CFX .res files.

Note

This example requires DPF 7.0 (ansys-dpf-server-2024-1-pre0) or above. For more information, see Compatibility.

Exploring an Ansys CFX .res file#

The first part of the example demonstrates how you can load an Ansys CFX .res file in a model.

import ansys.dpf.core as dpf
from ansys.dpf.core import examples

path = examples.download_cfx_mixing_elbow()
model = dpf.Model(path)
print(model)
DPF Model
------------------------------
Static analysis
Unit system: SI: m, kg, N, s, V, A, K
Physics Type: Fluid
Available results:
     -  specific_heat: Nodal Specific Heat
     -  epsilon: Nodal Epsilon
     -  enthalpy: Nodal Enthalpy
     -  turbulent_kinetic_energy: Nodal Turbulent Kinetic Energy
     -  thermal_conductivity: Nodal Thermal Conductivity
     -  dynamic_viscosity: Nodal Dynamic Viscosity
     -  turbulent_viscosity: Nodal Turbulent Viscosity
     -  static_pressure: Nodal Static Pressure
     -  total_pressure: Nodal Total Pressure
     -  density: Nodal Density
     -  entropy: Nodal Entropy
     -  wall_shear_stress: Nodal Wall Shear Stress
     -  temperature: Nodal Temperature
     -  total_temperature: Nodal Total Temperature
     -  velocity: Nodal Velocity
Available qualifier labels:
     - zone: Default (5), main inlet (6), side inlet (7), outlet (8), Default 1 (1)
     - phase: <Mixture> (1), Water at 25 C (2)
------------------------------
DPF  Meshed Region:
  6219 nodes
  15695 elements
  Unit: m
  With solid (3D) elements
------------------------------
DPF  Time/Freq Support:
  Number of sets: 1
Cumulative     Frequency ()   LoadStep       Substep
1              0.000000       1              1

Exploring the mesh#

Explore the mesh through the MeshInfo. The MeshInfo provides metadata information about the mesh. For fluid models, it is useful to know the bodies and face zones, as well as the topological relationships between them. First get all the available information in the MeshInfo.

mesh_info = model.metadata.mesh_info
print(mesh_info)
DPF MeshInfo
------------------------------
with properties:
  num_nodes             int
  num_cells             int
  body_names            StringField
  body_cell_topology    PropertyField
  num_faces             int
  body_face_topology    PropertyField
  body_scoping          Scoping
  cell_zone_names       StringField
  cell_zone_elements    PropertyField
  face_zone_names       StringField
  cell_zone_scoping     Scoping
  face_zone_elements    PropertyField
  face_zone_scoping     Scoping
  zone_names            StringField
  num_elem_zone         PropertyField
  zone_scoping          Scoping
  splittable_by         StringField

The MeshInfo exposes several helpers, such as a dictionary of available bodies:

print(mesh_info.bodies)
{'1': 'Default 1'}

Or the dictionary of available face zones:

print(mesh_info.face_zones)
{'5': 'Default', '6': 'main inlet', '7': 'side inlet', '8': 'outlet'}

Exploring the results#

Explore the available results through the ResultInfo. The ResultInfo provides metadata information about the results stored in the files. First get all the available information in the ResultInfo. As you can see above, the ResultInfo information is also listed when printing the Model.

result_info = model.metadata.result_info
print(result_info)
Static analysis
Unit system: SI: m, kg, N, s, V, A, K
Physics Type: Fluid
Available results:
     -  specific_heat: Nodal Specific Heat
     -  epsilon: Nodal Epsilon
     -  enthalpy: Nodal Enthalpy
     -  turbulent_kinetic_energy: Nodal Turbulent Kinetic Energy
     -  thermal_conductivity: Nodal Thermal Conductivity
     -  dynamic_viscosity: Nodal Dynamic Viscosity
     -  turbulent_viscosity: Nodal Turbulent Viscosity
     -  static_pressure: Nodal Static Pressure
     -  total_pressure: Nodal Total Pressure
     -  density: Nodal Density
     -  entropy: Nodal Entropy
     -  wall_shear_stress: Nodal Wall Shear Stress
     -  temperature: Nodal Temperature
     -  total_temperature: Nodal Total Temperature
     -  velocity: Nodal Velocity
Available qualifier labels:
     - zone: Default (5), main inlet (6), side inlet (7), outlet (8), Default 1 (1)
     - phase: <Mixture> (1), Water at 25 C (2)

The ResultInfo class exposes the list of AvailableResults.

print(result_info.available_results)
[AvailableResult<name=specific_heat>, AvailableResult<name=epsilon>, AvailableResult<name=enthalpy>, AvailableResult<name=turbulent_kinetic_energy>, AvailableResult<name=thermal_conductivity>, AvailableResult<name=dynamic_viscosity>, AvailableResult<name=turbulent_viscosity>, AvailableResult<name=static_pressure>, AvailableResult<name=total_pressure>, AvailableResult<name=density>, AvailableResult<name=entropy>, AvailableResult<name=wall_shear_stress>, AvailableResult<name=temperature>, AvailableResult<name=total_temperature>, AvailableResult<name=velocity>]

Extracting data#

Extracting the mesh or results is then the same as for any other file type.

Total running time of the script: (0 minutes 0.813 seconds)

Gallery generated by Sphinx-Gallery