Skip to content

Commit

Permalink
chore: merge remote-tracking branch 'origin/main' into refactor/addin…
Browse files Browse the repository at this point in the history
…g-type-ints-to-misc
  • Loading branch information
germa89 committed Nov 18, 2024
2 parents b7447d2 + 6677797 commit 1e9238a
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 87 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/3527.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DOC: Update pymapdl.rst
1 change: 1 addition & 0 deletions doc/changelog.d/3549.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs: extracting information to another rst file
1 change: 1 addition & 0 deletions doc/changelog.d/3550.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
refactor: adding logging calls to misc.py
1 change: 1 addition & 0 deletions doc/changelog.d/3551.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
refactor: removing-`run_as_prep7`-in-favour-of-`run_as`
1 change: 1 addition & 0 deletions doc/changelog.d/3552.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: warning and add an exception if using class alone
1 change: 1 addition & 0 deletions doc/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ PyMAPDL, see :ref:`ref_mapdl_commands`.
database
geometry
helper
information
inline
krylov
launcher
Expand Down
35 changes: 35 additions & 0 deletions doc/source/api/information.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.. _ref_information_api:

``Information`` module
======================

``Information`` class attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. currentmodule:: ansys.mapdl.core.information

.. autosummary::
:toctree: _autosummary

Information.aux_capabilities
Information.boundary_condition_information
Information.config_values
Information.database_status
Information.global_status
Information.job_information
Information.load_step_options
Information.mapdl_version
Information.model_information
Information.post_capabilities
Information.preprocessing_capabilities
Information.product
Information.products
Information.pymapdl_version
Information.routine_information
Information.scratch_memory_status
Information.solution_options
Information.solution_options_configuration
Information.stitles
Information.title
Information.titles
Information.units
90 changes: 53 additions & 37 deletions doc/source/api/mapdl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,68 @@
:toctree: _autosummary

Mapdl.add_file_handler
Mapdl.allow_ignore
Mapdl.busy
Mapdl.chain_commands
Mapdl.check_parameter_names
Mapdl.default_file_type_for_plots
Mapdl.directory
Mapdl.exited
Mapdl.exiting
Mapdl.file_type_for_plots
Mapdl.finish_job_on_exit
Mapdl.force_output
Mapdl.get
Mapdl.get_array
Mapdl.get_esol
Mapdl.get_nodal_constrains
Mapdl.get_nodal_loads
Mapdl.get_nsol
Mapdl.get_value
Mapdl.get_variable
Mapdl.hostname
Mapdl.ignore_errors
Mapdl.info
Mapdl.input_strings
Mapdl.is_alive
Mapdl.is_console
Mapdl.is_corba
Mapdl.is_grpc
Mapdl.jobid
Mapdl.jobname
Mapdl.kill_job
Mapdl.last_response
Mapdl.launched
Mapdl.list_error_file
Mapdl.list_files
Mapdl.load_array
Mapdl.load_table
Mapdl.mesh
Mapdl.modal_analysis
Mapdl.locked
Mapdl.logger
Mapdl.mapdl_on_hpc
Mapdl.mute
Mapdl.name
Mapdl.non_interactive
Mapdl.on_docker
Mapdl.open_apdl_log
Mapdl.open_gui
Mapdl.parameters
Mapdl.platform
Mapdl.print_com
Mapdl.process_is_alive
Mapdl.remove_file_handler
Mapdl.remove_temp_dir_on_exit
Mapdl.result
Mapdl.result_file
Mapdl.run
Mapdl.run_as_routine
Mapdl.run_multiline
Mapdl.input_strings
Mapdl.save_selection
Mapdl.scalar_param
Mapdl.screenshot
Mapdl.set_log_level
Mapdl.version
Mapdl.thermal_result
Mapdl.use_vtk
Mapdl.file_type_for_plots
Mapdl.version


Constants
Expand All @@ -57,40 +95,18 @@ Constants
.. autosummary::
:toctree: _autosummary

