FEM: ccx input writer, write object labels as comments

This commit is contained in:
Bernd Hahnebach 2017-02-28 11:50:53 +01:00 committed by wmayer
parent de0cf45543
commit cc2c51b81d
4 changed files with 41 additions and 9 deletions

View File

@ -418,7 +418,9 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** Node sets for fixed constraint\n') f.write('** Node sets for fixed constraint\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for femobj in self.fixed_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.fixed_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
f.write('*NSET,NSET=' + femobj['Object'].Name + '\n') fix_obj = femobj['Object']
f.write('** ' + fix_obj.Label + '\n')
f.write('*NSET,NSET=' + fix_obj.Name + '\n')
for n in femobj['Nodes']: for n in femobj['Nodes']:
f.write(str(n) + ',\n') f.write(str(n) + ',\n')
@ -430,7 +432,9 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** Node sets for prescribed displacement constraint\n') f.write('** Node sets for prescribed displacement constraint\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for femobj in self.displacement_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.displacement_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
f.write('*NSET,NSET=' + femobj['Object'].Name + '\n') disp_obj = femobj['Object']
f.write('** ' + disp_obj.Label + '\n')
f.write('*NSET,NSET=' + disp_obj.Name + '\n')
for n in femobj['Nodes']: for n in femobj['Nodes']:
f.write(str(n) + ',\n') f.write(str(n) + ',\n')
@ -450,6 +454,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
for femobj in self.planerotation_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.planerotation_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
l_nodes = femobj['Nodes'] l_nodes = femobj['Nodes']
fric_obj = femobj['Object'] fric_obj = femobj['Object']
f.write('** ' + fric_obj.Label + '\n')
f.write('*NSET,NSET=' + fric_obj.Name + '\n') f.write('*NSET,NSET=' + fric_obj.Name + '\n')
# Code to extract nodes and coordinates on the PlaneRotation support face # Code to extract nodes and coordinates on the PlaneRotation support face
nodes_coords = [] nodes_coords = []
@ -479,6 +484,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
obj = 0 obj = 0
for femobj in self.contact_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.contact_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
contact_obj = femobj['Object'] contact_obj = femobj['Object']
f.write('** ' + contact_obj.Label + '\n')
cnt = 0 cnt = 0
obj = obj + 1 obj = obj + 1
for o, elem_tup in contact_obj.References: for o, elem_tup in contact_obj.References:
@ -504,6 +510,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for femobj in self.transform_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.transform_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
trans_obj = femobj['Object'] trans_obj = femobj['Object']
f.write('** ' + trans_obj.Label + '\n')
if trans_obj.TransformType == "Rectangular": if trans_obj.TransformType == "Rectangular":
f.write('*NSET,NSET=Rect' + trans_obj.Name + '\n') f.write('*NSET,NSET=Rect' + trans_obj.Name + '\n')
elif trans_obj.TransformType == "Cylindrical": elif trans_obj.TransformType == "Cylindrical":
@ -519,7 +526,9 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** Node sets for temperature constraints\n') f.write('** Node sets for temperature constraints\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for femobj in self.temperature_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.temperature_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
f.write('*NSET,NSET=' + femobj['Object'].Name + '\n') temp_obj = femobj['Object']
f.write('** ' + temp_obj.Label + '\n')
f.write('*NSET,NSET=' + temp_obj.Name + '\n')
for n in femobj['Nodes']: for n in femobj['Nodes']:
f.write(str(n) + ',\n') f.write(str(n) + ',\n')
@ -537,6 +546,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
mat_obj = femobj['Object'] mat_obj = femobj['Object']
mat_info_name = mat_obj.Material['Name'] mat_info_name = mat_obj.Material['Name']
mat_name = mat_obj.Name mat_name = mat_obj.Name
mat_label = mat_obj.Label
# get material properties of solid material, Currently in SI units: M/kg/s/Kelvin # get material properties of solid material, Currently in SI units: M/kg/s/Kelvin
if mat_obj.Category == 'Solid': if mat_obj.Category == 'Solid':
YM = FreeCAD.Units.Quantity(mat_obj.Material['YoungsModulus']) YM = FreeCAD.Units.Quantity(mat_obj.Material['YoungsModulus'])
@ -558,6 +568,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
DV_in_tmms = float(DV.getValueAs('t/mm/s')) DV_in_tmms = float(DV.getValueAs('t/mm/s'))
# write material properties # write material properties
f.write('** FreeCAD material name: ' + mat_info_name + '\n') f.write('** FreeCAD material name: ' + mat_info_name + '\n')
f.write('** ' + mat_label + '\n')
f.write('*MATERIAL, NAME=' + mat_name + '\n') f.write('*MATERIAL, NAME=' + mat_name + '\n')
if mat_obj.Category == 'Solid': if mat_obj.Category == 'Solid':
f.write('*ELASTIC\n') f.write('*ELASTIC\n')
@ -732,6 +743,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** Fixed Constraints\n') f.write('** Fixed Constraints\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for femobj in self.fixed_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.fixed_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
f.write('** ' + femobj['Object'].Label + '\n')
fix_obj_name = femobj['Object'].Name fix_obj_name = femobj['Object'].Name
f.write('*BOUNDARY\n') f.write('*BOUNDARY\n')
f.write(fix_obj_name + ',1\n') f.write(fix_obj_name + ',1\n')
@ -748,6 +760,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** Displacement constraint applied\n') f.write('** Displacement constraint applied\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for femobj in self.displacement_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.displacement_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
f.write('** ' + femobj['Object'].Label + '\n')
disp_obj = femobj['Object'] disp_obj = femobj['Object']
disp_obj_name = disp_obj.Name disp_obj_name = disp_obj.Name
f.write('*BOUNDARY\n') f.write('*BOUNDARY\n')
@ -787,6 +800,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
for femobj in self.contact_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.contact_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
obj = obj + 1 obj = obj + 1
contact_obj = femobj['Object'] contact_obj = femobj['Object']
f.write('** ' + contact_obj.Label + '\n')
f.write('*CONTACT PAIR, INTERACTION=INT' + str(obj) + ',TYPE=SURFACE TO SURFACE\n') f.write('*CONTACT PAIR, INTERACTION=INT' + str(obj) + ',TYPE=SURFACE TO SURFACE\n')
ind_surf = "IND" + str(obj) ind_surf = "IND" + str(obj)
dep_surf = "DEP" + str(obj) dep_surf = "DEP" + str(obj)
@ -806,6 +820,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** PlaneRotation Constraints\n') f.write('** PlaneRotation Constraints\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for femobj in self.planerotation_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.planerotation_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
f.write('** ' + femobj['Object'].Label + '\n')
fric_obj_name = femobj['Object'].Name fric_obj_name = femobj['Object'].Name
f.write('*MPC\n') f.write('*MPC\n')
f.write('PLANE,' + fric_obj_name + '\n') f.write('PLANE,' + fric_obj_name + '\n')
@ -816,6 +831,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for trans_object in self.transform_objects: for trans_object in self.transform_objects:
trans_obj = trans_object['Object'] trans_obj = trans_object['Object']
f.write('** ' + trans_obj.Label + '\n')
if trans_obj.TransformType == "Rectangular": if trans_obj.TransformType == "Rectangular":
f.write('*TRANSFORM, NSET=Rect' + trans_obj.Name + ', TYPE=R\n') f.write('*TRANSFORM, NSET=Rect' + trans_obj.Name + ', TYPE=R\n')
coords = FemMeshTools.get_rectangular_coords(trans_obj) coords = FemMeshTools.get_rectangular_coords(trans_obj)
@ -831,7 +847,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for femobj in self.selfweight_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.selfweight_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
selwei_obj = femobj['Object'] selwei_obj = femobj['Object']
f.write('** ' + selwei_obj.Name + '\n') f.write('** ' + selwei_obj.Label + '\n')
f.write('*DLOAD\n') f.write('*DLOAD\n')
f.write('Eall,GRAV,9810,' + str(selwei_obj.Gravity_x) + ',' + str(selwei_obj.Gravity_y) + ',' + str(selwei_obj.Gravity_z) + '\n') f.write('Eall,GRAV,9810,' + str(selwei_obj.Gravity_x) + ',' + str(selwei_obj.Gravity_y) + ',' + str(selwei_obj.Gravity_z) + '\n')
f.write('\n') f.write('\n')
@ -848,9 +864,8 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
f.write('*CLOAD\n') f.write('*CLOAD\n')
for femobj in self.force_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.force_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
frc_obj_name = femobj['Object'].Name f.write('** ' + femobj['Object'].Label + '\n')
direction_vec = femobj['Object'].DirectionVector direction_vec = femobj['Object'].DirectionVector
f.write('** ' + frc_obj_name + '\n')
for ref_shape in femobj['NodeLoadTable']: for ref_shape in femobj['NodeLoadTable']:
f.write('** ' + ref_shape[0] + '\n') f.write('** ' + ref_shape[0] + '\n')
for n in sorted(ref_shape[1]): for n in sorted(ref_shape[1]):
@ -876,6 +891,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) 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'] for femobj in self.pressure_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
prs_obj = femobj['Object'] prs_obj = femobj['Object']
f.write('** ' + prs_obj.Label + '\n')
rev = -1 if prs_obj.Reversed else 1 rev = -1 if prs_obj.Reversed else 1
f.write('*DLOAD\n') f.write('*DLOAD\n')
for ref_shape in femobj['PressureFaces']: for ref_shape in femobj['PressureFaces']:
@ -889,6 +905,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for ftobj in self.temperature_objects: for ftobj in self.temperature_objects:
fixedtemp_obj = ftobj['Object'] fixedtemp_obj = ftobj['Object']
f.write('** ' + fixedtemp_obj.Label + '\n')
NumberOfNodes = len(ftobj['Nodes']) NumberOfNodes = len(ftobj['Nodes'])
if fixedtemp_obj.ConstraintType == "Temperature": if fixedtemp_obj.ConstraintType == "Temperature":
f.write('*BOUNDARY\n') f.write('*BOUNDARY\n')
@ -905,6 +922,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for hfobj in self.heatflux_objects: for hfobj in self.heatflux_objects:
heatflux_obj = hfobj['Object'] heatflux_obj = hfobj['Object']
f.write('** ' + heatflux_obj.Label + '\n')
if heatflux_obj.ConstraintType == "Convection": if heatflux_obj.ConstraintType == "Convection":
f.write('*FILM\n') f.write('*FILM\n')
for o, elem_tup in heatflux_obj.References: for o, elem_tup in heatflux_obj.References:
@ -938,6 +956,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
self.get_constraints_fluidsection_nodes() self.get_constraints_fluidsection_nodes()
for femobj in self.fluidsection_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] for femobj in self.fluidsection_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
fluidsection_obj = femobj['Object'] fluidsection_obj = femobj['Object']
f.write('** ' + fluidsection_obj.Label + '\n')
if fluidsection_obj.SectionType == 'Liquid': if fluidsection_obj.SectionType == 'Liquid':
if fluidsection_obj.LiquidSectionType == 'PIPE INLET': if fluidsection_obj.LiquidSectionType == 'PIPE INLET':
f.write('**Fluid Section Inlet \n') f.write('**Fluid Section Inlet \n')

View File

@ -419,8 +419,9 @@
Eall Eall
*********************************************************** ***********************************************************
** Node set for fixed constraint ** Node sets for fixed constraint
** written by write_node_sets_constraints_fixed function ** written by write_node_sets_constraints_fixed function
** FemConstraintFixed
*NSET,NSET=FemConstraintFixed *NSET,NSET=FemConstraintFixed
1, 1,
2, 2,
@ -470,6 +471,7 @@ Eall
** Young's modulus unit is MPa = N/mm2 ** Young's modulus unit is MPa = N/mm2
** Density's unit is t/mm^3 ** Density's unit is t/mm^3
** FreeCAD material name: Steel-Generic ** FreeCAD material name: Steel-Generic
** MechanicalMaterial
*MATERIAL, NAME=MechanicalMaterial *MATERIAL, NAME=MechanicalMaterial
*ELASTIC *ELASTIC
200000, 0.300 200000, 0.300
@ -492,6 +494,7 @@ Eall
*********************************************************** ***********************************************************
** Fixed Constraints ** Fixed Constraints
** written by write_constraints_fixed function ** written by write_constraints_fixed function
** FemConstraintFixed
*BOUNDARY *BOUNDARY
FemConstraintFixed,1 FemConstraintFixed,1
FemConstraintFixed,2 FemConstraintFixed,2

