Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring base Mapdl class. #2518

Merged
merged 15 commits into from
Dec 18, 2023
2 changes: 1 addition & 1 deletion doc/source/api/mapdl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

.. currentmodule:: ansys.mapdl.core

.. autoclass:: ansys.mapdl.core.mapdl._MapdlCore
.. autoclass:: ansys.mapdl.core.mapdl.MapdlBase

.. autosummary::
:toctree: _autosummary
Expand Down
2 changes: 1 addition & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ immediately and Pythonically.
Calling MAPDL Pythonically
~~~~~~~~~~~~~~~~~~~~~~~~~~
MAPDL functions can be called directly from a :class:`Mapdl
<ansys.mapdl.core.mapdl._MapdlCore>` instance in a Pythonic manner. This is to
<ansys.mapdl.core.mapdl.MapdlBase>` instance in a Pythonic manner. This is to
germa89 marked this conversation as resolved.
Show resolved Hide resolved
simplify calling MAPDL, especially when inputs are variables within
Python. For example, the following two commands are equivalent:

Expand Down
8 changes: 4 additions & 4 deletions doc/source/user_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PyMAPDL overview
================
The :func:`launch_mapdl() <ansys.mapdl.core.launcher.launch_mapdl>` function
within the ``ansys-mapdl-core`` library creates an instance of the
:class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class in the background and sends
:class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class in the background and sends
commands to that instance. Errors and warnings are processed
Pythonically, letting you develop a script in real time, without
worrying about it functioning correctly when deployed in batch
Expand Down Expand Up @@ -95,7 +95,7 @@ you can write your MAPDL scripts in Python, run them interactively, and
then run them as a batch without worrying if the script would run correctly if
you had instead outputted it to a script file.

The :class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class supports much more
The :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class supports much more
than just sending text to MAPDL. It includes higher-level wrapping,
allowing for better scripting and interaction with MAPDL. For an overview of the
various advanced methods to visualize, script, and interact with MAPDL, see
Expand All @@ -105,7 +105,7 @@ various advanced methods to visualize, script, and interact with MAPDL, see
Calling MAPDL Pythonically
~~~~~~~~~~~~~~~~~~~~~~~~~~
MAPDL functions can be called directly from an instance of
:class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` in a Pythonic manner. This is
:class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` in a Pythonic manner. This is
to simplify calling Ansys, especially when inputs are variables within
Python. For example, the following two commands are equivalent:

Expand Down Expand Up @@ -165,7 +165,7 @@ area creation example, you can instead run:
mapdl.al(1, 2, 3, 4)

This approach has some obvious advantages, chiefly that it's a bit
easier to script as :class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>`
easier to script as :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>`
takes care of the string formatting for you. For example, inputting
points from a numpy array:

Expand Down
12 changes: 6 additions & 6 deletions doc/source/user_guide/mapdl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PyMAPDL language and usage
==========================

This page gives you an overview of the PyMAPDL API for the
:class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class.
:class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class.
For more information, see :ref:`ref_mapdl_api`.

Overview
Expand Down Expand Up @@ -121,7 +121,7 @@ Some commands can only be run non-interactively from within a
script. PyMAPDL gets around this restriction by writing the commands
to a temporary input file and then reading the input file. To run a
group of commands that must be run non-interactively, set the
:class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class to run a series
:class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class to run a series
of commands as an input file by using the
:func:`Mapdl.non_interactive() <ansys.mapdl.core.Mapdl.non_interactive>`
method. Here is an example:
Expand Down Expand Up @@ -532,7 +532,7 @@ APDL session by calling it using Python, it might be necessary to call
MAPDL again using an input file generated from a PyMAPDL script. This
is automatically enabled with the ``log_apdl='apdl.log'`` parameter.
Enabling this parameter causes the
:class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class to write each
:class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class to write each
command run into a log file named ``"apdl.log"`` in the active
:attr:`Mapdl.directory <ansys.mapdl.core.Mapdl.directory>`.
For example:
Expand Down Expand Up @@ -571,7 +571,7 @@ entire database command log to a file.
Interactive breakpoint
======================
In most circumstances, it is necessary or preferable to open up the
MAPDL GUI. The :class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class
MAPDL GUI. The :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class
has the :func:`Mapdl.open_gui() <ansys.mapdl.core.Mapdl.open_gui>` method, which
allows you to seamlessly open up the GUI without losing work or
having to restart your session. For example:
Expand Down Expand Up @@ -786,7 +786,7 @@ would run:
However, because each command executes individually and returns a
response, it is much faster to send the commands to be executed by
MAPDL in groups and have the :class:`Mapdl
<ansys.mapdl.core.mapdl._MapdlCore>` class handle grouping the commands by
<ansys.mapdl.core.mapdl.MapdlBase>` class handle grouping the commands by
using the :attr:`Mapdl.chain_commands <ansys.mapdl.core.Mapdl.chain_commands>` attribute.

