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 test_operator_mesh_plan_clip_rst #1542

Merged
merged 3 commits into from
Jul 24, 2024
Merged
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
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ def return_ds(server=None):

return return_ds

SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_2 = meets_version(
get_server_version(core._global_server()), "8.2"
)
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1 = meets_version(
get_server_version(core._global_server()), "8.1"
)
Expand Down
32 changes: 32 additions & 0 deletions tests/operators/test_operator_mesh_plan_clip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import ansys.dpf.core as dpf
import conftest


def test_operator_mesh_plan_clip_rst(simple_bar):
model = dpf.Model(simple_bar)
main_mesh = model.metadata.meshed_region

plane = dpf.fields_factory.create_3d_vector_field(1, dpf.locations.overall)
plane.append([0, 1, 0], 1)

origin = dpf.fields_factory.create_3d_vector_field(1, dpf.locations.overall)
origin.append([0, 2.0, 0], 1)

cut_mesh = dpf.operators.mesh.mesh_plan_clip(main_mesh, normal=plane, origin=origin).eval(2)
node_scoping_ids = cut_mesh.nodes.scoping.ids
assert len(node_scoping_ids) == 1331
assert node_scoping_ids[-1] == 1331
elements_scoping_ids = cut_mesh.elements.scoping.ids
assert len(elements_scoping_ids) == 6000
if conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_2:
assert elements_scoping_ids[-1] == 6000

# Check clipping a field
if conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_2:
disp = model.results.displacement.eval()[0]
op = dpf.operators.mesh.mesh_plan_clip()
op.inputs.mesh_or_field.connect(disp)
op.inputs.normal.connect(plane)
op.inputs.origin.connect(origin)
field: dpf.Field = op.outputs.field()
assert field.max().data[0] > 1.e-7
Loading