Skip to content

Commit

Permalink
FEM: nonlinear material, set nonlinear geometry for nonlinear materia…
Browse files Browse the repository at this point in the history
…l in ccx solver
  • Loading branch information
berndhahnebach authored and wwmayer committed Jul 3, 2017
1 parent b12831b commit 06054bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/Mod/Fem/FemTools.py
Expand Up @@ -340,8 +340,12 @@ def check_prerequisites(self):
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"
Expand Down Expand Up @@ -400,7 +404,7 @@ def check_prerequisites(self):
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):
Expand Down
7 changes: 5 additions & 2 deletions src/Mod/Fem/PyGui/_CommandFemMaterialMechanicalNonlinear.py
Expand Up @@ -61,17 +61,20 @@ def Activated(self):
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())
1 change: 1 addition & 0 deletions src/Mod/Fem/PyGui/_CommandFemSolverCalculix.py
Expand Up @@ -53,6 +53,7 @@ def Activated(self):
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:
Expand Down

0 comments on commit 06054bd

Please sign in to comment.