Skip to content

Commit f465260

Browse files
committed
Mapdl.info property (#1073)
* Defining 'Information' class * Implementing 'Information' class * Adding unit tests * Improving coverage * Fixing unit tests. * Fixing unit tests * fixing unit tests * fixing unit tests * Adding extra field getters * Adding mapping to /status command, unit tests and documentation. * Using a pure class instead of a dict. * removing previous test. * removing previous test. * Adding title and stitles method. Adding code review suggestions * Adding docs and unit tests * Adding docs and unit tests * Fixing unit test. * Fixing unit tests * Removing most setters. * Fixing unit tests
1 parent 6b31458 commit f465260

File tree

5 files changed

+485
-30
lines changed

5 files changed

+485
-30
lines changed

doc/source/api/mapdl.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,37 @@ Latest 2021R1 and newer features
5151
mapdl_grpc.MapdlGrpc.math
5252
mapdl_grpc.MapdlGrpc.mute
5353
mapdl_grpc.MapdlGrpc.upload
54+
55+
56+
Mapdl Information Class
57+
~~~~~~~~~~~~~~~~~~~~~~~
58+
59+
.. currentmodule:: ansys.mapdl.core.misc
60+
61+
.. autoclass:: ansys.mapdl.core.misc.Information
62+
63+
.. autosummary::
64+
:toctree: _autosummary
65+
66+
Information.product
67+
Information.mapdl_version
68+
Information.pymapdl_version
69+
Information.products
70+
Information.preprocessing_capabilities
71+
Information.aux_capabilities
72+
Information.solution_options
73+
Information.post_capabilities
74+
Information.title
75+
Information.titles
76+
Information.stitles
77+
Information.units
78+
Information.scratch_memory_status
79+
Information.database_status
80+
Information.config_values
81+
Information.global_status
82+
Information.job_information
83+
Information.model_information
84+
Information.boundary_condition_information
85+
Information.routine_information
86+
Information.solution_options_configuration
87+
Information.load_step_options

src/ansys/mapdl/core/mapdl.py

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from ansys.mapdl.core.errors import MapdlInvalidRoutineError, MapdlRuntimeError
3131
from ansys.mapdl.core.inline_functions import Query
3232
from ansys.mapdl.core.misc import (
33+
Information,
3334
last_created,
3435
load_file,
3536
random_string,
@@ -200,6 +201,8 @@ def __init__(
200201

201202
self._wrap_listing_functions()
202203

204+
self._info = Information(self)
205+
203206
@property
204207
def print_com(self):
205208
return self._print_com
@@ -569,27 +572,12 @@ def clear(self, *args, **kwargs):
569572

570573
@supress_logging
571574
def __str__(self):
572-
try:
573-
if self._exited:
574-
return "MAPDL exited"
575-
stats = self.slashstatus("PROD")
576-
except Exception: # pragma: no cover
577-
return "MAPDL exited"
578-
579-
st = stats.find("*** Products ***")
580-
en = stats.find("*** PrePro")
581-
product = "\n".join(stats[st:en].splitlines()[1:]).strip()
582-
583-
# get product version
584-
stats = self.slashstatus("TITLE")
585-
st = stats.find("RELEASE")
586-
en = stats.find("INITIAL", st)
587-
mapdl_version = stats[st:en].split("CUSTOMER")[0].strip()
588-
589-
info = [f"Product: {product}"]
590-
info.append(f"MAPDL Version: {mapdl_version}")
591-
info.append(f"PyMAPDL Version: {pymapdl.__version__}\n")
592-
return "\n".join(info)
575+
return self.info.__str__()
576+
577+
@property
578+
def info(self):
579+
"""General information"""
580+
return self._info
593581

594582
@property
595583
def geometry(self):
@@ -2419,11 +2407,10 @@ def run(self, command, write_to_log=True, mute=None, **kwargs) -> str:
24192407
msg = f"{cmd_} is ignored: {INVAL_COMMANDS_SILENT[cmd_]}."
24202408
self._log.info(msg)
24212409

2422-
# This very likely won't be recorded anywhere.
2423-
2410+
# This, very likely, won't be recorded anywhere.
24242411
# But just in case, I'm adding info as /com
24252412
command = (
2426-
f"/com, PyAnsys: {msg}" # Using '!' makes the output of '_run' empty
2413+
f"/com, PyMAPDL: {msg}" # Using '!' makes the output of '_run' empty
24272414
)
24282415

24292416
if command[:3].upper() in INVAL_COMMANDS:

0 commit comments

Comments
 (0)