From 7600855f2624f610a1efb37170a7ac8786bc028c Mon Sep 17 00:00:00 2001 From: Uwe Date: Sat, 6 Aug 2022 21:26:23 +0200 Subject: [PATCH] [Fem] Elmer: output the equation-specific settings - equation-specific things were not set at all. This is the first step for the heat and Stress equation --- src/Mod/Fem/femsolver/elmer/equations/heat.py | 20 ++++++- src/Mod/Fem/femsolver/elmer/writer.py | 54 +++++++++++++++++-- 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/src/Mod/Fem/femsolver/elmer/equations/heat.py b/src/Mod/Fem/femsolver/elmer/equations/heat.py index d4d7d43668..2b738ee8cd 100644 --- a/src/Mod/Fem/femsolver/elmer/equations/heat.py +++ b/src/Mod/Fem/femsolver/elmer/equations/heat.py @@ -32,6 +32,8 @@ from femtools import femutils from . import nonlinear from ... import equationbase +CONVECTION_TYPE = ["None", "Computed", "Constant"] +PHASE_MODEL = ["None", "Spatial 1", "Spatial 2", "Temporal"] def create(doc, name="Heat"): return femutils.createObject( @@ -53,9 +55,25 @@ class Proxy(nonlinear.Proxy, equationbase.HeatProxy): "Heat", "" ) - + obj.addProperty( + "App::PropertyEnumeration", + "Convection", + "Equation", + "Type of convection to be used" + ) + obj.addProperty( + "App::PropertyEnumeration", + "PhaseChangeModel", + "Equation", + "Model for phase change" + ) + obj.Bubbles = True obj.Stabilize = False + obj.Convection = CONVECTION_TYPE + obj.Convection = "None" + obj.PhaseChangeModel = PHASE_MODEL + obj.PhaseChangeModel = "None" obj.Priority = 20 diff --git a/src/Mod/Fem/femsolver/elmer/writer.py b/src/Mod/Fem/femsolver/elmer/writer.py index 897b6fd7b8..dafd7319a6 100644 --- a/src/Mod/Fem/femsolver/elmer/writer.py +++ b/src/Mod/Fem/femsolver/elmer/writer.py @@ -400,6 +400,7 @@ class Writer(object): solverSection = self._getHeatSolver(equation) for body in activeIn: self._addSolver(body, solverSection) + self._handleHeatEquation(activeIn, equation) if activeIn: self._handleHeatConstants() self._handleHeatBndConditions() @@ -408,6 +409,9 @@ class Writer(object): self._handleHeatMaterial(activeIn) def _getHeatSolver(self, equation): + # check if we need to update the equation + self._updateHeatSolver(equation) + # output the equation parameters s = self._createNonlinearSolver(equation) s["Equation"] = equation.Name s["Procedure"] = sifio.FileAttr("HeatSolve/HeatSolver") @@ -423,6 +427,34 @@ class Writer(object): "Stefan Boltzmann", self._getConstant("StefanBoltzmann", "M/(O^4*T^3)")) + def _handleHeatEquation(self, bodies, equation): + for b in bodies: + if equation.Convection != "None": + self._equation(b, "Convection", equation.Convection) + if equation.PhaseChangeModel != "None": + self._equation(b, "Phase Change Model", equation.PhaseChangeModel) + + def _updateHeatSolver(self, equation): + # updates older Heat equations + if not hasattr(equation, "Convection"): + equation.addProperty( + "App::PropertyEnumeration", + "Convection", + "Equation", + "Type of convection to be used" + ) + equation.Convection = ["None", "Computed", "Constant"] + equation.Convection = "None" + if not hasattr(equation, "PhaseChangeModel"): + equation.addProperty( + "App::PropertyEnumeration", + "PhaseChangeModel", + "Equation", + "Model for phase change" + ) + equation.PhaseChangeModel = ["None", "Spatial 1", "Spatial 2", "Temporal"] + equation.PhaseChangeModel = "None" + def _handleHeatBndConditions(self): for obj in self._getMember("Fem::ConstraintTemperature"): if obj.References: @@ -718,6 +750,7 @@ class Writer(object): solverSection = self._getElasticitySolver(equation) for body in activeIn: self._addSolver(body, solverSection) + self._handleElasticityEquation(activeIn, equation) if activeIn: self._handleElasticityConstants() self._handleElasticityBndConditions() @@ -775,6 +808,11 @@ class Writer(object): s["Variable DOFs"] = 3 return s + def _handleElasticityEquation(self, bodies, equation): + for b in bodies: + if equation.PlaneStress: + self._equation(b, "Plane Stress", equation.PlaneStress) + def _updateElasticitySolver(self, equation): # updates older Elasticity equations if not hasattr(equation, "Variable"): @@ -946,6 +984,16 @@ class Writer(object): "Elasticity", "File to save results from model lumping to" ) + if not hasattr(equation, "PlaneStress"): + equation.addProperty( + "App::PropertyBool", + "PlaneStress", + "Equation", + ( + "Computes solution according to plane\nstress situation.\n" + "Applies only for 2D geometry." + ) + ) if not hasattr(equation, "StabilityAnalysis"): equation.addProperty( "App::PropertyBool", @@ -1276,10 +1324,8 @@ class Writer(object): if self._hasExpression(equation) != equation.NonlinearTolerance: equation.setExpression("NonlinearTolerance", str(equation.NonlinearTolerance)) if self._hasExpression(equation) != equation.NonlinearNewtonAfterTolerance: - equation.setExpression( - "NonlinearNewtonAfterTolerance", - str(equation.NonlinearNewtonAfterTolerance) - ) + equation.setExpression("NonlinearNewtonAfterTolerance",\ + str(equation.NonlinearNewtonAfterTolerance)) def _createNonlinearSolver(self, equation): # first check if we have to update