mapdl_grpc.MapdlGrpc.channel_state
mapdl_grpc.MapdlGrpc.check_status
mapdl_grpc.MapdlGrpc.connection
mapdl_grpc.MapdlGrpc.download
mapdl_grpc.MapdlGrpc.download_project
mapdl_grpc.MapdlGrpc.download_result
mapdl_grpc.MapdlGrpc.file
mapdl_grpc.MapdlGrpc.ip
mapdl_grpc.MapdlGrpc.is_local
mapdl_grpc.MapdlGrpc.list_error_file
mapdl_grpc.MapdlGrpc.list_files
mapdl_grpc.MapdlGrpc.mute
mapdl_grpc.MapdlGrpc.port
mapdl_grpc.MapdlGrpc.upload


``Information`` class attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. currentmodule:: ansys.mapdl.core.information

.. autosummary::
:toctree: _autosummary

Information.product
Information.mapdl_version
Information.pymapdl_version
Information.products
Information.preprocessing_capabilities
Information.aux_capabilities
Information.solution_options
Information.post_capabilities
Information.title
Information.titles
Information.stitles
Information.units
Information.scratch_memory_status
Information.database_status
Information.config_values
Information.global_status
Information.job_information
Information.model_information
Information.boundary_condition_information
Information.routine_information
Information.solution_options_configuration
Information.load_step_options
2 changes: 1 addition & 1 deletion doc/source/user_guide/hpc/pymapdl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Introduction

