[FEM] Elmer: output the equation-specific settings for Navier-Stokes

This commit is contained in:
Uwe
2022-08-06 22:01:25 +02:00
parent 057a19af82
commit 4a8e4a8429
2 changed files with 54 additions and 3 deletions

View File

@@ -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

View File

@@ -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)