Skip to content

Visualize solution variable data #395

Open
@mkundu1

Description

@mkundu1

It might be useful to visualize the solution variable data in numerical format to understand how the data is ordered in space. For a face-thread, we can draw the background mesh and plot the centroid data as point cloud with variable data as labels. Following is an example code in pyvista without the background mesh:

import ansys.fluent.core as pyfluent
solver = pyfluent.launch_fluent()
solver.file.read_case_data(file_name=r"d:/work/elbow.cas.h5")
centroid_data = solver.fields.solution_variable_data.get_data(solution_variable_name="SV_CENTROID", zone_names=["inlet1"], domain_name="mixture")["inlet1"]
centroid_data = centroid_data.reshape(-1, 3)
pressure_data = solver.fields.solution_variable_data.get_data(solution_variable_name="SV_P", zone_names=["inlet1"], domain_name="mixture")["inlet1"]

import pyvista as pv
poly = pv.PolyData(centroid_data)
poly["Pressure"] = [f"{i},{p:.2f}" for i, p in enumerate(pressure_data)]
plotter = pv.Plotter()
plotter.add_point_labels(poly, "Pressure", point_size=3, point_color='black', font_size=10, bold=False, shape=None)
plotter.show_axes()
plotter.show()

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions