LCOV - code coverage report
Current view: top level - src/convergence - PostprocessorConvergence.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 24 25 96.0 %
Date: 2026-05-29 20:35:17 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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        3136 : PostprocessorConvergence::validParams()
      16             : {
      17        3136 :   InputParameters params = IterationCountConvergence::validParams();
      18             : 
      19        6272 :   params.addClassDescription("Compares the absolute value of a post-processor to a tolerance.");
      20             : 
      21       12544 :   params.addRequiredParam<PostprocessorName>("postprocessor",
      22             :                                              "Post-processor to use for convergence criteria");
      23        9408 :   params.addRequiredParam<Real>("tolerance", "Tolerance to use for convergence criteria");
      24             : 
      25        3136 :   return params;
      26           0 : }
      27             : 
      28          39 : PostprocessorConvergence::PostprocessorConvergence(const InputParameters & parameters)
      29             :   : IterationCountConvergence(parameters),
      30          39 :     _postprocessor(getPostprocessorValue("postprocessor")),
      31         117 :     _tol(getParam<Real>("tolerance"))
      32             : {
      33          39 : }
      34             : 
      35             : Convergence::MooseConvergenceStatus
      36         342 : PostprocessorConvergence::checkConvergenceInner(unsigned int /*iter*/)
      37             : {
      38         342 :   if (std::abs(_postprocessor) <= _tol)
      39             :   {
      40          34 :     std::ostringstream oss;
      41          34 :     oss << "Converged due to |post-processor| (" << std::abs(_postprocessor) << ") <= tolerance ("
      42          34 :         << _tol << ").";
      43          34 :     verboseOutput(oss);
      44          34 :     return MooseConvergenceStatus::CONVERGED;
      45          34 :   }
      46             :   else
      47             :   {
      48         308 :     std::ostringstream oss;
      49         308 :     oss << "Still iterating due to |post-processor| (" << std::abs(_postprocessor)
      50         308 :         << ") > tolerance (" << _tol << ").";
      51         308 :     verboseOutput(oss);
      52         308 :     return MooseConvergenceStatus::ITERATING;
      53         308 :   }
      54             : }

Generated by: LCOV version 1.14