Skip to content

Commit

Permalink
FEM: ccx input writer, write object labels as comments
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach authored and wwmayer committed Feb 28, 2017
1 parent de0cf45 commit cc2c51b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
31 changes: 25 additions & 6 deletions src/Mod/Fem/FemInputWriterCcx.py
Expand Up @@ -418,7 +418,9 @@ def write_node_sets_constraints_fixed(self, f):
f.write('** Node sets for fixed constraint\n')
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']
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']:
f.write(str(n) + ',\n')

Expand All @@ -430,7 +432,9 @@ def write_node_sets_constraints_displacement(self, f):
f.write('** Node sets for prescribed displacement constraint\n')
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']
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']:
f.write(str(n) + ',\n')

Expand All @@ -450,6 +454,7 @@ def write_node_sets_constraints_planerotation(self, f):
for femobj in self.planerotation_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
l_nodes = femobj['Nodes']
fric_obj = femobj['Object']
f.write('** ' + fric_obj.Label + '\n')
f.write('*NSET,NSET=' + fric_obj.Name + '\n')
# Code to extract nodes and coordinates on the PlaneRotation support face
nodes_coords = []
Expand Down Expand Up @@ -479,6 +484,7 @@ def write_surfaces_contraints_contact(self, f):
obj = 0
for femobj in self.contact_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
contact_obj = femobj['Object']
f.write('** ' + contact_obj.Label + '\n')
cnt = 0
obj = obj + 1
for o, elem_tup in contact_obj.References:
Expand All @@ -504,6 +510,7 @@ def write_node_sets_constraints_transform(self, f):
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']
trans_obj = femobj['Object']
f.write('** ' + trans_obj.Label + '\n')
if trans_obj.TransformType == "Rectangular":
f.write('*NSET,NSET=Rect' + trans_obj.Name + '\n')
elif trans_obj.TransformType == "Cylindrical":
Expand All @@ -519,7 +526,9 @@ def write_node_sets_constraints_temperature(self, f):
f.write('** Node sets for temperature constraints\n')
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']
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']:
f.write(str(n) + ',\n')

