From 4a8e4a84295bfa7db9ac9d4d98887cf9077c2dca Mon Sep 17 00:00:00 2001 From: Uwe Date: Sat, 6 Aug 2022 22:01:25 +0200 Subject: [PATCH] [FEM] Elmer: output the equation-specific settings for Navier-Stokes --- src/Mod/Fem/femsolver/elmer/equations/flow.py | 22 ++++++++++++ src/Mod/Fem/femsolver/elmer/writer.py | 35 +++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/Mod/Fem/femsolver/elmer/equations/flow.py b/src/Mod/Fem/femsolver/elmer/equations/flow.py index 5edc4eb527..85d40ea78c 100644 --- a/src/Mod/Fem/femsolver/elmer/equations/flow.py +++ b/src/Mod/Fem/femsolver/elmer/equations/flow.py @@ -32,6 +32,10 @@ from femtools import femutils from . import nonlinear from ... import equationbase +CONVECTION_TYPE = ["None", "Computed", "Constant"] + +def getConvectionType(): + return CONVECTION_TYPE def create(doc, name="Flow"): return femutils.createObject( @@ -45,6 +49,24 @@ class Proxy(nonlinear.Proxy, equationbase.FlowProxy): def __init__(self, obj): super(Proxy, self).__init__(obj) + obj.addProperty( + "App::PropertyEnumeration", + "Convection", + "Equation", + "Type of convection to be used" + ) + obj.addProperty( + "App::PropertyBool", + "MagneticInduction", + "Equation", + ( + "Magnetic induction equation will be solved\n" + "along with the Navier-Stokes equations" + ) + ) + + obj.Convection = CONVECTION_TYPE + obj.Convection = "Computed" obj.Priority = 10 diff --git a/src/Mod/Fem/femsolver/elmer/writer.py b/src/Mod/Fem/femsolver/elmer/writer.py index dafd7319a6..c5730cba4d 100644 --- a/src/Mod/Fem/femsolver/elmer/writer.py +++ b/src/Mod/Fem/femsolver/elmer/writer.py @@ -46,6 +46,7 @@ from femmesh import gmshtools from femtools import constants from femtools import femutils from femtools import membertools +from .equations import flow _STARTINFO_NAME = "ELMERSOLVER_STARTINFO" @@ -1169,6 +1170,7 @@ class Writer(object): for body in activeIn: if self._isMaterialFlow(body): self._addSolver(body, solverSection) + self._handleFlowEquation(activeIn, equation) if activeIn: self._handleFlowConstants() self._handleFlowBndConditions() @@ -1176,9 +1178,11 @@ class Writer(object): # self._handleFlowInitial(activeIn) # self._handleFlowBodyForces(activeIn) self._handleFlowMaterial(activeIn) - self._handleFlowEquation(activeIn) def _getFlowSolver(self, equation): + # check if we need to update the equation + self._updateFlowSolver(equation) + # output the equation parameters s = self._createNonlinearSolver(equation) s["Equation"] = "Navier-Stokes" s["Procedure"] = sifio.FileAttr("FlowSolve/FlowSolver") @@ -1191,6 +1195,28 @@ class Writer(object): gravity = self._getConstant("Gravity", "L/T^2") self._constant("Gravity", (0.0, -1.0, 0.0, gravity)) + def _updateFlowSolver(self, equation): + # updates older Flow equations + if not hasattr(equation, "Convection"): + equation.addProperty( + "App::PropertyEnumeration", + "Convection", + "Equation", + "Type of convection to be used" + ) + equation.Convection = flow.getConvectionType() + equation.Convection = "Computed" + if not hasattr(equation, "MagneticInduction"): + equation.addProperty( + "App::PropertyBool", + "MagneticInduction", + "Equation", + ( + "Magnetic induction equation will be solved\n" + "along with the Navier-Stokes equations" + ) + ) + def _handleFlowMaterial(self, bodies): tempObj = self._getSingleMember("Fem::ConstraintInitialTemperature") if tempObj is not None: @@ -1269,9 +1295,12 @@ class Writer(object): self._boundary(name, "Normal-Tangential Velocity", True) self._handled(obj) - def _handleFlowEquation(self, bodies): + def _handleFlowEquation(self, bodies, equation): for b in bodies: - self._equation(b, "Convection", "Computed") + if equation.Convection != "None": + self._equation(b, "Convection", equation.Convection) + if equation.MagneticInduction is True: + self._equation(b, "Magnetic Induction", equation.MagneticInduction) def _createEmptySolver(self): s = sifio.createSection(sifio.SOLVER)