Commit b5604a68 authored by Bernd Flemisch's avatar Bernd Flemisch
Browse files

[newton] improve terminology

The terminology for the Newton method is improved according to FS#238.
In particular, what has been referred to as "relative error" is now
termed "maximum relative shift", while "absolute error" has been renamed
to "residual reduction". This is particularly important, if
corresponding parameters or properties are set. See the CHANGELOG for
details.

Reviewed by gruenich.



git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@14132 2fb0f335-1f38-0410-981e-8018bf24f1b0
parent 33f511f2
Differences Between DuMuX 2.6 and DuMuX 2.7
===================================================
* IMPROVEMENTS and ENHANCEMENTS:
- The terminology for the Newton method has been improved according to FS#238.
In particular, what has been referred to as "relative error" is now termed
"maximum relative shift", while "absolute error" has been renamed to
"residual reduction". This is particularly important, if corresponding
parameters or properties are set, see below.
* IMMEDIATE INTERFACE CHANGES not allowing/requiring a deprecation period:
- Before, the "heatCapacity" function in the spatial parameters and volume
variables of the implicit nonisothermal models was a misnomer, since it
returned an effective quantity, namely,
heatCapacity*density*(1 - porosity) in [J/(K m^3)].
Except for mpnc, which resulted in an additional inconsistency.
Corresponding to the decision documented in FS#216, the function has been
renamed to "solidHeatCapacity" and returns always the "true" (non-effective)
heat capacity in [J/(kg K)]. This requires an additional function
......@@ -17,12 +23,34 @@ Differences Between DuMuX 2.6 and DuMuX 2.7
rather than to append is motivated by consistency with components and fluid
systems, where "gas" and "liquid" are always prepended to the corresponding
function names.
Therefore, it might be necessary to adapt your thermal solid parameters in
the spatialparams file such that they offer functions "solidHeatCapacity",
"solidDensity" and "solidThermalConductivity". See
test/implicit/2p2c/injectionspatialparams.hh for an example.
- Due to the change in the Newton terminology (see above), there exist two
backward-compatibility breakages:
. If a model re-implements the function "relativeErrorDof", it has to be
renamed to "relativeShiftAtDof". See dumux/implicit/implicitmodel.hh for
an example.
. If a NewtonController re-implements the function "newtonUpdateRelError",
it has to be renamed to "newtonUpdateShift". See
dumux/nonlinear/newtoncontroller.hh for an example.
* Deprecated PROPERTY and PARAMETER NAMES, to be removed after 2.7: BEWARE: The
compiler will not print any warning if a deprecated property or parameter name
is used. However, a run-time warning should appear in the summary lines after
the corresponding run.
- Corresponding to the improved Newton terminology, the following properties
(prepended with "Newton") and parameters (in the group "Newton") are
renamed:
AbsTolerance -> ResidualReduction
EnableAbsoluteCriterion -> EnableResidualCriterion
RelTolerance -> MaxRelativeShift
EnableRelativeCriterion -> EnableShiftCriterion
SatisfyAbsAndRel -> SatisfyResidualAndShiftCriterion
* Deprecated CLASSES/FILES, to be removed after 2.7:
- CellData2P2Cmultiphysics, replaced by CellData2P2CMultiPhysics
......@@ -33,11 +61,35 @@ Differences Between DuMuX 2.6 and DuMuX 2.7
"solid/fluidThermalConductivity" instead. See also the immediate interface
changes above.
- In dumux/implicit/common/implicitmodel.hh and
dumux/geomechanics/el2p/elp2basemodel.hh:
"relativeErrorDof" -> "relativeShiftAtDof"
- In dumux/nonlinear/newtoncontroller.hh:
"setRelTolerance" -> "setMaxRelativeShift"
"setAbsTolerance" -> "setResidualReduction"
"newtonUpdateRelError" -> "newtonUpdateShift"
- The 1p2c volume variables no longer use the method tortuosity() from
spatial params class, the value is now calculated within the effective
diffusivity model. Thus the method is deprecated in the spacial params
classes FVSpatialParamsOneP and ImplicitSpatialParamsOneP.
* Deprecated protected MEMBER VARIABLES, to be removed after 2.7: BEWARE: Older
compilers will not print any warning if a deprecated protected member variable
is used.
- In dumux/nonlinear/newtoncontroller.hh:
"error_" -> "shift_"
"lastError_" -> "lastShift_"
"tolerance_" -> "shiftTolerance_"
"absoluteError_" -> "reduction_"
"lastAbsoluteError_" -> "lastReduction_"
"initialAbsoluteError_" -> "initialResidual_"
"absoluteTolerance_" -> "reductionTolerance_"
"enableRelativeCriterion_" -> "enableShiftCriterion_"
"enableAbsoluteCriterion_" -> "enableResidualCriterion_"
"satisfyAbsAndRel_" -> "satisfyResidualAndShiftCriterion_"
* DELETED classes/files, property names, constants/enums,
member functions, which have been deprecated in DuMuX 2.6:
Everything listed as deprecated below has been removed.
......
......@@ -405,17 +405,14 @@ public:
{ return localJacobian().localResidual(); }
/*!
* \brief Returns the relative error between two vectors of
* \brief Returns the maximum relative shift between two vectors of
* primary variables.
*
* \param dofIdxGlobal The global index of the control volume's
* associated degree of freedom
* \param priVars1 The first vector of primary variables
* \param priVars2 The second vector of primary variables
*/
Scalar relativeErrorDof(const int dofIdxGlobal,
const PrimaryVariables &priVars1,
const PrimaryVariables &priVars2)
Scalar relativeShiftAtDof(const PrimaryVariables &priVars1,
const PrimaryVariables &priVars2)
{
Scalar result = 0.0;
for (int j = 0; j < numEq; ++j) {
......@@ -427,6 +424,14 @@ public:
return result;
}
Scalar relativeErrorDof(const int dofIdxGlobal,
const PrimaryVariables &priVars1,
const PrimaryVariables &priVars2)
DUNE_DEPRECATED_MSG("use relativeShiftAtDof(priVars1, priVars2) instead")
{
return relativeShiftAtDof(priVars1, priVars2);
}
/*!
* \brief Try to progress the model to the next timestep.
*
......
......@@ -284,9 +284,8 @@ public:
// we need to add the distance the solution was moved for
// this vertex
Scalar dist = model_().relativeErrorDof(i,
currentPriVars,
nextPriVars);
Scalar dist = model_().relativeShiftAtDof(currentPriVars,
nextPriVars);
delta_[i] += std::abs(dist);
}
......
......@@ -415,28 +415,33 @@ public:
{ return localJacobian().localResidual(); }
/*!
* \brief Returns the relative error between two vectors of
* \brief Returns the maximum relative shift between two vectors of
* primary variables.
*
* \param dofIdxGlobal The global index of the control volume's
* associated degree of freedom
* \param priVars1 The first vector of primary variables
* \param priVars2 The second vector of primary variables
*/
Scalar relativeErrorDof(const int dofIdxGlobal,
const PrimaryVariables &priVars1,
const PrimaryVariables &priVars2)
Scalar relativeShiftAtDof(const PrimaryVariables &priVars1,
const PrimaryVariables &priVars2)
{
Scalar result = 0.0;
for (int j = 0; j < numEq; ++j) {
Scalar eqErr = std::abs(priVars1[j] - priVars2[j]);
eqErr /= std::max<Scalar>(1.0, std::abs(priVars1[j] + priVars2[j])/2);
result = std::max(result, eqErr);
}
return result;
}
Scalar relativeErrorDof(const int dofIdxGlobal,
const PrimaryVariables &priVars1,
const PrimaryVariables &priVars2)
DUNE_DEPRECATED_MSG("use relativeShiftAtDof(priVars1, priVars2) instead")
{
return relativeShiftAtDof(priVars1, priVars2);
}
/*!
* \brief Try to progress the model to the next timestep.
*
......
......@@ -79,20 +79,25 @@ NEW_PROP_TAG(ImplicitEnablePartialReassemble);
*/
NEW_PROP_TAG(NewtonUseLineSearch);
//! indicate whether the relative error should be used
NEW_PROP_TAG(NewtonEnableRelativeCriterion);
//! indicate whether the shift criterion should be used
NEW_PROP_TAG(NewtonEnableShiftCriterion);
NEW_PROP_TAG(NewtonEnableRelativeCriterion);// DEPRECATED
//! the value for the relative error below which convergence is declared
NEW_PROP_TAG(NewtonRelTolerance);
//! the value for the maximum relative shift below which convergence is declared
NEW_PROP_TAG(NewtonMaxRelativeShift);
NEW_PROP_TAG(NewtonRelTolerance);// DEPRECATED
//! indicate whether the absolute error should be used
NEW_PROP_TAG(NewtonEnableAbsoluteCriterion);
//! indicate whether the residual criterion should be used
NEW_PROP_TAG(NewtonEnableResidualCriterion);
NEW_PROP_TAG(NewtonEnableAbsoluteCriterion);// DEPRECATED
//! the value for the absolute error reduction below which convergence is declared
NEW_PROP_TAG(NewtonAbsTolerance);
//! the value for the residual reduction below which convergence is declared
NEW_PROP_TAG(NewtonResidualReduction);
NEW_PROP_TAG(NewtonAbsTolerance);// DEPRECATED
//! indicate whether both of the criteria should be satisfied to declare convergence
NEW_PROP_TAG(NewtonSatisfyAbsAndRel);
NEW_PROP_TAG(NewtonSatisfyResidualAndShiftCriterion);
NEW_PROP_TAG(NewtonSatisfyAbsAndRel);// DEPRECATED
/*!
* \brief The number of iterations at which the Newton method
......@@ -114,11 +119,32 @@ NEW_PROP_TAG(JacobianAssembler);
SET_TYPE_PROP(NewtonMethod, NewtonController, Dumux::NewtonController<TypeTag>);
SET_BOOL_PROP(NewtonMethod, NewtonWriteConvergence, false);
SET_BOOL_PROP(NewtonMethod, NewtonUseLineSearch, false);
SET_BOOL_PROP(NewtonMethod, NewtonEnableRelativeCriterion, true);
SET_BOOL_PROP(NewtonMethod, NewtonEnableAbsoluteCriterion, false);
SET_BOOL_PROP(NewtonMethod, NewtonSatisfyAbsAndRel, false);
SET_SCALAR_PROP(NewtonMethod, NewtonRelTolerance, 1e-8);
SET_SCALAR_PROP(NewtonMethod, NewtonAbsTolerance, 1e-5);
// Renaming: EnableRelativeCriterion -> EnableShiftCriterion
SET_BOOL_PROP(NewtonMethod, NewtonEnableShiftCriterion,
GET_PROP_VALUE(TypeTag, NewtonEnableRelativeCriterion));
SET_BOOL_PROP(NewtonMethod, NewtonEnableRelativeCriterion, true);// DEPRECATED
// Renaming: EnableAbsoluteCriterion -> EnableResidualCriterion
SET_BOOL_PROP(NewtonMethod, NewtonEnableResidualCriterion,
GET_PROP_VALUE(TypeTag, NewtonEnableAbsoluteCriterion));
SET_BOOL_PROP(NewtonMethod, NewtonEnableAbsoluteCriterion, false);// DEPRECATED
// Renaming: SatisfyAbsAndRel -> SatisfyResidualAndShiftCriterion
SET_BOOL_PROP(NewtonMethod, NewtonSatisfyResidualAndShiftCriterion,
GET_PROP_VALUE(TypeTag, NewtonSatisfyAbsAndRel));
SET_BOOL_PROP(NewtonMethod, NewtonSatisfyAbsAndRel, false);// DEPRECATED
// Renaming: RelTolerance -> MaxRelativeShift
SET_SCALAR_PROP(NewtonMethod, NewtonMaxRelativeShift,
GET_PROP_VALUE(TypeTag, NewtonRelTolerance));
SET_SCALAR_PROP(NewtonMethod, NewtonRelTolerance, 1e-8);// DEPRECATED
// Renaming: AbsTolerance -> ResidualReduction
SET_SCALAR_PROP(NewtonMethod, NewtonResidualReduction,
GET_PROP_VALUE(TypeTag, NewtonAbsTolerance));
SET_SCALAR_PROP(NewtonMethod, NewtonAbsTolerance, 1e-5);// DEPRECATED
SET_INT_PROP(NewtonMethod, NewtonTargetSteps, 10);
SET_INT_PROP(NewtonMethod, NewtonMaxSteps, 18);
......@@ -158,6 +184,9 @@ public:
/*!
* \brief
*/
// Avoid warnings when deprecated member variables are default-initialized
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
NewtonController(const Problem &problem)
: endIterMsgStream_(std::ostringstream::out)
, convergenceWriter_(asImp_())
......@@ -167,41 +196,113 @@ public:
enableJacobianRecycling_ = GET_PARAM_FROM_GROUP(TypeTag, bool, Implicit, EnableJacobianRecycling);
useLineSearch_ = GET_PARAM_FROM_GROUP(TypeTag, bool, Newton, UseLineSearch);
enableRelativeCriterion_ = GET_PARAM_FROM_GROUP(TypeTag, bool, Newton, EnableRelativeCriterion);
enableAbsoluteCriterion_ = GET_PARAM_FROM_GROUP(TypeTag, bool, Newton, EnableAbsoluteCriterion);
satisfyAbsAndRel_ = GET_PARAM_FROM_GROUP(TypeTag, bool, Newton, SatisfyAbsAndRel);
if (!enableRelativeCriterion_ && !enableAbsoluteCriterion_)
enableShiftCriterion_ = GET_PARAM_FROM_GROUP(TypeTag, bool, Newton, EnableShiftCriterion);
enableResidualCriterion_ = GET_PARAM_FROM_GROUP(TypeTag, bool, Newton, EnableResidualCriterion);
satisfyResidualAndShiftCriterion_ = GET_PARAM_FROM_GROUP(TypeTag, bool, Newton, SatisfyResidualAndShiftCriterion);
if (!enableShiftCriterion_ && !enableResidualCriterion_)
{
DUNE_THROW(Dune::NotImplemented, "at least one of NewtonEnableRelativeCriterion or "
<< "NewtonEnableAbsoluteCriterion has to be set to true");
DUNE_THROW(Dune::NotImplemented, "at least one of NewtonEnableShiftCriterion or "
<< "NewtonEnableResidualCriterion has to be set to true");
}
setRelTolerance(GET_PARAM_FROM_GROUP(TypeTag, Scalar, Newton, RelTolerance));
setAbsTolerance(GET_PARAM_FROM_GROUP(TypeTag, Scalar, Newton, AbsTolerance));
setMaxRelativeShift(GET_PARAM_FROM_GROUP(TypeTag, Scalar, Newton, MaxRelativeShift));
setResidualReduction(GET_PARAM_FROM_GROUP(TypeTag, Scalar, Newton, ResidualReduction));
setTargetSteps(GET_PARAM_FROM_GROUP(TypeTag, int, Newton, TargetSteps));
setMaxSteps(GET_PARAM_FROM_GROUP(TypeTag, int, Newton, MaxSteps));
verbose_ = true;
numSteps_ = 0;
}
#pragma GCC diagnostic pop
/*!
* \brief Destructor
*/
~NewtonController()
{
typedef typename GET_PROP(TypeTag, ParameterTree) Params;
const Dune::ParameterTree &tree = Params::tree();
// check if deprecated parameter names have been set run-time:
if (tree.hasKey("Newton.EnableRelativeCriterion")
|| tree.hasKey("Newton.RelTolerance")
|| tree.hasKey("Newton.EnableAbsoluteCriterion")
|| tree.hasKey("Newton.AbsTolerance")
|| tree.hasKey("Newton.SatisfyAbsAndRel"))
{
std::cout << std::endl << "[Newton] The following DEPRECATED parameters"
<< "are set run-time and are therefore not used:" << std::endl;
if (tree.hasKey("Newton.EnableRelativeCriterion"))
{
std::cout << "EnableRelativeCriterion: use EnableShiftCriterion instead" << std::endl;
}
if (tree.hasKey("Newton.RelTolerance"))
{
std::cout << "RelTolerance: use MaxRelativeShift instead" << std::endl;
}
if (tree.hasKey("Newton.EnableAbsoluteCriterion"))
{
std::cout << "EnableAbsoluteCriterion: use EnableResidualCriterion instead" << std::endl;
}
if (tree.hasKey("Newton.AbsTolerance"))
{
std::cout << "AbsTolerance: use ResidualReduction instead" << std::endl;
}
if (tree.hasKey("Newton.SatisfyAbsAndRel"))
{
std::cout << "SatisfyAbsAndRel: use SatisfyResidualAndShiftCriterion instead" << std::endl;
}
}
// check if deprecated property names have been set compile-time to
// a non-default value:
if (GET_PROP_VALUE(TypeTag, NewtonEnableRelativeCriterion) != true
|| GET_PROP_VALUE(TypeTag, NewtonRelTolerance) != 1e-8
|| GET_PROP_VALUE(TypeTag, NewtonEnableAbsoluteCriterion) != false
|| GET_PROP_VALUE(TypeTag, NewtonAbsTolerance) != 1e-5
|| GET_PROP_VALUE(TypeTag, NewtonSatisfyAbsAndRel) != false)
{
std::cout << std::endl << "[Newton] The following DEPRECATED properties"
<< " are set compile-time and the corresponding new properties are used:"
<< std::endl;
if (GET_PROP_VALUE(TypeTag, NewtonEnableRelativeCriterion) != true)
{
std::cout << "NewtonEnableRelativeCriterion: use NewtonEnableShiftCriterion instead" << std::endl;
}
if (GET_PROP_VALUE(TypeTag, NewtonRelTolerance) != 1e-8)
{
std::cout << "NewtonRelTolerance: use NewtonMaxRelativeShift instead" << std::endl;
}
if (GET_PROP_VALUE(TypeTag, NewtonEnableAbsoluteCriterion) != false)
{
std::cout << "NewtonEnableAbsoluteCriterion: use NewtonEnableResidualCriterion instead" << std::endl;
}
if (GET_PROP_VALUE(TypeTag, NewtonAbsTolerance) != 1e-5)
{
std::cout << "NewtonAbsTolerance: use NewtonResidualReduction instead" << std::endl;
}
if (GET_PROP_VALUE(TypeTag, NewtonSatisfyAbsAndRel) != false)
{
std::cout << "NewtonSatisfyAbsAndRel: use NewtonSatisfyResidualAndShiftCriterion instead" << std::endl;
}
}
}
/*!
* \brief Set the maximum acceptable difference for convergence of
* any primary variable between two iterations.
* \brief Set the maximum acceptable difference of any primary variable
* between two iterations for declaring convergence.
*
* \param tolerance The maximum relative error between two Newton
* iterations at which the scheme is considered
* finished
* \param tolerance The maximum relative shift between two Newton
* iterations at which the scheme is considered finished
*/
void setMaxRelativeShift(Scalar tolerance)
{ shiftTolerance_ = tolerance; }
void setRelTolerance(Scalar tolerance)
{ tolerance_ = tolerance; }
DUNE_DEPRECATED_MSG("use setMaxRelativeShift instead")
{ setMaxRelativeShift(tolerance); }
/*!
* \brief Set the maximum acceptable residual norm reduction.
......@@ -209,8 +310,12 @@ public:
* \param tolerance The maximum reduction of the residual norm
* at which the scheme is considered finished
*/
void setResidualReduction(Scalar tolerance)
{ reductionTolerance_ = tolerance; }
void setAbsTolerance(Scalar tolerance)
{ absoluteTolerance_ = tolerance; }
DUNE_DEPRECATED_MSG("use setResidualReduction instead")
{ setResidualReduction(tolerance); }
/*!
* \brief Set the number of iterations at which the Newton method
......@@ -247,14 +352,13 @@ public:
return false; // we are below the desired tolerance
}
else if (numSteps_ >= maxSteps_) {
// we have exceeded the allowed number of steps. if the
// relative error was reduced by a factor of at least 4,
// we proceed even if we are above the maximum number of
// steps
if (enableRelativeCriterion_)
return error_*4.0 < lastError_;
// We have exceeded the allowed number of steps. If the
// maximum relative shift was reduced by a factor of at least 4,
// we proceed even if we are above the maximum number of steps.
if (enableShiftCriterion_)
return shift_*4.0 < lastShift_;
else
return absoluteError_*4.0 < lastAbsoluteError_;
return reduction_*4.0 < lastReduction_;
}
return true;
......@@ -266,23 +370,23 @@ public:
*/
bool newtonConverged() const
{
if (enableRelativeCriterion_ && !enableAbsoluteCriterion_)
if (enableShiftCriterion_ && !enableResidualCriterion_)
{
return error_ <= tolerance_;
return shift_ <= shiftTolerance_;
}
else if (!enableRelativeCriterion_ && enableAbsoluteCriterion_)
else if (!enableShiftCriterion_ && enableResidualCriterion_)
{
return absoluteError_ <= absoluteTolerance_;
return reduction_ <= reductionTolerance_;
}
else if (satisfyAbsAndRel_)
else if (satisfyResidualAndShiftCriterion_)
{
return error_ <= tolerance_
&& absoluteError_ <= absoluteTolerance_;
return shift_ <= shiftTolerance_
&& reduction_ <= reductionTolerance_;
}
else
{
return error_ <= tolerance_
|| absoluteError_ <= absoluteTolerance_;
return shift_ <= shiftTolerance_
|| reduction_ <= reductionTolerance_;
}
return false;
......@@ -309,8 +413,8 @@ public:
*/
void newtonBeginStep()
{
lastError_ = error_;
lastAbsoluteError_ = absoluteError_;
lastShift_ = shift_;
lastReduction_ = reduction_;
}
/*!
......@@ -321,37 +425,35 @@ public:
{ return numSteps_; }
/*!
* \brief Update the relative error of the solution compared to
* \brief Update the maximum relative shift of the solution compared to
* the previous iteration.
*
* The relative error can be seen as a norm of the difference
* between the current and the next iteration.
*
* \param uLastIter The current iterative solution
* \param deltaU The difference between the current and the next solution
*/
void newtonUpdateRelError(const SolutionVector &uLastIter,
const SolutionVector &deltaU)
void newtonUpdateShift(const SolutionVector &uLastIter,
const SolutionVector &deltaU)
{
// calculate the relative error as the maximum relative
// deflection in any degree of freedom.
error_ = 0;
shift_ = 0;
for (int i = 0; i < int(uLastIter.size()); ++i) {
typename SolutionVector::block_type uNewI = uLastIter[i];
uNewI -= deltaU[i];
Scalar dofError = model_().relativeErrorDof(i,
uLastIter[i],
uNewI);
error_ = std::max(error_, dofError);
Scalar shiftAtDof = model_().relativeShiftAtDof(uLastIter[i],
uNewI);
shift_ = std::max(shift_, shiftAtDof);
}
if (gridView_().comm().size() > 1)
error_ = gridView_().comm().max(error_);
shift_ = gridView_().comm().max(shift_);
}
void newtonUpdateRelError(const SolutionVector &uLastIter,
const SolutionVector &deltaU)
DUNE_DEPRECATED_MSG("use newtonUpdateShift instead")
{ newtonUpdateShift(uLastIter, deltaU); }
/*!
* \brief Solve the linear system of equations \f$\mathbf{A}x - b = 0\f$.
*
......@@ -373,8 +475,8 @@ public:
if (gridView_().comm().size() > 1)
norm2 = gridView_().comm().sum(norm2);
initialAbsoluteError_ = std::sqrt(norm2);
lastAbsoluteError_ = initialAbsoluteError_;
initialResidual_ = std::sqrt(norm2);
lastReduction_ = initialResidual_;
}
int converged = linearSolver_.solve(A, x, b);
......@@ -439,14 +541,14 @@ public:
const SolutionVector &uLastIter,
const SolutionVector &deltaU)
{
if (enableRelativeCriterion_ || enablePartialReassemble_)
newtonUpdateRelError(uLastIter, deltaU);
if (enableShiftCriterion_ || enablePartialReassemble_)
newtonUpdateShift(uLastIter, deltaU);
// compute the vertex and element colors for partial reassembly
if (enablePartialReassemble_) {
const Scalar minReasmTol = 1e-2*tolerance_;
const Scalar maxReasmTol = 1e1*tolerance_;
Scalar reassembleTol = std::max(minReasmTol, std::min(maxReasmTol, this->error_/1e4));
const Scalar minReasmTol = 1e-2*shiftTolerance_;
const Scalar maxReasmTol = 1e1*shiftTolerance_;
Scalar reassembleTol = std::max(minReasmTol, std::min(maxReasmTol, this->shift_/1e4));
//Scalar reassembleTol = minReasmTol;
this->model_().jacobianAssembler().updateDiscrepancy(uLastIter, deltaU);
......@@ -465,11 +567,11 @@ public:
uCurrentIter[i] -= deltaU[i];
}
if (enableAbsoluteCriterion_)
if (enableResidualCriterion_)
{
SolutionVector tmp(uLastIter);
absoluteError_ = this->method().model().globalResidual(tmp, uCurrentIter);
absoluteError_ /= initialAbsoluteError_;
reduction_ = this->method().model().globalResidual(tmp, uCurrentIter);
reduction_ /= initialResidual_;
}
}
......@@ -489,10 +591,10 @@ public:
if (verbose())
{
std::cout << "\rNewton iteration " << numSteps_ << " done";
if (enableRelativeCriterion_)
std::cout << ", relative error = " << error_;
if (enableAbsoluteCriterion_)
std::cout << ", absolute error = " << absoluteError_;
if (enableShiftCriterion_)
std::cout << ", maximum relative shift = " << shift_;
if (enableResidualCriterion_)
std::cout << ", residual reduction = " << reduction_;
std::cout << endIterMsg().str() << "\n";
}
endIterMsgStream_.str("");
......@@ -669,11 +771,11 @@ protected:
uCurrentIter += uLastIter;
// calculate the residual of the current solution
absoluteError_ = this->method().model().globalResidual(tmp, uCurrentIter);
absoluteError_ /= initialAbsoluteError_;
reduction_ = this->method().model().globalResidual(tmp, uCurrentIter);
reduction_ /= initialResidual_;
if (absoluteError_ < lastAbsoluteError_ || lambda <= 0.125) {
this->endIterMsg() << ", defect " << lastAbsoluteError_ << "->" << absoluteError_ << "@lambda=" << lambda;
if (reduction_ < lastReduction_ || lambda <= 0.125) {
this->endIterMsg() << ", residual reduction " << lastReduction_ << "->" << reduction_ << "@lambda=" << lambda;
return;
}
......@@ -689,16 +791,16 @@ protected:
ConvergenceWriter convergenceWriter_;
// relative errors and tolerance
Scalar error_;
Scalar lastError_;