FEM: ccx run, do not run ccx if input file writer returned an error

This commit is contained in:
Bernd Hahnebach
2018-12-20 20:35:18 +01:00
committed by Yorik van Havre
parent e2716b2f80
commit 25ebc7479b
5 changed files with 28 additions and 5 deletions

View File

@@ -386,8 +386,11 @@ def get_femelement_sets(femmesh, femelement_table, fem_objects, femnodes_ele_tab
if obj.Name == has_remaining_femelements:
fem_object['FEMElements'] = sorted(remaining_femelements)
# check if all worked out well
if not femelements_count_ok(len(femelement_table), count_femelements):
if femelements_count_ok(len(femelement_table), count_femelements):
return True
else:
FreeCAD.Console.PrintError('Error in get_femelement_sets -- > femelements_count_ok() failed!\n')
return False
def get_femelement_direction1D_set(femmesh, femelement_table, beamrotation_objects, theshape=None):

View File

@@ -70,7 +70,7 @@ class Prepare(run.Prepare):
self.directory)
path = w.write_calculix_input_file()
# report to user if task succeeded
if path is not None:
if path != "":
self.pushStatus("Write completed!")
else:
self.pushStatus("Writing CalculiX input file failed!")
@@ -80,6 +80,9 @@ class Prepare(run.Prepare):
class Solve(run.Solve):
def run(self):
if not _inputFileName:
# 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.pushStatus("Executing solver...\n")
binary = settings.getBinary("Calculix")
self._process = subprocess.Popen(
@@ -99,6 +102,9 @@ class Solve(run.Solve):
class Results(run.Results):
def run(self):
if not _inputFileName:
# 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')
prefs = App.ParamGet(
"User parameter:BaseApp/Preferences/Mod/Fem/General")
if not prefs.GetBool("KeepResultsOnReRun", False):

View File

@@ -74,8 +74,14 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
self.write_calculix_splitted_input_file()
else:
self.write_calculix_one_input_file()
FreeCAD.Console.PrintMessage("Writing time input file: " + str(time.clock() - timestart) + ' \n\n')
return self.file_name
writing_time_string = "Writing time input file: " + str(time.clock() - timestart)
if self.femelement_count_test is True:
FreeCAD.Console.PrintMessage(writing_time_string + ' \n\n')
return self.file_name
else:
FreeCAD.Console.PrintMessage(writing_time_string + ' \n')
FreeCAD.Console.PrintError("Problems on writing input file, check report prints.\n\n")
return ""
def write_calculix_one_input_file(self):
self.femmesh.writeABAQUS(self.file_name, 1, False)

View File

@@ -91,6 +91,7 @@ class FemInputWriter():
self.femelement_volumes_table = {}
self.femelement_faces_table = {}
self.femelement_edges_table = {}
self.femelement_count_test = True
def get_constraints_fixed_nodes(self):
# get nodes
@@ -260,7 +261,9 @@ class FemInputWriter():
self.femnodes_mesh = self.femmesh.Nodes
if not self.femnodes_ele_table:
self.femnodes_ele_table = FemMeshTools.get_femnodes_ele_table(self.femnodes_mesh, self.femelement_table)
FemMeshTools.get_femelement_sets(self.femmesh, self.femelement_table, self.material_objects, self.femnodes_ele_table)
control = FemMeshTools.get_femelement_sets(self.femmesh, self.femelement_table, self.material_objects, self.femnodes_ele_table)
if (self.femelement_count_test is True) and (control is False): # we only need to set it, if it is still True
self.femelement_count_test = False
if self.shellthickness_objects:
if not self.femelement_faces_table:
self.femelement_faces_table = FemMeshTools.get_femelement_faces_table(self.femmesh)

View File

@@ -641,6 +641,11 @@ class FemToolsCcx(QtCore.QRunnable, QtCore.QObject):
message = self.check_prerequisites()
if not message:
self.write_inp_file()
if self.inp_file_name != "":
FreeCAD.Console.PrintMessage("Writing CalculiX input file completed!")
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')
from FreeCAD import Base
progress_bar = Base.ProgressIndicator()
progress_bar.start("Running CalculiX ccx...", 0)