Skip to content

Standardize the mapdl.inquire("", "RSTXXX") behaviour #1452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 7, 2022
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
22 changes: 14 additions & 8 deletions src/ansys/mapdl/core/mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1911,22 +1911,28 @@ def result_file(self):
def _result_file(self):
"""Path of the non-distributed result file"""
try:
filename = self.inquire("", "RSTFILE")
if not filename:
filename = self.jobname
except Exception:
with self.run_as_routine("POST1"):
filename = self.inquire("", "RSTFILE")
except Exception: # pragma: no cover
filename = self.jobname

try:
ext = self.inquire("", "RSTEXT")
except Exception: # check if rth file exists
ext = ""
with self.run_as_routine("POST1"):
ext = self.inquire("", "RSTEXT")
except Exception: # pragma: no cover
ext = "rst"

if self._local: # pragma: no cover
if ext == "":
# Case where there is RST extension because it is thermal for example
filename = self.jobname

rth_file = os.path.join(self.directory, f"{filename}.rth")
rst_file = os.path.join(self.directory, f"{filename}.rst")

if self._prioritize_thermal and os.path.isfile(rth_file):
return rth_file

if os.path.isfile(rth_file) and os.path.isfile(rst_file):
return last_created([rth_file, rst_file])
elif os.path.isfile(rth_file):
Expand All @@ -1938,7 +1944,7 @@ def _result_file(self):
if os.path.isfile(filename):
return filename
else:
return os.path.join(filename, ext) # pragma: no cover
return f"{filename}.{ext}"

@property
def _distributed_result_file(self):
Expand Down
33 changes: 0 additions & 33 deletions src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2215,39 +2215,6 @@ def _distributed_result_file(self):
elif os.path.isfile(rst_file):
return rst_file

@property
def _result_file(self):
"""Path of the non-distributed result file"""
try:
filename = self.inquire("", "RSTFILE")
if not filename:
filename = self.jobname
except:
filename = self.jobname

try:
ext = self.inquire("", "RSTEXT")
except: # check if rth file exists
ext = ""

if ext == "":
rth_file = os.path.join(self.directory, "%s.%s" % (filename, "rth"))
rst_file = os.path.join(self.directory, "%s.%s" % (filename, "rst"))

if self._prioritize_thermal and os.path.isfile(rth_file):
return rth_file

if os.path.isfile(rth_file) and os.path.isfile(rst_file):
return last_created([rth_file, rst_file])
elif os.path.isfile(rth_file):
return rth_file
elif os.path.isfile(rst_file):
return rst_file
else:
filename = os.path.join(self.directory, "%s.%s" % (filename, ext))
if os.path.isfile(filename):
return filename

@property
def thermal_result(self):
"""The thermal result object"""
Expand Down
5 changes: 0 additions & 5 deletions tests/test_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,16 +1385,11 @@ def test_equal_in_comments_and_title(mapdl):
mapdl.title("This is '=' ")


@pytest.mark.xfail
def test_result_file(mapdl, solved_box):
assert mapdl.result_file
assert isinstance(mapdl.result_file, str)


def test_empty_result_file(mapdl, cleared):
assert mapdl.result_file is None


@skip_in_cloud
def test_file_command_local(mapdl, cube_solve, tmpdir):
rst_file = mapdl._result_file
Expand Down