LCOV - code coverage report
Current view: top level - src/convergence - ComponentsConvergence.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 22 24 91.7 %
Date: 2026-05-29 20:41:18 Functions: 4 4 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 "ComponentsConvergence.h"
      11             : #include "THMProblem.h"
      12             : #include "Component.h"
      13             : 
      14             : registerMooseObject("ThermalHydraulicsApp", ComponentsConvergence);
      15             : 
      16             : InputParameters
      17          38 : ComponentsConvergence::validParams()
      18             : {
      19          38 :   InputParameters params = IterationCountConvergence::validParams();
      20             : 
      21          38 :   params.addClassDescription("Assesses convergence of all Component objects in a simulation.");
      22             : 
      23          38 :   return params;
      24           0 : }
      25             : 
      26          20 : ComponentsConvergence::ComponentsConvergence(const InputParameters & parameters)
      27             :   : IterationCountConvergence(parameters),
      28          20 :     _thm_problem(
      29          60 :         dynamic_cast<THMProblem *>(getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")))
      30             : {
      31          20 :   if (!_thm_problem)
      32           0 :     mooseError("ComponentsConvergence only works with THMProblem.");
      33          20 : }
      34             : 
      35             : void
      36          20 : ComponentsConvergence::initialSetup()
      37             : {
      38             :   IterationCountConvergence::initialSetup();
      39             : 
      40          90 :   for (const auto & comp : _thm_problem->getComponents())
      41             :   {
      42          70 :     const auto nl_conv = comp->getNonlinearConvergence();
      43          70 :     if (nl_conv)
      44          20 :       _convergence_objects.push_back(nl_conv);
      45             :   }
      46          20 : }
      47             : 
      48             : Convergence::MooseConvergenceStatus
      49         257 : ComponentsConvergence::checkConvergenceInner(unsigned int iter)
      50             : {
      51             :   bool all_converged = true;
      52         514 :   for (auto & conv : _convergence_objects)
      53             :   {
      54         257 :     const auto status = conv->checkConvergence(iter);
      55         257 :     if (status == Convergence::MooseConvergenceStatus::DIVERGED)
      56             :       return Convergence::MooseConvergenceStatus::DIVERGED;
      57         257 :     else if (status == Convergence::MooseConvergenceStatus::ITERATING)
      58             :       all_converged = false;
      59             :     else
      60             :     {
      61             :       // checking in case additional status added in future
      62             :       mooseAssert(status == Convergence::MooseConvergenceStatus::CONVERGED,
      63             :                   "Status not implemented");
      64             :     }
      65             :   }
      66             : 
      67         257 :   if (all_converged)
      68             :     return Convergence::MooseConvergenceStatus::CONVERGED;
      69             :   else
      70         167 :     return Convergence::MooseConvergenceStatus::ITERATING;
      71             : }

Generated by: LCOV version 1.14