Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the iso_contours example using iso_surfaces operator #1164

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Changes from all commits
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
32 changes: 15 additions & 17 deletions examples/12-fluids/03-fluids_isosurface.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,9 @@
###############################################################################
# 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
# We can finally use the iso_surfaces operator on this specific variable.
# We choose to cut the whole mesh with 9 iso-surface manually selected between
# the min and max of the static_pressure variable.

pl = DpfPlotter()
c_pos_iso = [
Expand All @@ -87,18 +83,20 @@
opacity=0.3,
)

for i in range(number_of_iso_surface):
iso_surface = dpf.operators.mesh.mesh_cut(
field=P_S[0], iso_value=min_pressure, closed_surface=0, mesh=whole_mesh, slice_surfaces=True
).eval()
P_S_step = dpf.Field(location=dpf.locations.overall, nature=dpf.common.natures.scalar)
P_S_step.append([min_pressure], i)
P_S_step.name = "static pressure"
P_S_step.unit = "Pa"
vec_iso_values = [-153.6, -100.0, -50.0, 50.0, 100.0, 150.0, 200.0, 300.0, 361.8]

iso_surfaces_op = dpf.operators.mesh.iso_surfaces(field=P_S[0], mesh=whole_mesh, slice_surfaces=True,
vector_iso_values=vec_iso_values)

iso_surfaces_meshes = iso_surfaces_op.outputs.meshes()

iso_surfaces_fields = iso_surfaces_op.outputs.fields_container()

for i in range(len(iso_surfaces_fields)):
pl.add_field(
field=P_S_step, meshed_region=iso_surface, style="surface", show_edges=False, show_axes=True
field=iso_surfaces_fields[i], meshed_region=iso_surfaces_meshes[i], style="surface", show_edges=False,
show_axes=True
)
min_pressure += step

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

Expand Down
Loading