Skip to content

Commit

Permalink
Add test_operator_mesh_plan_clip_rst (#1542)
Browse files Browse the repository at this point in the history
* Add test_operator_mesh_plan_clip_rst

Signed-off-by: paul.profizi <[email protected]>

* Fix retro, add field clipping

Signed-off-by: paul.profizi <[email protected]>

---------

Signed-off-by: paul.profizi <[email protected]>
  • Loading branch information
PProfizi authored Jul 24, 2024
1 parent 2e05dec commit f2631f7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
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

0 comments on commit f2631f7

Please sign in to comment.