Extract a mesh in split parts#

Fluent CFX

This tutorial shows how to extract meshes split on a given space or time from a result file.

To accomplish this goal, use the meshes_provider operator. The split meshes are given in a MeshesContainer and can be spatially or temporally varying.

Import the necessary modules#

from ansys.dpf import core as dpf
from ansys.dpf.core import examples, operators as ops

Define the DataSources#

Create DataSources objects so the meshes_provider operator can access the mesh. For this tutorial, use result files available in the examples module. For more information on importing result files, see the Import Data tutorials section.

# Fluent
result_file_path_3 = examples.download_fluent_axial_comp()["flprj"]
ds_3 = dpf.DataSources(result_path=result_file_path_3)

# CFX
result_file_path_4 = examples.download_cfx_mixing_elbow()
ds_4 = dpf.DataSources(result_path=result_file_path_4)

Extract all mesh parts — Fluent#

Instantiate and evaluate the meshes_provider operator.

meshes_31 = ops.mesh.meshes_provider(data_sources=ds_3).eval()
print(meshes_31)
DPF  Meshes Container
  with 24 mesh(es)
  defined on labels: time zone

  with:
  - mesh 0 {time:  1, zone:  3, } with 429 nodes and 0 elements.
  - mesh 1 {time:  1, zone:  4, } with 429 nodes and 0 elements.
  - mesh 2 {time:  1, zone:  5, } with 187 nodes and 0 elements.
  - mesh 3 {time:  1, zone:  6, } with 187 nodes and 0 elements.
  - mesh 4 {time:  1, zone:  7, } with 425 nodes and 0 elements.
  - mesh 5 {time:  1, zone:  8, } with 425 nodes and 0 elements.
  - mesh 6 {time:  1, zone:  9, } with 204 nodes and 0 elements.
  - mesh 7 {time:  1, zone:  10, } with 204 nodes and 0 elements.
  - mesh 8 {time:  1, zone:  11, } with 68 nodes and 0 elements.
  - mesh 9 {time:  1, zone:  12, } with 68 nodes and 0 elements.
  - mesh 10 {time:  1, zone:  13, } with 7293 nodes and 6080 elements.
  - mesh 11 {time:  1, zone:  16, } with 551 nodes and 0 elements.
  - mesh 12 {time:  1, zone:  17, } with 551 nodes and 0 elements.
  - mesh 13 {time:  1, zone:  18, } with 323 nodes and 0 elements.
  - mesh 14 {time:  1, zone:  19, } with 323 nodes and 0 elements.
  - mesh 15 {time:  1, zone:  20, } with 357 nodes and 0 elements.
  - mesh 16 {time:  1, zone:  21, } with 357 nodes and 0 elements.
  - mesh 17 {time:  1, zone:  22, } with 357 nodes and 0 elements.
  - mesh 18 {time:  1, zone:  23, } with 357 nodes and 0 elements.
  - mesh 19 {time:  1, zone:  24, } with 68 nodes and 0 elements.
  - mesh 20 {time:  1, zone:  25, } with 68 nodes and 0 elements.
  - mesh 21 {time:  1, zone:  26, } with 85 nodes and 0 elements.
  - mesh 22 {time:  1, zone:  27, } with 85 nodes and 0 elements.
  - mesh 23 {time:  1, zone:  28, } with 9367 nodes and 7776 elements.

Extract all mesh parts — CFX

meshes_41 = ops.mesh.meshes_provider(data_sources=ds_4).eval()
print(meshes_41)
DPF  Meshes Container
  with 5 mesh(es)
  defined on labels: time zone

  with:
  - mesh 0 {time:  1, zone:  5, } with 921 nodes and 0 elements.
  - mesh 1 {time:  1, zone:  6, } with 102 nodes and 0 elements.
  - mesh 2 {time:  1, zone:  7, } with 48 nodes and 0 elements.
  - mesh 3 {time:  1, zone:  8, } with 102 nodes and 0 elements.
  - mesh 4 {time:  1, zone:  1, } with 6219 nodes and 15695 elements.

Scope the mesh regions to extract — Fluent#

A region corresponds to a zone for Fluid and CFX results. Specify the mesh regions you want to get by passing zone ids to the region_scoping argument.

meshes_32 = ops.mesh.meshes_provider(data_sources=ds_3, region_scoping=[3, 12]).eval()
print(meshes_32)
DPF  Meshes Container
  with 2 mesh(es)
  defined on labels: time zone

  with:
  - mesh 0 {time:  1, zone:  3, } with 429 nodes and 0 elements.
  - mesh 1 {time:  1, zone:  12, } with 68 nodes and 0 elements.

Scope the mesh regions to extract — CFX

meshes_42 = ops.mesh.meshes_provider(data_sources=ds_4, region_scoping=[5, 8]).eval()
print(meshes_42)
DPF  Meshes Container
  with 2 mesh(es)
  defined on labels: time zone

  with:
  - mesh 0 {time:  1, zone:  5, } with 921 nodes and 0 elements.
  - mesh 1 {time:  1, zone:  8, } with 102 nodes and 0 elements.

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

Gallery generated by Sphinx-Gallery