From e1dad9f882c666b17ba35b7cc05550e14076b6ac Mon Sep 17 00:00:00 2001 From: "paul.profizi" Date: Mon, 29 Apr 2024 15:59:10 +0200 Subject: [PATCH 1/2] Add test_operator_mesh_plan_clip_rst Signed-off-by: paul.profizi --- .../operators/test_operator_mesh_plan_clip.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/operators/test_operator_mesh_plan_clip.py diff --git a/tests/operators/test_operator_mesh_plan_clip.py b/tests/operators/test_operator_mesh_plan_clip.py new file mode 100644 index 0000000000..02a183b71f --- /dev/null +++ b/tests/operators/test_operator_mesh_plan_clip.py @@ -0,0 +1,20 @@ +import ansys.dpf.core as dpf + + +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 + assert elements_scoping_ids[-1] == 6000 From 23484573a1ead100670688dc112a6eed91b78c8d Mon Sep 17 00:00:00 2001 From: "paul.profizi" Date: Mon, 29 Apr 2024 16:16:09 +0200 Subject: [PATCH 2/2] Fix retro, add field clipping Signed-off-by: paul.profizi --- tests/conftest.py | 3 +++ tests/operators/test_operator_mesh_plan_clip.py | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index bd63851974..bfaf525d53 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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" ) diff --git a/tests/operators/test_operator_mesh_plan_clip.py b/tests/operators/test_operator_mesh_plan_clip.py index 02a183b71f..21b9f96d15 100644 --- a/tests/operators/test_operator_mesh_plan_clip.py +++ b/tests/operators/test_operator_mesh_plan_clip.py @@ -1,4 +1,5 @@ import ansys.dpf.core as dpf +import conftest def test_operator_mesh_plan_clip_rst(simple_bar): @@ -17,4 +18,15 @@ def test_operator_mesh_plan_clip_rst(simple_bar): assert node_scoping_ids[-1] == 1331 elements_scoping_ids = cut_mesh.elements.scoping.ids assert len(elements_scoping_ids) == 6000 - assert elements_scoping_ids[-1] == 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