FEM: input writer, constraint force, move the refshape type code into fem tools
This commit is contained in:
committed by
Yorik van Havre
parent
90c948d95f
commit
22e990073a
@@ -118,16 +118,6 @@ class FemInputWriter():
|
||||
# check shape type of reference shape
|
||||
for femobj in self.force_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
|
||||
frc_obj = femobj['Object']
|
||||
# in GUI defined frc_obj all ref_shape have the same shape type
|
||||
# TODO in FemTools: check if all RefShapes really have the same type an write type to dictionary
|
||||
femobj['RefShapeType'] = ''
|
||||
if frc_obj.References:
|
||||
first_ref_obj = frc_obj.References[0]
|
||||
first_ref_shape = first_ref_obj[0].Shape.getElement(first_ref_obj[1][0])
|
||||
femobj['RefShapeType'] = first_ref_shape.ShapeType
|
||||
else:
|
||||
# frc_obj.References could be empty ! # TODO in FemTools: check
|
||||
FreeCAD.Console.PrintError('At least one Force Object has empty References!\n')
|
||||
if femobj['RefShapeType'] == 'Vertex':
|
||||
# print("load on vertices --> we do not need the femelement_table and femnodes_mesh for node load calculation")
|
||||
pass
|
||||
|
||||
@@ -269,6 +269,7 @@ class FemTools(QtCore.QRunnable, QtCore.QObject):
|
||||
elif m.isDerivedFrom("Fem::ConstraintForce"):
|
||||
force_constraint_dict = {}
|
||||
force_constraint_dict['Object'] = m
|
||||
force_constraint_dict['RefShapeType'] = get_refshape_type(m)
|
||||
self.force_constraints.append(force_constraint_dict)
|
||||
elif m.isDerivedFrom("Fem::ConstraintPressure"):
|
||||
PressureObjectDict = {}
|
||||
@@ -577,4 +578,25 @@ class FemTools(QtCore.QRunnable, QtCore.QObject):
|
||||
stats = match[result_type]
|
||||
return stats
|
||||
|
||||
|
||||
# helper
|
||||
def get_refshape_type(fem_doc_object):
|
||||
# returns the reference shape type
|
||||
# for force object:
|
||||
# in GUI defined frc_obj all frc_obj have at leas one ref_shape and ref_shape have all the same shape type
|
||||
# for material object:
|
||||
# in GUI defined material_obj could have no RefShape and RefShapes could be different type
|
||||
# we gone need the RefShapes to be the same type inside one fem_doc_object
|
||||
# TODO here: check if all RefShapes inside the object really have the same type
|
||||
import FemMeshTools
|
||||
if hasattr(fem_doc_object, 'References') and fem_doc_object.References:
|
||||
first_ref_obj = fem_doc_object.References[0]
|
||||
first_ref_shape = FemMeshTools.get_element(first_ref_obj[0], first_ref_obj[1][0])
|
||||
st = first_ref_shape.ShapeType
|
||||
print(fem_doc_object.Name + ' has ' + st + ' reference shapes.')
|
||||
return st
|
||||
else:
|
||||
print(fem_doc_object.Name + ' has empty References.')
|
||||
return ''
|
||||
|
||||
## @}
|
||||
|
||||
Reference in New Issue
Block a user