FEM: nonlinear materials, set CalculiX solver to nonlinear analysis if nonlinear material is added
This commit is contained in:
parent
dd92486ab5
commit
d39ef34b4a
|
@ -30,6 +30,7 @@ from FemCommands import FemCommands
|
|||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
import FemGui
|
||||
from PySide import QtCore
|
||||
|
||||
|
||||
|
@ -60,6 +61,18 @@ class _CommandMaterialMechanicalNonlinear(FemCommands):
|
|||
FreeCAD.ActiveDocument.openTransaction("Create FemMaterialMechanicalNonlinear")
|
||||
FreeCADGui.addModule("FemMaterialMechanicalNonlinear")
|
||||
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
|
||||
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
|
||||
solver_object = None
|
||||
break
|
||||
if solver_object and solver_object.SolverType == 'FemSolverCalculix':
|
||||
solver_object.MaterialNonlinearity = "nonlinear"
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Fem_MaterialMechanicalNonlinear', _CommandMaterialMechanicalNonlinear())
|
||||
|
|
|
@ -30,6 +30,7 @@ from FemCommands import FemCommands
|
|||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
import FemGui
|
||||
from PySide import QtCore
|
||||
|
||||
|
||||
|
@ -44,10 +45,18 @@ class _CommandSolverCalculix(FemCommands):
|
|||
self.is_active = 'with_analysis'
|
||||
|
||||
def Activated(self):
|
||||
has_nonlinear_material_obj = False
|
||||
for m in FemGui.getActiveAnalysis().Member:
|
||||
if hasattr(m, "Proxy") and m.Proxy.Type == "FemMaterialMechanicalNonlinear":
|
||||
has_nonlinear_material_obj = True
|
||||
FreeCAD.ActiveDocument.openTransaction("Create SolverCalculix")
|
||||
FreeCADGui.addModule("FemSolverCalculix")
|
||||
FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [FemSolverCalculix.makeFemSolverCalculix()]")
|
||||
|
||||
if has_nonlinear_material_obj:
|
||||
FreeCADGui.doCommand("solver = FemSolverCalculix.makeFemSolverCalculix()")
|
||||
FreeCADGui.doCommand("solver.MaterialNonlinearity = 'nonlinear'")
|
||||
FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [solver]")
|
||||
else:
|
||||
FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [FemSolverCalculix.makeFemSolverCalculix()]")
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Fem_SolverCalculix', _CommandSolverCalculix())
|
||||
|
|
Loading…
Reference in New Issue
Block a user