.. code:: python
Expand Down Expand Up @@ -844,7 +844,7 @@ was a Python dictionary:
Download a remote MAPDL file
----------------------------
When running MAPDL in gRPC mode, remote MAPDL files can be listed and
downloaded using the :class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>`
downloaded using the :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>`
class with the :func:`Mapdl.download() <ansys.mapdl.core.mapdl_grpc.MapdlGrpc.download>`
function. For example, the following code lists the remote files and downloads one of them:

Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/mapdl_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Here is the beginning of the MAPDL script:
PRESSURE = FORCE/(H_TIP*2*PI*RADIUS)

Here is the corresponding PyMAPDL script, including the initialization of an
instance of the :class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class:
instance of the :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class:

.. code:: python

Expand Down
4 changes: 2 additions & 2 deletions doc/source/user_guide/mesh_geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

Mesh and geometry
=================
The :class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class allows you to access
The :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class allows you to access
the mesh and geometry without writing to an intermediate file or
interpreting the text output from various MAPDL commands. For
example, to access the nodes and elements of a model, normally you
Expand All @@ -53,7 +53,7 @@ software:

However, with the :attr:`Mapdl.mesh <ansys.mapdl.core.mesh_grpc.MeshGrpc>` class,
you can interface with a current instance of the
:class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class and access the current nodes coordinates
:class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class and access the current nodes coordinates
with this code:

.. code:: pycon
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Setting and retrieving parameters
*********************************

MAPDL parameters can be retrieved from an instance of
:class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>`
:class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>`
using the :attr:`Mapdl.parameters <ansys.mapdl.core.Mapdl.parameters>`.
For example, if you want to use MAPDL's
:func:`Mapdl.get() <ansys.mapdl.core.Mapdl.get>` method to
Expand Down
4 changes: 2 additions & 2 deletions doc/source/user_guide/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Interactive plotting
When generating geometry from scratch within MAPDL, it is often
necessary to plot the geometry, such as key points, lines, areas,
and volumes. PyMAPDL supports plotting basic CAD using VTK. The
:class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class leverages the
:class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class leverages the
existing MAPDL commands by providing the following functions, which
transfer the geometry to Python to visualize it:

Expand Down Expand Up @@ -75,7 +75,7 @@ extrudes it.
Node and element plotting
~~~~~~~~~~~~~~~~~~~~~~~~~
You can plot nodes and elements directly from the instance of the
:class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class. This code defines
:class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class. This code defines
some element types, performs meshing, and then displays the mesh:

.. code:: pycon
Expand Down
1 change: 1 addition & 0 deletions doc/source/user_guide/pool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Create a pool of MAPDL instances
================================

PyMAPDL contains the :class:`LocalMapdlPool <ansys.mapdl.core.pool.LocalMapdlPool>`
class to simplify creating multiple local instances of the
:class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>`
Expand Down
8 changes: 4 additions & 4 deletions doc/source/user_guide/post.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Postprocessing
==============
In an active MAPDL session, you can postprocess using the
:class:`Mapdl.post_processing <ansys.mapdl.core.post.PostProcessing>` class,
an attribute of an instance of :class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>`.
an attribute of an instance of :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>`.
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.
Expand All @@ -27,10 +27,10 @@ streamed back to the client for review or visualization.

Enriched command output
~~~~~~~~~~~~~~~~~~~~~~~
All :class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class commands output
All :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class commands output
a string object that can be parsed to obtain specific data from it.

In certain :class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>` class commands
In certain :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>` class commands
the returned string contains some methods to process the output.
These commands are listed in Table-1_.

Expand Down Expand Up @@ -143,7 +143,7 @@ You would typically request nodal results from MAPDL using the
MORE (YES,NO OR CONTINUOUS)=


However, using an instance of the :class:`Mapdl <ansys.mapdl.core.mapdl._MapdlCore>`
However, using an instance of the :class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>`
class, you can instead request the nodal displacement:

