Skip to content

Commit

Permalink
feat: node/element selection commands returning selected ids (#3636)
Browse files Browse the repository at this point in the history
* 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 <92810346+pyansys-ci-bot@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: German <28149841+germa89@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 8, 2025
1 parent 3df7801 commit ce34c76
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
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)

0 comments on commit ce34c76

Please sign in to comment.