Skip to content
Permalink
Browse files

FEM: ccx tools, better error handling on run ccx

  • Loading branch information...
berndhahnebach authored and wwmayer committed Jan 4, 2019
1 parent 37a2cce commit 56db51867c3ca54838a400cc636cffe29e68552c
Showing with 26 additions and 27 deletions.
  1. +1 −17 src/Mod/Fem/femcommands/commands.py
  2. +25 −10 src/Mod/Fem/femtools/ccxtools.py
@@ -764,29 +764,13 @@ def Activated(self):
import femsolver.run
from PySide import QtGui

def load_results(ret_code):
if ret_code == 0:
self.fea.load_results()
elif ret_code == 201:
if self.fea.solver.AnalysisType == 'check':
print('We run into the NOANALYSIS problem!')
# https://forum.freecadweb.org/viewtopic.php?f=18&t=31303&start=10#p260743
self.fea.load_results()
else:
print("CalculiX failed ccx finished with error {}".format(ret_code))

self.solver = self.selobj
if self.solver.Proxy.Type == 'Fem::FemSolverCalculixCcxTools':
print('CalxuliX ccx tools solver!')
from femtools import ccxtools
self.fea = ccxtools.FemToolsCcx(None, self.solver)
self.fea.reset_mesh_purge_results_checked()
message = self.fea.check_prerequisites()
if message:
QtGui.QMessageBox.critical(None, "Missing prerequisite", message)
return
self.fea.finished.connect(load_results)
QtCore.QThreadPool.globalInstance().start(self.fea)
self.fea.run()
else:
print('Frame work solver!')
try:
@@ -666,18 +666,33 @@ def ccx_run(self):

def run(self):
message = self.check_prerequisites()
if not message:
if message:
error_message = "CalculiX was not started due to missing prerequisites:\n{}\n".format(message)
FreeCAD.Console.PrintError(error_message)
if FreeCAD.GuiUp:
QtGui.QMessageBox.critical(None, "Missing prerequisite", error_message)
return False
else:
self.write_inp_file()
if self.inp_file_name != "":
FreeCAD.Console.PrintMessage("Writing CalculiX input file completed!\n")
if self.inp_file_name == "":
error_message = "Error on writing CalculiX input file.\n"
FreeCAD.Console.PrintError(error_message)
if FreeCAD.GuiUp:
QtGui.QMessageBox.critical(None, "Error", error_message)
return False
else:
# TODO do not run solver, do not try to read results in a smarter way than an Exception
raise Exception('Error on writing CalculiX input file.\n')
self.ccx_run()
else:
FreeCAD.Console.PrintError("CalculiX was not started due to missing prerequisites:\n{}\n".format(message))
# ATM it is not possible to start CalculiX if prerequisites are not fulfilled
self.load_results()
FreeCAD.Console.PrintMessage("Writing CalculiX input file completed.\n")
ret_code = self.ccx_run()
if ret_code != 0:
error_message = "CalculiX finished with error {}".format(ret_code)
FreeCAD.Console.PrintError(error_message)
if FreeCAD.GuiUp:
QtGui.QMessageBox.critical(None, "Error", error_message)
return False
else:
self.load_results()
# TODO: output an error message if there where problems reading the results
return True

def has_no_material_assigned(self):
if ' *ERROR in calinput: no material was assigned' in self.ccx_stdout:

0 comments on commit 56db518

Please sign in to comment.
You can’t perform that action at this time.