[FEM] Elmer: fix initial flow velocity
- we must allow must be several velocities because there can be several fluid bodies - don't output flow velocity for solid bodies
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2017 Markus Hovorka <m.hovorka@live.de> *
|
||||
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * Copyright (c) 2022 Uwe Stöhr <uwestoehr@lyx.org> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -23,7 +24,7 @@
|
||||
# ***************************************************************************
|
||||
|
||||
__title__ = "FreeCAD FEM solver Elmer writer"
|
||||
__author__ = "Markus Hovorka"
|
||||
__author__ = "Markus Hovorka, Uwe Stöhr"
|
||||
__url__ = "https://www.freecadweb.org"
|
||||
|
||||
## \addtogroup FEM
|
||||
@@ -1442,19 +1443,37 @@ class Writer(object):
|
||||
name, "Compressibility Model",
|
||||
m["CompressibilityModel"])
|
||||
|
||||
def _outputInitialVelocity(self, obj, name):
|
||||
# flow only makes sense for fluid material
|
||||
if self._isBodyMaterialFluid(name):
|
||||
if obj.VelocityXEnabled:
|
||||
velocity = self._getFromUi(obj.VelocityX, "m/s", "L/T")
|
||||
self._initial(name, "Velocity 1", velocity)
|
||||
if obj.VelocityYEnabled:
|
||||
velocity = self._getFromUi(obj.VelocityY, "m/s", "L/T")
|
||||
self._initial(name, "Velocity 2", velocity)
|
||||
if obj.VelocityZEnabled:
|
||||
velocity = self._getFromUi(obj.VelocityZ, "m/s", "L/T")
|
||||
self._initial(name, "Velocity 3", velocity)
|
||||
|
||||
def _handleFlowInitialVelocity(self, bodies):
|
||||
obj = self._getSingleMember("Fem::ConstraintInitialFlowVelocity")
|
||||
if obj is not None:
|
||||
for name in bodies:
|
||||
if obj.VelocityXEnabled:
|
||||
velocity = self._getFromUi(obj.VelocityX, "m/s", "L/T")
|
||||
self._initial(name, "Velocity 1", velocity)
|
||||
if obj.VelocityYEnabled:
|
||||
velocity = self._getFromUi(obj.VelocityY, "m/s", "L/T")
|
||||
self._initial(name, "Velocity 2", velocity)
|
||||
if obj.VelocityZEnabled:
|
||||
velocity = self._getFromUi(obj.VelocityZ, "m/s", "L/T")
|
||||
self._initial(name, "Velocity 3", velocity)
|
||||
initialVelocities = self._getMember("Fem::ConstraintInitialFlowVelocity")
|
||||
for obj in initialVelocities:
|
||||
if obj.References:
|
||||
for name in obj.References[0][1]:
|
||||
self._outputInitialVelocity(obj, name)
|
||||
self._handled(obj)
|
||||
else:
|
||||
# if there is only one initial velocity without a reference
|
||||
# add it to all fluid bodies
|
||||
if len(initialVelocities) == 1:
|
||||
for name in bodies:
|
||||
self._outputInitialVelocity(obj, name)
|
||||
else:
|
||||
raise WriteError(
|
||||
"Several initial velocities found without reference to a body.\n"
|
||||
"Please set a body for each initial velocity."
|
||||
)
|
||||
self._handled(obj)
|
||||
|
||||
def _handleFlowBndConditions(self):
|
||||
|
||||
@@ -34,6 +34,7 @@ import FreeCAD
|
||||
import FreeCADGui
|
||||
from FreeCAD import Units
|
||||
|
||||
from femguiutils import selection_widgets
|
||||
from femtools import femutils
|
||||
from femtools import membertools
|
||||
|
||||
@@ -42,10 +43,23 @@ class _TaskPanel(object):
|
||||
|
||||
def __init__(self, obj):
|
||||
self._obj = obj
|
||||
|
||||
self._paramWidget = FreeCADGui.PySideUic.loadUi(
|
||||
FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/InitialFlowVelocity.ui")
|
||||
self._initParamWidget()
|
||||
self.form = [self._paramWidget]
|
||||
|
||||
# geometry selection widget
|
||||
# start with Solid in list!
|
||||
self._selectionWidget = selection_widgets.GeometryElementsSelection(
|
||||
obj.References,
|
||||
["Solid", "Face"],
|
||||
True,
|
||||
False
|
||||
)
|
||||
|
||||
# form made from param and selection widget
|
||||
self.form = [self._paramWidget, self._selectionWidget]
|
||||
|
||||
analysis = obj.getParentGroup()
|
||||
self._mesh = None
|
||||
self._part = None
|
||||
@@ -69,6 +83,8 @@ class _TaskPanel(object):
|
||||
return True
|
||||
|
||||
def accept(self):
|
||||
if self._obj.References != self._selectionWidget.references:
|
||||
self._obj.References = self._selectionWidget.references
|
||||
self._applyWidgetChanges()
|
||||
self._obj.Document.recompute()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
|
||||
Reference in New Issue
Block a user