Skip to content

Commit

Permalink
FEM: constraint self weight: implementation for solver CalculiX
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach authored and yorikvanhavre committed Jul 21, 2016
1 parent 3554c70 commit b69116b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Mod/Fem/FemInputWriter.py
Expand Up @@ -44,7 +44,7 @@ class FemInputWriter():
def __init__(self, analysis_obj, solver_obj,
mesh_obj, mat_obj,
fixed_obj,
force_obj, pressure_obj,
selfweight_obj, force_obj, pressure_obj,
displacement_obj,
beamsection_obj, shellthickness_obj,
analysis_type, eigenmode_parameters,
Expand All @@ -54,6 +54,7 @@ def __init__(self, analysis_obj, solver_obj,
self.mesh_object = mesh_obj
self.material_objects = mat_obj
self.fixed_objects = fixed_obj
self.selfweight_objects = selfweight_obj
self.force_objects = force_obj
self.pressure_objects = pressure_obj
self.displacement_objects = displacement_obj
Expand Down
18 changes: 16 additions & 2 deletions src/Mod/Fem/FemInputWriterCcx.py
Expand Up @@ -39,15 +39,15 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
def __init__(self, analysis_obj, solver_obj,
mesh_obj, mat_obj,
fixed_obj,
force_obj, pressure_obj,
selfweight_obj, force_obj, pressure_obj,
displacement_obj,
beamsection_obj, shellthickness_obj,
analysis_type=None, eigenmode_parameters=None,
dir_name=None):
FemInputWriter.FemInputWriter.__init__(self, analysis_obj, solver_obj,
mesh_obj, mat_obj,
fixed_obj,
force_obj, pressure_obj,
selfweight_obj, force_obj, pressure_obj,
displacement_obj,
beamsection_obj, shellthickness_obj,
analysis_type, eigenmode_parameters,
Expand All @@ -71,6 +71,7 @@ def write_calculix_input_file(self):
self.write_constraints_fixed(inpfile)
self.write_constraints_displacement(inpfile)
if self.analysis_type is None or self.analysis_type == "static":
self.write_constraints_selfweight(inpfile)
self.write_constraints_force(inpfile)
self.write_constraints_pressure(inpfile)
elif self.analysis_type == "frequency":
Expand Down Expand Up @@ -260,6 +261,19 @@ def write_constraints_displacement(self, f):
f.write(disp_obj_name + ',6,6,' + str(disp_obj.zRotation) + '\n')
f.write('\n')

def write_constraints_selfweight(self, f):
f.write('\n***********************************************************\n')
f.write('** Self weight\n')
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_name = femobj['Object'].Name
f.write('** ' + selwei_obj_name + '\n')
f.write('*DLOAD\n')
f.write('Eall,GRAV,9810,0,0,-1\n')
f.write('\n')
# die grav (erdbeschleunigung) ist fuer alle gleich
# die verschidene density wurde in den material sets geschrieben !

def write_constraints_force(self, f):
# check shape type of reference shape and get node loads
self.get_constraints_force_nodeloads()
Expand Down
8 changes: 8 additions & 0 deletions src/Mod/Fem/FemTools.py
Expand Up @@ -165,6 +165,10 @@ def update_objects(self):
# set of fixed constraints from the analysis. Updated with update_objects
# Individual constraints are "Fem::ConstraintFixed" type
self.fixed_constraints = []
## @var selfweight_constraints
# set of selfweight constraints from the analysis. Updated with update_objects
# Individual constraints are Proxy.Type "FemConstraintSelfWeight"
self.selfweight_constraints = []
## @var force_constraints
# set of force constraints from the analysis. Updated with update_objects
# Individual constraints are "Fem::ConstraintForce" type
Expand Down Expand Up @@ -215,6 +219,10 @@ def update_objects(self):
fixed_constraint_dict = {}
fixed_constraint_dict['Object'] = m
self.fixed_constraints.append(fixed_constraint_dict)
elif hasattr(m, "Proxy") and m.Proxy.Type == "FemConstraintSelfWeight":
selfweight_dict = {}
selfweight_dict['Object'] = m
self.selfweight_constraints.append(selfweight_dict)
elif m.isDerivedFrom("Fem::ConstraintForce"):
force_constraint_dict = {}
force_constraint_dict['Object'] = m
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/FemToolsCcx.py
Expand Up @@ -90,7 +90,7 @@ def write_inp_file(self):
inp_writer = iw.FemInputWriterCcx(self.analysis, self.solver,
self.mesh, self.materials,
self.fixed_constraints,
self.force_constraints, self.pressure_constraints,
self.selfweight_constraints, self.force_constraints, self.pressure_constraints,
self.displacement_constraints,
self.beam_sections, self.shell_thicknesses,
self.analysis_type, self.eigenmode_parameters,
Expand Down

0 comments on commit b69116b

Please sign in to comment.