LCOV - code coverage report
Current view: top level - src/postprocessors - NumNonlinearIterations.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 25 28 89.3 %
Date: 2025-07-17 01:28:37 Functions: 5 5 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 "NumNonlinearIterations.h"
      11             : 
      12             : #include "FEProblem.h"
      13             : #include "SubProblem.h"
      14             : #include "SystemBase.h"
      15             : 
      16             : registerMooseObject("MooseApp", NumNonlinearIterations);
      17             : 
      18             : InputParameters
      19       15031 : NumNonlinearIterations::validParams()
      20             : {
      21       15031 :   InputParameters params = GeneralPostprocessor::validParams();
      22       45093 :   params.addParam<bool>(
      23             :       "accumulate_over_step",
      24       30062 :       false,
      25             :       "When set to true, accumulates to count the total over all Picard iterations for each step");
      26       15031 :   params.addClassDescription("Outputs the number of nonlinear iterations");
      27             : 
      28             :   // Not supported
      29       15031 :   params.suppressParameter<bool>("use_displaced_mesh");
      30       15031 :   return params;
      31           0 : }
      32             : 
      33         379 : NumNonlinearIterations::NumNonlinearIterations(const InputParameters & parameters)
      34             :   : GeneralPostprocessor(parameters),
      35         379 :     _fe_problem(dynamic_cast<FEProblemBase *>(&_subproblem)),
      36         379 :     _accumulate_over_step(getParam<bool>("accumulate_over_step")),
      37         379 :     _num_iters(0),
      38         758 :     _time(-std::numeric_limits<Real>::max())
      39             : {
      40         379 :   if (!_fe_problem)
      41           0 :     mooseError("Couldn't cast to FEProblemBase");
      42         379 : }
      43             : 
      44             : void
      45        1087 : NumNonlinearIterations::timestepSetup()
      46             : {
      47        1087 :   if (_fe_problem->time() != _time)
      48             :   {
      49        1087 :     _num_iters = 0;
      50        1087 :     _time = _fe_problem->time();
      51             :   }
      52        1087 : }
      53             : 
      54             : void
      55        1049 : NumNonlinearIterations::finalize()
      56             : {
      57        1049 :   if (_accumulate_over_step)
      58           0 :     _num_iters += _subproblem.nNonlinearIterations(_sys.number());
      59             :   else
      60        1049 :     _num_iters = _subproblem.nNonlinearIterations(_sys.number());
      61        1049 : }
      62             : 
      63             : Real
      64        1049 : NumNonlinearIterations::getValue() const
      65             : {
      66        1049 :   return _num_iters;
      67             : }

Generated by: LCOV version 1.14