Skip to content

Commit a6db30a

Browse files
authored
Ignore distortion elements (#357)
1 parent fdbb94c commit a6db30a

File tree

10 files changed

+62
-24
lines changed

10 files changed

+62
-24
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,7 @@ examples/.local
6666
.ipynb_checkpoints/
6767

6868
# docker
69-
docker/mapdl/v211
69+
docker/mapdl/v211
70+
71+
# temp testing
72+
tmp.out

ansys/mapdl/core/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Version of ansys-mapdl-core module."""
22

33
# major, minor, patch
4-
version_info = 0, 57, 5
4+
version_info = 0, 57, 6
55

66
# Nice string for the version
77
__version__ = '.'.join(map(str, version_info))

ansys/mapdl/core/launcher.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def _get_available_base_ansys():
380380
381381
Within Linux
382382
383-
>>>
383+
>>> _get_available_base_ansys()
384384
{194: '/usr/ansys_inc/v194',
385385
202: '/usr/ansys_inc/v202',
386386
211: '/usr/ansys_inc/v211'}
@@ -402,12 +402,12 @@ def _get_available_base_ansys():
402402
raise OSError(f'Unsupported OS {os.name}')
403403

404404
if base_path is None:
405-
return '', ''
405+
return {}
406406

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

409409
if not paths:
410-
return None
410+
return {}
411411

412412
ansys_paths = {}
413413
for path in paths:
@@ -444,6 +444,8 @@ def find_ansys():
444444
(/usr/ansys_inc/v211/ansys/bin/ansys211, 21.1)
445445
"""
446446
versions = _get_available_base_ansys()
447+
if not versions:
448+
return '', ''
447449
version = max(versions.keys())
448450
ans_path = versions[version]
449451
if os.name == 'nt':

ansys/mapdl/core/mapdl.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import tempfile
99
from shutil import rmtree, copyfile
1010
import weakref
11+
import warnings
1112

1213
import numpy as np
1314
import pyvista as pv
@@ -25,6 +26,11 @@
2526
from ansys.mapdl.core.plotting import general_plotter
2627
from ansys.mapdl.core.post import PostProcessing
2728

29+
_PERMITTED_ERRORS = [
30+
r'(\*\*\* ERROR \*\*\*).*(?:[\r\n]+.*)+highly distorted.',
31+
r'(\*\*\* ERROR \*\*\*).*[\r\n]+.*is turning inside out.',
32+
]
33+
2834

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

1769-
# flag error
1775+
# flag errors
17701776
if '*** ERROR ***' in self._response and not self._ignore_errors:
1771-
# remove "is turning inside out" as this allows the
1772-
# solution to continue
1773-
sub = re.sub(r'(\*\*\* ERROR \*\*\*).*[\r\n]+.*is turning inside out.',
1774-
'', self._response)
1775-
if '*** ERROR ***' in sub:
1777+
# remove permitted errors and allow MAPDL to continue
1778+
response = self._response
1779+
for err_str in _PERMITTED_ERRORS:
1780+
response = re.sub(err_str, '', response)
1781+
1782+
if '*** ERROR ***' in response:
17761783
self._log.error(self._response)
17771784
raise MapdlRuntimeError(self._response)
1785+
else:
1786+
warnings.warn('MAPDL returned non-abort errors. Please '
1787+
'check the logs.')
17781788

17791789
# special returns for certain geometry commands
17801790
short_cmd = parse_to_short_cmd(command)

docs/source/contributing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ or in Linux
206206

207207
.. code::
208208
209-
PYANSYS_START_INSTANCE=False
210-
PYMAPDL_PORT=<MAPDL Port> (default 50052)
211-
PYMAPDL_IP=<MAPDL IP> (default 127.0.0.1)
209+
export PYMAPDL_START_INSTANCE=False
210+
export PYMAPDL_PORT=<MAPDL Port> (default 50052)
211+
export PYMAPDL_IP=<MAPDL IP> (default 127.0.0.1)
212212
213213
This will tell the ``ansys.mapdl.core`` to attempt to connect to the existing
214214
MAPDL service by default when the ``launch_mapdl`` function is used.

tests/conftest.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,29 @@
2727

2828
# check if the user wants to permit pytest to start MAPDL
2929
START_INSTANCE = get_start_instance()
30-
# if START_INSTANCE:
31-
# local.append(True)
3230

31+
if os.name == 'nt':
32+
os_msg = """SET PYMAPDL_START_INSTANCE=False
33+
SET PYMAPDL_PORT=<MAPDL Port> (default 50052)
34+
SET PYMAPDL_IP=<MAPDL IP> (default 127.0.0.1)"""
35+
else:
36+
os_msg = """export PYMAPDL_START_INSTANCE=False
37+
export PYMAPDL_PORT=<MAPDL Port> (default 50052)
38+
export PYMAPDL_IP=<MAPDL IP> (default 127.0.0.1)"""
39+
40+
ERRMSG = f"""Unable to run CI without MAPDL installed or accessible.
41+
Either install Ansys 2021R1 or newer or specify the remote server with:
42+
43+
{os_msg}
44+
45+
If you do have Ansys installed, you may have to patch pymapdl to
46+
automatically find your Ansys installation. Email the developer at:
47+
48+
49+
"""
50+
51+
if START_INSTANCE and EXEC_FILE is None:
52+
raise RuntimeError(ERRMSG)
3353

3454
def pytest_addoption(parser):
3555
parser.addoption(

tests/test_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_basic_input_output(mapdl, tmpdir):
3939
f.write('FINISH\n')
4040
f.write('/PREP7\n')
4141

42-
resp = mapdl.upload(basic_inp)
42+
mapdl.upload(basic_inp)
4343
tmpfile = 'tmp.out'
4444
mapdl._send_command('/OUT, %s' % tmpfile, mute=True)
4545
mapdl._send_command('/INPUT, %s' % filename, mute=True)

tests/test_mapdl.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ def test_invalid_input(mapdl):
216216
with pytest.raises(FileNotFoundError):
217217
mapdl.input('thisisnotafile')
218218

219+
219220
@skip_no_xserver
220221
def test_kplot(cleared, mapdl, tmpdir):
221222
with pytest.raises(MapdlRuntimeError):
@@ -471,8 +472,10 @@ def test_builtin_parameters(mapdl, cleared):
471472

472473
assert isinstance(mapdl.parameters.revision, float)
473474

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

477480
mapdl.csys(1)
478481
assert mapdl.parameters.csys == 1

tests/test_post.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ def plastic_solve(mapdl):
104104

105105

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

112113

113114
@pytest.mark.parametrize('comp', ['X', 'Y', 'z']) # lowercase intentional

tmp.out

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)