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
2 changes: 1 addition & 1 deletion pyansys/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# major, minor, patch
version_info = 0, 44, 20
version_info = 0, 44, 21

# Nice string for the version
__version__ = '.'.join(map(str, version_info))
20 changes: 12 additions & 8 deletions pyansys/mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,9 @@ def directory(self):
self._path = self.inquire('DIRECTORY')
except:
pass

# os independent path format
self._path = self._path.replace('\\', '/')
return self._path

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

def __del__(self): # pragma: no cover
"""Clean up when complete"""
if self._cleanup:
try:
self.exit()
except Exception as e:
try: # logger might be closed
self._log.error('exit: %s', str(e))
except:
pass
if hasattr(self, '_cleanup'):
if self._cleanup:
try:
self.exit()
except Exception as e:
try: # logger might be closed
self._log.error('exit: %s', str(e))
except:
pass

@supress_logging
def get_array(self, entity='', entnum='', item1='', it1num='', item2='',
Expand Down
25 changes: 7 additions & 18 deletions pyansys/mapdl_corba.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@
'Only supported on Python3.5 - Python3.8 for '
'Linux and Windows\n')

INSTANCES = []

# Ensure all instances close on exit within Windows
@atexit.register
def cleanup(): # pragma: no cover
if os.name == 'nt':
for ref in INSTANCES:
# check if object has already been collected
instance = ref()
if instance is not None:
instance.exit()


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

INSTANCES.append(weakref.ref(self))

@property
def _broadcast_file(self):
return os.path.join(self.directory, 'mapdl_broadcasts.txt')
Expand Down Expand Up @@ -219,14 +205,17 @@ def _start_broadcast_logger(self, update_rate=1.0):

def exit(self, close_log=True, timeout=3):
"""Exit MAPDL process"""
# cache final path and lockfile before exiting
path = self.directory
lockfile = self._lockfile
if self._exited:
return

self._log.debug('Exiting ANSYS')
if self._server is not None:
# cache final path and lockfile before exiting
path = self.directory
lockfile = self._lockfile

try:
self.run('/EXIT') # untested on Windows
self.run('/EXIT')
except:
pass
try:
Expand Down
8 changes: 3 additions & 5 deletions pyansys/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -1954,11 +1954,9 @@ def element_solution_data(self, rnum, datatype, sort=True, **kwargs):
enode = []
nnode = nodstr[etype]
if sort:
for i in sidx:
enode.append(self._mesh.elem[i][10:10+nnode[i]])
enode = [self._mesh.elem[i][10:10+nnode[i]] for i in sidx]
else:
for i in range(enum.size):
enode.append(self._mesh.elem[i][10:10+nnode[i]])
enode = [self._mesh.elem[i][10:10+nnode[i]] for i in range(enum.size)]

return enum, element_data, enode

Expand Down Expand Up @@ -2674,7 +2672,7 @@ def save_as_vtk(self, filename, rsets=None, result_types=['ENS']):

"""
# Copy grid as to not write results to original object
grid = self.grid.copy()
grid = self.quadgrid.copy()

if rsets is None:
rsets = range(self.nsets)
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
pyvista.OFF_SCREEN = True

# check for a valid MAPDL install with CORBA
valid_rver = ['211', '202', '201', '195', '194', '193', '192', '191', '190', '182']
# valid_rver = ['211', '202', '201', '195', '194', '193', '192', '191', '190', '182']
valid_rver = ['202', '201', '195', '194', '193', '192', '191', '190', '182']
EXEC_FILE = None
for rver in valid_rver:
if os.path.isfile(get_ansys_bin(rver)):
Expand Down