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, you must use the meshes_provider operator.

Download tutorial as Python script Download tutorial as Jupyter notebook

Define the DataSources#

We must create a DataSources object so the meshes_provider operator can access the mesh. This object manages paths to their files.

For this tutorial, you can use a result file available in the Examples module. For more information about how to import your own result file in DPF, see the Import Data tutorial section.

# Import the ``ansys.dpf.core`` module
from ansys.dpf import core as dpf
# Import the examples module
from ansys.dpf.core import examples
# Import the operators module
from ansys.dpf.core import operators as ops

# Define the result file path
result_file_path_3 = examples.download_fluent_axial_comp()["flprj"]
# Create the DataSources object
ds_3 = dpf.DataSources(result_path=result_file_path_3)
# Import the ``ansys.dpf.core`` module
from ansys.dpf import core as dpf
# Import the examples module
from ansys.dpf.core import examples
# Import the operators module
from ansys.dpf.core import operators as ops

# Define the result file path
result_file_path_4 = examples.download_cfx_mixing_elbow()
# Create the DataSources object
ds_4 = dpf.DataSources(result_path=result_file_path_4)

Extract the mesh in split parts#

Instanciate and evaluate the meshes_provider operator. The split meshes are given in a MeshesContainer and can be spatially or temporally varying.

# Instanciate the meshes_provider operator
meshes_31 =  ops.mesh.meshes_provider(data_sources=ds_3).eval()

# Print the meshes
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.

# Instanciate the meshes_provider operator
meshes_41 =  ops.mesh.meshes_provider(data_sources=ds_4).eval()

# Print the meshes
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 be extracted in split regions#

A region corresponds to a zone for Fluid and CFX results. You can specify the mesh regions you want to get by giving the zones ids to the region_scoping argument.

# Instanciate the meshes_provider operator and specify a region
meshes_32 =  ops.mesh.meshes_provider(data_sources=ds_3, region_scoping=[3,12]).eval()

# Print the meshes
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.

# Instanciate the meshes_provider operator specifying a region
meshes_42 =  ops.mesh.meshes_provider(data_sources=ds_4, region_scoping=[5,8]).eval()

# Print the meshes
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.