FEM: Python objects and guiobjects, code formating

This commit is contained in:
Bernd Hahnebach
2020-03-03 21:04:56 +01:00
parent d233c2e957
commit 2cf8c17102
35 changed files with 267 additions and 162 deletions

View File

@@ -36,6 +36,7 @@ class Proxy(FemConstraint.Proxy):
def __init__(self, obj):
super(Proxy, self).__init__(obj)
obj.addProperty(
"App::PropertyFloat",
"HeatSource",

View File

@@ -31,7 +31,9 @@ from . import FemConstraint
class _FemConstraintSelfWeight(FemConstraint.Proxy):
"The FemConstraintSelfWeight object"
"""
The FemConstraintSelfWeight object"
"""
Type = "Fem::ConstraintSelfWeight"
@@ -44,18 +46,21 @@ class _FemConstraintSelfWeight(FemConstraint.Proxy):
"Gravity",
"Gravity direction: set the x-component of the normalized gravity vector"
)
obj.addProperty(
"App::PropertyFloat",
"Gravity_y",
"Gravity",
"Gravity direction: set the y-component of the normalized gravity vector"
)
obj.addProperty(
"App::PropertyFloat",
"Gravity_z",
"Gravity",
"Gravity direction: set the z-component of the normalized gravity vector"
)
obj.Gravity_x = 0.0
obj.Gravity_y = 0.0
obj.Gravity_z = -1.0

View File

@@ -1,5 +1,5 @@
# ***************************************************************************
# * Copyright (c) 2015 Bernd Hahnebach <bernd@bimstatik.org> *
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
@@ -31,7 +31,9 @@ from . import FemConstraint
class _FemConstraintTie(FemConstraint.Proxy):
"The FemConstraintTie object"
"""
The FemConstraintTie object
"""
Type = "Fem::ConstraintTie"

View File

@@ -1,5 +1,6 @@
# ***************************************************************************
# * Copyright (c) 2016 Ofentse Kgoa <kgoaot@eskom.co.za> *
# * Copyright (c) 2018 Bernd Hahnebach <bernd@bimstatik.org> *
# * Based on the FemElementGeometry1D by Bernd Hahnebach *
# * *
# * This program is free software; you can redistribute it and/or modify *
@@ -32,9 +33,12 @@ from . import FemConstraint
class _FemElementFluid1D(FemConstraint.Proxy):
"The FemElementFluid1D object"
"""
The FemElementFluid1D object
"""
Type = "Fem::ElementFluid1D"
known_fluid_types = ["Liquid"]
# "Gas", "Open Channel" are not implemented in ccx writer
# known_fluid_types = ["Liquid", "Gas", "Open Channel"]
@@ -56,42 +60,49 @@ class _FemElementFluid1D(FemConstraint.Proxy):
def __init__(self, obj):
super(_FemElementFluid1D, self).__init__(obj)
obj.addProperty(
"App::PropertyLinkSubList",
"References",
"FluidSection",
"List of fluid section shapes"
)
obj.addProperty(
"App::PropertyEnumeration",
"SectionType",
"FluidSection",
"select fluid section type"
)
obj.addProperty(
"App::PropertyEnumeration",
"LiquidSectionType",
"LiquidSection",
"select liquid section type"
)
obj.addProperty(
"App::PropertyArea",
"ManningArea",
"LiquidManning",
"set area of the manning fluid section"
)
obj.addProperty(
"App::PropertyLength",
"ManningRadius",
"LiquidManning",
"set hydraulic radius of manning fluid section"
)
obj.addProperty(
"App::PropertyFloat",
"ManningCoefficient",
"LiquidManning",
"set coefficient of manning fluid section"
)
obj.addProperty(
"App::PropertyArea",
"EnlargeArea1",
@@ -104,168 +115,196 @@ class _FemElementFluid1D(FemConstraint.Proxy):
"LiquidEnlargement",
"set enlarged area of enlargement fluid section"
)
obj.addProperty(
"App::PropertyArea",
"ContractArea1",
"LiquidContraction",
"set initial area of the contraction fluid section"
)
obj.addProperty(
"App::PropertyArea",
"ContractArea2",
"LiquidContraction",
"set contracted area of contraction fluid section"
)
obj.addProperty(
"App::PropertyFloat",
"InletPressure",
"LiquidInlet",
"set inlet pressure for fluid section"
)
obj.addProperty(
"App::PropertyFloat",
"OutletPressure",
"LiquidOutlet",
"set outlet pressure for fluid section"
)
obj.addProperty(
"App::PropertyFloat",
"InletFlowRate",
"LiquidInlet",
"set inlet mass flow rate for fluid section"
)
obj.addProperty(
"App::PropertyFloat",
"OutletFlowRate",
"LiquidOutlet",
"set outlet mass flow rate for fluid section"
)
obj.addProperty(
"App::PropertyBool",
"InletPressureActive",
"LiquidInlet",
"activates or deactivates inlet pressure for fluid section"
)
obj.addProperty(
"App::PropertyBool",
"OutletPressureActive",
"LiquidOutlet",
"activates or deactivates outlet pressure for fluid section"
)
obj.addProperty(
"App::PropertyBool",
"InletFlowRateActive",
"LiquidInlet",
"activates or deactivates inlet flow rate for fluid section"
)
obj.addProperty(
"App::PropertyBool",
"OutletFlowRateActive",
"LiquidOutlet",
"activates or deactivates outlet flow rate for fluid section"
)
obj.addProperty(
"App::PropertyArea",
"EntrancePipeArea",
"LiquidEntrance",
"set the pipe area of the entrance fluid section"
)
obj.addProperty(
"App::PropertyArea",
"EntranceArea",
"LiquidEntrance",
"set the entrance area of the entrance fluid section"
)
obj.addProperty(
"App::PropertyArea",
"DiaphragmPipeArea",
"LiquidDiaphragm",
"set the pipe area of the diaphragm fluid section"
)
obj.addProperty(
"App::PropertyArea",
"DiaphragmArea",
"LiquidDiaphragm",
"set the diaphragm area of the diaphragm fluid section"
)
obj.addProperty(
"App::PropertyArea",
"BendPipeArea",
"LiquidBend",
"set pipe area of the bend fluid section"
)
obj.addProperty(
"App::PropertyFloat",
"BendRadiusDiameter",
"LiquidBend",
"set ratio of bend radius over pipe diameter of the bend fluid section"
)
obj.addProperty(
"App::PropertyFloat",
"BendAngle",
"LiquidBend",
"set bend angle of the bend fluid section"
)
obj.addProperty(
"App::PropertyFloat",
"BendLossCoefficient",
"LiquidBend",
"set loss coefficient of the bend fluid section"
)
obj.addProperty(
"App::PropertyArea",
"GateValvePipeArea",
"LiquidGateValve",
"set pipe area of the gate valve fluid section"
)
obj.addProperty(
"App::PropertyFloat",
"GateValveClosingCoeff",
"LiquidGateValve",
"set closing coefficient of the gate valve fluid section"
)
obj.addProperty(
"App::PropertyFloatList",
"PumpFlowRate",
"LiquidPump",
"set the pump characteristic flow rate of the pump fluid section"
)
obj.addProperty(
"App::PropertyFloatList",
"PumpHeadLoss",
"LiquidPump",
"set the pump characteristic head loss of the pump fluid section"
)
obj.addProperty(
"App::PropertyArea",
"ColebrookeArea",
"LiquidColebrooke",
"set pipe area of the colebrooke fluid section"
)
obj.addProperty(
"App::PropertyLength",
"ColebrookeRadius",
"LiquidColebrooke",
"set hydraulic radius of the colebrooke fluid section"
)
obj.addProperty(
"App::PropertyLength",
"ColebrookeGrainDiameter",
"LiquidColebrooke",
"set grain diameter of the colebrooke fluid section"
)
obj.addProperty(
"App::PropertyFloat",
"ColebrookeFormFactor",
"LiquidColebrooke",
"set coefficient of the colebrooke fluid section"
)
obj.addProperty(
"App::PropertyEnumeration",
"GasSectionType",
"GasSection",
"select gas section type"
)
obj.addProperty(
"App::PropertyEnumeration",
"ChannelSectionType",

View File

@@ -31,54 +31,64 @@ from . import FemConstraint
class _FemElementGeometry1D(FemConstraint.Proxy):
"The FemElementGeometry1D object"
"""
The FemElementGeometry1D object
"""
Type = "Fem::ElementGeometry1D"
known_beam_types = ["Rectangular", "Circular", "Pipe"]
def __init__(self, obj):
super(_FemElementGeometry1D, self).__init__(obj)
obj.addProperty(
"App::PropertyLength",
"RectWidth",
"RectBeamSection",
"set width of the rectangular beam elements"
)
obj.addProperty(
"App::PropertyLength",
"RectHeight",
"RectBeamSection",
"set height of therectangular beam elements"
)
obj.addProperty(
"App::PropertyLength",
"CircDiameter",
"CircBeamSection",
"set diameter of the circular beam elements"
)
obj.addProperty(
"App::PropertyLength",
"PipeDiameter",
"PipeBeamSection",
"set outer diameter of the pipe beam elements"
)
obj.addProperty(
"App::PropertyLength",
"PipeThickness",
"PipeBeamSection",
"set thickness of the pipe beam elements"
)
obj.addProperty(
"App::PropertyEnumeration",
"SectionType",
"BeamSection",
"select beam section type"
)
obj.addProperty(
"App::PropertyLinkSubList",
"References",
"BeamSection",
"List of beam section shapes"
)
obj.SectionType = _FemElementGeometry1D.known_beam_types
obj.SectionType = "Rectangular"

View File

@@ -31,7 +31,9 @@ from . import FemConstraint
class _FemElementGeometry2D(FemConstraint.Proxy):
"The FemElementGeometry2D object"
"""
The FemElementGeometry2D object
"""
Type = "Fem::ElementGeometry2D"
@@ -44,6 +46,7 @@ class _FemElementGeometry2D(FemConstraint.Proxy):
"ShellThickness",
"set thickness of the shell elements"
)
obj.addProperty(
"App::PropertyLinkSubList",
"References",

View File

@@ -31,18 +31,22 @@ from . import FemConstraint
class _FemElementRotation1D(FemConstraint.Proxy):
"The FemElementRotation1D object"
"""
The FemElementRotation1D object
"""
Type = "Fem::ElementRotation1D"
def __init__(self, obj):
super(_FemElementRotation1D, self).__init__(obj)
obj.addProperty(
"App::PropertyAngle",
"Rotation",
"BeamRotation",
"Set the rotation of beam elements"
)
obj.addProperty(
"App::PropertyLinkSubList",
"References",

View File

@@ -1,5 +1,6 @@
# ***************************************************************************
# * Copyright (c) 2013 Juergen Riegel <FreeCAD@juergen-riegel.net> *
# * Copyright (c) 2016 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
@@ -31,22 +32,27 @@ from . import FemConstraint
class _FemMaterial(FemConstraint.Proxy):
"The FEM Material object"
"""
The FEM Material object
"""
Type = "Fem::Material"
def __init__(self, obj):
super(_FemMaterial, self).__init__(obj)
obj.addProperty(
"App::PropertyLinkSubList",
"References",
"Material",
"List of material shapes"
)
obj.addProperty(
"App::PropertyEnumeration",
"Category",
"Material",
"Material type: fluid or solid"
)
obj.Category = ["Solid", "Fluid"] # used in TaskPanel

View File

@@ -31,7 +31,9 @@ from . import FemConstraint
class _FemMaterialMechanicalNonlinear(FemConstraint.Proxy):
"The FemMaterialMechanicalNonlinear object"
"""
The FemMaterialMechanicalNonlinear object
"""
Type = "Fem::MaterialMechanicalNonlinear"

View File

@@ -31,29 +31,35 @@ from . import FemConstraint
class _FemMaterialReinforced(FemConstraint.Proxy):
"The FemMaterialReinforced object"
"""
The FemMaterialReinforced object
"""
Type = "Fem::MaterialReinforced"
def __init__(self, obj):
super(_FemMaterialReinforced, self).__init__(obj)
obj.addProperty(
"App::PropertyLinkSubList",
"References",
"Material",
"List of material shapes"
)
obj.addProperty(
"App::PropertyMap",
"Reinforcement",
"Composites",
"Reinforcement material properties"
)
obj.addProperty(
"App::PropertyEnumeration",
"Category",
"Material",
"Matrix material properties"
)
obj.Category = ["Solid"]
obj.Category = "Solid"

View File

@@ -31,7 +31,9 @@ from . import FemConstraint
class _FemMeshBoundaryLayer(FemConstraint.Proxy):
"The FemMeshBoundaryLayer object"
"""
The FemMeshBoundaryLayer object
"""
Type = "Fem::FemMeshBoundaryLayer"
@@ -44,7 +46,6 @@ class _FemMeshBoundaryLayer(FemConstraint.Proxy):
"MeshBoundaryLayerProperties",
"set number of inflation layers for this boundary"
)
obj.NumberOfLayers = 3
obj.addProperty(
@@ -61,7 +62,6 @@ class _FemMeshBoundaryLayer(FemConstraint.Proxy):
"MeshBoundaryLayerProperties",
"set growth rate of inflation layers for smooth transition"
)
obj.GrowthRate = 1.5
obj.addProperty(

View File

@@ -31,18 +31,22 @@ from . import FemConstraint
class _FemMeshGroup(FemConstraint.Proxy):
"The FemMeshGroup object"
"""
The FemMeshGroup object
"""
Type = "Fem::FemMeshGroup"
def __init__(self, obj):
super(_FemMeshGroup, self).__init__(obj)
obj.addProperty(
"App::PropertyBool",
"UseLabel",
"MeshGroupProperties",
"The identifier used for export (True: Label, False: Name)"
)
obj.addProperty(
"App::PropertyLinkSubList",
"References",

View File

@@ -31,18 +31,22 @@ from . import FemConstraint
class _FemMeshRegion(FemConstraint.Proxy):
"The FemMeshRegion object"
"""
The FemMeshRegion object
"""
Type = "Fem::FemMeshRegion"
def __init__(self, obj):
super(_FemMeshRegion, self).__init__(obj)
obj.addProperty(
"App::PropertyLength",
"CharacteristicLength",
"MeshRegionProperties",
"set characteristic length of FEM elements for this region"
)
obj.addProperty(
"App::PropertyLinkSubList",
"References",

View File

@@ -31,7 +31,8 @@ from . import FemConstraint
class _FemMeshResult(FemConstraint.Proxy):
"""The Fem::FemMeshObject's Proxy python type, add Result specific object type
"""
The Fem::FemMeshObject's Proxy python type, add Result specific object type
"""
Type = "Fem::FemMeshResult"

View File

@@ -1,5 +1,6 @@
# ***************************************************************************
# * Copyright (c) 2016 Qingfeng Xia <qingfeng.xia()eng.ox.ac.uk> *
# * Copyright (c) 2016 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
@@ -31,7 +32,8 @@ from . import FemConstraint
class _FemResultMechanical(FemConstraint.Proxy):
"""The Fem::_FemResultMechanical's Proxy python type, add result specific properties
"""
The Fem::_FemResultMechanical's Proxy python type, add result specific properties
"""
Type = "Fem::FemResultMechanical"
@@ -292,18 +294,6 @@ class _FemResultMechanical(FemConstraint.Proxy):
zero_list = 26 * [0]
obj.Stats = zero_list
# standard Feature methods
def execute(self, obj):
""""this method is executed on object creation and
whenever the document is recomputed"
update Part or Mesh should NOT lead to recomputation
of the analysis automatically, time consuming
"""
return
def onChanged(self, obj, prop):
return
def onDocumentRestored(self, obj):
# migrate old result objects, because property "StressValues"
# was renamed to "vonMises" in commit 8b68ab7
@@ -325,10 +315,3 @@ class _FemResultMechanical(FemConstraint.Proxy):
for i in range(12, -1, -1):
del temp[3 * i + 1]
obj.Stats = temp
def __getstate__(self):
return self.Type
def __setstate__(self, state):
if state:
self.Type = state