Skip to content

Commit

Permalink
Reworking post-processing section (#2578)
Browse files Browse the repository at this point in the history
Reworking a bit the post-processing section
  • Loading branch information
germa89 authored Dec 22, 2023
1 parent b7cd03c commit d5c4edc
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 104 deletions.
25 changes: 25 additions & 0 deletions doc/source/user_guide/mapdl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,31 @@ these commands, such as ``"/SOLU"``:
mapdl.solution()
Selecting entities
------------------
You can select entities such as nodes or lines using these methods:

* :func:`Mapdl.nsel() <ansys.mapdl.core.Mapdl.nsel>`
* :func:`Mapdl.esel() <ansys.mapdl.core.Mapdl.esel>`
* :func:`Mapdl.ksel() <ansys.mapdl.core.Mapdl.ksel>`
* :func:`Mapdl.lsel() <ansys.mapdl.core.Mapdl.lsel>`
* :func:`Mapdl.asel() <ansys.mapdl.core.Mapdl.asel>`
* :func:`Mapdl.vsel() <ansys.mapdl.core.Mapdl.vsel>`

The preceding methods return the IDs of the selected entities. For example:

.. code:: pycon
>>> selected_nodes = mapdl.nsel("S", "NODE", vmin=1, vmax=2000)
>>> print(selected_nodes)
array([ 1 2 3 ... 1998 1999 2000])
.. code:: pycon
>>> mapdl.ksel("all")
array([1, 2, 3, ..., 1998, 1999, 2000])
Running in non-interactive mode
-------------------------------

Expand Down
181 changes: 77 additions & 104 deletions doc/source/user_guide/post.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ One advantage of this approach is that it integrates well with existing MAPDL
scripting or automation. This approach can also be used on result files generated
from other programs, including ANSYS Mechanical.

Perhaps one of the biggest advantages of gRPC-based postprocessing is
One of the biggest advantages of gRPC-based postprocessing is
that it can be done remotely without any file exchange. Multi gigabyte
result files can remain remote, with only the necessary data being
streamed back to the client for review or visualization.
Expand All @@ -24,6 +24,81 @@ streamed back to the client for review or visualization.
but via a Python client.


You would typically request nodal results from MAPDL using the
``PRNSOL`` command:

.. code:: output
POST1:
PRNSOL, U, X
PRINT U NODAL SOLUTION PER NODE
***** POST1 NODAL DEGREE OF FREEDOM LISTING *****
LOAD STEP= 1 SUBSTEP= 1
TIME= 1.0000 LOAD CASE= 0
THE FOLLOWING DEGREE OF FREEDOM RESULTS ARE IN THE GLOBAL COORDINATE SYSTEM
NODE UX
1 0.10751E-003
2 0.85914E-004
3 0.57069E-004
4 0.13913E-003
5 0.35621E-004
6 0.52186E-004
7 0.30417E-004
8 0.36139E-004
9 0.15001E-003
MORE (YES,NO OR CONTINUOUS)=
However, using an instance of the :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>`
class, you can instead request the nodal displacement:

.. code:: pycon
>>> mapdl.set(1, 1)
>>> disp_x = mapdl.post_processing.nodal_displacement("X")
array([1.07512979e-04, 8.59137773e-05, 5.70690047e-05, ...,
5.70333124e-05, 8.58600402e-05, 1.07445726e-04])
You could also plot the nodal displacement with this code:

.. code:: pycon
>>> mapdl.post_processing.plot_nodal_displacement("X")
.. figure:: ../images/post_norm_disp.png
:width: 300pt

Normalized Displacement of a Cylinder from MAPDL


Selecting entities
------------------

The MAPDL database processes some results independently if nodes or
elements are selected. If you have subselected a certain component
and want to also limit the result of a certain output
(:func:`nodal_displacement() <ansys.mapdl.core.post.PostProcessing.nodal_displacement>`),
use the :attr:`selected_nodes <ansys.mapdl.core.post.PostProcessing.selected_nodes>` attribute to get
a mask of the currently selected nodes:

.. code:: pycon
>>> mapdl.nsel("S", "NODE", vmin=1, vmax=2000)
>>> mapdl.esel("S", "ELEM", vmin=500, vmax=2000)
>>> mask = mapdl.post_processing.selected_nodes
Postprocessing object methods
------------------------------
For a list of all postprocessing methods, see
:ref:`post_processing_api`.


Enriched command output
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -72,7 +147,7 @@ These commands are listed in Table-1_.
| **Listing** | | |
+----------------+---------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------+

.. warning:: If you use these methods, you might obtain a lower
.. warning:: If you use methods like :func:`Mapdl.nlist() <ansys.mapdl.core.Mapdl.nlist>` , you might obtain a lower
precision than using :class:`Mesh <ansys.mapdl.core.mesh_grpc.MeshGrpc>` methods.

Here's a simple example that demonstrates usage:
Expand Down Expand Up @@ -110,105 +185,3 @@ Here's a simple example that demonstrates usage:
NODE UX
0 1.0
1 2.0
Examples
~~~~~~~~
You would typically request nodal results from MAPDL using the
``PRNSOL`` command:

.. code:: output
POST1:
PRNSOL, U, X
PRINT U NODAL SOLUTION PER NODE
***** POST1 NODAL DEGREE OF FREEDOM LISTING *****
LOAD STEP= 1 SUBSTEP= 1
TIME= 1.0000 LOAD CASE= 0
THE FOLLOWING DEGREE OF FREEDOM RESULTS ARE IN THE GLOBAL COORDINATE SYSTEM
NODE UX
1 0.10751E-003
2 0.85914E-004
3 0.57069E-004
4 0.13913E-003
5 0.35621E-004
6 0.52186E-004
7 0.30417E-004
8 0.36139E-004
9 0.15001E-003
MORE (YES,NO OR CONTINUOUS)=
However, using an instance of the :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>`
class, you can instead request the nodal displacement:

.. code:: pycon
>>> mapdl.set(1, 1)
>>> disp_x = mapdl.post_processing.nodal_displacement("X")
array([1.07512979e-04, 8.59137773e-05, 5.70690047e-05, ...,
5.70333124e-05, 8.58600402e-05, 1.07445726e-04])
You could also plot the nodal displacement with this code:

.. code:: pycon
>>> mapdl.post_processing.plot_nodal_displacement("X")
.. figure:: ../images/post_norm_disp.png
:width: 300pt

Normalized Displacement of a Cylinder from MAPDL


Selecting entities
------------------
You can select entities such as nodes, or lines using the following methods:

* :func:`Mapdl.nsel() <ansys.mapdl.core.Mapdl.nsel>`
* :func:`Mapdl.esel() <ansys.mapdl.core.Mapdl.esel>`
* :func:`Mapdl.ksel() <ansys.mapdl.core.Mapdl.ksel>`
* :func:`Mapdl.lsel() <ansys.mapdl.core.Mapdl.lsel>`
* :func:`Mapdl.asel() <ansys.mapdl.core.Mapdl.asel>`
* :func:`Mapdl.vsel() <ansys.mapdl.core.Mapdl.vsel>`

These methods returns the ids of the selected entities. For example:

.. code:: pycon
>>> selected_nodes = mapdl.nsel("S", "NODE", vmin=1, vmax=2000)
>>> print(selected_nodes)
array([ 1 2 3 ... 1998 1999 2000])
.. code:: pycon
>>> mapdl.ksel("all")
array([1, 2, 3, ..., 1998, 1999, 2000])
Selected nodes
~~~~~~~~~~~~~~

The MAPDL database processes some results independently if nodes or
elements are selected. If you have subselected a certain component
and want to also limit the result of a certain output
(:func:`nodal_displacement() <ansys.mapdl.core.post.PostProcessing.nodal_displacement>`),
use the :attr:`selected_nodes <ansys.mapdl.core.post.PostProcessing.selected_nodes>` attribute to get
a mask of the currently selected nodes:

.. code:: pycon
>>> mapdl.nsel("S", "NODE", vmin=1, vmax=2000)
>>> mapdl.esel("S", "ELEM", vmin=500, vmax=2000)
>>> mask = mapdl.post_processing.selected_nodes
Postprocessing object methods
------------------------------
For a full list of all available postprocessing methods, see
:ref:`post_processing_api`.

0 comments on commit d5c4edc

Please sign in to comment.