From b69116b4aa28fdac51fcab1e0b87f02b1f019da7 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Thu, 21 Jul 2016 06:07:44 +0100 Subject: [PATCH] FEM: constraint self weight: implementation for solver CalculiX --- src/Mod/Fem/FemInputWriter.py | 3 ++- src/Mod/Fem/FemInputWriterCcx.py | 18 ++++++++++++++++-- src/Mod/Fem/FemTools.py | 8 ++++++++ src/Mod/Fem/FemToolsCcx.py | 2 +- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/Mod/Fem/FemInputWriter.py b/src/Mod/Fem/FemInputWriter.py index fd3de176cc..416f5029de 100644 --- a/src/Mod/Fem/FemInputWriter.py +++ b/src/Mod/Fem/FemInputWriter.py @@ -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, @@ -54,6 +54,7 @@ class FemInputWriter(): 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 diff --git a/src/Mod/Fem/FemInputWriterCcx.py b/src/Mod/Fem/FemInputWriterCcx.py index 686f2d04c6..889475eac6 100644 --- a/src/Mod/Fem/FemInputWriterCcx.py +++ b/src/Mod/Fem/FemInputWriterCcx.py @@ -39,7 +39,7 @@ 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, @@ -47,7 +47,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter): 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, @@ -71,6 +71,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter): 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": @@ -260,6 +261,19 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter): 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() diff --git a/src/Mod/Fem/FemTools.py b/src/Mod/Fem/FemTools.py index a178a0fd3c..c353bad993 100644 --- a/src/Mod/Fem/FemTools.py +++ b/src/Mod/Fem/FemTools.py @@ -165,6 +165,10 @@ class FemTools(QtCore.QRunnable, QtCore.QObject): # 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 @@ -215,6 +219,10 @@ class FemTools(QtCore.QRunnable, QtCore.QObject): 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 diff --git a/src/Mod/Fem/FemToolsCcx.py b/src/Mod/Fem/FemToolsCcx.py index 20888c5e42..d7cb4a530f 100644 --- a/src/Mod/Fem/FemToolsCcx.py +++ b/src/Mod/Fem/FemToolsCcx.py @@ -90,7 +90,7 @@ class FemToolsCcx(FemTools.FemTools): 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,