FEM: constraint pressure, move geting the faces from FemInputwriterCcx to FemInputWriter and FemMeshTools module

This commit is contained in:
Bernd Hahnebach 2016-10-17 10:23:07 +01:00
parent 6ab0937ea0
commit 746ee873aa
4 changed files with 29 additions and 10 deletions

View File

@ -153,3 +153,11 @@ class FemInputWriter():
femobj['NodeLoadTable'] = FemMeshTools.get_force_obj_edge_nodeload_table(self.femmesh, self.femelement_table, self.femnodes_mesh, frc_obj)
elif femobj['RefShapeType'] == 'Face': # area load on faces
femobj['NodeLoadTable'] = FemMeshTools.get_force_obj_face_nodeload_table(self.femmesh, self.femelement_table, self.femnodes_mesh, frc_obj)
def get_constraints_pressure_faces(self):
# TODO see comments in get_constraints_force_nodeloads(), it applies here too. Mhh it applies to all constraints ...
# get the faces and face numbers
for femobj in self.pressure_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
femobj['PressureFaces'] = FemMeshTools.get_pressure_obj_faces(self.femmesh, femobj)
# print femobj['PressureFaces']

View File

@ -607,21 +607,20 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('\n')
def write_constraints_pressure(self, f):
# get the faces and face numbers
self.get_constraints_pressure_faces()
# write face loads to file
f.write('\n***********************************************************\n')
f.write('** Element + CalculiX face + load in [MPa]\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for femobj in self.pressure_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
prs_obj = femobj['Object']
rev = -1 if prs_obj.Reversed else 1
f.write('*DLOAD\n')
for o, elem_tup in prs_obj.References:
rev = -1 if prs_obj.Reversed else 1
for elem in elem_tup:
ref_shape = o.Shape.getElement(elem)
if ref_shape.ShapeType == 'Face':
v = self.femmesh.getccxVolumesByFace(ref_shape)
f.write("** Load on face {}\n".format(elem))
for i in v:
f.write("{},P{},{}\n".format(i[0], i[1], rev * prs_obj.Pressure))
for ref_shape in femobj['PressureFaces']:
f.write('** ' + ref_shape[0] + '\n')
for face, fno in ref_shape[1]:
f.write("{},P{},{}\n".format(face, fno, rev * prs_obj.Pressure))
def write_constraints_temperature(self, f):
f.write('\n***********************************************************\n')

View File

@ -370,6 +370,18 @@ def get_force_obj_edge_nodeload_table(femmesh, femelement_table, femnodes_mesh,
return force_obj_node_load_table
def get_pressure_obj_faces(femmesh, femobj):
pressure_faces = []
for o, elem_tup in femobj['Object'].References:
for elem in elem_tup:
ref_shape = o.Shape.getElement(elem)
elem_info_string = 'face load on shape: ' + o.Name + ':' + elem
print(elem_info_string)
if ref_shape.ShapeType == 'Face':
pressure_faces.append((elem_info_string, femmesh.getccxVolumesByFace(ref_shape)))
return pressure_faces
def get_force_obj_face_nodeload_table(femmesh, femelement_table, femnodes_mesh, frc_obj):
# force_obj_node_load_table = [('refshape_name.elemname',node_load_table), ..., ('refshape_name.elemname',node_load_table)]
force_obj_node_load_table = []

View File

@ -547,7 +547,7 @@ FemConstraintFixed,3
** Element + CalculiX face + load in [MPa]
** written by write_constraints_pressure function
*DLOAD
** Load on face Face2
** face load on shape: Box:Face2
635,P1,1000.0
638,P3,1000.0
641,P2,1000.0