Skip to content

Commit

Permalink
FEM: solver elmer, workaround for result reading
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Jan 27, 2020
1 parent fa40b50 commit 2edabee
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Mod/Fem/femsolver/elmer/tasks.py
Expand Up @@ -133,7 +133,7 @@ class Results(run.Results):
def run(self):
if self.solver.ElmerResult is None:
self._createResults()
postPath = os.path.join(self.directory, "case0001.vtu")
postPath = self._getResultFile()
self.solver.ElmerResult.read(postPath)
self.solver.ElmerResult.getLastPostObject().touch()
self.solver.Document.recompute()
Expand All @@ -144,4 +144,20 @@ def _createResults(self):
self.solver.ElmerResult.Label = self.solver.Label + "Result"
self.analysis.addObject(self.solver.ElmerResult)

def _getResultFile(self):
postPath = None
# elmer post file path changed with version x.x
# see https://forum.freecadweb.org/viewtopic.php?f=18&t=42732
# workaround
possible_post_file_0 = os.path.join(self.directory, "case0001.vtu")
possible_post_file_t = os.path.join(self.directory, "case_t0001.vtu")
if os.path.isfile(possible_post_file_0):
postPath = possible_post_file_0
elif os.path.isfile(possible_post_file_t):
postPath = possible_post_file_t
else:
self.report.error("Result file not found.")
self.fail()
return postPath

## @}

0 comments on commit 2edabee

Please sign in to comment.