Fem: add _CommandMaterialFluid.py and FemMaterial.makeFluidMaterial method

This commit is contained in:
qingfengxia 2017-01-08 21:46:27 +00:00
parent 81e9228cf0
commit 61fb3d429a
9 changed files with 264 additions and 28 deletions

View File

@ -68,7 +68,8 @@ SET(FemScripts_SRCS
_CommandConstraintSelfWeight.py
_CommandFEMMesh2Mesh.py
_CommandMaterialMechanicalNonlinear.py
_CommandMaterial.py
_CommandMaterialSolid.py
_CommandMaterialFluid.py
_CommandMeshGmshFromShape.py
_CommandMeshNetgenFromShape.py
_CommandMeshGroup.py

View File

@ -91,7 +91,8 @@ INSTALL(
FemMaterial.py
_FemMaterial.py
_ViewProviderFemMaterial.py
_CommandMaterial.py
_CommandMaterialSolid.py
_CommandMaterialFluid.py
_TaskPanelFemMaterial.py
TaskPanelFemMaterial.ui

View File

@ -31,11 +31,25 @@ import FreeCAD
import _FemMaterial
def makeFemMaterial(name):
'''makeFemMaterial(name): makes an FEM Material
def makeSolidMaterial(name):
'''makeSolidMaterial(name): makes an FEM Material for solid
'''
obj = FreeCAD.ActiveDocument.addObject("App::MaterialObjectPython", name)
_FemMaterial._FemMaterial(obj)
obj.Category = 'Solid'
if FreeCAD.GuiUp:
import _ViewProviderFemMaterial
_ViewProviderFemMaterial._ViewProviderFemMaterial(obj.ViewObject)
# FreeCAD.ActiveDocument.recompute()
return obj
def makeFluidMaterial(name):
'''makeFluidMaterial(name): makes an FEM Material for fluid
'''
obj = FreeCAD.ActiveDocument.addObject("App::MaterialObjectPython", name)
_FemMaterial._FemMaterial(obj)
obj.Category = 'Fluid'
if FreeCAD.GuiUp:
import _ViewProviderFemMaterial
_ViewProviderFemMaterial._ViewProviderFemMaterial(obj.ViewObject)

View File

@ -74,7 +74,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
<< "Fem_MeshGroup"
//<< "Fem_CreateNodesSet"
<< "Separator"
<< "Fem_Material"
<< "Fem_MaterialSolid"
<< "Fem_MaterialFluid"
<< "Fem_MaterialMechanicalNonlinear"
<< "Fem_BeamSection"
<< "Fem_ShellThickness"
@ -147,7 +148,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "Fem_MeshGroup"
<< "Fem_CreateNodesSet"
<< "Separator"
<< "Fem_Material"
<< "Fem_MaterialSolid"
<< "Fem_MaterialFluid"
<< "Fem_MaterialMechanicalNonlinear"
<< "Fem_BeamSection"
<< "Fem_ShellThickness"

View File

@ -59,7 +59,8 @@ class FemWorkbench (Workbench):
import _CommandAnalysis
import _CommandShellThickness
import _CommandBeamSection
import _CommandMaterial
import _CommandMaterialSolid
import _CommandMaterialFluid
import _CommandMaterialMechanicalNonlinear
import _CommandSolverCalculix
import _CommandSolverZ88

181
src/Mod/Fem/TaskPanelFemMaterial.ui Normal file → Executable file
View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>370</width>
<height>700</height>
<width>396</width>
<height>790</height>
</rect>
</property>
<property name="windowTitle">
@ -26,6 +26,31 @@
<string>Material</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="2">
<widget class="QRadioButton" name="radioButton">
<property name="text">
<string>Fluid</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radioButton_2">
<property name="text">
<string>Solid</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Category</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QComboBox" name="cb_materials">
<item>
@ -86,7 +111,7 @@
<item row="1" column="2">
<widget class="QRadioButton" name="rb_solid">
<property name="text">
<string>Solid</string>
<string>Body (3D)</string>
</property>
</widget>
</item>
@ -102,6 +127,116 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="GroupQuantities_24">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1677215</height>
</size>
</property>
<property name="title">
<string>Basic Properties</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
<item>
<layout class="QFormLayout" name="formLayout_20">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::InputField" name="input_fd_name">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>steel</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep" stdset="0">
<double>2.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>2000000000.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true">Pa</string>
</property>
<property name="decimals" stdset="0">
<number>3</number>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::InputField" name="input_fd_density">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>8000 kg/m^3</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep" stdset="0">
<double>2.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>2000000000.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true">kg/m^3</string>
</property>
<property name="decimals" stdset="0">
<number>3</number>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Density</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="GroupQuantities_4">
<property name="maximumSize">
@ -111,7 +246,7 @@
</size>
</property>
<property name="title">
<string>Material Properties</string>
<string>Mechanical Properties</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
@ -201,15 +336,37 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="GroupQuantities_14">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1677215</height>
</size>
</property>
<property name="title">
<string>Fluidic Properties</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
<item>
<layout class="QFormLayout" name="formLayout_10">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Density</string>
<string>Kinetic viscosity:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::InputField" name="input_fd_density">
<item row="0" column="1">
<widget class="Gui::InputField" name="input_fd_kinetic_viscosity">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -223,7 +380,7 @@
</size>
</property>
<property name="text">
<string>8000 kg/m^3</string>
<string>0.000001</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -235,7 +392,7 @@
<double>2000000000.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true">kg/m^3</string>
<string notr="true">Pa</string>
</property>
<property name="decimals" stdset="0">
<number>3</number>
@ -259,7 +416,7 @@
</size>
</property>
<property name="title">
<string>Temperature-Dependant Material Properties</string>
<string>Thermal Properties</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>

View File

@ -20,7 +20,7 @@
# * *
# ***************************************************************************
__title__ = "_CommandMaterial"
__title__ = "_CommandFluidMaterial"
__author__ = "Juergen Riegel, Bernd Hahnebach"
__url__ = "http://www.freecadweb.org"
@ -34,25 +34,25 @@ import FemGui
from PySide import QtCore
class _CommandMaterial(FemCommands):
"the Fem_Material command definition"
class _CommandMaterialFluid(FemCommands):
"the Fem_MaterialFluid command definition"
def __init__(self):
super(_CommandMaterial, self).__init__()
super(_CommandMaterialFluid, self).__init__()
self.resources = {'Pixmap': 'fem-material',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Material", "FEM material"),
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_MaterialFluid", "FEM material for Fluid"),
'Accel': "M, M",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Material", "Creates a FEM material")}
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_MaterialFluid", "Creates a FEM material for Fluid")}
self.is_active = 'with_analysis'
def Activated(self):
femDoc = FemGui.getActiveAnalysis().Document
if FreeCAD.ActiveDocument is not femDoc:
FreeCADGui.setActiveDocument(femDoc)
FreeCAD.ActiveDocument.openTransaction("Create Material")
FreeCAD.ActiveDocument.openTransaction("Create Fluid Material")
FreeCADGui.addModule("FemMaterial")
FreeCADGui.doCommand("FemMaterial.makeFemMaterial('FemMaterial')")
FreeCADGui.doCommand("FemMaterial.makeFluidMaterial('FluidMaterial')")
FreeCADGui.doCommand("App.activeDocument()." + FemGui.getActiveAnalysis().Name + ".Member = App.activeDocument()." + FemGui.getActiveAnalysis().Name + ".Member + [App.ActiveDocument.ActiveObject]")
FreeCADGui.doCommand("Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name)")
FreeCADGui.addCommand('Fem_Material', _CommandMaterial())
FreeCADGui.addCommand('Fem_MaterialFluid', _CommandMaterialFluid())

View File

@ -0,0 +1,58 @@
# ***************************************************************************
# * *
# * Copyright (c) 2013 - Juergen Riegel <FreeCAD@juergen-riegel.net> *
# * *
# * 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__ = "_CommandSolidMaterial"
__author__ = "Juergen Riegel, Bernd Hahnebach"
__url__ = "http://www.freecadweb.org"
## @package CommandMaterial
# \ingroup FEM
import FreeCAD
from FemCommands import FemCommands
import FreeCADGui
import FemGui
from PySide import QtCore
class _CommandMaterialSolid(FemCommands):
"the Fem_MaterialSolid command definition"
def __init__(self):
super(_CommandMaterialSolid, self).__init__()
self.resources = {'Pixmap': 'fem-material',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_MaterialSolid", "FEM material for solid"),
'Accel': "M, M",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_MaterialSolid", "Creates a FEM material for solid")}
self.is_active = 'with_analysis'
def Activated(self):
femDoc = FemGui.getActiveAnalysis().Document
if FreeCAD.ActiveDocument is not femDoc:
FreeCADGui.setActiveDocument(femDoc)
FreeCAD.ActiveDocument.openTransaction("Create Solid Material")
FreeCADGui.addModule("FemMaterial")
FreeCADGui.doCommand("FemMaterial.makeSolidMaterial('SolidMaterial')")
FreeCADGui.doCommand("App.activeDocument()." + FemGui.getActiveAnalysis().Name + ".Member = App.activeDocument()." + FemGui.getActiveAnalysis().Name + ".Member + [App.ActiveDocument.ActiveObject]")
FreeCADGui.doCommand("Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name)")
FreeCADGui.addCommand('Fem_MaterialSolid', _CommandMaterialSolid())

View File

@ -32,6 +32,8 @@ class _FemMaterial:
"The FEM Material object"
def __init__(self, obj):
obj.addProperty("App::PropertyLinkSubList", "References", "Material", "List of material shapes")
obj.addProperty("App::PropertyEnum", "Category", "Material", "Material type: fluid or solid")
obj.Category = ['Solid', 'Fluid']
obj.Proxy = self
self.Type = "FemMaterial"