Skip to content

Commit 5b9d0fb

Browse files
committed
fix reaction forces result 0 bug; fix creation time; bump to 0.44.10
1 parent 4bd065d commit 5b9d0fb

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
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, 9
2+
version_info = 0, 44, 10
33

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

pyansys/mapdl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,7 @@ def result(self):
11071107
result_path = self._result_file
11081108

11091109
if result_path is None:
1110+
breakpoint()
11101111
raise FileNotFoundError('No result file(s) at %s' % self.directory)
11111112
if not os.path.isfile(result_path):
11121113
raise FileNotFoundError('No results found at %s' % result_path)

pyansys/misc.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Module for miscellaneous functions and methods"""
2-
import stat
2+
import platform
33
import os
44
from threading import Thread
55
import sys
@@ -279,19 +279,33 @@ def unique_rows(a):
279279
return a[idx], idx, idx2
280280

281281

282-
def creation_time(filename):
283-
"""Returns the file creation time in UNIX time"""
284-
return os.stat(filename)[stat.ST_CTIME]
282+
def creation_time(path_to_file):
283+
"""The file creation time.
284+
285+
Try to get the date that a file was created, falling back to when it was
286+
last modified if that isn't possible.
287+
See http://stackoverflow.com/a/39501288/1709587 for explanation.
288+
"""
289+
if platform.system() == 'Windows':
290+
return os.path.getctime(path_to_file)
291+
else:
292+
stat = os.stat(path_to_file)
293+
try:
294+
return stat.st_birthtime
295+
except AttributeError:
296+
# We're probably on Linux. No easy way to get creation dates here,
297+
# so we'll settle for when its content was last modified.
298+
return stat.st_mtime
285299

286300

287301
def last_created(filenames):
288302
"""Return the last created file given a list of filenames
289303
290-
If all filenames have the same creation time, then return None.
304+
If all filenames have the same creation time, then return the last filename.
291305
"""
292306
ctimes = [creation_time(filename) for filename in filenames]
293307
idx = np.argmax(ctimes)
294308
if len(set(ctimes)):
295-
return None
309+
return filenames[-1]
296310

297311
return filenames[idx]

pyansys/rst.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,10 +2934,11 @@ def nodal_reaction_forces(self, rnum, sort=True):
29342934
# according to the DOF order
29352935
# shown above in the DOF
29362936
# number reference table.
2937-
rnum = self.parse_step_substep(rnum)
29382937

2938+
# pointer to result reaction forces
2939+
rnum = self.parse_step_substep(rnum)
29392940
rpointers = self._resultheader['rpointers']
2940-
ptr = rpointers[0] + self._solution_header(0)['ptrRF']
2941+
ptr = rpointers[rnum] + self._solution_header(rnum)['ptrRF']
29412942

29422943
# table is always ANSYS LONG (INT64)
29432944
table, bufsz = self.read_record(ptr, True)

0 commit comments

Comments
 (0)