https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ComponentsConvergence.C
Go to the documentation of this file.
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
11#include "THMProblem.h"
12#include "Component.h"
13
15
18{
20
21 params.addClassDescription("Assesses convergence of all Component objects in a simulation.");
22
23 return params;
24}
25
27 : IterationCountConvergence(parameters),
28 _thm_problem(
29 dynamic_cast<THMProblem *>(getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")))
30{
31 if (!_thm_problem)
32 mooseError("ComponentsConvergence only works with THMProblem.");
33}
34
35void
37{
39
40 for (const auto & comp : _thm_problem->getComponents())
41 {
42 const auto nl_conv = comp->getNonlinearConvergence();
43 if (nl_conv)
44 _convergence_objects.push_back(nl_conv);
45 }
46}
47
50{
51 bool all_converged = true;
52 for (auto & conv : _convergence_objects)
53 {
54 const auto status = conv->checkConvergence(iter);
55 if (status == Convergence::MooseConvergenceStatus::DIVERGED)
56 return Convergence::MooseConvergenceStatus::DIVERGED;
57 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 if (all_converged)
68 return Convergence::MooseConvergenceStatus::CONVERGED;
69 else
70 return Convergence::MooseConvergenceStatus::ITERATING;
71}
registerMooseObject("ThermalHydraulicsApp", ComponentsConvergence)
Assesses convergence of all Component objects in a simulation.
static InputParameters validParams()
ComponentsConvergence(const InputParameters &parameters)
virtual void initialSetup() override
std::vector< Convergence * > _convergence_objects
Convergence objects for all Components that provide one.
const THMProblem *const _thm_problem
THM problem.
virtual MooseConvergenceStatus checkConvergenceInner(unsigned int iter) override
virtual void initialSetup() override
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
void mooseError(Args &&... args) const
const std::vector< std::shared_ptr< Component > > & getComponents() const
Return list of components available in the simulation.
Definition Simulation.h:117
Specialization of FEProblem to run with component subsystem.
Definition THMProblem.h:19