|
| 1 | +""" |
| 2 | +.. _ref_cfx_res_files: |
| 3 | +
|
| 4 | +Read CFX `.res` files |
| 5 | +--------------------- |
| 6 | +
|
| 7 | +This example demonstrates how to read Ansys CFX `.res` files. |
| 8 | +
|
| 9 | +.. note:: |
| 10 | + This example requires DPF 7.0 (ansys-dpf-server-2024-1-pre0) or above. |
| 11 | + For more information, see :ref:`ref_compatibility`. |
| 12 | +
|
| 13 | +""" |
| 14 | + |
| 15 | +############################################################################### |
| 16 | +# Exploring an Ansys CFX `.res` file |
| 17 | +# ---------------------------------- |
| 18 | +# The first part of the example demonstrates how you can load an |
| 19 | +# Ansys CFX `.res` file in a model. |
| 20 | + |
| 21 | +import ansys.dpf.core as dpf |
| 22 | +from ansys.dpf.core import examples |
| 23 | + |
| 24 | +path = examples.download_cfx_mixing_elbow() |
| 25 | +model = dpf.Model(path) |
| 26 | +print(model) |
| 27 | + |
| 28 | +############################################################################### |
| 29 | +# Exploring the mesh |
| 30 | +# ~~~~~~~~~~~~~~~~~~ |
| 31 | +# Explore the mesh through the ``MeshInfo``. The ``MeshInfo`` provides metadata |
| 32 | +# information about the mesh. For fluid models, it is useful to know the bodies and |
| 33 | +# face zones, as well as the topological relationships between them. First get all |
| 34 | +# the available information in the ``MeshInfo``. |
| 35 | +mesh_info = model.metadata.mesh_info |
| 36 | +print(mesh_info) |
| 37 | + |
| 38 | +############################################################################### |
| 39 | +# The ``MeshInfo`` exposes several helpers, such as a dictionary of available bodies: |
| 40 | +print(mesh_info.bodies) |
| 41 | + |
| 42 | +############################################################################### |
| 43 | +# Or the dictionary of available face zones: |
| 44 | +print(mesh_info.face_zones) |
| 45 | + |
| 46 | +############################################################################### |
| 47 | +# Exploring the results |
| 48 | +# ~~~~~~~~~~~~~~~~~~~~~ |
| 49 | +# Explore the available results through the ``ResultInfo``. |
| 50 | +# The ``ResultInfo`` provides metadata information about the results stored in the files. |
| 51 | +# First get all the available information in the ``ResultInfo``. |
| 52 | +# As you can see above, the ``ResultInfo`` information is also listed when printing the ``Model``. |
| 53 | +result_info = model.metadata.result_info |
| 54 | +print(result_info) |
| 55 | + |
| 56 | +############################################################################### |
| 57 | +# The ``ResultInfo`` class exposes the list of ``AvailableResults``. |
| 58 | +print(result_info.available_results) |
| 59 | + |
| 60 | +############################################################################### |
| 61 | +# Extracting data |
| 62 | +# ~~~~~~~~~~~~~~~ |
| 63 | +# Extracting the mesh or results is then the same as for any other file type. |
0 commit comments