Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "PostprocessorConvergence.h" 11 : 12 : registerMooseObject("MooseApp", PostprocessorConvergence); 13 : 14 : InputParameters 15 14315 : PostprocessorConvergence::validParams() 16 : { 17 14315 : InputParameters params = IterationCountConvergence::validParams(); 18 : 19 14315 : params.addClassDescription("Compares the absolute value of a post-processor to a tolerance."); 20 : 21 14315 : params.addRequiredParam<PostprocessorName>("postprocessor", 22 : "Post-processor to use for convergence criteria"); 23 14315 : params.addRequiredParam<Real>("tolerance", "Tolerance to use for convergence criteria"); 24 : 25 14315 : return params; 26 0 : } 27 : 28 26 : PostprocessorConvergence::PostprocessorConvergence(const InputParameters & parameters) 29 : : IterationCountConvergence(parameters), 30 26 : _postprocessor(getPostprocessorValue("postprocessor")), 31 52 : _tol(getParam<Real>("tolerance")) 32 : { 33 26 : } 34 : 35 : Convergence::MooseConvergenceStatus 36 121 : PostprocessorConvergence::checkConvergenceInner(unsigned int /*iter*/) 37 : { 38 121 : if (std::abs(_postprocessor) <= _tol) 39 : { 40 22 : std::ostringstream oss; 41 22 : oss << "Converged due to |post-processor| (" << std::abs(_postprocessor) << ") <= tolerance (" 42 22 : << _tol << ")."; 43 22 : verboseOutput(oss); 44 22 : return MooseConvergenceStatus::CONVERGED; 45 22 : } 46 : else 47 99 : return MooseConvergenceStatus::ITERATING; 48 : }