View File

@ -419,8 +419,9 @@
Eall Eall
*********************************************************** ***********************************************************
** Node set for fixed constraint ** Node sets for fixed constraint
** written by write_node_sets_constraints_fixed function ** written by write_node_sets_constraints_fixed function
** FemConstraintFixed
*NSET,NSET=FemConstraintFixed *NSET,NSET=FemConstraintFixed
1, 1,
2, 2,
@ -469,6 +470,7 @@ Eall
** written by write_materials function ** written by write_materials function
** Young's modulus unit is MPa = N/mm2 ** Young's modulus unit is MPa = N/mm2
** FreeCAD material name: Steel-Generic ** FreeCAD material name: Steel-Generic
** MechanicalMaterial
*MATERIAL, NAME=MechanicalMaterial *MATERIAL, NAME=MechanicalMaterial
*ELASTIC *ELASTIC
200000, 0.300 200000, 0.300
@ -488,6 +490,7 @@ Eall
*********************************************************** ***********************************************************
** Fixed Constraints ** Fixed Constraints
** written by write_constraints_fixed function ** written by write_constraints_fixed function
** FemConstraintFixed
*BOUNDARY *BOUNDARY
FemConstraintFixed,1 FemConstraintFixed,1
FemConstraintFixed,2 FemConstraintFixed,2
@ -547,6 +550,7 @@ FemConstraintFixed,3
*********************************************************** ***********************************************************
** Element + CalculiX face + load in [MPa] ** Element + CalculiX face + load in [MPa]
** written by write_constraints_pressure function ** written by write_constraints_pressure function
** FemConstraintPressure
*DLOAD *DLOAD
** FemConstraintPressure: face load ** FemConstraintPressure: face load
3,P1,1000.0 3,P1,1000.0

View File

@ -67,8 +67,9 @@
Eall Eall
*********************************************************** ***********************************************************
** Node set for fixed constraint ** Node sets for fixed constraint
** written by write_node_sets_constraints_fixed function ** written by write_node_sets_constraints_fixed function
** FemConstraintFixed
*NSET,NSET=FemConstraintFixed *NSET,NSET=FemConstraintFixed
5, 5,
6, 6,
@ -83,6 +84,7 @@ Eall
*********************************************************** ***********************************************************
** Node sets for temperature constraints ** Node sets for temperature constraints
** written by write_node_sets_constraints_temperature function ** written by write_node_sets_constraints_temperature function
** FemConstraintTemperature
*NSET,NSET=FemConstraintTemperature *NSET,NSET=FemConstraintTemperature
5, 5,
6, 6,
@ -101,6 +103,7 @@ Eall
** Thermal conductivity unit is kW/mm/K = t*mm/K*s^3 ** Thermal conductivity unit is kW/mm/K = t*mm/K*s^3
** Specific Heat unit is kJ/t/K = mm^2/s^2/K ** Specific Heat unit is kJ/t/K = mm^2/s^2/K
** FreeCAD material name: Steel-Generic ** FreeCAD material name: Steel-Generic
** MechanicalMaterial
*MATERIAL, NAME=MechanicalMaterial *MATERIAL, NAME=MechanicalMaterial
*ELASTIC *ELASTIC
200000, 0.300 200000, 0.300
@ -135,6 +138,7 @@ Nall,300.0
*********************************************************** ***********************************************************
** Fixed Constraints ** Fixed Constraints
** written by write_constraints_fixed function ** written by write_constraints_fixed function
** FemConstraintFixed
*BOUNDARY *BOUNDARY
FemConstraintFixed,1 FemConstraintFixed,1
FemConstraintFixed,2 FemConstraintFixed,2
@ -144,6 +148,7 @@ FemConstraintFixed,3
*********************************************************** ***********************************************************
** Fixed temperature constraint applied ** Fixed temperature constraint applied
** written by write_constraints_temperature function ** written by write_constraints_temperature function
** FemConstraintTemperature
*BOUNDARY *BOUNDARY
FemConstraintTemperature,11,11,310.93 FemConstraintTemperature,11,11,310.93
@ -151,6 +156,7 @@ FemConstraintTemperature,11,11,310.93
*********************************************************** ***********************************************************
** Heatflux constraints ** Heatflux constraints
** written by write_constraints_heatflux function ** written by write_constraints_heatflux function
** FemConstraintHeatflux
*FILM *FILM
** Heat flux on face Face3 ** Heat flux on face Face3
3,F2,255.3722,0.005678 3,F2,255.3722,0.005678