From 06054bdeb489aefcccd7bf8e5c76f094ceac4d69 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Sat, 1 Jul 2017 12:07:05 +0200 Subject: [PATCH] FEM: nonlinear material, set nonlinear geometry for nonlinear material in ccx solver --- src/Mod/Fem/FemTools.py | 10 +++++++--- .../PyGui/_CommandFemMaterialMechanicalNonlinear.py | 7 +++++-- src/Mod/Fem/PyGui/_CommandFemSolverCalculix.py | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Mod/Fem/FemTools.py b/src/Mod/Fem/FemTools.py index f0ee816491..4822cae0dc 100644 --- a/src/Mod/Fem/FemTools.py +++ b/src/Mod/Fem/FemTools.py @@ -340,8 +340,12 @@ class FemTools(QtCore.QRunnable, QtCore.QObject): message += "Frequency analysis: Solver has no EigenmodeLowLimit.\n" elif not hasattr(self.solver, "EigenmodesCount"): message += "Frequency analysis: Solver has no EigenmodesCount.\n" - if hasattr(self.solver, "MaterialNonlinearity") and self.solver.MaterialNonlinearity == "nonlinear" and not self.materials_nonlinear: - message += "Solver is set to nonlinear materials, but there is no nonlinear material in the analysis. \n" + if hasattr(self.solver, "MaterialNonlinearity") and self.solver.MaterialNonlinearity == "nonlinear": + if not self.materials_nonlinear: + message += "Solver is set to nonlinear materials, but there is no nonlinear material in the analysis.\n" + if self.solver.SolverType == 'FemSolverCalculix' and self.solver.GeometricalNonlinearity != "nonlinear": + # nonlinear geometry --> should be set https://forum.freecadweb.org/viewtopic.php?f=18&t=23101&p=180489#p180489 + message += "Solver CalculiX triggers nonlinear geometry for nonlinear material, thus it should to be set too.\n" # mesh if not self.mesh: message += "No mesh object defined in the analysis\n" @@ -400,7 +404,7 @@ class FemTools(QtCore.QRunnable, QtCore.QObject): if has_nonlinear_material is False: has_nonlinear_material = True else: - message += "At least two nonlinear materials use the same linear base material. Only one nonlinear material for each linear material allowed. \n" + message += "At least two nonlinear materials use the same linear base material. Only one nonlinear material for each linear material allowed.\n" # constraints if self.analysis_type == "static": if not (self.fixed_constraints or self.displacement_constraints): diff --git a/src/Mod/Fem/PyGui/_CommandFemMaterialMechanicalNonlinear.py b/src/Mod/Fem/PyGui/_CommandFemMaterialMechanicalNonlinear.py index bfdf95a05a..25313f7f15 100644 --- a/src/Mod/Fem/PyGui/_CommandFemMaterialMechanicalNonlinear.py +++ b/src/Mod/Fem/PyGui/_CommandFemMaterialMechanicalNonlinear.py @@ -61,17 +61,20 @@ class _CommandFemMaterialMechanicalNonlinear(FemCommands): FreeCAD.ActiveDocument.openTransaction("Create FemMaterialMechanicalNonlinear") FreeCADGui.addModule("ObjectsFem") FreeCADGui.doCommand(command_to_run) - # set the material nonlinear property of the solver to nonlinear if only one solver is available and if this solver is a CalculiX solver + # set some property of the solver to nonlinear (only if one solver is available and if this solver is a CalculiX solver): + # nonlinear material + # nonlinear geometry --> its is triggered anyway https://forum.freecadweb.org/viewtopic.php?f=18&t=23101&p=180489#p180489 solver_object = None for m in FemGui.getActiveAnalysis().Member: if m.isDerivedFrom('Fem::FemSolverObjectPython'): if not solver_object: solver_object = m else: - # we do not change the material nonlinear attribut if we have more than one solver + # we do not change attributes if we have more than one solver, since we do not know which one to take solver_object = None break if solver_object and solver_object.SolverType == 'FemSolverCalculix': solver_object.MaterialNonlinearity = "nonlinear" + solver_object.GeometricalNonlinearity = "nonlinear" FreeCADGui.addCommand('FEM_MaterialMechanicalNonlinear', _CommandFemMaterialMechanicalNonlinear()) diff --git a/src/Mod/Fem/PyGui/_CommandFemSolverCalculix.py b/src/Mod/Fem/PyGui/_CommandFemSolverCalculix.py index bfefb94fb9..e72fcf2fde 100644 --- a/src/Mod/Fem/PyGui/_CommandFemSolverCalculix.py +++ b/src/Mod/Fem/PyGui/_CommandFemSolverCalculix.py @@ -53,6 +53,7 @@ class _CommandFemSolverCalculix(FemCommands): FreeCADGui.addModule("ObjectsFem") if has_nonlinear_material_obj: FreeCADGui.doCommand("solver = ObjectsFem.makeSolverCalculix()") + FreeCADGui.doCommand("solver.GeometricalNonlinearity = 'nonlinear'") FreeCADGui.doCommand("solver.MaterialNonlinearity = 'nonlinear'") FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [solver]") else: