FEM: move writing inp file to FemTools module
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
parent
e0956f67f3
commit
3187141dfe
|
@ -50,3 +50,62 @@ class FemTools:
|
|||
self.mesh.ViewObject.NodeColor = {}
|
||||
self.mesh.ViewObject.ElementColor = {}
|
||||
self.mesh.ViewObject.setNodeColorByScalars()
|
||||
|
||||
def update_objects(self):
|
||||
# [{'Object':material}, {}, ...]
|
||||
# [{'Object':fixed_constraints, 'NodeSupports':bool}, {}, ...]
|
||||
# [{'Object':force_constraints, 'NodeLoad':value}, {}, ...
|
||||
# [{'Object':pressure_constraints, 'xxxxxxxx':value}, {}, ...]
|
||||
self.mesh = None
|
||||
self.material = []
|
||||
self.fixed_constraints = []
|
||||
self.force_constraints = []
|
||||
self.pressure_constraints = []
|
||||
|
||||
for m in self.analysis.Member:
|
||||
if m.isDerivedFrom("Fem::FemMeshObject"):
|
||||
self.mesh = m
|
||||
elif m.isDerivedFrom("App::MaterialObjectPython"):
|
||||
material_dict = {}
|
||||
material_dict['Object'] = m
|
||||
self.material.append(material_dict)
|
||||
elif m.isDerivedFrom("Fem::ConstraintFixed"):
|
||||
fixed_constraint_dict = {}
|
||||
fixed_constraint_dict['Object'] = m
|
||||
self.fixed_constraints.append(fixed_constraint_dict)
|
||||
elif m.isDerivedFrom("Fem::ConstraintForce"):
|
||||
force_constraint_dict = {}
|
||||
force_constraint_dict['Object'] = m
|
||||
self.force_constraints.append(force_constraint_dict)
|
||||
elif m.isDerivedFrom("Fem::ConstraintPressure"):
|
||||
PressureObjectDict = {}
|
||||
PressureObjectDict['Object'] = m
|
||||
self.pressure_constraints.append(PressureObjectDict)
|
||||
|
||||
def check_prerequisites(self):
|
||||
message = ""
|
||||
if not self.analysis:
|
||||
message += "No active Analysis\n"
|
||||
if not self.mesh:
|
||||
message += "No mesh object in the Analysis\n"
|
||||
if not self.material:
|
||||
message += "No material object in the Analysis\n"
|
||||
if not self.fixed_constraints:
|
||||
message += "No fixed-constraint nodes defined in the Analysis\n"
|
||||
if not (self.force_constraints or self.pressure_constraints):
|
||||
message += "No force-constraint or pressure-constraint defined in the Analysis\n"
|
||||
return message
|
||||
|
||||
def write_inp_file(self, working_dir):
|
||||
import ccxInpWriter as iw
|
||||
import sys
|
||||
self.working_dir = working_dir
|
||||
self.base_name = ""
|
||||
try:
|
||||
inp_writer = iw.inp_writer(self.analysis, self.mesh, self.material,
|
||||
self.fixed_constraints, self.force_constraints,
|
||||
self.pressure_constraints, self.working_dir)
|
||||
self.base_name = inp_writer.write_calculix_input_file()
|
||||
except:
|
||||
print "Unexpected error when writing CalculiX input file:", sys.exc_info()[0]
|
||||
raise
|
||||
|
|
|
@ -25,7 +25,6 @@ import FreeCAD
|
|||
from FemTools import FemTools
|
||||
import FemGui
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
|
@ -377,23 +376,18 @@ class _JobControlTaskPanel:
|
|||
QApplication.restoreOverrideCursor()
|
||||
if self.check_prerequisites_helper():
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
import ccxInpWriter as iw
|
||||
inp_writer = iw.inp_writer(self.analysis_object, self.MeshObject, self.MaterialObjects,
|
||||
self.FixedObjects, self.ForceObjects, self.PressureObjects, self.working_dir)
|
||||
self.base_name = inp_writer.write_calculix_input_file()
|
||||
if self.base_name != "":
|
||||
self.femConsoleMessage("Write completed.")
|
||||
else:
|
||||
self.femConsoleMessage("Write .inp file failed!", "#FF0000")
|
||||
except:
|
||||
print "Unexpected error when writing CalculiX input file:", sys.exc_info()[0]
|
||||
raise
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
if self.base_name:
|
||||
self.base_name = ""
|
||||
fea = FemTools()
|
||||
fea.update_objects()
|
||||
fea.write_inp_file(self.working_dir)
|
||||
if fea.base_name != "":
|
||||
self.base_name = fea.base_name
|
||||
self.femConsoleMessage("Write completed.")
|
||||
self.form.pushButton_edit.setEnabled(True)
|
||||
self.form.pushButton_generate.setEnabled(True)
|
||||
else:
|
||||
self.femConsoleMessage("Write .inp file failed!", "#FF0000")
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
def check_prerequisites_helper(self):
|
||||
self.Start = time.time()
|
||||
|
|
Loading…
Reference in New Issue
Block a user