Skip to content

Commit ce34c76

Browse files
moe-adpyansys-ci-botpre-commit-ci[bot]germa89
authored
feat: node/element selection commands returning selected ids (#3636)
* feat: changes to source code * chore: adding changelog file 3636.miscellaneous.md [dependabot-skip] * ci: auto fixes from pre-commit.com hooks. for more information, see https://pre-commit.ci * chore: adding changelog file 3636.documentation.md [dependabot-skip] * ci: auto fixes from pre-commit.com hooks. for more information, see https://pre-commit.ci * chore: adding changelog file 3636.miscellaneous.md [dependabot-skip] * feat: added unit tests --------- Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: German <[email protected]>
1 parent 3df7801 commit ce34c76

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

doc/changelog.d/3636.miscellaneous.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat: node/element selection commands returning selected ids

src/ansys/mapdl/core/commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@
193193
"LSEL",
194194
"ASEL",
195195
"VSEL",
196+
"ESLN",
197+
"NSLE",
196198
]
197199

198200

src/ansys/mapdl/core/mapdl_core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,10 @@ def wrap_xsel_function_output(method):
13211321
return self.geometry.anum
13221322
elif name == "VSEL":
13231323
return self.geometry.vnum
1324+
elif name == "ESLN":
1325+
return self.mesh.enum
1326+
elif name == "NSLE":
1327+
return self.mesh.nnum
13241328
else:
13251329
return None
13261330

tests/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,24 @@ def create_geometry(mapdl):
11571157
return areas, keypoints
11581158

11591159

1160+
@pytest.fixture(scope="function")
1161+
def two_dimensional_mesh(mapdl, cleared):
1162+
length = 4
1163+
height = 1
1164+
thickness = 0.2
1165+
mesh_size = 0.1
1166+
1167+
mapdl.prep7()
1168+
1169+
mapdl.r(r1=thickness)
1170+
mapdl.et(1, "PLANE182", kop3=3, kop6=0)
1171+
mapdl.rectng(0, length, 0, height)
1172+
mapdl.mshkey(1)
1173+
mapdl.mshape(0, "2D")
1174+
mapdl.esize(mesh_size)
1175+
mapdl.amesh("ALL")
1176+
1177+
11601178
@pytest.fixture
11611179
def query(mapdl, cleared):
11621180
return mapdl.queries

tests/test_mesh_grpc.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,3 +317,42 @@ def test_nodal_rotation(mapdl, cleared):
317317
]
318318
)
319319
assert np.allclose(nrotation_ref, nrotations[:7, :])
320+
321+
322+
def test_esln(mapdl, two_dimensional_mesh):
323+
mapdl.nsel("S", "LOC", "X", 0)
324+
selected_ids = mapdl.esln("S", 0)
325+
expected_selected_ids = np.array([1, 41, 81, 121, 161, 201, 241, 281, 321, 361])
326+
assert all(selected_ids == expected_selected_ids)
327+
328+
329+
def test_nsle(mapdl, two_dimensional_mesh):
330+
mapdl.esel("S", "CENT", "X", 0, 0.1)
331+
selected_ids = mapdl.nsle("S")
332+
expected_selected_ids = np.array(
333+
[
334+
1,
335+
3,
336+
52,
337+
91,
338+
92,
339+
93,
340+
94,
341+
95,
342+
96,
343+
97,
344+
98,
345+
99,
346+
100,
347+
101,
348+
102,
349+
103,
350+
104,
351+
105,
352+
106,
353+
107,
354+
108,
355+
109,
356+
]
357+
)
358+
assert all(selected_ids == expected_selected_ids)

0 commit comments

Comments
 (0)