Skip to content

Commit

Permalink
FEM: prevent python added properties to be removed
Browse files Browse the repository at this point in the history
  • Loading branch information
FlachyJoe authored and yorikvanhavre committed Apr 29, 2024
1 parent d1946bf commit abd5d4d
Show file tree
Hide file tree
Showing 24 changed files with 201 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Mod/Fem/femobjects/base_fempythonobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ def __init__(self, **kwds):

def add_to_object(self, obj):
obj.addProperty(**self.info)
obj.setPropertyStatus(self.name, "LockDynamic")
setattr(obj, self.name, self.value)
1 change: 1 addition & 0 deletions src/Mod/Fem/femobjects/constant_vacuumpermittivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, obj):
"Constants",
"Overwrites default permittivity of vacuum"
)
obj.setPropertyStatus("VacuumPermittivity", "LockDynamic")
# we must set an expression so that the small value can actually be entered
permittivity = Units.Quantity(constants.vacuum_permittivity()).getValueAs("F/m")
obj.setExpression("VacuumPermittivity", str(permittivity))
1 change: 1 addition & 0 deletions src/Mod/Fem/femobjects/constraint_bodyheatsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ def add_properties(self, obj):
"Base",
"Body heat source"
)
obj.setPropertyStatus("HeatSource", "LockDynamic")
obj.HeatSource = 0.0
2 changes: 2 additions & 0 deletions src/Mod/Fem/femobjects/constraint_centrif.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ def __init__(self, obj):
"Constraint CENTRIF",
"set rotation frequency f<sub>rot"
)
obj.setPropertyStatus("RotationFrequency", "LockDynamic")

obj.addProperty(
"App::PropertyLinkSubList",
"RotationAxis",
"Constraint CENTRIF",
"set line as axis of rotation"
)
obj.setPropertyStatus("RotationAxis", "LockDynamic")
12 changes: 12 additions & 0 deletions src/Mod/Fem/femobjects/constraint_currentdensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def add_properties(self, obj):
"Vector Potential",
"Real part of current density x-component"
)
obj.setPropertyStatus("CurrentDensity_re_1", "LockDynamic")
obj.CurrentDensity_re_1 = "0 A/m^2"
if not hasattr(obj, "CurrentDensity_re_2"):
obj.addProperty(
Expand All @@ -59,6 +60,7 @@ def add_properties(self, obj):
"Vector Potential",
"Real part of current density y-component"
)
obj.setPropertyStatus("CurrentDensity_re_2", "LockDynamic")
obj.CurrentDensity_re_2 = "0 A/m^2"
if not hasattr(obj, "CurrentDensity_re_3"):
obj.addProperty(
Expand All @@ -67,6 +69,7 @@ def add_properties(self, obj):
"Vector Potential",
"Real part of current density z-component"
)
obj.setPropertyStatus("CurrentDensity_re_3", "LockDynamic")
obj.CurrentDensity_re_3 = "0 A/m^2"
if not hasattr(obj, "CurrentDensity_im_1"):
obj.addProperty(
Expand All @@ -75,6 +78,7 @@ def add_properties(self, obj):
"Vector Potential",
"Imaginary part of current density x-component"
)
obj.setPropertyStatus("CurrentDensity_im_1", "LockDynamic")
obj.CurrentDensity_im_1 = "0 A/m^2"
if not hasattr(obj, "CurrentDensity_im_2"):
obj.addProperty(
Expand All @@ -83,6 +87,7 @@ def add_properties(self, obj):
"Vector Potential",
"Imaginary part of current density y-component"
)
obj.setPropertyStatus("CurrentDensity_im_2", "LockDynamic")
obj.CurrentDensity_im_2 = "0 A/m^2"
if not hasattr(obj, "CurrentDensity_im_3"):
obj.addProperty(
Expand All @@ -91,6 +96,7 @@ def add_properties(self, obj):
"Vector Potential",
"Imaginary part of current density z-component"
)
obj.setPropertyStatus("CurrentDensity_im_3", "LockDynamic")
obj.CurrentDensity_im_3 = "0 A/m^2"

# now the enable bools
Expand All @@ -101,6 +107,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_re_1_Disabled", "LockDynamic")
obj.CurrentDensity_re_1_Disabled = True
if not hasattr(obj, "CurrentDensity_re_2_Disabled"):
obj.addProperty(
Expand All @@ -109,6 +116,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_re_2_Disabled", "LockDynamic")
obj.CurrentDensity_re_2_Disabled = True
if not hasattr(obj, "CurrentDensity_re_3_Disabled"):
obj.addProperty(
Expand All @@ -117,6 +125,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_re_3_Disabled", "LockDynamic")
obj.CurrentDensity_re_3_Disabled = True
if not hasattr(obj, "CurrentDensity_im_1_Disabled"):
obj.addProperty(
Expand All @@ -125,6 +134,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_im_1_Disabled", "LockDynamic")
obj.CurrentDensity_im_1_Disabled = True
if not hasattr(obj, "CurrentDensity_im_2_Disabled"):
obj.addProperty(
Expand All @@ -133,6 +143,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_im_2_Disabled", "LockDynamic")
obj.CurrentDensity_im_2_Disabled = True
if not hasattr(obj, "CurrentDensity_im_3_Disabled"):
obj.addProperty(
Expand All @@ -141,4 +152,5 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_im_3_Disabled", "LockDynamic")
obj.CurrentDensity_im_3_Disabled = True
21 changes: 21 additions & 0 deletions src/Mod/Fem/femobjects/constraint_electrostaticpotential.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def add_properties(self, obj):
"Parameter",
"Electric Potential"
)
obj.setPropertyStatus("Potential", "LockDynamic")
# setting 1 V assures that the unit does not switch to mV
# and the constraint holds usually Volts
obj.Potential = "1 V"
Expand All @@ -64,6 +65,7 @@ def add_properties(self, obj):
"Vector Potential",
"Real part of potential x-component"
)
obj.setPropertyStatus("AV_re_1", "LockDynamic")
obj.AV_re_1 = "0 V"
if not hasattr(obj, "AV_re_2"):
obj.addProperty(
Expand All @@ -72,6 +74,7 @@ def add_properties(self, obj):
"Vector Potential",
"Real part of potential y-component"
)
obj.setPropertyStatus("AV_re_2", "LockDynamic")
obj.AV_re_2 = "0 V"
if not hasattr(obj, "AV_re_3"):
obj.addProperty(
Expand All @@ -80,6 +83,7 @@ def add_properties(self, obj):
"Vector Potential",
"Real part of potential z-component"
)
obj.setPropertyStatus("AV_re_3", "LockDynamic")
obj.AV_re_3 = "0 V"
if not hasattr(obj, "AV_im"):
obj.addProperty(
Expand All @@ -88,6 +92,7 @@ def add_properties(self, obj):
"Vector Potential",
"Imaginary part of scalar potential"
)
obj.setPropertyStatus("AV_im", "LockDynamic")
obj.AV_im = "0 V"
if not hasattr(obj, "AV_im_1"):
obj.addProperty(
Expand All @@ -96,6 +101,7 @@ def add_properties(self, obj):
"Vector Potential",
"Imaginary part of potential x-component"
)
obj.setPropertyStatus("AV_im_1", "LockDynamic")
obj.AV_im_1 = "0 V"
if not hasattr(obj, "AV_im_2"):
obj.addProperty(
Expand All @@ -104,6 +110,7 @@ def add_properties(self, obj):
"Vector Potential",
"Imaginary part of potential y-component"
)
obj.setPropertyStatus("AV_im_2", "LockDynamic")
obj.AV_im_2 = "0 V"
if not hasattr(obj, "AV_im_3"):
obj.addProperty(
Expand All @@ -112,6 +119,7 @@ def add_properties(self, obj):
"Vector Potential",
"Imaginary part of potential z-component"
)
obj.setPropertyStatus("AV_im_3", "LockDynamic")
obj.AV_im_3 = "0 V"

# now the enable bools
Expand All @@ -122,6 +130,7 @@ def add_properties(self, obj):
"Parameter",
"Potential Enabled"
)
obj.setPropertyStatus("PotentialEnabled", "LockDynamic")
obj.PotentialEnabled = True
if not hasattr(obj, "AV_re_1_Disabled"):
obj.addProperty(
Expand All @@ -130,6 +139,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("AV_re_1_Disabled", "LockDynamic")
obj.AV_re_1_Disabled = True
if not hasattr(obj, "AV_re_2_Disabled"):
obj.addProperty(
Expand All @@ -138,6 +148,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("AV_re_2_Disabled", "LockDynamic")
obj.AV_re_2_Disabled = True
if not hasattr(obj, "AV_re_3_Disabled"):
obj.addProperty(
Expand All @@ -146,6 +157,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("AV_re_3_Disabled", "LockDynamic")
obj.AV_re_3_Disabled = True
if not hasattr(obj, "AV_im_Disabled"):
obj.addProperty(
Expand All @@ -154,6 +166,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("AV_im_Disabled", "LockDynamic")
obj.AV_im_Disabled = True
if not hasattr(obj, "AV_im_1_Disabled"):
obj.addProperty(
Expand All @@ -162,6 +175,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("AV_im_1_Disabled", "LockDynamic")
obj.AV_im_1_Disabled = True
if not hasattr(obj, "AV_im_2_Disabled"):
obj.addProperty(
Expand All @@ -170,6 +184,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("AV_im_2_Disabled", "LockDynamic")
obj.AV_im_2_Disabled = True
if not hasattr(obj, "AV_im_3_Disabled"):
obj.addProperty(
Expand All @@ -178,6 +193,7 @@ def add_properties(self, obj):
"Vector Potential",
""
)
obj.setPropertyStatus("AV_im_3_Disabled", "LockDynamic")
obj.AV_im_3_Disabled = True

if not hasattr(obj, "PotentialConstant"):
Expand All @@ -187,6 +203,7 @@ def add_properties(self, obj):
"Parameter",
"Potential Constant"
)
obj.setPropertyStatus("PotentialConstant", "LockDynamic")
obj.PotentialConstant = False

if not hasattr(obj, "ElectricInfinity"):
Expand All @@ -196,6 +213,7 @@ def add_properties(self, obj):
"Parameter",
"Electric Infinity"
)
obj.setPropertyStatus("ElectricInfinity", "LockDynamic")
obj.ElectricInfinity = False

if not hasattr(obj, "ElectricForcecalculation"):
Expand All @@ -205,6 +223,7 @@ def add_properties(self, obj):
"Parameter",
"Electric Force Calculation"
)
obj.setPropertyStatus("ElectricForcecalculation", "LockDynamic")
obj.ElectricForcecalculation = False

if not hasattr(obj, "CapacitanceBody"):
Expand All @@ -214,6 +233,7 @@ def add_properties(self, obj):
"Parameter",
"Capacitance Body"
)
obj.setPropertyStatus("CapacitanceBody", "LockDynamic")
obj.CapacitanceBody = 0

if not hasattr(obj, "CapacitanceBodyEnabled"):
Expand All @@ -223,4 +243,5 @@ def add_properties(self, obj):
"Parameter",
"Capacitance Body Enabled"
)
obj.setPropertyStatus("CapacitanceBodyEnabled", "LockDynamic")
obj.CapacitanceBodyEnabled = False
13 changes: 13 additions & 0 deletions src/Mod/Fem/femobjects/constraint_flowvelocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,81 +46,94 @@ def __init__(self, obj):
"Parameter",
"Velocity in x-direction"
)
obj.setPropertyStatus("VelocityX", "LockDynamic")
obj.addProperty(
"App::PropertyString",
"VelocityXFormula",
"Parameter",
"Velocity formula in x-direction"
)
obj.setPropertyStatus("VelocityXFormula", "LockDynamic")
obj.addProperty(
"App::PropertyBool",
"VelocityXUnspecified",
"Parameter",
"Use velocity in x-direction"
)
obj.setPropertyStatus("VelocityXUnspecified", "LockDynamic")
obj.VelocityXUnspecified = True
obj.addProperty(
"App::PropertyBool",
"VelocityXHasFormula",
"Parameter",
"Use formula for velocity in x-direction"
)
obj.setPropertyStatus("VelocityXHasFormula", "LockDynamic")

obj.addProperty(
"App::PropertyVelocity",
"VelocityY",
"Parameter",
"Velocity in y-direction"
)
obj.setPropertyStatus("VelocityY", "LockDynamic")
obj.addProperty(
"App::PropertyString",
"VelocityYFormula",
"Parameter",
"Velocity formula in y-direction"
)
obj.setPropertyStatus("VelocityYFormula", "LockDynamic")
obj.addProperty(
"App::PropertyBool",
"VelocityYUnspecified",
"Parameter",
"Use velocity in y-direction"
)
obj.setPropertyStatus("VelocityYUnspecified", "LockDynamic")
obj.VelocityYUnspecified = True
obj.addProperty(
"App::PropertyBool",
"VelocityYHasFormula",
"Parameter",
"Use formula for velocity in y-direction"
)
obj.setPropertyStatus("VelocityYHasFormula", "LockDynamic")

obj.addProperty(
"App::PropertyVelocity",
"VelocityZ",
"Parameter",
"Velocity in z-direction"
)
obj.setPropertyStatus("VelocityZ", "LockDynamic")
obj.addProperty(
"App::PropertyString",
"VelocityZFormula",
"Parameter",
"Velocity formula in z-direction"
)
obj.setPropertyStatus("VelocityZFormula", "LockDynamic")
obj.addProperty(
"App::PropertyBool",
"VelocityZUnspecified",
"Parameter",
"Use velocity in z-direction"
)
obj.setPropertyStatus("VelocityZUnspecified", "LockDynamic")
obj.VelocityZUnspecified = True
obj.addProperty(
"App::PropertyBool",
"VelocityZHasFormula",
"Parameter",
"Use formula for velocity in z-direction"
)
obj.setPropertyStatus("VelocityZHasFormula", "LockDynamic")

obj.addProperty(
"App::PropertyBool",
"NormalToBoundary",
"Parameter",
"Flow is in normal direction"
)
obj.setPropertyStatus("NormalToBoundary", "LockDynamic")

0 comments on commit abd5d4d

Please sign in to comment.