Skip to content

Commit

Permalink
FEM: constraint contact: add implementation for solver CalculiX
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach authored and wwmayer committed Aug 4, 2016
1 parent 116c971 commit 9107e92
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Mod/Fem/FemInputWriter.py
Expand Up @@ -45,6 +45,7 @@ def __init__(self,
analysis_obj, solver_obj,
mesh_obj, mat_obj,
fixed_obj, displacement_obj,
contact_obj,
selfweight_obj, force_obj, pressure_obj,
beamsection_obj, shellthickness_obj,
analysis_type, eigenmode_parameters,
Expand All @@ -56,6 +57,7 @@ def __init__(self,
self.material_objects = mat_obj
self.fixed_objects = fixed_obj
self.displacement_objects = displacement_obj
self.contact_objects = contact_obj
self.selfweight_objects = selfweight_obj
self.force_objects = force_obj
self.pressure_objects = pressure_obj
Expand Down
52 changes: 52 additions & 0 deletions src/Mod/Fem/FemInputWriterCcx.py
Expand Up @@ -40,6 +40,7 @@ def __init__(self,
analysis_obj, solver_obj,
mesh_obj, mat_obj,
fixed_obj, displacement_obj,
contact_obj,
selfweight_obj, force_obj, pressure_obj,
beamsection_obj, shellthickness_obj,
analysis_type=None, eigenmode_parameters=None,
Expand All @@ -49,6 +50,7 @@ def __init__(self,
analysis_obj, solver_obj,
mesh_obj, mat_obj,
fixed_obj, displacement_obj,
contact_obj,
selfweight_obj, force_obj, pressure_obj,
beamsection_obj, shellthickness_obj,
analysis_type, eigenmode_parameters,
Expand All @@ -69,8 +71,12 @@ def write_calculix_input_file(self):
self.write_node_sets_constraints_fixed(inpfile)
if self.displacement_objects:
self.write_node_sets_constraints_displacement(inpfile)
if self.contact_objects:
self.write_surfaces_contraints_contact(inpfile)
self.write_materials(inpfile)
self.write_femelementsets(inpfile)
if self.contact_objects:
self.write_constraints_contact(inpfile)
self.write_step_begin(inpfile)
if self.fixed_objects:
self.write_constraints_fixed(inpfile)
Expand Down Expand Up @@ -152,6 +158,30 @@ def write_node_sets_constraints_displacement(self, f):
for n in femobj['Nodes']:
f.write(str(n) + ',\n')

def write_surfaces_contraints_contact(self, f):
# get surface nodes and write them to file
f.write('\n***********************************************************\n')
f.write('** Surfaces for contact constraint\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
obj = 0
for femobj in self.contact_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
contact_obj = femobj['Object']
cnt = 0
obj = obj + 1
for o, elem_tup in contact_obj.References:
for elem in elem_tup:
ref_shape = o.Shape.getElement(elem)
cnt = cnt + 1
if ref_shape.ShapeType == 'Face':
if cnt == 1:
name = "DEP" + str(obj)
else:
name = "IND" + str(obj)
f.write('*SURFACE, NAME =' + name + '\n')
v = self.mesh_object.FemMesh.getccxVolumesByFace(ref_shape)
for i in v:
f.write("{},S{}\n".format(i[0], i[1]))

def write_materials(self, f):
f.write('\n***********************************************************\n')
f.write('** Materials\n')
Expand Down Expand Up @@ -286,6 +316,28 @@ def write_constraints_displacement(self, f):
f.write(disp_obj_name + ',6,6,' + str(disp_obj.zRotation) + '\n')
f.write('\n')

def write_constraints_contact(self, f):
f.write('\n***********************************************************\n')
f.write('** Contact Constraints\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
obj = 0
for femobj in self.contact_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
obj = obj + 1
contact_obj = femobj['Object']
f.write('*CONTACT PAIR, INTERACTION=INT' + str(obj) + ',TYPE=SURFACE TO SURFACE\n')
ind_surf = "IND" + str(obj)
dep_surf = "DEP" + str(obj)
f.write(dep_surf + ',' + ind_surf + '\n')
f.write('*SURFACE INTERACTION, NAME=INT' + str(obj) + '\n')
f.write('*SURFACE BEHAVIOR,PRESSURE-OVERCLOSURE=LINEAR\n')
slope = contact_obj.Slope
f.write(str(slope) + ' \n')
friction = contact_obj.Friction
if friction > 0:
f.write('*FRICTION \n')
stick = (slope / 10.0)
f.write(str(friction) + ', ' + str(stick) + ' \n')

def write_constraints_selfweight(self, f):
f.write('\n***********************************************************\n')
f.write('** Self weight\n')
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Fem/FemInputWriterZ88.py
Expand Up @@ -37,6 +37,7 @@ def __init__(self,
analysis_obj, solver_obj,
mesh_obj, mat_obj,
fixed_obj, displacement_obj,
contact_obj,
selfweight_obj, force_obj, pressure_obj,
beamsection_obj, shellthickness_obj,
analysis_type=None, eigenmode_parameters=None,
Expand All @@ -46,6 +47,7 @@ def __init__(self,
analysis_obj, solver_obj,
mesh_obj, mat_obj,
fixed_obj, displacement_obj,
contact_obj,
selfweight_obj, force_obj, pressure_obj,
beamsection_obj, shellthickness_obj,
analysis_type, eigenmode_parameters,
Expand Down
9 changes: 9 additions & 0 deletions src/Mod/Fem/FemTools.py
Expand Up @@ -153,6 +153,7 @@ def update_objects(self):
# [{'Object':pressure_constraints, 'xxxxxxxx':value}, {}, ...]
# [{'Object':beam_sections, 'xxxxxxxx':value}, {}, ...]
# [{'Object':shell_thicknesses, 'xxxxxxxx':value}, {}, ...]
# [{'Object':contact_constraints, 'xxxxxxxx':value}, {}, ...]

## @var mesh
# mesh of the analysis. Used to generate .inp file and to show results
Expand Down Expand Up @@ -189,6 +190,10 @@ def update_objects(self):
# set of displacements for the analysis. Updated with update_objects
# Individual displacement_constraints are Proxy.Type "FemConstraintDisplacement"
self.displacement_constraints = []
## @var contact_constraints
# set of contact constraints from the analysis. Updated with update_objects
# Individual constraints are "Fem::ConstraintContact" type
self.contact_constraints = []

found_solver_for_use = False
for m in self.analysis.Member:
Expand Down Expand Up @@ -235,6 +240,10 @@ def update_objects(self):
displacement_constraint_dict = {}
displacement_constraint_dict['Object'] = m
self.displacement_constraints.append(displacement_constraint_dict)
elif m.isDerivedFrom("Fem::ConstraintContact"):
contact_constraint_dict = {}
contact_constraint_dict['Object'] = m
self.contact_constraints.append(contact_constraint_dict)
elif hasattr(m, "Proxy") and m.Proxy.Type == "FemBeamSection":
beam_section_dict = {}
beam_section_dict['Object'] = m
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Fem/FemToolsCcx.py
Expand Up @@ -92,6 +92,7 @@ def write_inp_file(self):
self.analysis, self.solver,
self.mesh, self.materials,
self.fixed_constraints, self.displacement_constraints,
self.contact_constraints,
self.selfweight_constraints, self.force_constraints, self.pressure_constraints,
self.beam_sections, self.shell_thicknesses,
self.analysis_type, self.eigenmode_parameters,
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Fem/FemToolsZ88.py
Expand Up @@ -84,6 +84,7 @@ def write_inp_file(self):
self.analysis, self.solver,
self.mesh, self.materials,
self.fixed_constraints, self.displacement_constraints,
self.contact_constraints,
self.selfweight_constraints, self.force_constraints, self.pressure_constraints,
self.beam_sections, self.shell_thicknesses,
self.analysis_type, None,
Expand Down

0 comments on commit 9107e92

Please sign in to comment.