Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ examples/.local
.ipynb_checkpoints/

# docker
docker/mapdl/v211
docker/mapdl/v211

# temp testing
tmp.out
2 changes: 1 addition & 1 deletion ansys/mapdl/core/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Version of ansys-mapdl-core module."""

# major, minor, patch
version_info = 0, 57, 5
version_info = 0, 57, 6

# Nice string for the version
__version__ = '.'.join(map(str, version_info))
8 changes: 5 additions & 3 deletions ansys/mapdl/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def _get_available_base_ansys():

Within Linux

>>>
>>> _get_available_base_ansys()
{194: '/usr/ansys_inc/v194',
202: '/usr/ansys_inc/v202',
211: '/usr/ansys_inc/v211'}
Expand All @@ -402,12 +402,12 @@ def _get_available_base_ansys():
raise OSError(f'Unsupported OS {os.name}')

if base_path is None:
return '', ''
return {}

paths = glob(os.path.join(base_path, 'v*'))

if not paths:
return None
return {}

ansys_paths = {}
for path in paths:
Expand Down Expand Up @@ -444,6 +444,8 @@ def find_ansys():
(/usr/ansys_inc/v211/ansys/bin/ansys211, 21.1)
"""
versions = _get_available_base_ansys()
if not versions:
return '', ''
version = max(versions.keys())
ans_path = versions[version]
if os.name == 'nt':
Expand Down
22 changes: 16 additions & 6 deletions ansys/mapdl/core/mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import tempfile
from shutil import rmtree, copyfile
import weakref
import warnings

import numpy as np
import pyvista as pv
Expand All @@ -25,6 +26,11 @@
from ansys.mapdl.core.plotting import general_plotter
from ansys.mapdl.core.post import PostProcessing

_PERMITTED_ERRORS = [
r'(\*\*\* ERROR \*\*\*).*(?:[\r\n]+.*)+highly distorted.',
r'(\*\*\* ERROR \*\*\*).*[\r\n]+.*is turning inside out.',
]


MATPLOTLIB_LOADED = True
try:
Expand Down Expand Up @@ -1766,15 +1772,19 @@ def run(self, command, write_to_log=True, **kwargs):
text += '\n\nIgnore these messages by setting allow_ignore=True'
raise MapdlInvalidRoutineError(text)

# flag error
# flag errors
if '*** ERROR ***' in self._response and not self._ignore_errors:
# remove "is turning inside out" as this allows the
# solution to continue
sub = re.sub(r'(\*\*\* ERROR \*\*\*).*[\r\n]+.*is turning inside out.',
'', self._response)
if '*** ERROR ***' in sub:
# remove permitted errors and allow MAPDL to continue
response = self._response
for err_str in _PERMITTED_ERRORS:
response = re.sub(err_str, '', response)

if '*** ERROR ***' in response:
self._log.error(self._response)
raise MapdlRuntimeError(self._response)
else:
warnings.warn('MAPDL returned non-abort errors. Please '
'check the logs.')

# special returns for certain geometry commands
short_cmd = parse_to_short_cmd(command)
Expand Down
6 changes: 3 additions & 3 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ or in Linux

.. code::

PYANSYS_START_INSTANCE=False
PYMAPDL_PORT=<MAPDL Port> (default 50052)
PYMAPDL_IP=<MAPDL IP> (default 127.0.0.1)
export PYMAPDL_START_INSTANCE=False
export PYMAPDL_PORT=<MAPDL Port> (default 50052)
export PYMAPDL_IP=<MAPDL IP> (default 127.0.0.1)

This will tell the ``ansys.mapdl.core`` to attempt to connect to the existing
MAPDL service by default when the ``launch_mapdl`` function is used.
Expand Down
24 changes: 22 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,29 @@

# check if the user wants to permit pytest to start MAPDL
START_INSTANCE = get_start_instance()
# if START_INSTANCE:
# local.append(True)

if os.name == 'nt':
os_msg = """SET PYMAPDL_START_INSTANCE=False
SET PYMAPDL_PORT=<MAPDL Port> (default 50052)
SET PYMAPDL_IP=<MAPDL IP> (default 127.0.0.1)"""
else:
os_msg = """export PYMAPDL_START_INSTANCE=False
export PYMAPDL_PORT=<MAPDL Port> (default 50052)
export PYMAPDL_IP=<MAPDL IP> (default 127.0.0.1)"""

ERRMSG = f"""Unable to run CI without MAPDL installed or accessible.
Either install Ansys 2021R1 or newer or specify the remote server with:

{os_msg}

If you do have Ansys installed, you may have to patch pymapdl to
automatically find your Ansys installation. Email the developer at:
alexander.kaszynski@ansys.com

"""

if START_INSTANCE and EXEC_FILE is None:
raise RuntimeError(ERRMSG)

def pytest_addoption(parser):
parser.addoption(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_basic_input_output(mapdl, tmpdir):
f.write('FINISH\n')
f.write('/PREP7\n')

resp = mapdl.upload(basic_inp)
mapdl.upload(basic_inp)
tmpfile = 'tmp.out'
mapdl._send_command('/OUT, %s' % tmpfile, mute=True)
mapdl._send_command('/INPUT, %s' % filename, mute=True)
Expand Down
7 changes: 5 additions & 2 deletions tests/test_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def test_invalid_input(mapdl):
with pytest.raises(FileNotFoundError):
mapdl.input('thisisnotafile')


@skip_no_xserver
def test_kplot(cleared, mapdl, tmpdir):
with pytest.raises(MapdlRuntimeError):
Expand Down Expand Up @@ -471,8 +472,10 @@ def test_builtin_parameters(mapdl, cleared):

assert isinstance(mapdl.parameters.revision, float)

if os.name == 'posix':
assert 'LIN' in mapdl.parameters.platform
# Platform could be either windows or Linux, without regards to
# the testing OS.
plat = mapdl.parameters.platform
assert 'L' in plat or 'W' in plat

mapdl.csys(1)
assert mapdl.parameters.csys == 1
Expand Down
9 changes: 5 additions & 4 deletions tests/test_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ def plastic_solve(mapdl):


# must be run first before loading a result
@pytest.mark.skipif(os.name == 'nt', reason="Causes MAPDL to die on windows")
def test_nodal_eqv_stress_fail(mapdl, static_solve):
with pytest.raises(MapdlRuntimeError):
mapdl.post_processing.nodal_eqv_stress
# since MAPDL may be on a remote windows machine, cannot test
# @pytest.mark.skipif(os.name == 'nt', reason="Causes MAPDL to die on windows")
# def test_nodal_eqv_stress_fail(mapdl, static_solve):
# with pytest.raises(MapdlRuntimeError):
# mapdl.post_processing.nodal_eqv_stress


@pytest.mark.parametrize('comp', ['X', 'Y', 'z']) # lowercase intentional
Expand Down
1 change: 0 additions & 1 deletion tmp.out

This file was deleted.