.. code:: pycon
Expand Down
149 changes: 93 additions & 56 deletions src/ansys/mapdl/core/_commands/apdl/parameter_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,78 +200,115 @@ def get(

APDL Command: ``*GET``

See the full MADPL command at `*GET
<https://www.mm.bme.hu/~gyebro/files/ans_help_v182/ans_cmd/Hlp_C_GET.html>`_

GET retrieves a value for a specified item and stores the
value as a scalar parameter, or as a value in a user-named
array parameter. An item is identified by various keyword,
label, and number combinations. Usage is similar to the SET
command except that the parameter values are retrieved from
previously input or calculated results. For example,
``GET,A,ELEM,5,CENT,X`` returns the centroid x-location of element
5 and stores the result as parameter A. GET command
operations, along with the associated Get functions return
values in the active coordinate system unless stated
otherwise. A Get function is an alternative in- line function
that can be used to retrieve a value instead of the GET
command (see Using In-line Get Functions for more
information).
Both GET and VGET retrieve information from the active data
stored in memory. The database is often the source, and
sometimes the information is retrieved from common memory
blocks that the program uses to manipulate
information. Although POST1 and POST26 operations use a .rst
file, GET data is accessed from the database or from the
common blocks. Get operations do not access the .rst file
directly. For repeated gets of sequential items, such as from
a series of elements, see the VGET command.
Most items are stored in the database after they are
calculated and are available anytime thereafter. Items are
grouped according to where they are usually first defined or
calculated. Preprocessing data will often not reflect the
calculated values generated from section data. Do not use GET
to obtain data from elements that use calculated section data,
such as beams or shells. Most of the general items listed
below are available from all modules.

Parameters
----------
par
The name of the resulting parameter. See ``*SET`` for name
par : str, optional
The name of the resulting parameter. See \*SET for name
restrictions.

entity
Entity keyword. Valid keywords are NODE, ELEM, KP, LINE, AREA,
VOLU, PDS, etc., as shown for Entity = in the tables below.
Entity keyword. Valid keywords are NODE, ELEM, KP, LINE,
AREA, VOLU, PDS, etc., as shown for Entity = in the tables
below.

entnum
The number or label for the entity (as shown for ENTNUM = in the
tables below). In some cases, a zero (or blank) ENTNUM represents
all entities of the set.
The number or label for the entity (as shown for ENTNUM =
in the tables below). In some cases, a zero (or blank)
ENTNUM represents all entities of the set.

item1
The name of a particular item for the given entity. Valid items are
as shown in the Item1 columns of the tables below.
The name of a particular item for the given entity.

it1num
The number (or label) for the specified Item1 (if any). Valid
IT1NUM values are as shown in the IT1NUM columns of the tables
below. Some Item1 labels do not require an IT1NUM value.
The number (or label) for the specified Item1 (if
any). Valid IT1NUM values are as shown in the IT1NUM
columns of the tables below. Some Item1 labels do not
require an IT1NUM value.

item2, it2num
A second set of item labels and numbers to further qualify the item
A second set of item labels and numbers to further qualify
the item for which data are to be retrieved. Most items do
not require this level of information.

item3
A third set of item labels to further qualify
the item for which data are to be retrieved. Almost all items do
not require this level of information.

item3 : str, optional
A third set of item labels and numbers to further qualify the item
for which data are to be retrieved. Most items do not require this
level of information.

Notes
-----
``*GET`` retrieves a value for a specified item and stores the value as a
scalar parameter, or as a value in a user-named array parameter. An
item is identified by various keyword, label, and number combinations.
Usage is similar to the ``*SET`` command except that the parameter values
are retrieved from previously input or calculated results. For example,
``*GET,A,ELEM,5,CENT,X`` returns the centroid x-location of element 5 and
stores the result as parameter A. ``*GET`` command operations, along with
the associated Get functions return values in the active coordinate
system unless stated otherwise. A Get function is an alternative in-
line function that can be used to retrieve a value instead of the ``*GET``
command (see Using In-line Get Functions for more information).

Both ``*GET`` and ``*VGET`` retrieve information from the active data stored in
memory. The database is often the source, and sometimes the information
is retrieved from common memory blocks that the program uses to
manipulate information. Although POST1 and POST26 operations use a
*.rst file, ``*GET`` data is accessed from the database or from the common
blocks. Get operations do not access the *.rst file directly. For
repeated gets of sequential items, such as from a series of elements,
see the ``*VGET`` command.

Most items are stored in the database after they are calculated and are
available anytime thereafter. Items are grouped according to where they
are usually first defined or calculated. Preprocessing data will often
not reflect the calculated values generated from section data. Do not
use ``*GET`` to obtain data from elements that use calculated section data,
such as beams or shells. Most of the general items listed below are
available from all modules. Each of the sections for accessing ``*GET``
parameters are shown in the following order:

``*GET`` General Entity Items

``*GET`` Preprocessing Entity Items

``*GET`` Solution Entity Items

``*GET`` Postprocessing Entity Items

``*GET`` Probabilistic Design Entity Items

The ``*GET`` command is valid in any processor.
it3num : str, int, optional
The number (or label) for the specified ``item3`` (if
any). Some ``item3`` labels do not require an ``it3num``
value.

item4 : str, optional
A fourth set of item labels and numbers to further qualify the item
for which data are to be retrieved. Most items do not require this level of information.

it4num : str, int, optional
The number (or label) for the specified ``item4`` (if
any). Some ``item4`` labels do not require an ``it4num``
value.

Returns
-------
float
Floating point value of the parameter.

Examples
--------
Retrieve the number of nodes

>>> value = mapdl.get('val', 'node', '', 'count')
>>> value
3003

Retrieve the number of nodes using keywords. Note that the
parameter name is optional.

>>> value = mapdl.get(entity='node', item1='count')
>>> value
3003

"""
command = f"*GET,{par},{entity},{entnum},{item1},{it1num},{item2},{it2num}"
return self.run(command, **kwargs)
Expand Down
Loading
Loading