FEM: elmer equation flux, better name without word solver

This commit is contained in:
Bernd Hahnebach
2020-06-29 22:28:26 +02:00
parent 0c1f99a30c
commit 9bfd947886
21 changed files with 3590 additions and 61 deletions

View File

@@ -172,7 +172,7 @@ SET(FemSolverElmerEquations_SRCS
femsolver/elmer/equations/elasticity.py
femsolver/elmer/equations/equation.py
femsolver/elmer/equations/flow.py
femsolver/elmer/equations/fluxsolver.py
femsolver/elmer/equations/flux.py
femsolver/elmer/equations/heat.py
femsolver/elmer/equations/linear.py
femsolver/elmer/equations/nonlinear.py

View File

@@ -39,7 +39,7 @@
<file>icons/FEM_EquationElectricforce.svg</file>
<file>icons/FEM_EquationElectrostatic.svg</file>
<file>icons/FEM_EquationFlow.svg</file>
<file>icons/FEM_EquationFluxsolver.svg</file>
<file>icons/FEM_EquationFlux.svg</file>
<file>icons/FEM_EquationHeat.svg</file>
<!-- gui command icons: meshes -->

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@@ -178,7 +178,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
<< "FEM_EquationElasticity"
<< "FEM_EquationElectrostatic"
<< "FEM_EquationFlow"
<< "FEM_EquationFluxsolver"
<< "FEM_EquationFlux"
<< "FEM_EquationElectricforce"
<< "FEM_EquationHeat"
<< "Separator"
@@ -339,7 +339,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "FEM_EquationElasticity"
<< "FEM_EquationElectrostatic"
<< "FEM_EquationFlow"
<< "FEM_EquationFluxsolver"
<< "FEM_EquationFlux"
<< "FEM_EquationElectricforce"
<< "FEM_EquationHeat"
<< "Separator"

View File

@@ -719,15 +719,15 @@ def makeEquationFlow(
return obj
def makeEquationFluxsolver(
def makeEquationFlux(
doc,
base_solver=None,
name="Fluxsolver"
name="Flux"
):
"""makeEquationFluxsolver(document, [base_solver], [name]):
creates a FEM fluxsolver equation for a solver"""
from femsolver.elmer.equations import fluxsolver
obj = fluxsolver.create(doc, name)
"""makeEquationFlux(document, [base_solver], [name]):
creates a FEM flux equation for a solver"""
from femsolver.elmer.equations import flux
obj = flux.create(doc, name)
if base_solver:
base_solver.addObject(obj)
return obj

View File

@@ -307,13 +307,13 @@ class _EquationFlow(CommandManager):
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
class _EquationFluxsolver(CommandManager):
"The FEM_EquationFluxsolver command definition"
class _EquationFlux(CommandManager):
"The FEM_EquationFlux command definition"
def __init__(self):
super(_EquationFluxsolver, self).__init__()
self.menuetext = "Fluxsolver equation"
self.tooltip = "Creates a FEM equation for fluxsolver"
super(_EquationFlux, self).__init__()
self.menuetext = "Flux equation"
self.tooltip = "Creates a FEM equation for flux"
self.is_active = "with_solver_elmer"
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
@@ -861,8 +861,8 @@ FreeCADGui.addCommand(
_EquationFlow()
)
FreeCADGui.addCommand(
"FEM_EquationFluxsolver",
_EquationFluxsolver()
"FEM_EquationFlux",
_EquationFlux()
)
FreeCADGui.addCommand(
"FEM_EquationElectricforce",

View File

@@ -385,6 +385,10 @@ class FemMigrateGui(object):
possible entries in the old files:
(the class name in the old file does not matter, we ever only had one class per module)
further renaming objects
module="femsolver.elmer.equations.fluxsolver"
see App migrate because object class and viewprovider class are in the same module
fourth big moving
renaming class and module names in femobjects
TODO add link to commit before the first commit

View File

@@ -1,5 +1,6 @@
# ***************************************************************************
# * Copyright (c) 2017 Markus Hovorka <m.hovorka@live.de> *
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -21,7 +22,7 @@
# * *
# ***************************************************************************
__title__ = "FreeCAD FEM solver Elmer equation object Fluxsolver"
__title__ = "FreeCAD FEM solver Elmer equation object Flux"
__author__ = "Markus Hovorka"
__url__ = "http://www.freecadweb.org"
@@ -33,49 +34,49 @@ from ... import equationbase
from . import linear
def create(doc, name="Fluxsolver"):
def create(doc, name="Flux"):
return femutils.createObject(
doc, name, Proxy, ViewProxy)
class Proxy(linear.Proxy, equationbase.FluxsolverProxy):
class Proxy(linear.Proxy, equationbase.FluxProxy):
Type = "Fem::EquationElmerFluxsolver"
Type = "Fem::EquationElmerFlux"
def __init__(self, obj):
super(Proxy, self).__init__(obj)
obj.addProperty(
"App::PropertyBool", "CalculateFlux",
"Fluxsolver", "Select type of solver for linear system")
"Flux", "Select type of solver for linear system")
obj.addProperty(
"App::PropertyString", "FluxVariable",
"Fluxsolver", "Insert variable name for flux calculation")
"Flux", "Insert variable name for flux calculation")
"""
#obj.addProperty(
#"App::PropertyBool", "CalculateFluxAbs",
#"Fluxsolver", "Select calculation of abs of flux")
#"Flux", "Select calculation of abs of flux")
#obj.addProperty(
#"App::PropertyBool", "CalculateFluxMagnitude",
#"Fluxsolver", "Select calculation of magnitude of flux")
#"Flux", "Select calculation of magnitude of flux")
"""
obj.addProperty(
"App::PropertyBool", "CalculateGrad",
"Fluxsolver", "Select calculation of gradient")
"Flux", "Select calculation of gradient")
"""
#obj.addProperty(
#"App::PropertyBool", "CalculateGradAbs",
#"Fluxsolver", "Select calculation of abs of gradient")
#"Flux", "Select calculation of abs of gradient")
#obj.addProperty(
#"App::PropertyBool", "CalculateGradMagnitude",
#"Fluxsolver", "Select calculation of magnitude of gradient")
#"Flux", "Select calculation of magnitude of gradient")
#obj.addProperty(
#"App::PropertyBool", "EnforcePositiveMagnitude",
#"Fluxsolver", "Select calculation of positive magnitude")
#"Flux", "Select calculation of positive magnitude")
"""
obj.Priority = 5
class ViewProxy(linear.ViewProxy, equationbase.FluxsolverViewProxy):
class ViewProxy(linear.ViewProxy, equationbase.FluxViewProxy):
pass
## @}

View File

@@ -32,7 +32,7 @@ from . import tasks
from .equations import elasticity
from .equations import electrostatic
from .equations import flow
from .equations import fluxsolver
from .equations import flux
from .equations import electricforce
from .equations import heat
from .. import run
@@ -54,7 +54,7 @@ class Proxy(solverbase.Proxy):
"Heat": heat,
"Elasticity": elasticity,
"Electrostatic": electrostatic,
"Fluxsolver": fluxsolver,
"Flux": flux,
"Electricforce": electricforce,
"Flow": flow,
}

View File

@@ -1,5 +1,6 @@
# ***************************************************************************
# * Copyright (c) 2017 Markus Hovorka <m.hovorka@live.de> *
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -144,7 +145,7 @@ class Writer(object):
self._handleHeat()
self._handleElasticity()
self._handleElectrostatic()
self._handleFluxsolver()
self._handleFlux()
self._handleElectricforce()
self._handleFlow()
self._addOutputSolver()
@@ -435,19 +436,19 @@ class Writer(object):
self._boundary(name, "Capacitance Body", obj.CapacitanceBody)
self._handled(obj)
def _handleFluxsolver(self):
def _handleFlux(self):
activeIn = []
for equation in self.solver.Group:
if femutils.is_of_type(equation, "Fem::EquationElmerFluxsolver"):
if femutils.is_of_type(equation, "Fem::EquationElmerFlux"):
if equation.References:
activeIn = equation.References[0][1]
else:
activeIn = self._getAllBodies()
solverSection = self._getFluxsolverSolver(equation)
solverSection = self._getFlux(equation)
for body in activeIn:
self._addSolver(body, solverSection)
def _getFluxsolverSolver(self, equation):
def _getFlux(self, equation):
s = self._createLinearSolver(equation)
s["Equation"] = "Flux Solver" # equation.Name
s["Procedure"] = sifio.FileAttr("FluxSolver/FluxSolver")

View File

@@ -99,13 +99,13 @@ class ElectrostaticProxy(BaseProxy):
pass
class FluxsolverViewProxy(BaseViewProxy):
class FluxViewProxy(BaseViewProxy):
def getIcon(self):
return ":/icons/FEM_EquationFluxsolver.svg"
return ":/icons/FEM_EquationFlux.svg"
class FluxsolverProxy(BaseProxy):
class FluxProxy(BaseProxy):
pass

View File

@@ -340,8 +340,8 @@ class TestObjectType(unittest.TestCase):
type_of_obj(ObjectsFem.makeEquationFlow(doc, solverelmer))
)
self.assertEqual(
"Fem::EquationElmerFluxsolver",
type_of_obj(ObjectsFem.makeEquationFluxsolver(doc, solverelmer))
"Fem::EquationElmerFlux",
type_of_obj(ObjectsFem.makeEquationFlux(doc, solverelmer))
)
self.assertEqual(
"Fem::EquationElmerHeat",
@@ -551,8 +551,8 @@ class TestObjectType(unittest.TestCase):
"Fem::EquationElmerFlow"
))
self.assertTrue(is_of_type(
ObjectsFem.makeEquationFluxsolver(doc, solverelmer),
"Fem::EquationElmerFluxsolver"
ObjectsFem.makeEquationFlux(doc, solverelmer),
"Fem::EquationElmerFlux"
))
self.assertTrue(is_of_type(
ObjectsFem.makeEquationHeat(doc, solverelmer),
@@ -1274,8 +1274,8 @@ class TestObjectType(unittest.TestCase):
"Fem::EquationElmerFlow"
))
# FemEquationElmerFluxsolver
equation_flux = ObjectsFem.makeEquationFluxsolver(doc, solver_elmer)
# FemEquationElmerFlux
equation_flux = ObjectsFem.makeEquationFlux(doc, solver_elmer)
self.assertTrue(is_derived_from(
equation_flux,
"App::DocumentObject"
@@ -1286,7 +1286,7 @@ class TestObjectType(unittest.TestCase):
))
self.assertTrue(is_derived_from(
equation_flux,
"Fem::EquationElmerFluxsolver"
"Fem::EquationElmerFlux"
))
# FemEquationElmerHeat
@@ -1551,7 +1551,7 @@ class TestObjectType(unittest.TestCase):
).isDerivedFrom("App::FeaturePython")
)
self.assertTrue(
ObjectsFem.makeEquationFluxsolver(
ObjectsFem.makeEquationFlux(
doc,
solverelmer
).isDerivedFrom("App::FeaturePython")
@@ -1635,7 +1635,7 @@ def create_all_fem_objects_doc(
ObjectsFem.makeEquationElectricforce(doc, sol)
ObjectsFem.makeEquationElectrostatic(doc, sol)
ObjectsFem.makeEquationFlow(doc, sol)
ObjectsFem.makeEquationFluxsolver(doc, sol)
ObjectsFem.makeEquationFlux(doc, sol)
ObjectsFem.makeEquationHeat(doc, sol)
doc.recompute()

View File

@@ -118,6 +118,13 @@ class TestObjectOpen(unittest.TestCase):
# FeaturePythons objects
self.compare_feature_pythons_class_app(self.document)
# standard name changed
from femsolver.elmer.equations.flux import Proxy
self.assertEqual(
Proxy,
self.document.Flux.Proxy.__class__
)
# ********************************************************************************************
def test_femobjects_open_de9b3fb438(
self
@@ -139,6 +146,13 @@ class TestObjectOpen(unittest.TestCase):
# FeaturePythons objects
self.compare_feature_pythons_class_app(self.document)
# standard name changed
from femsolver.elmer.equations.flux import Proxy
self.assertEqual(
Proxy,
self.document.Fluxsolver.Proxy.__class__
)
# ********************************************************************************************
def compare_cpp_objs(
self,
@@ -330,12 +344,6 @@ class TestObjectOpen(unittest.TestCase):
doc.Flow.Proxy.__class__
)
from femsolver.elmer.equations.fluxsolver import Proxy
self.assertEqual(
Proxy,
doc.Fluxsolver.Proxy.__class__
)
from femsolver.elmer.equations.heat import Proxy
self.assertEqual(
Proxy,

View File

@@ -115,6 +115,13 @@ class TestObjectOpen(unittest.TestCase):
# FeaturePythons view provider
self.compare_feature_pythons_class_gui(self.document)
# standard name changed
from femsolver.elmer.equations.flux import ViewProxy
self.assertEqual(
ViewProxy,
self.document.Flux.ViewObject.Proxy.__class__
)
# ********************************************************************************************
def test_femobjects_open_de9b3fb438(
self
@@ -134,6 +141,13 @@ class TestObjectOpen(unittest.TestCase):
# FeaturePythons view provider
self.compare_feature_pythons_class_gui(self.document)
# standard name changed
from femsolver.elmer.equations.flux import ViewProxy
self.assertEqual(
ViewProxy,
self.document.Fluxsolver.ViewObject.Proxy.__class__
)
# ********************************************************************************************
def compare_feature_pythons_class_gui(
self,
@@ -305,12 +319,6 @@ class TestObjectOpen(unittest.TestCase):
doc.Flow.ViewObject.Proxy.__class__
)
from femsolver.elmer.equations.fluxsolver import ViewProxy
self.assertEqual(
ViewProxy,
doc.Fluxsolver.ViewObject.Proxy.__class__
)
from femsolver.elmer.equations.heat import ViewProxy
self.assertEqual(
ViewProxy,

View File

@@ -37,6 +37,11 @@ class FemMigrateApp(object):
def find_module(self, fullname, path):
if fullname == "femsolver.elmer.equations":
return self
if fullname == "femsolver.elmer.equations.fluxsolver":
return self
if fullname == "femobjects":
return self
if fullname == "femobjects._FemConstraintBodyHeatSource":
@@ -174,6 +179,14 @@ class FemMigrateApp(object):
def load_module(self, module):
if module.__name__ == "femsolver.elmer.equations":
return self
if module.__name__ == "femsolver.elmer.equations.fluxsolver":
import femsolver.elmer.equations.flux
module.Proxy = femsolver.elmer.equations.flux.Proxy
if FreeCAD.GuiUp:
module.ViewProxy = femsolver.elmer.equations.flux.ViewProxy
if module.__name__ == "femobjects":
module.__path__ = "femobjects"
if module.__name__ == "femobjects._FemConstraintBodyHeatSource":
@@ -388,6 +401,11 @@ class FemMigrateApp(object):
possible entries in the old files:
(the class name in the old file does not matter, we ever only had one class per module)
further renaming objects
module="femsolver.elmer.equations.fluxsolver"
in this modules object class and viewprovider class are in same module
fourth big moving
renaming class and module names in femobjects
TODO add link to commit before the first commit