FEM: Potential-boundary constraint and elmerflux-solver, add objects and implement them in elmer

This commit is contained in:
Wilfried Hortschitz
2017-12-01 19:44:28 +01:00
committed by wmayer
parent fc9350f2a0
commit f0a33ddb30
14 changed files with 498 additions and 2 deletions

View File

@@ -0,0 +1,74 @@
# ***************************************************************************
# * *
# * Copyright (c) 2017 - Markus Hovorka <m.hovorka@live.de> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
__title__ = "Fluxsolver"
__author__ = "Markus Hovorka"
__url__ = "http://www.freecadweb.org"
import FemUtils
from ... import equationbase
from . import linear
def create(doc, name="Fluxsolver"):
return FemUtils.createObject(
doc, name, Proxy, ViewProxy)
class Proxy(linear.Proxy, equationbase.FluxsolverProxy):
Type = "Fem::FemEquationElmerFluxsolver"
def __init__(self, obj):
super(Proxy, self).__init__(obj)
obj.addProperty(
"App::PropertyBool", "CalculateFlux",
"Fluxsolver", "Select type of solver for linear system")
obj.addProperty(
"App::PropertyString", "FluxVariable",
"Fluxsolver", "Insert variable name for flux calculation")
#obj.addProperty(
#"App::PropertyBool", "CalculateFluxAbs",
#"Fluxsolver", "Select calculation of abs of flux")
#obj.addProperty(
#"App::PropertyBool", "CalculateFluxMagnitude",
#"Fluxsolver", "Select calculation of magnitude of flux")
obj.addProperty(
"App::PropertyBool", "CalculateGrad",
"Fluxsolver", "Select calculation of gradient")
#obj.addProperty(
#"App::PropertyBool", "CalculateGradAbs",
#"Fluxsolver", "Select calculation of abs of gradient")
#obj.addProperty(
#"App::PropertyBool", "CalculateGradMagnitude",
#"Fluxsolver", "Select calculation of magnitude of gradient")
#obj.addProperty(
#"App::PropertyBool", "EnforcePositiveMagnitude",
#"Fluxsolver", "Select calculation of positive magnitude")
obj.Priority = 5
class ViewProxy(linear.ViewProxy, equationbase.FluxsolverViewProxy):
pass

View File

@@ -35,6 +35,7 @@ from . import tasks
from .equations import heat
from .equations import elasticity
from .equations import electrostatic
from .equations import fluxsolver
from .equations import flow
@@ -52,6 +53,7 @@ class Proxy(solverbase.Proxy):
"Heat": heat,
"Elasticity": elasticity,
"Electrostatic": electrostatic,
"Fluxsolver": fluxsolver,
"Flow": flow,
}

View File

@@ -107,6 +107,7 @@ class Writer(object):
self._handleHeat()
self._handleElasticity()
self._handleElectrostatic()
self._handleFluxsolver()
self._handleFlow()
self._addOutputSolver()
@@ -294,7 +295,7 @@ class Writer(object):
self._addSolver(body, solverSection)
if activeIn:
self._handleElectrostaticConstants()
#self._handleElectrostaticBndConditions()
self._handleElectrostaticBndConditions()
#self._handleElectrostaticInitial(activeIn)
#self._handleElectrostaticBodyForces(activeIn)
self._handleElectrostaticMaterial(activeIn)
@@ -306,7 +307,7 @@ class Writer(object):
s["Variable"] = self._getUniqueVarName("Potential")
s["Variable DOFs"] = 1
s["Calculate Electric Field"] = equation.CalculateElectricField
s["Calculate Electric Flux"] = equation.CalculateElectricFlux
#s["Calculate Electric Flux"] = equation.CalculateElectricFlux
s["Calculate Electric Energy"] = equation.CalculateElectricEnergy
s["Calculate Surface Charge"] = equation.CalculateSurfaceCharge
s["Displace mesh"] = False
@@ -334,6 +335,42 @@ class Writer(object):
name, "Relative Permittivity",
float(m["RelativePermittivity"]))
def _handleElectrostaticBndConditions(self):
for obj in self._getMember("Fem::ConstraintElectrostaticPotential"):
if obj.References:
for name in obj.References[0][1]:
if obj.Potential:
potential = getFromUi(obj.Potential, "V", "M*L^2/(T^3 * I)")
self._boundary(name, "Potential", potential)
if obj.PotentialConstant:
self._boundary(name, "Potential Constant", True)
self._handled(obj)
def _handleFluxsolver(self):
activeIn = []
for equation in self.solver.Group:
if FemUtils.isOfType(equation, "Fem::FemEquationElmerFluxsolver"):
if equation.References:
activeIn = equation.References[0][1]
else:
activeIn = self._getAllBodies()
solverSection = self._getFluxsolverSolver(equation)
for body in activeIn:
self._addSolver(body, solverSection)
def _getFluxsolverSolver(self, equation):
s = self._createLinearSolver(equation)
s["Equation"] = "Flux Solver" # equation.Name
s["Procedure"] = sifio.FileAttr("FluxSolver/FluxSolver")
s["Flux Variable"] = equation.FluxVariable
s["Calculate Flux"] = equation.CalculateFlux
s["Calculate Grad"] = equation.CalculateGrad
return s
def _handleElasticity(self):
activeIn = []
for equation in self.solver.Group:

View File

@@ -96,6 +96,16 @@ class ElectrostaticProxy(BaseProxy):
pass
class FluxsolverViewProxy(BaseViewProxy):
def getIcon(self):
return ":/icons/fem-equation-fluxsolver.svg"
class FluxsolverProxy(BaseProxy):
pass
class FlowProxy(BaseProxy):
pass