Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions examples/12-fluids/03-fluids_isosurface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

###############################################################################
# Import the ``dpf-core`` module and its examples files.
# ------------------------------
# # ~~~~~~~~~~~~~~~~~~

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

###############################################################################
# Specify the file path.
# We first work on a cas/dat.h5 file with only nodal variable.
# ------------------------------
# ~~~~~~~~~~~~~~~~~~
# We work on a cas/dat.h5 file with only nodal variable.

path = examples.download_cfx_heating_coil()
ds = dpf.DataSources()
Expand All @@ -27,9 +27,10 @@
streams = dpf.operators.metadata.streams_provider(data_sources=ds)

###############################################################################
# Evaluate the mesh with mesh_provider operator in order to scope the mesh_cut operator
# with the mesh.
# ------------------------------
# Whole mesh scoping.
# ~~~~~~~~~~~~~~~~~~
# We evaluate the mesh with mesh_provider operator in order to scope the mesh_cut operator
# with the whole mesh.

whole_mesh = dpf.operators.mesh.mesh_provider(streams_container=streams).eval()
print(whole_mesh)
Expand All @@ -41,13 +42,14 @@
(-0.0011924505233764648, 1.8596649169921875e-05, 1.125),
(-0.2738679385987956, -0.30771426079547065, 0.9112125360807675),
]
pl.show_figure(cpos=cpos_whole_mesh, show_axes=True, return_cpos=True)
pl.show_figure(cpos=cpos_whole_mesh, show_axes=True)

###############################################################################
# Extract the physic variable.
# ~~~~~~~~~~~~~~~~~~
# Here we choose to work with the static pressure by default which is a scalar and
# nodal variable without multi-species/phases. With a multi-species case, we should have
# select one specific using qualifiers ellipsis pins and connecting a LabelSpace "specie"/"phase".
# ------------------------------

P_S = dpf.operators.result.static_pressure(streams_container=streams, mesh=whole_mesh).eval()
print(P_S[0])
Expand All @@ -62,14 +64,13 @@
pl.show_figure(cpos=cpos_mesh_variable, show_axes=True)

###############################################################################
# We can finally use the mesh_cut operator on this specific variable for a specific iso-value
# arbitrary chosen. We have to specify also the mesh scoping. By default, we choose to take
# into account shell and skin elements.
# ------------------------------
# Evaluate iso-surfaces.
# ~~~~~~~~~~~~~~~~~~
# We can finally use the mesh_cut operator on this specific variable.
# We choose to cut the whole with 5 iso-surface equally spaced between min and max.

max_pressure = 361.8170 # Pa
min_pressure = -153.5356 # Pa

number_of_iso_surface = 5
step = (max_pressure - min_pressure) / number_of_iso_surface

Expand Down Expand Up @@ -101,9 +102,11 @@
)
min_pressure += step

pl.show_figure(show_axes=True, cpos=c_pos_iso, return_cpos=True)
pl.show_figure(show_axes=True, cpos=c_pos_iso)

###############################################################################
# Important note
# ------------------------------
# For elemental or face variables we should have done an averaging on node
# by using elemental_to_node operator and set as an input of the
# mesh_cut operator the node scoping
# mesh_cut operator the node scoping.