[Fem] Elmer: update tolerances
- update tolerances also for existing analyses to fix the bug that users see e.g. "0.001" and not the actual used tolerance - also a fix for new stress analyses - also a formatting fix
This commit is contained in:
@@ -235,7 +235,9 @@ class Proxy(linear.Proxy, equationbase.ElasticityProxy):
|
||||
obj.EigenSystemSelect = "Smallest Magnitude"
|
||||
# according to Elmer manual default is 100 times the Linear Tolerance
|
||||
# since this is a small value we must set an expression, see linear.py for background
|
||||
obj.setExpression("EigenSystemTolerance", str(100 * obj.LinearTolerance))
|
||||
for (prop, expr) in obj.ExpressionEngine:
|
||||
if (prop == "LinearTolerance"):
|
||||
obj.setExpression("EigenSystemTolerance", str(100 * obj.evalExpression(expr)))
|
||||
obj.Variable = "Displacement"
|
||||
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ class Proxy(equation.Proxy):
|
||||
# view and edit the tolerance via the property editor and this does not
|
||||
# yet allow to view and edit small numbers in scientific notation
|
||||
# forum thread: https://forum.freecadweb.org/viewtopic.php?p=613897#p613897
|
||||
obj.setExpression('LinearTolerance', "1e-8")
|
||||
obj.setExpression("LinearTolerance", "1e-8")
|
||||
obj.addProperty(
|
||||
"App::PropertyInteger",
|
||||
"LinearIterations",
|
||||
@@ -125,7 +125,7 @@ class Proxy(equation.Proxy):
|
||||
""
|
||||
)
|
||||
# same as with LinearTolerance
|
||||
obj.setExpression('SteadyStateTolerance', "1e-5")
|
||||
obj.setExpression("SteadyStateTolerance", "1e-5")
|
||||
|
||||
obj.addProperty(
|
||||
"App::PropertyBool",
|
||||
|
||||
@@ -76,9 +76,9 @@ class Proxy(linear.Proxy):
|
||||
# the user has to view and edit the tolerance via the property editor and
|
||||
# this does not yet allow to view and edit small numbers in scientific notation
|
||||
# forum thread: https://forum.freecadweb.org/viewtopic.php?p=613897#p613897
|
||||
obj.setExpression('NonlinearTolerance', "1e-8")
|
||||
obj.setExpression('NonlinearNewtonAfterTolerance', "1e-3")
|
||||
obj.setExpression('RelaxationFactor', "1.0") # must often be < 1 down to 0.01
|
||||
obj.setExpression("NonlinearTolerance", "1e-8")
|
||||
obj.setExpression("NonlinearNewtonAfterTolerance", "1e-3")
|
||||
obj.setExpression("RelaxationFactor", "1.0") # must often be < 1 down to 0.01
|
||||
|
||||
|
||||
class ViewProxy(linear.ViewProxy):
|
||||
|
||||
@@ -1223,7 +1223,24 @@ class Writer(object):
|
||||
s = sifio.createSection(sifio.SOLVER)
|
||||
return s
|
||||
|
||||
def _hasExpression(self, equation):
|
||||
obj = None
|
||||
exp = None
|
||||
for (obj, exp) in equation.ExpressionEngine:
|
||||
if obj == equation:
|
||||
return exp
|
||||
return None
|
||||
|
||||
def _updateLinearSolver(self, equation):
|
||||
if self._hasExpression(equation) != equation.LinearTolerance:
|
||||
equation.setExpression("LinearTolerance", str(equation.LinearTolerance))
|
||||
if self._hasExpression(equation) != equation.SteadyStateTolerance:
|
||||
equation.setExpression("SteadyStateTolerance", str(equation.SteadyStateTolerance))
|
||||
|
||||
def _createLinearSolver(self, equation):
|
||||
# first check if we have to update
|
||||
self._updateLinearSolver(equation)
|
||||
# write the solver
|
||||
s = sifio.createSection(sifio.SOLVER)
|
||||
s.priority = equation.Priority
|
||||
s["Linear System Solver"] = equation.LinearSolverType
|
||||
@@ -1249,8 +1266,19 @@ class Writer(object):
|
||||
s["Linear System Precondition Recompute"] = 1
|
||||
return s
|
||||
|
||||
def _updateNonlinearSolver(self, equation):
|
||||
if self._hasExpression(equation) != equation.NonlinearTolerance:
|
||||
equation.setExpression("NonlinearTolerance", str(equation.NonlinearTolerance))
|
||||
if self._hasExpression(equation) != equation.NonlinearNewtonAfterTolerance:
|
||||
equation.setExpression("NonlinearNewtonAfterTolerance",\
|
||||
str(equation.NonlinearNewtonAfterTolerance))
|
||||
|
||||
def _createNonlinearSolver(self, equation):
|
||||
# first check if we have to update
|
||||
self._updateNonlinearSolver(equation)
|
||||
# write the linear solver
|
||||
s = self._createLinearSolver(equation)
|
||||
# write the nonlinear solver
|
||||
s["Nonlinear System Max Iterations"] = \
|
||||
equation.NonlinearIterations
|
||||
s["Nonlinear System Convergence Tolerance"] = \
|
||||
|
||||
Reference in New Issue
Block a user