Expand All @@ -537,6 +546,7 @@ def write_materials(self, f):
mat_obj = femobj['Object']
mat_info_name = mat_obj.Material['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
if mat_obj.Category == 'Solid':
YM = FreeCAD.Units.Quantity(mat_obj.Material['YoungsModulus'])
Expand All @@ -558,6 +568,7 @@ def write_materials(self, f):
DV_in_tmms = float(DV.getValueAs('t/mm/s'))
# write material properties
f.write('** FreeCAD material name: ' + mat_info_name + '\n')
f.write('** ' + mat_label + '\n')
f.write('*MATERIAL, NAME=' + mat_name + '\n')
if mat_obj.Category == 'Solid':
f.write('*ELASTIC\n')
Expand Down Expand Up @@ -732,6 +743,7 @@ def write_constraints_fixed(self, f):
f.write('** Fixed Constraints\n')
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']
f.write('** ' + femobj['Object'].Label + '\n')
fix_obj_name = femobj['Object'].Name
f.write('*BOUNDARY\n')
f.write(fix_obj_name + ',1\n')
Expand All @@ -748,6 +760,7 @@ def write_constraints_displacement(self, f):
f.write('** Displacement constraint applied\n')
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']
f.write('** ' + femobj['Object'].Label + '\n')
disp_obj = femobj['Object']
disp_obj_name = disp_obj.Name
f.write('*BOUNDARY\n')
Expand Down Expand Up @@ -787,6 +800,7 @@ def write_constraints_contact(self, f):
for femobj in self.contact_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
obj = obj + 1
contact_obj = femobj['Object']
f.write('** ' + contact_obj.Label + '\n')
f.write('*CONTACT PAIR, INTERACTION=INT' + str(obj) + ',TYPE=SURFACE TO SURFACE\n')
ind_surf = "IND" + str(obj)
dep_surf = "DEP" + str(obj)
Expand All @@ -806,6 +820,7 @@ def write_constraints_planerotation(self, f):
f.write('** PlaneRotation Constraints\n')
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']
f.write('** ' + femobj['Object'].Label + '\n')
fric_obj_name = femobj['Object'].Name
f.write('*MPC\n')
f.write('PLANE,' + fric_obj_name + '\n')
Expand All @@ -816,6 +831,7 @@ def write_constraints_transform(self, f):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for trans_object in self.transform_objects:
trans_obj = trans_object['Object']
f.write('** ' + trans_obj.Label + '\n')
if trans_obj.TransformType == "Rectangular":
f.write('*TRANSFORM, NSET=Rect' + trans_obj.Name + ', TYPE=R\n')
coords = FemMeshTools.get_rectangular_coords(trans_obj)
Expand All @@ -831,7 +847,7 @@ def write_constraints_selfweight(self, f):
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']
selwei_obj = femobj['Object']
f.write('** ' + selwei_obj.Name + '\n')
f.write('** ' + selwei_obj.Label + '\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('\n')
Expand All @@ -848,9 +864,8 @@ def write_constraints_force(self, f):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
f.write('*CLOAD\n')
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
f.write('** ' + frc_obj_name + '\n')
for ref_shape in femobj['NodeLoadTable']:
f.write('** ' + ref_shape[0] + '\n')
for n in sorted(ref_shape[1]):
Expand All @@ -876,6 +891,7 @@ def write_constraints_pressure(self, f):
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']
f.write('** ' + prs_obj.Label + '\n')
rev = -1 if prs_obj.Reversed else 1
f.write('*DLOAD\n')
for ref_shape in femobj['PressureFaces']:
Expand All @@ -889,6 +905,7 @@ def write_constraints_temperature(self, f):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for ftobj in self.temperature_objects:
fixedtemp_obj = ftobj['Object']
f.write('** ' + fixedtemp_obj.Label + '\n')
NumberOfNodes = len(ftobj['Nodes'])
if fixedtemp_obj.ConstraintType == "Temperature":
f.write('*BOUNDARY\n')
Expand All @@ -905,6 +922,7 @@ def write_constraints_heatflux(self, f):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for hfobj in self.heatflux_objects:
heatflux_obj = hfobj['Object']
f.write('** ' + heatflux_obj.Label + '\n')
if heatflux_obj.ConstraintType == "Convection":
f.write('*FILM\n')
for o, elem_tup in heatflux_obj.References:
Expand Down Expand Up @@ -938,6 +956,7 @@ def write_constraints_fluidsection(self, f):
self.get_constraints_fluidsection_nodes()
for femobj in self.fluidsection_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
fluidsection_obj = femobj['Object']
f.write('** ' + fluidsection_obj.Label + '\n')
if fluidsection_obj.SectionType == 'Liquid':
if fluidsection_obj.LiquidSectionType == 'PIPE INLET':
f.write('**Fluid Section Inlet \n')
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/Fem/test_files/ccx/cube_frequency.inp
Expand Up @@ -419,8 +419,9 @@
Eall

***********************************************************
** Node set for fixed constraint
** Node sets for fixed constraint
** written by write_node_sets_constraints_fixed function
** FemConstraintFixed
*NSET,NSET=FemConstraintFixed
1,
2,
Expand Down Expand Up @@ -470,6 +471,7 @@ Eall
** Young's modulus unit is MPa = N/mm2
** Density's unit is t/mm^3
** FreeCAD material name: Steel-Generic
** MechanicalMaterial
*MATERIAL, NAME=MechanicalMaterial
*ELASTIC
200000, 0.300
Expand All @@ -492,6 +494,7 @@ Eall
***********************************************************
** Fixed Constraints
** written by write_constraints_fixed function
** FemConstraintFixed
*BOUNDARY
FemConstraintFixed,1
FemConstraintFixed,2
Expand Down
6 changes: 5 additions & 1 deletion src/Mod/Fem/test_files/ccx/cube_static.inp
Expand Up @@ -419,8 +419,9 @@
Eall

***********************************************************
** Node set for fixed constraint
** Node sets for fixed constraint
** written by write_node_sets_constraints_fixed function
** FemConstraintFixed
*NSET,NSET=FemConstraintFixed
1,
2,
Expand Down Expand Up @@ -469,6 +470,7 @@ Eall
** written by write_materials function
** Young's modulus unit is MPa = N/mm2
** FreeCAD material name: Steel-Generic
** MechanicalMaterial
*MATERIAL, NAME=MechanicalMaterial
*ELASTIC
200000, 0.300
Expand All @@ -488,6 +490,7 @@ Eall
***********************************************************
** Fixed Constraints
** written by write_constraints_fixed function
** FemConstraintFixed
*BOUNDARY
FemConstraintFixed,1
FemConstraintFixed,2
Expand Down Expand Up @@ -547,6 +550,7 @@ FemConstraintFixed,3
***********************************************************
** Element + CalculiX face + load in [MPa]
** written by write_constraints_pressure function
** FemConstraintPressure
*DLOAD
** FemConstraintPressure: face load
3,P1,1000.0
Expand Down
8 changes: 7 additions & 1 deletion src/Mod/Fem/test_files/ccx/spine_thermomech.inp
Expand Up @@ -67,8 +67,9 @@
Eall

***********************************************************
** Node set for fixed constraint
** Node sets for fixed constraint
** written by write_node_sets_constraints_fixed function
** FemConstraintFixed
*NSET,NSET=FemConstraintFixed
5,
6,
Expand All @@ -83,6 +84,7 @@ Eall
***********************************************************
** Node sets for temperature constraints
** written by write_node_sets_constraints_temperature function
** FemConstraintTemperature
*NSET,NSET=FemConstraintTemperature
5,
6,
Expand All @@ -101,6 +103,7 @@ Eall
** Thermal conductivity unit is kW/mm/K = t*mm/K*s^3
** Specific Heat unit is kJ/t/K = mm^2/s^2/K
** FreeCAD material name: Steel-Generic
** MechanicalMaterial
*MATERIAL, NAME=MechanicalMaterial
*ELASTIC
200000, 0.300
Expand Down Expand Up @@ -135,6 +138,7 @@ Nall,300.0
***********************************************************
** Fixed Constraints
** written by write_constraints_fixed function
** FemConstraintFixed
*BOUNDARY
FemConstraintFixed,1
FemConstraintFixed,2
Expand All @@ -144,13 +148,15 @@ FemConstraintFixed,3
***********************************************************
** Fixed temperature constraint applied
** written by write_constraints_temperature function
** FemConstraintTemperature
*BOUNDARY
FemConstraintTemperature,11,11,310.93


***********************************************************
** Heatflux constraints
** written by write_constraints_heatflux function
** FemConstraintHeatflux
*FILM
** Heat flux on face Face3
3,F2,255.3722,0.005678
Expand Down

0 comments on commit cc2c51b

Please sign in to comment.