Skip to content

Commit

Permalink
Fem: add _CommandMaterialFluid.py and FemMaterial.makeFluidMaterial m…
Browse files Browse the repository at this point in the history
…ethod
  • Loading branch information
qingfengxia committed Jan 8, 2017
1 parent 81e9228 commit 61fb3d4
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 28 deletions.
3 changes: 2 additions & 1 deletion src/Mod/Fem/App/CMakeLists.txt
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Fem/CMakeLists.txt
Expand Up @@ -91,7 +91,8 @@ INSTALL(
FemMaterial.py
_FemMaterial.py
_ViewProviderFemMaterial.py
_CommandMaterial.py
_CommandMaterialSolid.py
_CommandMaterialFluid.py
_TaskPanelFemMaterial.py
TaskPanelFemMaterial.ui

Expand Down
18 changes: 16 additions & 2 deletions src/Mod/Fem/FemMaterial.py
Expand Up @@ -31,11 +31,25 @@
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)
Expand Down
6 changes: 4 additions & 2 deletions src/Mod/Fem/Gui/Workbench.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Fem/InitGui.py
Expand Up @@ -59,7 +59,8 @@ def Initialize(self):
import _CommandAnalysis
import _CommandShellThickness
import _CommandBeamSection
import _CommandMaterial
import _CommandMaterialSolid
import _CommandMaterialFluid
import _CommandMaterialMechanicalNonlinear
import _CommandSolverCalculix
import _CommandSolverZ88
Expand Down
181 changes: 169 additions & 12 deletions src/Mod/Fem/TaskPanelFemMaterial.ui 100644 → 100755
Expand Up @@ -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">
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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">
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down
Expand Up @@ -20,7 +20,7 @@
# * *
# ***************************************************************************

__title__ = "_CommandMaterial"
__title__ = "_CommandFluidMaterial"
__author__ = "Juergen Riegel, Bernd Hahnebach"
__url__ = "http://www.freecadweb.org"

Expand All @@ -34,25 +34,25 @@
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())

0 comments on commit 61fb3d4

Please sign in to comment.