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

feat: Polyhedral connectivity #3631

Merged
merged 1 commit into from
Jan 13, 2025
Merged

feat: Polyhedral connectivity #3631

merged 1 commit into from
Jan 13, 2025

Conversation

mkundu1
Copy link
Contributor

@mkundu1 mkundu1 commented Jan 10, 2025

import pyvista as pv
import ansys.fluent.core as pyfluent
from ansys.fluent.core.services.field_data import CellElementType

def convert_fluent_element_type_to_pv_cell_type(element_type):
    if element_type == CellElementType.POLYHEDRON:
        return pv.CellType.POLYHEDRON
    # Add other element types
    raise ValueError(f"Unknown element type {element_type}")

solver = pyfluent.launch_fluent(processor_count=4)
solver.settings.file.read_case(file_name="d:/work/Static_Mixer_main.cas.h5")
mesh = solver.fields.field_data.get_mesh(zone_id=97)
points = [(node.x, node.y, node.z) for node in mesh.nodes]
cells = []
for element in mesh.elements:
    connectivity = []
    connectivity.append(len(element.facets))
    for facet in element.facets:
        connectivity.append(len(facet.node_indices))
        connectivity.extend(facet.node_indices)
    cells.append(len(connectivity))
    cells.extend(connectivity)
cell_types = [convert_fluent_element_type_to_pv_cell_type(element.element_type) for element in mesh.elements]
grid = pv.UnstructuredGrid(cells, cell_types, points)
pv.plot(grid, show_edges=True)

image

@mkundu1 mkundu1 force-pushed the feat/poly-connectivity branch from 28d9241 to 982b9b1 Compare January 10, 2025 19:25
@mkundu1 mkundu1 linked an issue Jan 13, 2025 that may be closed by this pull request
@mkundu1 mkundu1 merged commit 59ec347 into main Jan 13, 2025
30 checks passed
@mkundu1 mkundu1 deleted the feat/poly-connectivity branch January 13, 2025 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetch mesh data on-demand in solution mode
4 participants