PyMAPDL communicates with MAPDL using the gRPC protocol.
This protocol offers the many advantages and features described in
see :ref:`ref_project_page`.
:ref:`ref_project_page`.
One of these features is that it is not required to have both
PyMAPDL and MAPDL processes running on the same machine.
This possibility opens the door to many configurations, depending
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/mapdl/core/mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MapdlBase(_MapdlExtended):
"""Base MAPDL class shared across all MAPDL subclasses.
.. warning:: This class should NOT be imported by itself.
You should always import a subclass of it
"""
You should always import a subclass of it like
:class:`MapdlGrpc <ansys.mapdl.core.mapdl_grpc.MapdlGrpc>`
pass
"""
19 changes: 16 additions & 3 deletions src/ansys/mapdl/core/mapdl_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
last_created,
random_string,
requires_package,
run_as_prep7,
run_as,
supress_logging,
)

Expand Down Expand Up @@ -295,7 +295,7 @@ def __init__(
self._start_parm: Dict[str, Any] = start_parm
self._jobname: str = start_parm.get("jobname", "file")
self._path: Union[str, pathlib.Path] = start_parm.get("run_location", None)
self.check_parameter_names = start_parm.get("check_parameter_names", True)
self._check_parameter_names = start_parm.get("check_parameter_names", True)

# Setting up loggers
self._log: logger = logger.add_instance_logger(
Expand Down Expand Up @@ -715,8 +715,19 @@ def launched(self):
"""Check if the MAPDL instance has been launched by PyMAPDL."""
return self._launched

@property
def check_parameter_names(self):
"""Whether check if the name which is given to the parameter is allowed or not"""
return self._check_parameter_names

@check_parameter_names.setter
def check_parameter_names(self, value: bool):
"""Whether check if the name which is given to the parameter is allowed or not"""
self._check_parameter_names = value

@property
def logger(self) -> logging.Logger:
"""MAPDL Python-based logger"""
return self._log

@property
Expand Down Expand Up @@ -870,6 +881,8 @@ def post_processing(self) -> "PostProcessing":

@property
def print_com(self):
"""Whether to print or not to the console the
:meth:`mapdl.com ("/COM") <ansys.mapdl.core.Mapdl.com>` calls."""
return self._print_com

@print_com.setter
Expand Down Expand Up @@ -1561,7 +1574,7 @@ def open_apdl_log(
)

@supress_logging
@run_as_prep7
@run_as("PREP7")
def _generate_iges(self):
"""Save IGES geometry representation to disk"""
filename = os.path.join(self.directory, "_tmp.iges")
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/mapdl/core/mapdl_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
if TYPE_CHECKING: # pragma: no cover
from pyiges import Iges

from ansys.mapdl.core.misc import requires_package, run_as_prep7, supress_logging
from ansys.mapdl.core.misc import requires_package, run_as, supress_logging
from ansys.mapdl.core.plotting.theme import MapdlTheme

VALID_SELECTION_TYPE = ["S", "R", "A", "U"]
Expand Down Expand Up @@ -614,7 +614,7 @@ def get_areas(
return areas

@supress_logging
@run_as_prep7
@run_as("PREP7")
@requires_package("pyvista")
def generate_surface(
self,
Expand Down
45 changes: 24 additions & 21 deletions src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
last_created,
only_numbers_and_dots,
random_string,
run_as_prep7,
run_as,
supress_logging,
)
from ansys.mapdl.core.parameters import interp_star_status
Expand Down Expand Up @@ -629,6 +629,7 @@ def _is_alive_subprocess(self):

@property
def process_is_alive(self):
"""Check if the MAPDL process is alive"""
return self._is_alive_subprocess()

def _post_mortem_checks(self):
Expand Down Expand Up @@ -2960,7 +2961,7 @@ def __str__(self):
return info

@supress_logging
@run_as_prep7
@run_as("PREP7")
def _generate_iges(self):
"""Save IGES geometry representation to disk"""
basename = "_tmp.iges"
Expand Down Expand Up @@ -3403,24 +3404,20 @@ def get_esol(
node : int
Node number on this element for which data are to be
stored. If blank, store the average element value (except
for FMAG values, which are summed instead of averaged).
for ``FMAG`` values, which are summed instead of averaged).
item : str
Label identifying the item. General item labels are shown
in Table 134: ESOL - General Item and Component Labels
below. Some items also require a component label.
Label identifying the item. Some items also require a component label.
comp : str
Component of the item (if required). General component
labels are shown in Table 134: ESOL - General Item and
Component Labels below. If Comp is a sequence number (n),
the NODE field will be ignored.
Component of the item (if required). If Comp is a sequence number (n),
the ``NODE`` field will be ignored.
name : str, optional
Thirty-two character name for identifying the item on the
printout and displays. The default is a label formed by
concatenating the first four characters of the ``item`` and
``comp`` labels.
``comp`` labels.
tstrt : str, optional
Time (or frequency) corresponding to start of IR data. If between
Expand All @@ -3441,21 +3438,18 @@ def get_esol(
Notes
-----
By default, this command store temporally the variable on the
variable number set by ``VAR_IR`` in the class MapdlGrpc.
variable number set by ``VAR_IR`` in the class
:class:`Mapdl <ansys.mapdl.core.mapdl.MapdlBase>`
Therefore, any variable in that slot will be deleted when using
this command.
See Table: 134:: ESOL - General Item and Component Labels for
a list of valid item and component labels for element (except
line element) results.
The ESOL command defines element results data to be stored
from a results file (FILE). Not all items are valid for all
The ``ESOL`` command defines element results data to be stored
from a results file (``FILE``). Not all items are valid for all
elements. To see the available items for a given element,
refer to the input and output summary tables in the
documentation for that element.
Two methods of data access are available via the ESOL
Two methods of data access are available via the ``ESOL``
command. You can access some simply by using a generic label
(component name method), while others require a label and
number (sequence number method).
Expand All @@ -3476,10 +3470,10 @@ def get_esol(
system. Element forces and moments are in the nodal
coordinate system. Results are obtainable for an element at a
specified node. Further location specifications can be made
for some elements via the SHELL, LAYERP26, and FORCE commands.
for some elements via the ``SHELL``, ``LAYERP26``, and ``FORCE`` commands.
For more information on the meaning of contact status and its
possible values, see Reviewing Results in POST1 in the Contact
possible values, see Reviewing Results in ``POST1`` in the Contact
Technology Guide.
"""
self.esol(
Expand Down Expand Up @@ -3759,6 +3753,15 @@ def get_file_name(path):
return os.path.basename(target_dir)

def kill_job(self, jobid: int) -> None:
"""Kill an HPC job
Kill a job given its identifier.
Parameters
----------
jobid : int
Job ID.
"""
cmd = ["scancel", f"{jobid}"]
# to ensure the job is stopped properly, let's issue the scancel twice.
subprocess.Popen(cmd)
Expand Down
Loading

0 comments on commit 1e9238a

Please sign in to comment.