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: node/element selection commands returning selected ids #3636

Merged
merged 9 commits into from
Jan 8, 2025
1 change: 1 addition & 0 deletions doc/changelog.d/3636.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feat: node/element selection commands returning selected ids
2 changes: 2 additions & 0 deletions src/ansys/mapdl/core/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@
"LSEL",
"ASEL",
"VSEL",
"ESLN",
"NSLE",
]


Expand Down
4 changes: 4 additions & 0 deletions src/ansys/mapdl/core/mapdl_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,10 @@ def wrap_xsel_function_output(method):
return self.geometry.anum
elif name == "VSEL":
return self.geometry.vnum
elif name == "ESLN":
return self.mesh.enum
elif name == "NSLE":
return self.mesh.nnum
else:
return None

Expand Down
18 changes: 18 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,24 @@ def create_geometry(mapdl):
return areas, keypoints


@pytest.fixture(scope="function")
def two_dimensional_mesh(mapdl, cleared):
length = 4
height = 1
thickness = 0.2
mesh_size = 0.1

mapdl.prep7()

mapdl.r(r1=thickness)
mapdl.et(1, "PLANE182", kop3=3, kop6=0)
mapdl.rectng(0, length, 0, height)
mapdl.mshkey(1)
mapdl.mshape(0, "2D")
mapdl.esize(mesh_size)
mapdl.amesh("ALL")


@pytest.fixture
def query(mapdl, cleared):
return mapdl.queries
Expand Down
39 changes: 39 additions & 0 deletions tests/test_mesh_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,42 @@ def test_nodal_rotation(mapdl, cleared):
]
)
assert np.allclose(nrotation_ref, nrotations[:7, :])


def test_esln(mapdl, two_dimensional_mesh):
mapdl.nsel("S", "LOC", "X", 0)
selected_ids = mapdl.esln("S", 0)
expected_selected_ids = np.array([1, 41, 81, 121, 161, 201, 241, 281, 321, 361])
assert all(selected_ids == expected_selected_ids)


def test_nsle(mapdl, two_dimensional_mesh):
mapdl.esel("S", "CENT", "X", 0, 0.1)
selected_ids = mapdl.nsle("S")
expected_selected_ids = np.array(
[
1,
3,
52,
91,
92,
93,
94,
95,
96,
97,
98,
99,
100,
101,
102,
103,
104,
105,
106,
107,
108,
109,
]
)
assert all(selected_ids == expected_selected_ids)
Loading