Skip to content
Snippets Groups Projects
Commit c55e90fa authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Add convenience method for absulute norm criterion

parent a6a514ee
No related branches found
No related tags found
1 merge request!4Feature/flexible loopsolver monitoring
...@@ -207,6 +207,54 @@ namespace Dune { ...@@ -207,6 +207,54 @@ namespace Dune {
" iter"); " iter");
} }
/**
* \brief Create a Criterion for checking the correction norm
*
* \param iterationStep The IterationStep to be monitored
* \param norm Norm to be evaluated for the correction
* \param tolerance Tolerance necessary to satisfy the criterion
* \param correctionNorms A container to store the computed correction norms
*/
template<class IterationStepType, class NormType, class CorrectionNormContainer>
Criterion correctionNormCriterion(
const IterationStepType& iterationStep,
const NormType& norm,
double tolerance,
CorrectionNormContainer& correctionNorms)
{
auto lastIterate = std::make_shared<typename IterationStepType::Vector>(*iterationStep.getIterate());
return Criterion(
[&, lastIterate, tolerance] () mutable {
double normOfCorrection = norm.diff(*lastIterate, *iterationStep.getIterate());
correctionNorms.push_back(normOfCorrection);
*lastIterate = *iterationStep.getIterate();
return std::make_tuple(normOfCorrection < tolerance, Dune::formatString(" % 14.7e", normOfCorrection));
},
" abs correction");
}
/**
* \brief Create a Criterion for checking the correction norm
*
* \param iterationStep The IterationStep to be monitored
* \param norm Norm to be evaluated for the correction
* \param tolerance Tolerance necessary to satisfy the criterion
*/
template<class IterationStepType, class NormType>
Criterion correctionNormCriterion(
const IterationStepType& iterationStep,
const NormType& norm,
double tolerance)
{
auto lastIterate = std::make_shared<typename IterationStepType::Vector>(*iterationStep.getIterate());
return Criterion(
[&, lastIterate, tolerance] () mutable {
double normOfCorrection = norm.diff(*lastIterate, *iterationStep.getIterate());
*lastIterate = *iterationStep.getIterate();
return std::make_tuple(normOfCorrection < tolerance, Dune::formatString(" % 14.7e", normOfCorrection));
},
" abs correction");
}
} // end namespace Solvers } // end namespace Solvers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment