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

Add beam element in skin extraction #778

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/ansys/dpf/post/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def select_skin(
on the expanded mesh.
"""
skin_operator = operators.mesh.skin(server=self._server)
skin_operator.inputs.add_beam(True)
self._selection.add_operator(skin_operator)

initial_mesh_fwd_op = operators.utility.forward(server=self._server)
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ def average_per_body_complex_multi_body():
)


@pytest.fixture()
def beam_example():
return _download_file(
"result_files/beams", "post_beam_result_01.rst", True, None, False
)


@dataclasses.dataclass
class ReferenceCsvFiles:
# reference result with all bodies combined
Expand Down
28 changes: 28 additions & 0 deletions tests/test_simulation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import csv
import dataclasses
from itertools import groupby
import os.path
import pathlib
from typing import Optional, Union
Expand Down Expand Up @@ -4185,3 +4186,30 @@ def test_build_selection(
assert len(scoping_from_selection.ids) == 36
else:
assert set(scoping_from_selection.ids) == set(scoping.ids)


def test_beam_results_on_skin(beam_example):
simulation: StaticMechanicalSimulation = post.load_simulation(
data_sources=beam_example,
simulation_type=AvailableSimulationTypes.static_mechanical,
)

res = simulation.displacement(skin=True, norm=True)

element_type_array = res._fc[0].meshed_region.elements.element_types_field.data
element_count_dict = {
key: sum(1 for _ in value) for key, value in groupby(sorted(element_type_array))
}

unit_converter = dpf.operators.math.unit_convert(
unit_name=2, # NMM unit system
)

unit_converter.inputs.entity_to_convert(res._fc[0])
converted_field = unit_converter.eval()

assert element_types.Line2.value in element_count_dict.keys()

assert element_count_dict[element_types.Line2.value] == 40

assert converted_field.max().data[0] == pytest.approx(190, 1e-2)
Loading