[FEM] Add backward compatibility for simple hardening
Prior to a recent commit (or this, if squashed), yield points of a non-linear material with simple hardening were stored as three different properties. These changes consolidate them into the new `YieldPoints` property.
This commit is contained in:
committed by
Bernd Hahnebach
parent
16a82d1eb7
commit
0327a09879
@@ -41,29 +41,62 @@ class MaterialMechanicalNonlinear(base_fempythonobject.BaseFemPythonObject):
|
||||
|
||||
def __init__(self, obj):
|
||||
super(MaterialMechanicalNonlinear, self).__init__(obj)
|
||||
self.add_properties(obj)
|
||||
|
||||
obj.addProperty(
|
||||
"App::PropertyLink",
|
||||
"LinearBaseMaterial",
|
||||
"Base",
|
||||
"Set the linear material the nonlinear builds upon."
|
||||
)
|
||||
def onDocumentRestored(self, obj):
|
||||
|
||||
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]
|
||||
# YieldPoints was (until 0.19) stored as 3 separate variables. Consolidate them if present.
|
||||
yield_points = []
|
||||
if hasattr(obj, "YieldPoint1"):
|
||||
if obj.YieldPoint1:
|
||||
yield_points.append(obj.YieldPoint1)
|
||||
obj.removeProperty("YieldPoint1")
|
||||
if hasattr(obj, "YieldPoint2"):
|
||||
if obj.YieldPoint2:
|
||||
yield_points.append(obj.YieldPoint2)
|
||||
obj.removeProperty("YieldPoint2")
|
||||
if hasattr(obj, "YieldPoint3"):
|
||||
if obj.YieldPoint3:
|
||||
yield_points.append(obj.YieldPoint3)
|
||||
obj.removeProperty("YieldPoint3")
|
||||
|
||||
obj.addProperty(
|
||||
"App::PropertyStringList",
|
||||
"YieldPoints",
|
||||
"Fem",
|
||||
"Set stress and strain for yield points as a list of strings, "
|
||||
"each point \"stress, plastic strain\""
|
||||
)
|
||||
obj.YieldPoints = []
|
||||
self.add_properties(obj)
|
||||
if yield_points:
|
||||
obj.YieldPoints = yield_points
|
||||
|
||||
# TODO: If in the future more nonlinear options are added, update choices here.
|
||||
|
||||
def add_properties(self, obj):
|
||||
|
||||
# this method is called from onDocumentRestored
|
||||
# thus only add and or set a attribute
|
||||
# if the attribute does not exist
|
||||
|
||||
if not hasattr(obj, "LinearBaseMaterial"):
|
||||
obj.addProperty(
|
||||
"App::PropertyLink",
|
||||
"LinearBaseMaterial",
|
||||
"Base",
|
||||
"Set the linear material the nonlinear builds upon."
|
||||
)
|
||||
|
||||
if not hasattr(obj, "MaterialModelNonlinearity"):
|
||||
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]
|
||||
|
||||
if not hasattr(obj, "YieldPoints"):
|
||||
obj.addProperty(
|
||||
"App::PropertyStringList",
|
||||
"YieldPoints",
|
||||
"Fem",
|
||||
"Set stress and strain for yield points as a list of strings, "
|
||||
"each point \"stress, plastic strain\""
|
||||
)
|
||||
obj.YieldPoints = []
|
||||
|
||||
Reference in New Issue
Block a user