From 854002f08b0384f2073203bbc0831d966601c5af Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Sun, 25 Sep 2016 19:36:46 +0100 Subject: [PATCH] FEM: nonlinear materials, core object implementation --- src/Mod/Fem/App/CMakeLists.txt | 4 ++ src/Mod/Fem/CMakeLists.txt | 5 ++ src/Mod/Fem/FemMaterialMechanicalNonlinear.py | 40 ++++++++++++ src/Mod/Fem/Gui/Workbench.cpp | 2 + src/Mod/Fem/InitGui.py | 1 + .../_CommandMaterialMechanicalNonlinear.py | 53 ++++++++++++++++ .../Fem/_FemMaterialMechanicalNonlinear.py | 46 ++++++++++++++ ...wProviderFemMaterialMechanicalNonlinear.py | 61 +++++++++++++++++++ 8 files changed, 212 insertions(+) create mode 100644 src/Mod/Fem/FemMaterialMechanicalNonlinear.py create mode 100644 src/Mod/Fem/_CommandMaterialMechanicalNonlinear.py create mode 100644 src/Mod/Fem/_FemMaterialMechanicalNonlinear.py create mode 100644 src/Mod/Fem/_ViewProviderFemMaterialMechanicalNonlinear.py diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt index 7b1661122..25722b5d6 100755 --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -78,6 +78,7 @@ SET(FemScripts_SRCS _CommandConstraintSelfWeight.py _CommandMechanicalMaterial.py _CommandShowResult.py + _CommandMaterialMechanicalNonlinear.py _CommandMeshFromShape.py _CommandPurgeResults.py _CommandRunSolver.py @@ -86,6 +87,7 @@ SET(FemScripts_SRCS _CommandSolverZ88.py _FemBeamSection.py _FemConstraintSelfWeight.py + _FemMaterialMechanicalNonlinear.py _FemShellThickness.py _FemSolverCalculix.py _FemSolverZ88.py @@ -97,6 +99,7 @@ SET(FemScripts_SRCS _TaskPanelShowResult.py _ViewProviderFemBeamSection.py _ViewProviderFemConstraintSelfWeight.py + _ViewProviderFemMaterialMechanicalNonlinear.py _ViewProviderFemShellThickness.py _ViewProviderFemSolverCalculix.py _ViewProviderFemSolverZ88.py @@ -115,6 +118,7 @@ SET(FemScripts_SRCS FemInputWriter.py FemInputWriterCcx.py FemInputWriterZ88.py + FemMaterialMechanicalNonlinear.py FemMeshTools.py FemShellThickness.py FemSolverCalculix.py diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt index a325520b0..ac036bd1e 100755 --- a/src/Mod/Fem/CMakeLists.txt +++ b/src/Mod/Fem/CMakeLists.txt @@ -59,6 +59,11 @@ INSTALL( _TaskPanelMechanicalMaterial.py TaskPanelMechanicalMaterial.ui + FemMaterialMechanicalNonlinear.py + _FemMaterialMechanicalNonlinear.py + _ViewProviderFemMaterialMechanicalNonlinear.py + _CommandMaterialMechanicalNonlinear.py + # solver CalculiX ccx importInpMesh.py ccxDatReader.py diff --git a/src/Mod/Fem/FemMaterialMechanicalNonlinear.py b/src/Mod/Fem/FemMaterialMechanicalNonlinear.py new file mode 100644 index 000000000..a6e26b8f2 --- /dev/null +++ b/src/Mod/Fem/FemMaterialMechanicalNonlinear.py @@ -0,0 +1,40 @@ +# *************************************************************************** +# * * +# * Copyright (c) 2016 - Bernd Hahnebach * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +__title__ = "FemMaterialMechanicalNonlinear" +__author__ = "Bernd Hahnebach" +__url__ = "http://www.freecadweb.org" + + +import FreeCAD +import FemGui +import _FemMaterialMechanicalNonlinear + + +def makeFemMaterialMechanicalNonlinear(name="MechanicalMaterialNonlinear"): + '''makeFemMaterialMechanicalNonlinear([name]): creates an nonlinear material object''' + obj = FemGui.getActiveAnalysis().Document.addObject("Fem::FeaturePython", name) + _FemMaterialMechanicalNonlinear._FemMaterialMechanicalNonlinear(obj) + if FreeCAD.GuiUp: + import _ViewProviderFemMaterialMechanicalNonlinear + _ViewProviderFemMaterialMechanicalNonlinear._ViewProviderFemMaterialMechanicalNonlinear(obj.ViewObject) + return obj diff --git a/src/Mod/Fem/Gui/Workbench.cpp b/src/Mod/Fem/Gui/Workbench.cpp index 95b449b5d..e785f27bd 100755 --- a/src/Mod/Fem/Gui/Workbench.cpp +++ b/src/Mod/Fem/Gui/Workbench.cpp @@ -60,6 +60,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const // << "Fem_SolverZ88" << "Fem_MeshFromShape" << "Fem_MechanicalMaterial" + << "Fem_MaterialMechanicalNonlinear" << "Fem_BeamSection" << "Fem_ShellThickness" << "Separator" @@ -120,6 +121,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Fem_SolverZ88" << "Fem_MeshFromShape" << "Fem_MechanicalMaterial" + << "Fem_MaterialMechanicalNonlinear" << "Fem_BeamSection" << "Fem_ShellThickness" << "Separator" diff --git a/src/Mod/Fem/InitGui.py b/src/Mod/Fem/InitGui.py index 7e3893b22..b144fb31c 100644 --- a/src/Mod/Fem/InitGui.py +++ b/src/Mod/Fem/InitGui.py @@ -56,6 +56,7 @@ class FemWorkbench (Workbench): import _CommandShellThickness import _CommandBeamSection import _CommandMechanicalMaterial + import _CommandMaterialMechanicalNonlinear import _CommandSolverCalculix import _CommandSolverZ88 import _CommandConstraintSelfWeight diff --git a/src/Mod/Fem/_CommandMaterialMechanicalNonlinear.py b/src/Mod/Fem/_CommandMaterialMechanicalNonlinear.py new file mode 100644 index 000000000..a7a8de552 --- /dev/null +++ b/src/Mod/Fem/_CommandMaterialMechanicalNonlinear.py @@ -0,0 +1,53 @@ +# *************************************************************************** +# * * +# * Copyright (c) 2016 - Bernd Hahnebach * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +__title__ = "Command nonlinear mechanical material" +__author__ = "Bernd Hahnebach" +__url__ = "http://www.freecadweb.org" + + +import FreeCAD +from FemCommands import FemCommands + +if FreeCAD.GuiUp: + import FreeCADGui + from PySide import QtCore + + +class _CommandMaterialMechanicalNonlinear(FemCommands): + "The Fem_MaterialMechanicalNonlinear command definition" + def __init__(self): + super(_CommandMaterialMechanicalNonlinear, self).__init__() + self.resources = {'Pixmap': 'fem-material', + 'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_MaterialMechanicalNonlinear", "Nonlinear mechanical material"), + 'Accel': "C, W", + 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_MaterialMechanicalNonlinear", "Creates a nonlinear mechanical material")} + self.is_active = 'with_analysis' + + def Activated(self): + FreeCAD.ActiveDocument.openTransaction("Create FemMaterialMechanicalNonlinear") + FreeCADGui.addModule("FemMaterialMechanicalNonlinear") + FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [FemMaterialMechanicalNonlinear.makeFemMaterialMechanicalNonlinear()]") + + +if FreeCAD.GuiUp: + FreeCADGui.addCommand('Fem_MaterialMechanicalNonlinear', _CommandMaterialMechanicalNonlinear()) diff --git a/src/Mod/Fem/_FemMaterialMechanicalNonlinear.py b/src/Mod/Fem/_FemMaterialMechanicalNonlinear.py new file mode 100644 index 000000000..1a22f2ed7 --- /dev/null +++ b/src/Mod/Fem/_FemMaterialMechanicalNonlinear.py @@ -0,0 +1,46 @@ +# *************************************************************************** +# * * +# * Copyright (c) 2016 - Bernd Hahnebach * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +__title__ = "the fem nonlinear mechanical material object" +__author__ = "Bernd Hahnebach" +__url__ = "http://www.freecadweb.org" + + +class _FemMaterialMechanicalNonlinear: + "The FemMaterialMechanicalNonlinear object" + def __init__(self, obj): + obj.Proxy = self + self.Type = "FemMaterialMechanicalNonlinear" + + choices_nonlinear_material_models = ["simple hardening"] + obj.addProperty("App::PropertyEnumeration", "MaterialModelNonlinearity", "Fem", "Set the type on nonlinear material model") + obj.MaterialModelNonlinearity = choices_nonlinear_material_models + obj.MaterialModelNonlinearity = choices_nonlinear_material_models[0] + + obj.addProperty("App::PropertyString", "YieldPoint1", "Fem", "Set stress and strain for yield point one, separated by a comma.") + obj.YieldPoint1 = "235.0, 0.0" + + obj.addProperty("App::PropertyString", "YieldPoint2", "Fem", "Set stress and strain for yield point one, separated by a comma.") + obj.YieldPoint2 = "241.0, 0.025" + + def execute(self, obj): + return diff --git a/src/Mod/Fem/_ViewProviderFemMaterialMechanicalNonlinear.py b/src/Mod/Fem/_ViewProviderFemMaterialMechanicalNonlinear.py new file mode 100644 index 000000000..f5d9a5c4d --- /dev/null +++ b/src/Mod/Fem/_ViewProviderFemMaterialMechanicalNonlinear.py @@ -0,0 +1,61 @@ +# *************************************************************************** +# * * +# * Copyright (c) 2016 - Bernd Hahnebach * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +__title__ = "_ViewProviderFemMaterialMechanicalNonlinear" +__author__ = "Bernd Hahnebach" +__url__ = "http://www.freecadweb.org" + + +from pivy import coin + + +class _ViewProviderFemMaterialMechanicalNonlinear: + "A View Provider for the FemMaterialMechanicalNonlinear object" + def __init__(self, vobj): + vobj.Proxy = self + + def getIcon(self): + return ":/icons/fem-material.svg" + + def attach(self, vobj): + self.ViewObject = vobj + self.Object = vobj.Object + self.standard = coin.SoGroup() + vobj.addDisplayMode(self.standard, "Standard") + + def getDisplayModes(self, obj): + return ["Standard"] + + def getDefaultDisplayMode(self): + return "Standard" + + def updateData(self, obj, prop): + return + + def onChanged(self, vobj, prop): + return + + def __getstate__(self): + return None + + def __setstate__(self, state): + return None