Skip to content

Commit d0b4e20

Browse files
Fix rst to VTK and MAPDL Collection (#323)
* cleanup path * fix mapdl collection for corba * use shell * version bump to 0.44.21 Co-authored-by: Alexander Kaszynski <[email protected]>
1 parent d5d3cbf commit d0b4e20

File tree

5 files changed

+25
-33
lines changed

5 files changed

+25
-33
lines changed

pyansys/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# major, minor, patch
2-
version_info = 0, 44, 20
2+
version_info = 0, 44, 21
33

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

pyansys/mapdl.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,9 @@ def directory(self):
18881888
self._path = self.inquire('DIRECTORY')
18891889
except:
18901890
pass
1891+
1892+
# os independent path format
1893+
self._path = self._path.replace('\\', '/')
18911894
return self._path
18921895

18931896
@property
@@ -1903,14 +1906,15 @@ def exit(self): # pragma: no cover
19031906

19041907
def __del__(self): # pragma: no cover
19051908
"""Clean up when complete"""
1906-
if self._cleanup:
1907-
try:
1908-
self.exit()
1909-
except Exception as e:
1910-
try: # logger might be closed
1911-
self._log.error('exit: %s', str(e))
1912-
except:
1913-
pass
1909+
if hasattr(self, '_cleanup'):
1910+
if self._cleanup:
1911+
try:
1912+
self.exit()
1913+
except Exception as e:
1914+
try: # logger might be closed
1915+
self._log.error('exit: %s', str(e))
1916+
except:
1917+
pass
19141918

19151919
@supress_logging
19161920
def get_array(self, entity='', entnum='', item1='', it1num='', item2='',

pyansys/mapdl_corba.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@
1717
'Only supported on Python3.5 - Python3.8 for '
1818
'Linux and Windows\n')
1919

20-
INSTANCES = []
21-
22-
# Ensure all instances close on exit within Windows
23-
@atexit.register
24-
def cleanup(): # pragma: no cover
25-
if os.name == 'nt':
26-
for ref in INSTANCES:
27-
# check if object has already been collected
28-
instance = ref()
29-
if instance is not None:
30-
instance.exit()
31-
3220

3321
def tail(filename, nlines):
3422
"""Read the last nlines of a text file """
@@ -177,8 +165,6 @@ def _launch(self, start_parm):
177165
if self._log_broadcast:
178166
self._broadcast_logger = self._start_broadcast_logger()
179167

180-
INSTANCES.append(weakref.ref(self))
181-
182168
@property
183169
def _broadcast_file(self):
184170
return os.path.join(self.directory, 'mapdl_broadcasts.txt')
@@ -219,14 +205,17 @@ def _start_broadcast_logger(self, update_rate=1.0):
219205

220206
def exit(self, close_log=True, timeout=3):
221207
"""Exit MAPDL process"""
222-
# cache final path and lockfile before exiting
223-
path = self.directory
224-
lockfile = self._lockfile
208+
if self._exited:
209+
return
225210

226211
self._log.debug('Exiting ANSYS')
227212
if self._server is not None:
213+
# cache final path and lockfile before exiting
214+
path = self.directory
215+
lockfile = self._lockfile
216+
228217
try:
229-
self.run('/EXIT') # untested on Windows
218+
self.run('/EXIT')
230219
except:
231220
pass
232221
try:

pyansys/rst.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,11 +1954,9 @@ def element_solution_data(self, rnum, datatype, sort=True, **kwargs):
19541954
enode = []
19551955
nnode = nodstr[etype]
19561956
if sort:
1957-
for i in sidx:
1958-
enode.append(self._mesh.elem[i][10:10+nnode[i]])
1957+
enode = [self._mesh.elem[i][10:10+nnode[i]] for i in sidx]
19591958
else:
1960-
for i in range(enum.size):
1961-
enode.append(self._mesh.elem[i][10:10+nnode[i]])
1959+
enode = [self._mesh.elem[i][10:10+nnode[i]] for i in range(enum.size)]
19621960

19631961
return enum, element_data, enode
19641962

@@ -2674,7 +2672,7 @@ def save_as_vtk(self, filename, rsets=None, result_types=['ENS']):
26742672
26752673
"""
26762674
# Copy grid as to not write results to original object
2677-
grid = self.grid.copy()
2675+
grid = self.quadgrid.copy()
26782676

26792677
if rsets is None:
26802678
rsets = range(self.nsets)

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
pyvista.OFF_SCREEN = True
1313

1414
# check for a valid MAPDL install with CORBA
15-
valid_rver = ['211', '202', '201', '195', '194', '193', '192', '191', '190', '182']
15+
# valid_rver = ['211', '202', '201', '195', '194', '193', '192', '191', '190', '182']
16+
valid_rver = ['202', '201', '195', '194', '193', '192', '191', '190', '182']
1617
EXEC_FILE = None
1718
for rver in valid_rver:
1819
if os.path.isfile(get_ansys_bin(rver)):

0 commit comments

Comments
 (0)