Skip to content

Commit 882e360

Browse files
committed
Merge branch 'main' into release/0.59
2 parents 8037c12 + e74d7f7 commit 882e360

File tree

19 files changed

+702
-57
lines changed

19 files changed

+702
-57
lines changed

.github/workflows/nightly-doc-build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ jobs:
5656
5757
- name: Deploy
5858
uses: JamesIves/[email protected]
59-
if: startsWith(github.ref, 'refs/tags/')
6059
with:
6160
repository-name: pyansys/pymapdl-dev-docs
6261
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}

ansys/mapdl/core/_commands/preproc/elements.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,8 @@ def eplot(self, show_node_numbering=False, vtk=None, **kwargs):
12011201
labels = [{'points': esurf.points,
12021202
'labels': esurf['ansys_node_num']}]
12031203

1204-
return general_plotter([{'mesh': esurf}],
1204+
return general_plotter([{'mesh': esurf,
1205+
'style': kwargs.pop('style', 'surface')}],
12051206
[],
12061207
labels,
12071208
**kwargs)

ansys/mapdl/core/inline_functions/inline_functions.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
_NextSelectedEntityQueries
55
from .line_queries import _LineFractionCoordinateQueries, \
66
_LineFractionSlopeQueries
7+
from .normals_queries import _NodeNormalQueries, _KeypointNormalQueries
8+
from .nearest_queries import _EntityNearestEntityQueries
79

810

911
class Query(_ComponentQueries,
@@ -12,7 +14,10 @@ class Query(_ComponentQueries,
1214
_SelectionStatusQueries,
1315
_LineFractionCoordinateQueries,
1416
_LineFractionSlopeQueries,
15-
_NextSelectedEntityQueries):
17+
_NextSelectedEntityQueries,
18+
_NodeNormalQueries,
19+
_KeypointNormalQueries,
20+
_EntityNearestEntityQueries):
1621
"""Class containing all the inline functions of APDL.
1722
1823
Most of the results of these methods are shortcuts for specific
@@ -53,6 +58,9 @@ class Query(_ComponentQueries,
5358
- ``arnext(a)`` - get the next selected area with a number greater than `a`.
5459
- ``elnext(e)`` - get the next selected element with a number greater than `e`.
5560
- ``vlnext(v)`` - get the next selected volume with a number greater than `v`.
61+
- ``nnear(n)`` - get the selected node nearest node `n`.
62+
- ``knear(k)`` - get the selected keypoint nearest keypoint `k`.
63+
- ``enearn(n)`` - get the selected element nearest node `n`.
5664
- ``node(x, y, z)`` - get the node closest to coordinate (x, y, z)
5765
- ``kp(x, y, z)`` - get the keypoint closest to coordinate (x, y, z)
5866
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
2+
class _EntityNearestEntityQueries:
3+
_mapdl = None
4+
5+
def nnear(self, n: int) -> int:
6+
"""Returns the selected node nearest node `n`.
7+
8+
Parameters
9+
----------
10+
n : int
11+
Node number
12+
13+
Returns
14+
-------
15+
int
16+
Node number
17+
18+
Examples
19+
--------
20+
In this example we construct a solid box and mesh it. Then we
21+
use the ``Query`` method ``node`` to find the node closest to
22+
the centre of the block and finally use ``nnear`` to find the
23+
node nearest to that.
24+
25+
>>> from ansys.mapdl.core import launch_mapdl
26+
>>> mapdl = launch_mapdl()
27+
>>> mapdl.prep7()
28+
>>> mapdl.et(1, 'SOLID5')
29+
>>> mapdl.block(0, 10, 0, 10, 0, 10)
30+
>>> mapdl.esize(3)
31+
>>> mapdl.vmesh('ALL')
32+
>>> q = mapdl.query()
33+
>>> node_number = q.node(5., 5., 5.)
34+
>>> nearest_node = q.nnear(node_number)
35+
>>> node_number, nearest_node
36+
(112, 103)
37+
"""
38+
response = self._mapdl.run(f'_=NNEAR({n})')
39+
integer = self._parse_parameter_integer_response(response)
40+
return integer
41+
42+
def knear(self, k: int) -> int:
43+
"""Returns the selected keypoint nearest keypoint `k`.
44+
45+
Parameters
46+
----------
47+
k : int
48+
Keypoint number
49+
50+
Returns
51+
-------
52+
int
53+
Keypoint number
54+
55+
Examples
56+
--------
57+
In this example we construct two keypoints and then verify that
58+
the nearest keypoint to one is the other.
59+
60+
>>> from ansys.mapdl.core import launch_mapdl
61+
>>> mapdl = launch_mapdl()
62+
>>> mapdl.prep7()
63+
>>> k1 = mapdl.k(1, 0, 0, 0)
64+
>>> k2 = mapdl.k(2, 1, 1, 1)
65+
>>> q = mapdl.query()
66+
>>> q.knear(k1)
67+
1
68+
69+
>>> q.knear(k1) == k2
70+
True
71+
"""
72+
response = self._mapdl.run(f'_=KNEAR({k})')
73+
integer = self._parse_parameter_integer_response(response)
74+
return integer
75+
76+
def enearn(self, n: int) -> int:
77+
"""Returns the selected element nearest node `n`.
78+
79+
The element position is calculated from the selected nodes.
80+
81+
Parameters
82+
----------
83+
n : int
84+
Node number
85+
86+
Returns
87+
-------
88+
int
89+
Element number
90+
91+
Examples
92+
--------
93+
In this example we construct a solid box and mesh it. Then we
94+
use the ``Query`` method ``node`` to find the node closest to
95+
the centre of the block and finally use ``enearn`` to find the
96+
element nearest to that node.
97+
98+
>>> from ansys.mapdl.core import launch_mapdl
99+
>>> mapdl = launch_mapdl()
100+
>>> mapdl.prep7()
101+
>>> mapdl.et(1, 'SOLID5')
102+
>>> mapdl.block(0, 10, 0, 10, 0, 10)
103+
>>> mapdl.esize(3)
104+
>>> mapdl.vmesh('ALL')
105+
>>> q = mapdl.query()
106+
>>> node_number = q.node(5., 5., 5.)
107+
>>> nearest_element = q.enearn(node_number)
108+
>>> node_number, nearest_element
109+
(112, 22)
110+
"""
111+
response = self._mapdl.run(f'_=ENEARN({n})')
112+
integer = self._parse_parameter_integer_response(response)
113+
return integer
114+

0 commit comments

Comments
 (0)