Skip to content

Commit

Permalink
Merge branch 'main' into release/0.59
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Aug 25, 2021
2 parents 8037c12 + e74d7f7 commit 882e360
Show file tree
Hide file tree
Showing 19 changed files with 702 additions and 57 deletions.
1 change: 0 additions & 1 deletion .github/workflows/nightly-doc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
- name: Deploy
uses: JamesIves/[email protected]
if: startsWith(github.ref, 'refs/tags/')
with:
repository-name: pyansys/pymapdl-dev-docs
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion ansys/mapdl/core/_commands/preproc/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,8 @@ def eplot(self, show_node_numbering=False, vtk=None, **kwargs):
labels = [{'points': esurf.points,
'labels': esurf['ansys_node_num']}]

return general_plotter([{'mesh': esurf}],
return general_plotter([{'mesh': esurf,
'style': kwargs.pop('style', 'surface')}],
[],
labels,
**kwargs)
Expand Down
10 changes: 9 additions & 1 deletion ansys/mapdl/core/inline_functions/inline_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
_NextSelectedEntityQueries
from .line_queries import _LineFractionCoordinateQueries, \
_LineFractionSlopeQueries
from .normals_queries import _NodeNormalQueries, _KeypointNormalQueries
from .nearest_queries import _EntityNearestEntityQueries


class Query(_ComponentQueries,
Expand All @@ -12,7 +14,10 @@ class Query(_ComponentQueries,
_SelectionStatusQueries,
_LineFractionCoordinateQueries,
_LineFractionSlopeQueries,
_NextSelectedEntityQueries):
_NextSelectedEntityQueries,
_NodeNormalQueries,
_KeypointNormalQueries,
_EntityNearestEntityQueries):
"""Class containing all the inline functions of APDL.
Most of the results of these methods are shortcuts for specific
Expand Down Expand Up @@ -53,6 +58,9 @@ class Query(_ComponentQueries,
- ``arnext(a)`` - get the next selected area with a number greater than `a`.
- ``elnext(e)`` - get the next selected element with a number greater than `e`.
- ``vlnext(v)`` - get the next selected volume with a number greater than `v`.
- ``nnear(n)`` - get the selected node nearest node `n`.
- ``knear(k)`` - get the selected keypoint nearest keypoint `k`.
- ``enearn(n)`` - get the selected element nearest node `n`.
- ``node(x, y, z)`` - get the node closest to coordinate (x, y, z)
- ``kp(x, y, z)`` - get the keypoint closest to coordinate (x, y, z)
Expand Down
114 changes: 114 additions & 0 deletions ansys/mapdl/core/inline_functions/nearest_queries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@

class _EntityNearestEntityQueries:
_mapdl = None

def nnear(self, n: int) -> int:
"""Returns the selected node nearest node `n`.
Parameters
----------
n : int
Node number
Returns
-------
int
Node number
Examples
--------
In this example we construct a solid box and mesh it. Then we
use the ``Query`` method ``node`` to find the node closest to
the centre of the block and finally use ``nnear`` to find the
node nearest to that.
>>> from ansys.mapdl.core import launch_mapdl
>>> mapdl = launch_mapdl()
>>> mapdl.prep7()
>>> mapdl.et(1, 'SOLID5')
>>> mapdl.block(0, 10, 0, 10, 0, 10)
>>> mapdl.esize(3)
>>> mapdl.vmesh('ALL')
>>> q = mapdl.query()
>>> node_number = q.node(5., 5., 5.)
>>> nearest_node = q.nnear(node_number)
>>> node_number, nearest_node
(112, 103)
"""
response = self._mapdl.run(f'_=NNEAR({n})')
integer = self._parse_parameter_integer_response(response)
return integer

def knear(self, k: int) -> int:
"""Returns the selected keypoint nearest keypoint `k`.
Parameters
----------
k : int
Keypoint number
Returns
-------
int
Keypoint number
Examples
--------
In this example we construct two keypoints and then verify that
the nearest keypoint to one is the other.
>>> from ansys.mapdl.core import launch_mapdl
>>> mapdl = launch_mapdl()
>>> mapdl.prep7()
>>> k1 = mapdl.k(1, 0, 0, 0)
>>> k2 = mapdl.k(2, 1, 1, 1)
>>> q = mapdl.query()
>>> q.knear(k1)
1
>>> q.knear(k1) == k2
True
"""
response = self._mapdl.run(f'_=KNEAR({k})')
integer = self._parse_parameter_integer_response(response)
return integer

def enearn(self, n: int) -> int:
"""Returns the selected element nearest node `n`.
The element position is calculated from the selected nodes.
Parameters
----------
n : int
Node number
Returns
-------
int
Element number
Examples
--------
In this example we construct a solid box and mesh it. Then we
use the ``Query`` method ``node`` to find the node closest to
the centre of the block and finally use ``enearn`` to find the
element nearest to that node.
>>> from ansys.mapdl.core import launch_mapdl
>>> mapdl = launch_mapdl()
>>> mapdl.prep7()
>>> mapdl.et(1, 'SOLID5')
>>> mapdl.block(0, 10, 0, 10, 0, 10)
>>> mapdl.esize(3)
>>> mapdl.vmesh('ALL')
>>> q = mapdl.query()
>>> node_number = q.node(5., 5., 5.)
>>> nearest_element = q.enearn(node_number)
>>> node_number, nearest_element
(112, 22)
"""
response = self._mapdl.run(f'_=ENEARN({n})')
integer = self._parse_parameter_integer_response(response)
return integer

Loading

0 comments on commit 882e360

Please sign in to comment.